Author: alanmc
Date: 2007-08-08 16:31:13 -0400 (Wed, 08 Aug 2007)
New Revision: 83687
Added:
trunk/lunareclipse/Model/NameGenerator.cs
Modified:
trunk/lunareclipse/ChangeLog
trunk/lunareclipse/Controller/MoonlightController.cs
trunk/lunareclipse/LunarEclipse.mdp
trunk/lunareclipse/Model/Draw/RecordDraw.cs
trunk/lunareclipse/Model/Draw/Selector.cs
trunk/lunareclipse/Serialization/Serializer.cs
Log:
* Model/NameGenerator.cs, Model/Draw/RecordDraw.cs,
Model/Draw/Selector.cs, Controller/MoonlightController.cs,
LunarEclipse.mdp, Serialization/Serializer.cs: Added automatic
setting of the 'NameProperty' for all dependency properties. Items
are named when serialized or when you try to select/animate them.
Modified: trunk/lunareclipse/ChangeLog
===================================================================
--- trunk/lunareclipse/ChangeLog 2007-08-08 18:34:18 UTC (rev 83686)
+++ trunk/lunareclipse/ChangeLog 2007-08-08 20:31:13 UTC (rev 83687)
@@ -1,3 +1,11 @@
+2007-08-08 Alan McGovern <[EMAIL PROTECTED]>
+
+ * Model/NameGenerator.cs, Model/Draw/RecordDraw.cs,
Model/Draw/Selector.cs,
+ Controller/MoonlightController.cs, LunarEclipse.mdp,
+ Serialization/Serializer.cs: Added automatic setting of the
+ 'NameProperty' for all dependency properties. Items are named when
+ serialized or when you try to select/animate them.
+
2007-08-07 Alan McGovern <[EMAIL PROTECTED]>
* Model/Draw/RecordDraw.cs: Fixed several bugs involving setting the
first
Modified: trunk/lunareclipse/Controller/MoonlightController.cs
===================================================================
--- trunk/lunareclipse/Controller/MoonlightController.cs 2007-08-08
18:34:18 UTC (rev 83686)
+++ trunk/lunareclipse/Controller/MoonlightController.cs 2007-08-08
20:31:13 UTC (rev 83687)
@@ -28,10 +28,10 @@
private Serializer serializer;
private AnimationTimeline timeline;
- internal Canvas Canvas
- {
- get { return this.moonlight.Canvas; }
- }
+ internal Canvas Canvas
+ {
+ get { return this.moonlight.Canvas; }
+ }
public DrawBase Current
{
@@ -94,7 +94,7 @@
return;
active = true;
- try{this.Canvas.CaptureMouse();}catch{}
+ this.Canvas.CaptureMouse();
current.DrawStart(this.moonlight.Canvas, e);
Console.WriteLine("Current: {0}", current.ToString());
@@ -118,7 +118,7 @@
current.DrawEnd(e);
active = false;
- try{this.Canvas.ReleaseMouseCapture();}catch{}
+ this.Canvas.ReleaseMouseCapture();
if (!(current is SelectionDraw))
return;
Modified: trunk/lunareclipse/LunarEclipse.mdp
===================================================================
--- trunk/lunareclipse/LunarEclipse.mdp 2007-08-08 18:34:18 UTC (rev 83686)
+++ trunk/lunareclipse/LunarEclipse.mdp 2007-08-08 20:31:13 UTC (rev 83687)
@@ -62,6 +62,7 @@
<File name="./gtk-gui/generated.cs" subtype="Code" buildaction="Compile" />
<File name="./Model/Draw/RecordDraw.cs" subtype="Code"
buildaction="Compile" />
<File name="./Serialization/PropertyData.cs" subtype="Code"
buildaction="Compile" />
+ <File name="./Model/NameGenerator.cs" subtype="Code" buildaction="Compile"
/>
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="atk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
Modified: trunk/lunareclipse/Model/Draw/RecordDraw.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/RecordDraw.cs 2007-08-08 18:34:18 UTC (rev
83686)
+++ trunk/lunareclipse/Model/Draw/RecordDraw.cs 2007-08-08 20:31:13 UTC (rev
83687)
@@ -17,7 +17,6 @@
public class RecordDraw : Selector
{
private bool prepared;
- private static int nameCounter;
private Storyboard storyboard;
public RecordDraw(MoonlightController controller)
@@ -39,7 +38,6 @@
prepared = true;
storyboard = new Storyboard();
storyboard.Completed += new
EventHandler(Completed);
- storyboard.Pause();
Controller.Canvas.Resources.Add(storyboard);
}
}
@@ -61,11 +59,13 @@
public void Play()
{
+ Console.WriteLine(this.Controller.SerializeCanvas());
storyboard.Begin();
}
public void Seek(TimeSpan time)
{
+ Console.WriteLine(this.Controller.SerializeCanvas());
storyboard.BeginTime = time;
storyboard.Begin();
storyboard.Stop();
@@ -73,7 +73,7 @@
public void Stop()
{
- storyboard.Pause();
+ storyboard.Stop();
}
private void TimeChanged(object sender, EventArgs e)
@@ -85,10 +85,6 @@
{
LinearDoubleKeyFrame keyframe = null;
- // Make sure the 'name' of the shape isn't null. This
is a hack for the moment.
- if(string.IsNullOrEmpty(e.Target.Name))
-
e.Target.SetValue<string>(DependencyObject.NameProperty,
(nameCounter++).ToString());
-
// Get a timeline: either an existing one or a new one
DoubleAnimationUsingKeyFrames timeline =
GetTimeline(e.Target, e.Property);
Modified: trunk/lunareclipse/Model/Draw/Selector.cs
===================================================================
--- trunk/lunareclipse/Model/Draw/Selector.cs 2007-08-08 18:34:18 UTC (rev
83686)
+++ trunk/lunareclipse/Model/Draw/Selector.cs 2007-08-08 20:31:13 UTC (rev
83687)
@@ -254,6 +254,9 @@
private void Select(Visual s)
{
+ if(string.IsNullOrEmpty(s.Name))
+ s.SetValue<string>(Visual.NameProperty,
NameGenerator.GetName(this.Panel, s));
+
Console.WriteLine("Selecting: {0}", s.ToString());
SelectedBorder border = new SelectedBorder(s);
controller.Canvas.Children.Add(border);
Added: trunk/lunareclipse/Model/NameGenerator.cs
===================================================================
--- trunk/lunareclipse/Model/NameGenerator.cs 2007-08-08 18:34:18 UTC (rev
83686)
+++ trunk/lunareclipse/Model/NameGenerator.cs 2007-08-08 20:31:13 UTC (rev
83687)
@@ -0,0 +1,28 @@
+// NameGenerator.cs created with MonoDevelop
+// User: alan at 4:06 PMĀ 8/8/2007
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using LunarEclipse.Controller;
+
+namespace LunarEclipse
+{
+ public static class NameGenerator
+ {
+ public static string GetName(Panel container, DependencyObject
item)
+ {
+ int count = 0;
+ string basename = item.GetType().Name;
+ string name = basename;
+
+ while(container.FindName(name) != null)
+ name = string.Format("{0}{1}", basename,
++count);
+
+ return name;
+ }
+ }
+}
Modified: trunk/lunareclipse/Serialization/Serializer.cs
===================================================================
--- trunk/lunareclipse/Serialization/Serializer.cs 2007-08-08 18:34:18 UTC
(rev 83686)
+++ trunk/lunareclipse/Serialization/Serializer.cs 2007-08-08 20:31:13 UTC
(rev 83687)
@@ -14,14 +14,15 @@
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
-using PropertyPairList =
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.Type,
System.Reflection.FieldInfo>>;
+
namespace LunarEclipse.Serialization
{
internal class Serializer
{
+ private Canvas canvas;
private Dictionary<Type, DependencyObject> defaultValues;
-
+
internal Serializer()
{
defaultValues = new Dictionary<Type, DependencyObject>();
@@ -66,6 +67,8 @@
public string Serialize(Canvas canvas)
{
+ this.canvas = canvas;
+
StringBuilder sb = new StringBuilder();
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration=true;
@@ -81,8 +84,10 @@
private void Serialize(DependencyObject item, XmlWriter writer)
{
+ Type baseType = item.GetType();
- Type baseType = item.GetType();
+ if(string.IsNullOrEmpty(item.Name))
+
item.SetValue<string>(DependencyObject.NameProperty,
NameGenerator.GetName(this.canvas, item));
// Gets all the dependency properties for this item type
// and any relevant attached properties.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches