Author: alanmc
Date: 2007-07-11 17:23:16 -0400 (Wed, 11 Jul 2007)
New Revision: 81833
Added:
trunk/lunareclipse/Controller/UndoActions/UndoRotation.cs
Modified:
trunk/lunareclipse/ChangeLog
trunk/lunareclipse/LunarEclipse.mdp
trunk/lunareclipse/Model/Draw/SelectionDraw.cs
Log:
* Model/Draw/SelectionDraw.cs, Controller/UndoActions/UndoRotation.cs,
LunarEclipse.mdp: Added ability to undo rotations
Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog 2007-07-11 21:20:13 UTC (rev 81832)
+++ trunk/lunareclipse/ChangeLog 2007-07-11 21:23:16 UTC (rev 81833)
@@ -1,5 +1,10 @@
2007-07-11 Alan McGovern <[EMAIL PROTECTED]>
+ * Model/Draw/SelectionDraw.cs, Controller/UndoActions/UndoRotation.cs,
+ LunarEclipse.mdp: Added ability to undo rotations
+
+2007-07-11 Alan McGovern <[EMAIL PROTECTED]>
+
* Model/SelectedBorder.cs, Model/Draw/SelectionDraw.cs: Much cleaner
rotating now. Using RenderTransformOrigin to specifiy the offset at
which the transform should be applied
Added: trunk/lunareclipse/Controller/UndoActions/UndoRotation.cs
===================================================================
--- trunk/lunareclipse/Controller/UndoActions/UndoRotation.cs 2007-07-11
21:20:13 UTC (rev 81832)
+++ trunk/lunareclipse/Controller/UndoActions/UndoRotation.cs 2007-07-11
21:23:16 UTC (rev 81833)
@@ -0,0 +1,37 @@
+
+
+using System;
+using System.Windows.Controls;
+using System.Windows.Media;
+namespace LunarEclipse
+{
+
+
+ public class UndoRotation : UndoActionBase
+ {
+ private double angle;
+ private double initialAngle;
+ private Visual visual;
+
+ public UndoRotation(Visual visual, double initialAngle, double angle)
+ {
+ this.angle = angle;
+ this.initialAngle = initialAngle;
+ this.visual = visual;
+ }
+
+ public override void Redo ()
+ {
+ RotateTransform t =
visual.GetValue(Canvas.RenderTransformProperty) as RotateTransform;
+ if(t != null)
+ t.Angle = angle;
+ }
+
+ public override void Undo ()
+ {
+ RotateTransform t =
visual.GetValue(Canvas.RenderTransformProperty) as RotateTransform;
+ if(t != null)
+ t.Angle = initialAngle;
+ }
+ }
+}
Modified: trunk/lunareclipse/LunarEclipse.mdp
===================================================================
--- trunk/lunareclipse/LunarEclipse.mdp 2007-07-11 21:20:13 UTC (rev 81832)
+++ trunk/lunareclipse/LunarEclipse.mdp 2007-07-11 21:23:16 UTC (rev 81833)
@@ -54,6 +54,7 @@
<File name="./Model/SelectedBorder.cs" subtype="Code"
buildaction="Compile" />
<File name="./Serialization/ReflectionHelper.cs" subtype="Code"
buildaction="Compile" />
<File name="./Model/ZIndexComparer.cs" subtype="Code"
buildaction="Compile" />
+ <File name="./Controller/UndoActions/UndoRotation.cs" subtype="Code"
buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/lunareclipse/Model/Draw/SelectionDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-07-11 21:20:13 UTC
(rev 81832)
+++ trunk/lunareclipse/Model/Draw/SelectionDraw.cs 2007-07-11 21:23:16 UTC
(rev 81833)
@@ -23,6 +23,7 @@
private Visual clickedOnShape;
private bool prepared;
private Dictionary<Visual, SelectedBorder> selectedObjects;
+ private double initialRotation = 0;
private bool shapeMoved;
private bool shapeAdded;
@@ -63,7 +64,11 @@
base.DrawStart(panel, e);
mouseStart = Position;
shapeMoved = false;
- Console.WriteLine("Mouse down, Clicked?: " + (clickedOnShape !=
null).ToString());
+ if(clickedOnShape == null)
+ return;
+
+ RotateTransform t =
this.clickedOnShape.GetValue(Canvas.RenderTransformProperty) as RotateTransform;
+ this.initialRotation = (t != null) ? t.Angle : 0;
}
private List<Visual> GetSelectedObjects(MouseEventArgs e)
@@ -93,7 +98,6 @@
if(((rectLeft < (right)) && (rectLeft + rectWidth) > left)
&& (rectTop < (bottom)) && ((rectTop + rectHeight) > top))
{
- Console.WriteLine("Selected: " + visual.ToString());
// Due to the special handling for borders, we need to
// make sure we don't add the same shape twice
if(!shapes.Contains(visual))
@@ -177,7 +181,7 @@
Panel.Children.Remove(Element);
List<Visual> shapes = GetSelectedObjects(e);
Point mouseLocation = e.GetPosition(Panel);
- bool clickedOnShape = shapes.Count != 0;
+ bool clickedOnShape = shapes.Count != 0 || this.clickedOnShape !=
null;
bool mouseMoved = !mouseStart.Equals(Position);
shapeAdded = false;
@@ -191,6 +195,9 @@
Deselect(s);
else
Select(s);
+
+ if(this.clickedOnShape != null &&
!this.selectedObjects.ContainsKey(this.clickedOnShape))
+ Select(this.clickedOnShape);
}
if(!clickedOnShape && !mouseMoved)
@@ -206,6 +213,13 @@
controller.UndoEngine.PushUndo(new UndoMoveShape(movedShapes,
start));
}
+ if(this.clickedOnShape != null)
+ {
+ RotateTransform t =
this.clickedOnShape.GetValue(Canvas.RenderTransformProperty) as RotateTransform;
+ if(t != null && t.Angle != this.initialRotation)
+ this.controller.UndoEngine.PushUndo(new
UndoRotation(this.clickedOnShape, initialRotation, t.Angle));
+ }
+
foreach(KeyValuePair<Visual, SelectedBorder> keypair in
selectedObjects)
keypair.Value.MoveType = MoveType.Standard;
@@ -269,21 +283,29 @@
break;
case MoveType.StretchHeight:
- b.Child.SetValue<double>(Canvas.HeightProperty, oldHeight
+ offset.Y);
+ if((oldHeight + offset.Y) >= 0)
+ b.Child.SetValue<double>(Canvas.HeightProperty,
oldHeight + offset.Y);
break;
case MoveType.StretchLeft:
- b.Child.SetValue<double>(Canvas.LeftProperty, oldLeft +
offset.X);
- b.Child.SetValue<double>(Canvas.WidthProperty, oldWidth -
offset.X);
+ if((oldWidth - offset.X) >= 0)
+ {
+ b.Child.SetValue<double>(Canvas.LeftProperty, oldLeft
+ offset.X);
+ b.Child.SetValue<double>(Canvas.WidthProperty,
oldWidth - offset.X);
+ }
break;
case(MoveType.StretchTop):
- b.Child.SetValue<double>(Canvas.TopProperty, oldTop +
offset.Y);
- b.Child.SetValue<double>(Canvas.HeightProperty, oldHeight
- offset.Y);
+ if((oldHeight - offset.Y) >= 0)
+ {
+ b.Child.SetValue<double>(Canvas.TopProperty, oldTop +
offset.Y);
+ b.Child.SetValue<double>(Canvas.HeightProperty,
oldHeight - offset.Y);
+ }
break;
case MoveType.StretchWidth:
- b.Child.SetValue<double>(Canvas.WidthProperty, oldWidth +
offset.X);
+ if((oldWidth + offset.X) >= 0)
+ b.Child.SetValue<double>(Canvas.WidthProperty,
oldWidth + offset.X);
break;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches