Author: alanmc
Date: 2007-07-12 13:21:40 -0400 (Thu, 12 Jul 2007)
New Revision: 81884
Modified:
trunk/lunareclipse/ChangeLog
trunk/lunareclipse/Controller/MoonlightController.cs
trunk/lunareclipse/Model/Draw/SelectionDraw.cs
Log:
* Model/Draw/SelectionDraw.cs, Controller/MoonlightController.cs:
Rewrote some of the selection code to fix some idiosyncrasies.
Added comments
Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog 2007-07-12 16:43:50 UTC (rev 81883)
+++ trunk/lunareclipse/ChangeLog 2007-07-12 17:21:40 UTC (rev 81884)
@@ -1,3 +1,9 @@
+2007-07-12 Alan McGovern <[EMAIL PROTECTED]>
+
+ * Model/Draw/SelectionDraw.cs, Controller/MoonlightController.cs:
+ Rewrote some of the selection code to fix some idiosyncrasies.
+ Added comments
+
2007-07-11 Alan McGovern <[EMAIL PROTECTED]>
* Model/Draw/SelectionDraw.cs, Controller/UndoActions/UndoRotation.cs,
Modified: trunk/lunareclipse/Controller/MoonlightController.cs
===================================================================
--- trunk/lunareclipse/Controller/MoonlightController.cs 2007-07-12
16:43:50 UTC (rev 81883)
+++ trunk/lunareclipse/Controller/MoonlightController.cs 2007-07-12
17:21:40 UTC (rev 81884)
@@ -78,11 +78,14 @@
bool active = false;
private void MouseLeftDown(object sender, MouseEventArgs e)
{
+ Console.WriteLine("Mouse down");
if(current == null || active)
return;
active = true;
+ try{this.Canvas.CaptureMouse();}catch{}
current.DrawStart(this.moonlight.Canvas, e);
+
if(current.CanUndo)
undo.PushUndo(new UndoAddObject(moonlight.Canvas.Children,
current.Element));
}
@@ -97,23 +100,31 @@
private void MouseLeftUp(object sender, MouseEventArgs e)
{
+ Console.WriteLine("Mouse up");
if(!active)
return;
current.DrawEnd(e);
active = false;
-
- if (current is SelectionDraw) {
- SelectionDraw selection = (SelectionDraw)
current;
- if (selection.SelectedObjects.Count == 1)
- foreach(KeyValuePair<Visual, SelectedBorder> keypair in
selection.SelectedObjects)
- {
- properties.SelectedObject = keypair.Value;
- Console.WriteLine("Selected: " +
keypair.Key.ToString());
- }
- }
+ try{this.Canvas.ReleaseMouseCapture();}catch{}
+
+ if (!(current is SelectionDraw))
+ return;
+
+ SelectionDraw selection = (SelectionDraw) current;
+ if (selection.SelectedObjects.Count == 1)
+ {
+ foreach(KeyValuePair<Visual, SelectedBorder> keypair in
selection.SelectedObjects)
+ {
+ properties.SelectedObject = keypair.Value;
+ Console.WriteLine("Selected: " + keypair.Key.ToString());
+ }
+ }
+ else
+ {
+ properties.SelectedObject = null;
+ }
}
-
public string SerializeCanvas()
{
Modified: trunk/lunareclipse/Model/Draw/SelectionDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-07-12 16:43:50 UTC
(rev 81883)
+++ trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-07-12 17:21:40 UTC
(rev 81884)
@@ -185,24 +185,30 @@
bool mouseMoved = !mouseStart.Equals(Position);
shapeAdded = false;
- if(clickedOnShape && !mouseMoved)
+ // If we clicked and released on a visual, we select it, unless
+ // we are using one of the modifiers (ctrl/shift)
+ // If we clicked and released on an empty area of canvas, we
deselect
+ // everything
+ if(!mouseMoved)
{
- if(!e.Ctrl && !e.Shift)
- this.DeselectAll();
-
- foreach(Visual s in shapes)
- if(this.selectedObjects.ContainsKey(s))
- Deselect(s);
+ if(this.clickedOnShape != null)
+ {
+ if(!e.Ctrl && !e.Shift)
+ this.DeselectAll();
+
+ if(!this.selectedObjects.ContainsKey(this.clickedOnShape))
+ Select(this.clickedOnShape);
else
- Select(s);
-
- if(this.clickedOnShape != null &&
!this.selectedObjects.ContainsKey(this.clickedOnShape))
- Select(this.clickedOnShape);
+ Deselect(this.clickedOnShape);
+ }
+ else
+ {
+ DeselectAll();
+ }
}
-
- if(!clickedOnShape && !mouseMoved)
- DeselectAll();
+ // If we did move some shapes using a click+drag, then we need to
push
+ // an undo action onto the stack for the group of items which were
moved
if(shapeMoved)
{
Point start = mouseStart;
@@ -213,6 +219,8 @@
controller.UndoEngine.PushUndo(new UndoMoveShape(movedShapes,
start));
}
+ // If we have clicked on a shape, check to see if it was rotated
+ // if it was push an undo action for that rotation
if(this.clickedOnShape != null)
{
RotateTransform t =
this.clickedOnShape.GetValue(Canvas.RenderTransformProperty) as RotateTransform;
@@ -220,9 +228,13 @@
this.controller.UndoEngine.PushUndo(new
UndoRotation(this.clickedOnShape, initialRotation, t.Angle));
}
+ // Reset all the 'move types' to be a standard move. This is
needed so
+ // that on the nextMouseDown, a standard move will be performed
unless
+ // the user clicks on one of the handles for
stretching/skewing/rotating
foreach(KeyValuePair<Visual, SelectedBorder> keypair in
selectedObjects)
keypair.Value.MoveType = MoveType.Standard;
+ // Reset the clicked on shape = null
this.clickedOnShape = null;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches