Author: alanmc
Date: 2007-07-03 13:53:10 -0400 (Tue, 03 Jul 2007)
New Revision: 81284

Modified:
   trunk/lunareclipse/ChangeLog
   trunk/lunareclipse/Controller/UndoEngine.cs
   trunk/lunareclipse/Model/Draw/DrawBase.cs
   trunk/lunareclipse/Model/Draw/SelectionDraw.cs
   trunk/lunareclipse/Model/SelectedBorder.cs
   trunk/lunareclipse/View/MainWindow.cs
Log:
* Model/SelectedBorder.cs: Automatically setting the width/height of
  the canvas based on the child element
* Model/Draw/SelectionDraw.cs: Moving items wrapped in a canvas works
  correctly
* Model/Draw/DrawBase.cs: Added a default fill to shapes
* Controller/UndoEngine.cs: Made some methods private as they shouldn't
  be publicly accessible.
* View/MainWindow.cs: Correctly clean up the current draw item when
  undoing an action

Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog        2007-07-03 17:46:35 UTC (rev 81283)
+++ trunk/lunareclipse/ChangeLog        2007-07-03 17:53:10 UTC (rev 81284)
@@ -1,5 +1,17 @@
 2007-07-03  Alan McGovern <[EMAIL PROTECTED]> 
 
+       * Model/SelectedBorder.cs: Automatically setting the width/height of
+         the canvas based on the child element
+       * Model/Draw/SelectionDraw.cs: Moving items wrapped in a canvas works
+         correctly
+       * Model/Draw/DrawBase.cs: Added a default fill to shapes
+       * Controller/UndoEngine.cs: Made some methods private as they shouldn't
+         be publicly accessible.
+       * View/MainWindow.cs: Correctly clean up the current draw item when
+         undoing an action
+
+2007-07-03  Alan McGovern <[EMAIL PROTECTED]> 
+
        Implemented initial support for selecting objects and drawing custom 
detauls around those objects.
 
 2007-07-02  Alan McGovern <[EMAIL PROTECTED]> 

Modified: trunk/lunareclipse/Controller/UndoEngine.cs
===================================================================
--- trunk/lunareclipse/Controller/UndoEngine.cs 2007-07-03 17:46:35 UTC (rev 
81283)
+++ trunk/lunareclipse/Controller/UndoEngine.cs 2007-07-03 17:53:10 UTC (rev 
81284)
@@ -55,13 +55,13 @@
             }
         }
         
-        internal void PushRedo(UndoActionBase action)
+        private void PushRedo(UndoActionBase action)
         {
             this.redo.Push(action);
             RaiseRedoAdded();
         }
         
-        internal UndoActionBase PopRedo()
+        private UndoActionBase PopRedo()
         {
             UndoActionBase b = this.redo.Pop();
             RaiseRedoRemoved();

Modified: trunk/lunareclipse/Model/Draw/DrawBase.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/DrawBase.cs   2007-07-03 17:46:35 UTC (rev 
81283)
+++ trunk/lunareclipse/Model/Draw/DrawBase.cs   2007-07-03 17:53:10 UTC (rev 
81284)
@@ -64,7 +64,6 @@
         internal DrawBase(Shape element)
         {
             this.element = element;
-            element.Stroke = new SolidColorBrush(Colors.Red);
         }
         
         internal virtual void Cleanup()
@@ -86,6 +85,7 @@
         {
             element = (Shape)Activator.CreateInstance(Element.GetType());
             element.Stroke = new SolidColorBrush(Colors.Red);
+            element.Fill = new SolidColorBrush(Colors.Cyan);
             panel.Children.Add(Element);
         }
         

Modified: trunk/lunareclipse/Model/Draw/SelectionDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/SelectionDraw.cs      2007-07-03 17:46:35 UTC 
(rev 81283)
+++ trunk/lunareclipse/Model/Draw/SelectionDraw.cs      2007-07-03 17:53:10 UTC 
(rev 81284)
@@ -55,10 +55,10 @@
         {
             base.DrawStart(panel, e);
             List<Visual> selectedShapes = GetSelectedObjects(e);
-            this.clickedOnShape = selectedShapes.Count != 0;
+            clickedOnShape = selectedShapes.Count != 0;
             mouseStart = Position;
             shapeMoved = false;
-            //Console.WriteLine("Mouse down, Clicked?: " + 
(clickedOnShape).ToString());
+            Console.WriteLine("Mouse down, Clicked?: " + 
(clickedOnShape).ToString());
         }
         
         private List<Visual> GetSelectedObjects(MouseEventArgs e)
@@ -72,8 +72,9 @@
              //Console.WriteLine(string.Format("RectTop: {0}, Left: {1}, 
Width: {2}, Height: {3}",
              //                     rectTop, rectLeft, rectWidth, rectHeight));
             int count=0;
-            foreach(Visual visual in Panel.Children)
+            foreach(Visual v in Panel.Children)
             {
+                Visual visual = v;
                 //Console.WriteLine("Iteration: " + (++count).ToString());
                 if(visual == Element)
                     continue;
@@ -84,6 +85,14 @@
                 double width = (double)visual.GetValue(Shape.WidthProperty);
                 double height = (double)visual.GetValue(Shape.HeightProperty);
                 
+                if(visual is SelectedBorder)
+                {
+                    SelectedBorder border = (SelectedBorder)visual;
+                    visual = border.Child;
+                    top -= 
(Double)((Canvas)border.Parent).GetValue(Canvas.TopProperty);
+                    left -= 
(Double)((Canvas)border.Parent).GetValue(Canvas.LeftProperty);
+                }
+                
                //Console.WriteLine(string.Format("Top: {0}, Left: {1}, Width: 
{2}, Height: {3}",
                //                   top, left, width, height));
                 if(((rectLeft < (left + width)) && (rectLeft + rectWidth) > 
left)
@@ -96,6 +105,12 @@
             
             
             shapes.Sort(new ZIndexComparer());
+            Console.WriteLine("Found: ");
+            foreach(Visual va in shapes)
+            {
+                Console.Write('\t');
+                Console.WriteLine(va.ToString());
+            }
             return shapes;
         }
         
@@ -120,10 +135,11 @@
                 if(!shapeAdded)
                 {
                     shapeAdded = true;
-                    if(clickedShape && 
!selectedObjects.ContainsKey(clickedShapes[0]))
+                    if(!selectedObjects.ContainsKey(clickedShapes[0]))
+                    {
                         DeselectAll();
-                    
-                    Select(clickedShapes[0]);
+                        Select(clickedShapes[0]);
+                    }
                 }
                 
                 foreach(KeyValuePair<Visual, SelectedBorder> keypair in 
selectedObjects)
@@ -171,6 +187,7 @@
                 Point start = mouseStart;
                 start.Offset(-mouseLocation.X, -mouseLocation.Y);
                 //Console.WriteLine("Offset is: " + start.ToString());
+                int i=0;
                 Visual[] movedShapes = new Visual[selectedObjects.Keys.Count];
                 selectedObjects.Keys.CopyTo(movedShapes, 0);
                 controller.UndoEngine.PushUndo(new UndoMoveShape(movedShapes, 
start));
@@ -203,18 +220,10 @@
         private void Select(Visual s)
         {
             SelectedBorder border = new SelectedBorder();
-            this.controller.Canvas.Children.Remove(s);
-            border.Children.Add(s);
-            this.controller.Canvas.Children.Add(border);
-            this.selectedObjects.Add(s, border);
-            
-            border.SetValue<double>(Canvas.TopProperty,
-                   (double)s.GetValue(Canvas.TopProperty) - 
SelectedBorder.BorderWidth);
-            border.SetValue<double>(Canvas.LeftProperty,
-                   (double)s.GetValue(Canvas.LeftProperty) - 
SelectedBorder.BorderWidth);
-            
-            s.SetValue<double>(Canvas.TopProperty, SelectedBorder.BorderWidth);
-            s.SetValue<double>(Canvas.LeftProperty, 
SelectedBorder.BorderWidth);
+            controller.Canvas.Children.Remove(s);
+            border.Child = s;
+            controller.Canvas.Children.Add(border);
+            selectedObjects.Add(s, border);
         }
         
         private void MoveShape(Visual s, Point offset)

Modified: trunk/lunareclipse/Model/SelectedBorder.cs
===================================================================
--- trunk/lunareclipse/Model/SelectedBorder.cs  2007-07-03 17:46:35 UTC (rev 
81283)
+++ trunk/lunareclipse/Model/SelectedBorder.cs  2007-07-03 17:53:10 UTC (rev 
81284)
@@ -20,9 +20,33 @@
             this.Background = new SolidColorBrush(Colors.Blue);
             this.IsHitTestVisible = false;
             this.Opacity = 0.3;
-            this.Width = 100;
-            this.Height = 100;
-            Console.WriteLine("This is visual: " + (this is 
System.Windows.Media.Visual).ToString());
         }
+        
+                
+        public Visual Child
+        {
+            get { return (Children.Count == 1) ? this.Children[0] : null; }
+            set 
+            {
+                if(value == null)
+                    throw new ArgumentNullException();
+                
+                if(Children.Count != 0)
+                    throw new InvalidOperationException("Cannot have more than 
one child");
+                
+                Children.Add(value);
+                
+                SetValue<double>(TopProperty,
+                        (double)value.GetValue(TopProperty) - BorderWidth);
+                SetValue<double>(LeftProperty,
+                        (double)value.GetValue(LeftProperty) - BorderWidth);
+                
+                value.SetValue<double>(Canvas.TopProperty, BorderWidth);
+                value.SetValue<double>(Canvas.LeftProperty, BorderWidth);
+                
+                Width = (double)value.GetValue(WidthProperty) + 2 * 
BorderWidth;
+                Height = (double)value.GetValue(HeightProperty) + 2 * 
BorderWidth;
+            }
+        }
     }
 }

Modified: trunk/lunareclipse/View/MainWindow.cs
===================================================================
--- trunk/lunareclipse/View/MainWindow.cs       2007-07-03 17:46:35 UTC (rev 
81283)
+++ trunk/lunareclipse/View/MainWindow.cs       2007-07-03 17:53:10 UTC (rev 
81284)
@@ -165,7 +165,10 @@
             
             undo = new Button("Undo");
             undo.Sensitive = false;
-            undo.Clicked += delegate { controller.UndoEngine.Undo(); };
+            undo.Clicked += delegate { 
+                controller.Current = null;
+                controller.UndoEngine.Undo(); 
+            };
             widgets.Add(undo);
             
             redo = new Button("Redo");

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to