Author: alanmc
Date: 2007-08-22 14:57:37 -0400 (Wed, 22 Aug 2007)
New Revision: 84650

Modified:
   trunk/lunareclipse/ChangeLog
   trunk/lunareclipse/Controls/TimeLine/AnimationTimeline.cs
   trunk/lunareclipse/Controls/TimeLine/KeyframeMarker.cs
   trunk/lunareclipse/Model/SelectedBorder.cs
   trunk/lunareclipse/Model/StoryboardManager.cs
   trunk/lunareclipse/Serialization/ReflectionHelper.cs
   trunk/lunareclipse/View/MainWindow.cs
   trunk/lunareclipse/View/PropertyGroupLayout.cs
Log:
* Model/StoryboardManager.cs, Model/SelectedBorder.cs,
  Controls/TimeLine/KeyframeMarker.cs,
  Controls/TimeLine/AnimationTimeline.cs, View/MainWindow.cs,
  View/PropertyGroupLayout.cs, Serialization/ReflectionHelper.cs:
  Removed calls to Toolbox.ChangeProperty for properties that
  shouldn't announce their change globally. Reimplemented the
  Property Changing code.

Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog        2007-08-22 17:42:17 UTC (rev 84649)
+++ trunk/lunareclipse/ChangeLog        2007-08-22 18:57:37 UTC (rev 84650)
@@ -1,3 +1,12 @@
+2007-08-22  Alan McGovern <[EMAIL PROTECTED]> 
+
+       * Model/StoryboardManager.cs, Model/SelectedBorder.cs,
+         Controls/TimeLine/KeyframeMarker.cs,
+         Controls/TimeLine/AnimationTimeline.cs, View/MainWindow.cs,
+         View/PropertyGroupLayout.cs, Serialization/ReflectionHelper.cs: 
Removed
+         calls to Toolbox.ChangeProperty for properties that shouldn't announce
+         their change globally. Reimplemented the Property Changing code.
+
 2007-08-21  Alan McGovern <[EMAIL PROTECTED]> 
 
        * Properties/PropertyManager.cs: Hooking into the Selected and 
deselected

Modified: trunk/lunareclipse/Controls/TimeLine/AnimationTimeline.cs
===================================================================
--- trunk/lunareclipse/Controls/TimeLine/AnimationTimeline.cs   2007-08-22 
17:42:17 UTC (rev 84649)
+++ trunk/lunareclipse/Controls/TimeLine/AnimationTimeline.cs   2007-08-22 
18:57:37 UTC (rev 84650)
@@ -124,7 +124,7 @@
                                divisionMarkers[currentMarker++].Left = -200;
                        
                        while(currentTextblock < divisionTextblocks.Count)
-                               
Toolbox.ChangeProperty(divisionTextblocks[currentTextblock++], 
System.Windows.Controls.Canvas.LeftProperty, -200);
+                               
divisionTextblocks[currentTextblock++].SetValue<object>(System.Windows.Controls.Canvas.LeftProperty,
 -200);
                        
                        // Make sure that the position marker is placed 
correctly on
                        // the canvas
@@ -146,9 +146,9 @@
                        
                        block.Text = marker.Time.ToString();
                        block.Text = 
block.Text.Substring(block.Text.IndexOf(':') + 1);
-                       Toolbox.ChangeProperty(block, 
System.Windows.Controls.Canvas.LeftProperty, marker.Left - block.ActualWidth / 
2.0);
-                       Toolbox.ChangeProperty(block, 
System.Windows.Controls.Canvas.TopProperty, Height - block.ActualHeight);
-                       Toolbox.ChangeProperty(block, 
TextBlock.ForegroundProperty, new SolidColorBrush(Colors.White));
+                       
block.SetValue<double>(System.Windows.Controls.Canvas.LeftProperty, marker.Left 
- block.ActualWidth / 2.0);
+                       
block.SetValue<double>(System.Windows.Controls.Canvas.TopProperty, Height - 
block.ActualHeight);
+                       block.SetValue<Brush>(TextBlock.ForegroundProperty, new 
SolidColorBrush(Colors.White));
                }
                
                private void MouseDown(object sender, MouseEventArgs e)
@@ -235,7 +235,7 @@
                        marker.Time = time;
                        marker.Width = 15;
                        marker.Height = 15;
-                       Toolbox.ChangeProperty(marker, 
System.Windows.Controls.Canvas.TopProperty, (this.Height - 15.0) / 2.0);
+                       
marker.SetValue<double>(System.Windows.Controls.Canvas.TopProperty, 
(this.Height - 15.0) / 2.0);
                        marker.MouseLeftButtonDown += delegate (object sender, 
MouseEventArgs e) {
                                this.clickedItem = (IMarker)sender;
                        };

Modified: trunk/lunareclipse/Controls/TimeLine/KeyframeMarker.cs
===================================================================
--- trunk/lunareclipse/Controls/TimeLine/KeyframeMarker.cs      2007-08-22 
17:42:17 UTC (rev 84649)
+++ trunk/lunareclipse/Controls/TimeLine/KeyframeMarker.cs      2007-08-22 
18:57:37 UTC (rev 84650)
@@ -41,7 +41,7 @@
                        : base()
                {
                        ellipse = (Ellipse)InitializeFromXaml("<Ellipse 
Name=\"Ellipse\"/>");
-                       Toolbox.ChangeProperty(ellipse, Ellipse.FillProperty, 
new SolidColorBrush(Colors.Green)); 
+                       ellipse.SetValue<Brush>(Ellipse.FillProperty, new 
SolidColorBrush(Colors.Green)); 
                        this.time = time;
                        this.timeline = timeline;
                }

Modified: trunk/lunareclipse/Model/SelectedBorder.cs
===================================================================
--- trunk/lunareclipse/Model/SelectedBorder.cs  2007-08-22 17:42:17 UTC (rev 
84649)
+++ trunk/lunareclipse/Model/SelectedBorder.cs  2007-08-22 18:57:37 UTC (rev 
84650)
@@ -109,7 +109,7 @@
                 
                 child = value;
                 
-                Toolbox.ChangeProperty(this, ZIndexProperty, int.MaxValue);
+                SetValue<double>(ZIndexProperty, int.MaxValue);
                 if(!updating)
                 {
                     updating = true;
@@ -120,15 +120,15 @@
 
                 if(TransformGroup == null)
                                {
-                                       Toolbox.ChangeProperty(child, 
RenderTransformOriginProperty, new Point(0.5, 0.5));
+                                       
child.SetValue<Point>(RenderTransformOriginProperty, new Point(0.5, 0.5));
                                        TransformGroup = new TransformGroup();
                     TransformGroup.Children.Add(new ScaleTransform());
                                        TransformGroup.Children.Add(new 
SkewTransform());
                                        TransformGroup.Children.Add(new 
RotateTransform());
                                        TransformGroup.Children.Add(new 
TranslateTransform());
                                }
-                               Toolbox.ChangeProperty(this, 
RenderTransformProperty, TransformGroup);
-                               Toolbox.ChangeProperty(this, 
RenderTransformOriginProperty, Child.GetValue(RenderTransformOriginProperty));
+                               
SetValue<TransformGroup>(RenderTransformProperty, TransformGroup);
+                               SetValue<object>(RenderTransformOriginProperty, 
Child.GetValue(RenderTransformOriginProperty));
             }
         }
             
@@ -159,8 +159,8 @@
             // First set the position of the selection canvas
             Top = (childTop - BorderWidth);
             Left = (childLeft - BorderWidth);
-            Toolbox.ChangeProperty(this, WidthProperty, childWidth + 
BorderWidth * 2);
-                       Toolbox.ChangeProperty(this, HeightProperty, 
childHeight + BorderWidth * 2);
+            SetValue<double>(WidthProperty, childWidth + BorderWidth * 2);
+                       SetValue<double>(HeightProperty, childHeight + 
BorderWidth * 2);
 
             
DrawHandles(((VisualCollection)base.GetValue(ChildrenProperty)).Count == 0);
         }

Modified: trunk/lunareclipse/Model/StoryboardManager.cs
===================================================================
--- trunk/lunareclipse/Model/StoryboardManager.cs       2007-08-22 17:42:17 UTC 
(rev 84649)
+++ trunk/lunareclipse/Model/StoryboardManager.cs       2007-08-22 18:57:37 UTC 
(rev 84650)
@@ -128,12 +128,8 @@
                {
                        if(hook)
                        {
-                               s.ChangedHeight += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedHeight += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedLeft += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedRotation += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedTop += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedWidth += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
+                               Toolbox.PropertyChanged += new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
+                               
                                s.MouseDown += delegate {
                                        Stop();
                                };
@@ -145,12 +141,7 @@
                        }
                        else
                        {
-                               s.ChangedHeight -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedHeight -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedLeft -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedRotation -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedTop -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
-                               s.ChangedWidth -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
+                               Toolbox.PropertyChanged -= new 
EventHandler<PropertyChangedEventArgs>(PropertyChanged);
                                s.MouseDown -= delegate {
                                        Stop();
                                };
@@ -174,8 +165,13 @@
                        // Sometimes the dependency object we're changing the 
property of is not
                        // the object passed in. We are actually changing one 
of it's children. In this
                        // case we need to resolve down to that child and use 
it instead
-
+                       
+                       Console.WriteLine("Changing: {0} Property: {1} Value: 
{2}->{3}", e.Target.Name,
+                                         
ReflectionHelper.GetData(e.Property).ShortName,
+                                         e.OldValue, e.NewValue);
+                       
                        string path = ReflectionHelper.GetFullPath(e.Target, 
e.Property);
+                       Console.WriteLine("Path: {0}", path);
                        ReflectionHelper.Resolve(path, e.Target, out target, 
out property);
                        if(string.IsNullOrEmpty(target.Name))
                                
target.SetValue<string>(DependencyObject.NameProperty, 
NameGenerator.GetName(this.controller.Canvas, target));
@@ -190,7 +186,7 @@
                        {
                                LinearDoubleKeyFrame kf = new 
LinearDoubleKeyFrame();
                                kf.KeyTime = TimeSpan.Zero;
-                               kf.Value = (double)(target == e.Target ? 
e.OldValue : target.GetValue(property));
+                               kf.Value = Convert.ToDouble(target == e.Target 
? e.OldValue : target.GetValue(property));
                                timeline.KeyFrames.Add(kf);
                        }
                        
@@ -204,13 +200,13 @@
                        if(keyframe == null)
                        {
                                keyframe = new LinearDoubleKeyFrame();
-                               keyframe.Value = (double)(target == e.Target ? 
e.OldValue : target.GetValue(property));
+                               keyframe.Value = Convert.ToDouble(target == 
e.Target ? e.OldValue : target.GetValue(property));
                                keyframe.KeyTime = 
controller.Timeline.CurrentPosition;
                                timeline.KeyFrames.Add(keyframe);
                                controller.Timeline.AddKeyframe(timeline, 
keyframe.KeyTime.TimeSpan);
                        }
                        
-                       double difference = (double)e.NewValue - 
(double)e.OldValue;
+                       double difference = Convert.ToDouble(e.NewValue) - 
Convert.ToDouble(e.OldValue);
                        keyframe.Value += difference;
                        undos.Add(new UndoPropertyChange(e.Target, e.Property, 
e.OldValue, e.NewValue));
                        //e.Target.SetValue<object>(e.Property, e.OldValue);
@@ -245,9 +241,9 @@
                        
                        // There was no pre-existing timeline, so create a new 
one
                        animation = new DoubleAnimationUsingKeyFrames();
-                       Toolbox.ChangeProperty(animation, 
Storyboard.NameProperty, NameGenerator.GetName(controller.Canvas, animation));
-                       Toolbox.ChangeProperty(animation, 
Storyboard.TargetNameProperty, target.Name);
-                       Toolbox.ChangeProperty(animation, 
Storyboard.TargetPropertyProperty, ReflectionHelper.GetFullPath(target, 
property));
+                       animation.SetValue<string>(Storyboard.NameProperty, 
NameGenerator.GetName(controller.Canvas, animation));
+                       
animation.SetValue<string>(Storyboard.TargetNameProperty, target.Name);
+                       
animation.SetValue<string>(Storyboard.TargetPropertyProperty, 
ReflectionHelper.GetFullPath(target, property));
                        Current.Children.Add(animation);
                        return animation;
                }

Modified: trunk/lunareclipse/Serialization/ReflectionHelper.cs
===================================================================
--- trunk/lunareclipse/Serialization/ReflectionHelper.cs        2007-08-22 
17:42:17 UTC (rev 84649)
+++ trunk/lunareclipse/Serialization/ReflectionHelper.cs        2007-08-22 
18:57:37 UTC (rev 84650)
@@ -23,6 +23,9 @@
                
                // This dictionary is keyed by the 'fully' qualified name of 
the dependency property
                // i.e. the string "Canvas.LeftProperty" is paired with the 
DependencyProperty 'Canvas.LeftProperty' etc
+               // Note, the properties are stored by both the type the 
DependencyProperty is declared in
+               // and the Type it is accessible from i.e. 
'UIElement.Visibility' and 'Rectangle.Visibility'
+               // both point towards the same thing
                private static Dictionary<string, DependencyProperty> 
propertyByName;
                
                // This dictionary contains all the PropertyData objects except 
it is 
@@ -75,11 +78,17 @@
 
                public static string GetFullPath(DependencyObject target, 
DependencyProperty property)
                {
+                       if(target == null)
+                               throw new ArgumentNullException("target");
+                       
+                       if(property == null)
+                               throw new ArgumentNullException("property");
+                       
                        StringBuilder result = new StringBuilder(64);
                        
                        Type targetType = target.GetType();
                        List<PropertyData> properties = 
ReflectionHelper.GetProperties(target, true);
-                       
+                       Console.WriteLine("Target: {0}->{1}", 
target.GetType().Name, properties.Count); 
                        if(SpecialCase(target, property, result))
                                return result.ToString();
                        
@@ -104,6 +113,12 @@
 
                public static void Resolve(string propertyPath, 
DependencyObject original, out DependencyObject target, out DependencyProperty 
property)
                {
+                       if(string.IsNullOrEmpty(propertyPath))
+                               throw new ArgumentException("propertyPath 
cannot be null or empty");
+                       
+                       if(original == null)
+                               throw new ArgumentNullException("original");
+                       
                        // Initially we assume that the final object we will be 
applying the property to is the same as
                        // the original object
                        target = original;
@@ -119,6 +134,7 @@
                                // Get the property that is targeted by this 
string
                                string[] parts = matches[i].Value.Split(')');
                                string propertyName = parts[0].Substring(1, 
parts[0].Length - 1);
+                               Console.WriteLine("Finding: {0}", propertyName);
                                property = 
ReflectionHelper.propertyByName[propertyName];
 
                                // When this condition is true, we know we have 
found the target object and the property
@@ -133,9 +149,10 @@
                                        target = GetFromIndex(parts[1], target);
                        }
 
+                       Console.WriteLine("Couldn't resolve");
                        target = null;
                        property = null;
-                               }
+               }
                
                
                private static void SetUpList()
@@ -174,6 +191,10 @@
                                        string name = 
propData.DeclaringType.Name + '.' + propData.ShortName;
                                        if(!propertyByName.ContainsKey(name))
                                                propertyByName.Add(name, 
propData.Property);
+                                       
+                                       name = propData.BaseType.Name + '.' + 
propData.ShortName;
+                                       if(!propertyByName.ContainsKey(name))
+                                               propertyByName.Add(name, 
propData.Property);
                                
                                        
if(!propertyDataByProperty.ContainsKey(propData.Property))
                                                
propertyDataByProperty.Add(propData.Property, propData);

Modified: trunk/lunareclipse/View/MainWindow.cs
===================================================================
--- trunk/lunareclipse/View/MainWindow.cs       2007-08-22 17:42:17 UTC (rev 
84649)
+++ trunk/lunareclipse/View/MainWindow.cs       2007-08-22 18:57:37 UTC (rev 
84650)
@@ -8,8 +8,9 @@
 using System.Xml;
 using System.Text;
 using System.IO;
+using System.Windows;
 using System.Windows.Controls;
-using System.Windows;
+using System.Windows.Media;
 using Gtk;
 
 using LunarEclipse.Controls;
@@ -152,12 +153,107 @@
                                propertyPane.Remove(widget);
                        
                        foreach(PropertyInfo info in 
this.controller.PropertyManager.Properties)
-                               propertyPane.PackEnd(new 
Label(info.PropertyData.ShortName));
+                               
propertyPane.PackEnd(CreatePropertyWidget(controller.PropertyManager.SelectedObject.Child,
 info));
                        
                        propertyPane.ThawChildNotify();
                        propertyPane.ShowAll();
                }
                
+               private Widget CreatePropertyWidget(DependencyObject o, 
PropertyInfo info)
+               {
+                       HBox b = new HBox(true, 0);
+                       Adjustment adj = null;
+                       SpinButton spin = null;
+                       Label l  = new Label(info.PropertyData.ShortName);
+                       l.SetAlignment(0.0f, 0.5f);
+                       b.PackStart(l);
+                       
+                       switch(info.Type)
+                       {
+                               
+                       case PropertyType.Double:
+                       case PropertyType.Integer:
+                               adj = new Adjustment (0.0, 0.0, Int32.MaxValue, 
1.0, 10.0, 100.0);
+                               spin = new SpinButton (adj, 1.0, 0);
+                               spin.SetRange (0.0, (double) Int32.MaxValue);
+                               spin.Numeric = true;
+                               if(info.Type == PropertyType.Integer)
+                               {
+                                       spin.Value = 
(int)o.GetValue(info.PropertyData.Property);
+                                       spin.ValueChanged += delegate (object 
sender, EventArgs e) {
+                                               Toolbox.ChangeProperty(o, 
info.PropertyData.Property, spin.ValueAsInt);
+                                       };
+                               }
+                               else
+                               {
+                                       spin.Value = 
(double)o.GetValue(info.PropertyData.Property);
+                                       spin.ValueChanged += delegate (object 
sender, EventArgs e) {
+                                               Toolbox.ChangeProperty(o, 
info.PropertyData.Property, spin.Value);
+                                       };
+                               }
+                               b.PackEnd(spin);
+                               break;
+                       
+                       case PropertyType.Percent:
+                               adj = new Adjustment (0.0, 0.0, 1.0, 0.01, 0.1, 
1.0);
+                               spin = new SpinButton (adj, 0.01, 2);
+                               spin.Numeric = true;
+                               spin.SetRange (0.0, 1.0);
+                               spin.Value = 
(double)o.GetValue(info.PropertyData.Property);
+                               spin.ValueChanged += delegate (object sender, 
EventArgs e) {
+                                       Toolbox.ChangeProperty(o, 
info.PropertyData.Property, spin.Value);
+                               };
+                               b.PackEnd(spin);
+                               break;
+                               
+                       case PropertyType.PenLineCap:
+                               b.PackEnd(CreateEnumPropertyWidget(o, info, 
typeof(PenLineCap)));
+                               break;
+                               
+                       case PropertyType.PenLineJoin:
+                               b.PackEnd(CreateEnumPropertyWidget(o, info, 
typeof(PenLineJoin)));
+                               break;
+                               
+                       case PropertyType.Visibility:
+                               b.PackEnd(CreateEnumPropertyWidget(o, info, 
typeof(Visibility)));
+                               break;
+                       
+                       case PropertyType.Stretch:
+                               b.PackEnd(CreateEnumPropertyWidget(o, info, 
typeof(Stretch)));
+                               break;
+                               
+                       case PropertyType.DashArray:
+                       case PropertyType.Data:
+                               b.PackEnd(new Entry());
+                               break;
+                               
+                       default:
+                               b.PackEnd(new Label(string.Format("Unsupported: 
{0}", info.Type)));
+                               break;
+                       }
+                       
+                       return b;
+               }
+               
+               private Widget CreateEnumPropertyWidget(DependencyObject o, 
PropertyInfo info, Type type)
+               {
+                       string[] names = Enum.GetNames(type);
+                       int[] values = (int[])Enum.GetValues(type);
+                       int value = (int)o.GetValue(info.PropertyData.Property);
+                       
+                       ComboBox b = new ComboBox(names);
+                       
+                       for(int i=0; i < values.Length; i++)
+                               if(values[i] == value)
+                                       b.Active = i;
+                       
+                       b.Changed += delegate (object sender, EventArgs e) {
+                               Toolbox.ChangeProperty(o, 
info.PropertyData.Property, Enum.Parse(type, b.ActiveText));
+                       };
+                       
+                       return b;
+               }
+               
                private VBox InitialiseWidgets()
                {
                        VBox widgets = new VBox();

Modified: trunk/lunareclipse/View/PropertyGroupLayout.cs
===================================================================
--- trunk/lunareclipse/View/PropertyGroupLayout.cs      2007-08-22 17:42:17 UTC 
(rev 84649)
+++ trunk/lunareclipse/View/PropertyGroupLayout.cs      2007-08-22 18:57:37 UTC 
(rev 84650)
@@ -80,22 +80,8 @@
                                Widget label = new Label (propName);
                                label.Show ();
                                
-                               Adjustment adj = new Adjustment (0.0, 0.0, 
Int32.MaxValue, 1.0, 10.0, 100.0);
-                               Widget widget = new SpinButton (adj, 1.0, 0);
-                               ((SpinButton) widget).SetRange (0.0, (double) 
Int32.MaxValue);
-                               ((SpinButton) widget).Numeric = true;
-                               
-                               if (value != null) {
-                                       switch (value.GetType ().Name) {
-                                       case "Double":
-                                               ((SpinButton) widget).Value = 
(double) value;
-                                               break;
-                                       case "Int32":
-                                               ((SpinButton) widget).Value = 
(int) value;
-                                               break;
-                                       }
-                               }
 
+
                                ((SpinButton) widget).ValueChanged += new 
EventHandler(OnIntegerChanged);
                                
                                propTable.Add (widget, prop);

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

Reply via email to