Author: alanmc
Date: 2007-06-29 14:41:21 -0400 (Fri, 29 Jun 2007)
New Revision: 81060
Modified:
trunk/lunareclipse/ChangeLog
trunk/lunareclipse/Model/Draw/PenDraw.cs
trunk/lunareclipse/Model/Draw/SelectionDraw.cs
Log:
Fixed undo for shapes
Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog 2007-06-29 18:40:49 UTC (rev 81059)
+++ trunk/lunareclipse/ChangeLog 2007-06-29 18:41:21 UTC (rev 81060)
@@ -1,5 +1,9 @@
2007-06-29 Alan McGovern <[EMAIL PROTECTED]>
+ Fixed undo for shapes
+
+2007-06-29 Alan McGovern <[EMAIL PROTECTED]>
+
* Model/Draw/SelectionDraw.cs: You can now undo/redo movements to
shapes
Modified: trunk/lunareclipse/Model/Draw/PenDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/PenDraw.cs 2007-06-29 18:40:49 UTC (rev
81059)
+++ trunk/lunareclipse/Model/Draw/PenDraw.cs 2007-06-29 18:41:21 UTC (rev
81060)
@@ -43,14 +43,11 @@
geometry.Figures.Add(figure);
figure.Segments = new PathSegmentCollection();
- Console.WriteLine("Path set");
- Console.WriteLine("Path started");
}
internal override void Resize (MouseEventArgs e)
{
- Console.WriteLine("Path resizing");
Point end = e.GetPosition(Panel);
double top = (double)Element.GetValue(Canvas.TopProperty);
double left = (double)Element.GetValue(Canvas.LeftProperty);
@@ -58,12 +55,10 @@
LineSegment seg = new LineSegment();
seg.Point = end;
figure.Segments.Add(seg);
- Console.WriteLine("Path resized");
}
internal override void DrawEnd (MouseEventArgs point)
{
- Console.WriteLine("Path ending");
BezierSegment bezier;
PathSegmentCollection beziers = new PathSegmentCollection();
@@ -111,7 +106,6 @@
}
beziers.Add(bezier);
- Console.WriteLine("Path ended");
}
}
Modified: trunk/lunareclipse/Model/Draw/SelectionDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-06-29 18:40:49 UTC
(rev 81059)
+++ trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-06-29 18:41:21 UTC
(rev 81060)
@@ -21,6 +21,7 @@
private bool clickedOnShape;
private bool prepared;
private List<Shape> selectedObjects;
+ private bool shapeMoved;
public List<Shape> SelectedObjects
{
@@ -55,6 +56,7 @@
Shape shape;
this.clickedOnShape = this.ClickedOnShape(e.GetPosition(panel),
out shape);
mouseStart = Position;
+ shapeMoved = false;
}
private List<Shape> GetSelectedObjects(MouseEventArgs e)
@@ -138,7 +140,7 @@
if(this.clickedOnShape)
{
ClickedOnShape(mouseStart, out clickedShape);
- if(clickedShape!= null &&
!selectedObjects.Contains(clickedShape))
+ if(clickedShape != null &&
!selectedObjects.Contains(clickedShape))
DeselectAll();
if(selectedObjects.Count == 0)
@@ -168,9 +170,9 @@
Shape shape = null;
Point mouseLocation = e.GetPosition(Panel);
bool clickedOnShape = ClickedOnShape(mouseLocation, out shape);
- bool mouseDidntMove = mouseStart.Equals(Position);
+ bool mouseMoved = !mouseStart.Equals(Position);
- if(clickedOnShape && mouseDidntMove)
+ if(clickedOnShape && !mouseMoved)
{
if(!e.Ctrl && !e.Shift)
this.DeselectAll();
@@ -181,18 +183,16 @@
Select(shape);
}
- if(!clickedOnShape && mouseDidntMove)
+ if(!clickedOnShape && !mouseMoved)
DeselectAll();
- if(!mouseDidntMove)
+ if(shapeMoved)
{
Point start = mouseStart;
- start.Offset(-Position.X, -Position.Y);
+ start.Offset(-mouseLocation.X, -mouseLocation.Y);
+ Console.WriteLine("Offset is: " + start.ToString());
foreach(Shape s in selectedObjects)
- {
-
controller.UndoEngine.PushUndo(new UndoMoveShape(s,
start));
- }
}
}
@@ -211,9 +211,12 @@
private void Select(Shape s)
{
- s.Stroke = new SolidColorBrush(Colors.Green);
- s.Fill = new SolidColorBrush(Colors.Black);
- this.selectedObjects.Add(s);
+ SolidColorBrush b = new SolidColorBrush(Colors.Green);
+ s.Stroke = b;
+ b = new SolidColorBrush(Colors.Black);
+ b.Opacity = 0.3;
+ s.Fill = b;
+ this.selectedObjects.Add(s);
}
private void MoveShape(Shape s, Point offset)
@@ -221,6 +224,7 @@
Point oldPoint = new
Point((double)s.GetValue(Canvas.LeftProperty),
(double)s.GetValue(Canvas.TopProperty));
s.SetValue<double>(Canvas.LeftProperty, oldPoint.X + offset.X);
s.SetValue<double>(Canvas.TopProperty, oldPoint.Y + offset.Y);
+ shapeMoved = true;
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches