]> O.S.I.I.S - jp/crow.git/commitdiff
- generic conversion through Parse method for custom type xml
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Jun 2015 09:37:41 +0000 (11:37 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 6 Jun 2015 09:37:42 +0000 (11:37 +0200)
attribute

Templates/ItemTemplate.goml
Templates/Listbox.goml
Tests/Tests.csproj
src/GraphicObjects/Container.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/NumericControl.cs
src/LayoutingQueueItem.cs

index c35332e970dfd94bd7e29c3536d14a84103c505a..aa1b7371e48ef7cba2a8132a2fbe62a9b8d6c329 100755 (executable)
@@ -1,5 +1,7 @@
 <?xml version="1.0"?>\r
-<Label Margin="2" Focusable="true" Text="{}" \r
-       MouseEnter="{Background=SteelBlue}"\r
-       MouseLeave="{Background=Transparent}"\r
+\r
+<Label Text="{}" Focusable="true" Fit="true" Margin="0"\r
+               MouseEnter="{Background=SteelBlue}"\r
+               MouseLeave="{Background=Transparent}"\r
 />\r
+\r
index 4a661db0e01f0385e8415e56446835ebb4a6abb8..452877c3da99015035674a99f3f14555acd667e5 100755 (executable)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>\r
-<Border Margin="2" MinimumSize="0;200" Fit="True" Background="Gray">\r
-       <VerticalStack Name="List" Margin="0"/>\r
+<Border Margin="0" MinimumSize="0;200" Fit="True" Background="Gray">\r
+       <VerticalStack Name="List" Margin="1" VerticalAlignment="Top"/>\r
 </Border>
\ No newline at end of file
index d19fb844c2346a0474e09927611186dc15b38663..fc1ad786e965929cee7bfd73760f58dcdd09765c 100644 (file)
@@ -8,7 +8,7 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_Listbox</StartupObject>
+    <StartupObject>test.GOLIBTest_4</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
index 298f1873b1bb0f44bc4eefef41e6ba15c9742746..66e3b9e4c8277a9560de6129eec1fa2d5ad10d96 100644 (file)
@@ -63,7 +63,7 @@ namespace go
                }\r
                protected override Size measureRawSize ()\r
                {                       \r
-                       return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));\r
+                       return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));\r
                }\r
 \r
                protected override void OnLayoutChanges (LayoutingType layoutType)\r
index 0a402f12215fc100a4ae6deb3edd6a2a98e2ed93..9e55d1cfabedd63c72ed44afc90fb1012a1e6937 100644 (file)
@@ -213,7 +213,7 @@ namespace go
                                registerForGraphicUpdate ();\r
                        }\r
                }\r
-               [XmlAttributeAttribute()][DefaultValue(2)]\r
+               [XmlAttributeAttribute()][DefaultValue(2.0)]\r
                public virtual double CornerRadius {\r
                        get { return _cornerRadius; }\r
                        set {\r
@@ -314,23 +314,21 @@ namespace go
 \r
                                        DefaultValueAttribute dv = o as DefaultValueAttribute;\r
                                        if (dv != null) {\r
-                                               if (pi.PropertyType == typeof(Color))\r
-                                                       pi.SetValue (this, Color.Parse ((string)dv.Value), null);\r
-                                               else if (pi.PropertyType == typeof(Font))\r
-                                                       pi.SetValue (this, Font.Parse ((string)dv.Value), null);\r
-                                               else if (pi.PropertyType == typeof(Picture))\r
-                                                       pi.SetValue (this, Picture.Parse ((string)dv.Value), null);\r
-                                               else if (pi.PropertyType == typeof(Size))\r
-                                                       pi.SetValue (this, Size.Parse ((string)dv.Value), null);\r
-                                               else\r
-                                                       pi.SetValue (this, dv.Value, null);\r
-                                               continue;\r
-                                       }\r
-\r
-                                       //Debug.WriteLine (o.ToString ());\r
+                                               object defaultValue = dv.Value;\r
+                                               //avoid system types automaticaly converted by parser\r
+                                               if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {\r
+                                                       if (pi.PropertyType != defaultValue.GetType()) {\r
+                                                               MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);\r
+                                                               if (miParse != null) {                                                                  \r
+                                                                       pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);\r
+                                                                       continue;\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+                                               pi.SetValue (this, defaultValue, null); \r
+                                       }                                               \r
                                }\r
                        }\r
-\r
                }\r
 \r
                public virtual GraphicObject FindByName(string nameToFind){\r
@@ -749,18 +747,21 @@ namespace go
                                        string v = reader.GetAttribute (name);\r
 \r
                                        if (string.IsNullOrEmpty (v)) {\r
-                                               //TODO: maybe find another way to convert correctely colors default values\r
-                                               if (pi.PropertyType == typeof(Color))\r
-                                                       pi.SetValue (this, Color.Parse ((string)defaultValue), null);\r
-                                               else if (pi.PropertyType == typeof(Font))\r
-                                                       pi.SetValue (this, Font.Parse ((string)defaultValue), null);\r
-                                               else if (pi.PropertyType == typeof(Picture))\r
-                                                       pi.SetValue (this, Picture.Parse ((string)defaultValue), null);\r
-                                               else if (pi.PropertyType == typeof(Size))\r
-                                                       pi.SetValue (this, Size.Parse ((string)defaultValue), null);\r
-                                               else\r
-                                                       pi.SetValue (this, defaultValue, null);\r
+                                               //avoid system types automaticaly converted by parser\r
+                                               if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {\r
+                                                       if (pi.PropertyType != defaultValue.GetType()) {\r
+                                                               MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);\r
+                                                               if (miParse != null) {                                                                  \r
+                                                                       pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);\r
+                                                                       continue;\r
+                                                               }\r
+                                                       }\r
+                                               }\r
+\r
+                                               pi.SetValue (this, defaultValue, null);\r
+\r
                                        } else {\r
+                                               \r
                                                if (v.StartsWith("{")) {\r
                                                        //binding\r
                                                        if (!v.EndsWith("}"))\r
index 2cb7044680c03c27210a94bec76602415acb9ebe..9806c9928563f5f3e590f921186ba0e2baff578a 100755 (executable)
@@ -20,6 +20,7 @@ namespace go
                        get { return _pic == null ? null : _pic.Path; }\r
                        set {                           \r
                                LoadImage (value);\r
+                               _pic.KeepProportions = true;\r
                        }\r
                }\r
 \r
index c128929fee9aaedaec15cfc88ef1e6811a03c9cf..1e5332cad8576636d708523f202dc800a08068d8 100755 (executable)
@@ -405,14 +405,16 @@ namespace go
                        if (HasFocus)\r
                        {\r
                                //TODO:\r
-                               gr.Color = Color.White;\r
+                               gr.Color = Foreground;\r
                                gr.LineWidth = 1.5;\r
                                gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + currentLine * fe.Height));\r
                                gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (currentLine + 1) * fe.Height));\r
                                gr.Stroke();\r
                        }\r
                        #endregion\r
-                               \r
+\r
+                       //*******************\r
+                       //debug selection\r
 //                     gr.Color = Color.Green;\r
 //                     Rectangle R = new Rectangle(\r
 //                             rText.X +  (int)SelEndCursorPos-10,\r
@@ -429,6 +431,7 @@ namespace go
 //                             (int)fe.Height);\r
 //                     gr.Rectangle(R);\r
 //                     gr.Fill();\r
+                       //*******************\r
 \r
                        gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);\r
 \r
index c904712b1ef315951a62e1e87af4700aae5d9fe1..247b4e9264d86e4e5533d6f66a3965f56cfbbd28 100644 (file)
@@ -34,7 +34,7 @@ namespace go
                #endregion
 
                #region public properties
-               [XmlAttributeAttribute()][DefaultValue(0)]
+               [XmlAttributeAttribute()][DefaultValue(0.0)]
                public virtual double Minimum {
                        get { return minValue; }
                        set {
index b028fb83be76f7cce1169893a10c5a35b8829000..e1d21792790b0f06f05b01b68a79d8b6e351815e 100644 (file)
@@ -47,7 +47,7 @@ namespace go
                }
                public void ProcessLayouting()
                {
-                       //Debug.WriteLine ("Layouting => " + this.ToString ());
+                       Debug.WriteLine ("Layouting => " + this.ToString ());
                        try {
                                GraphicObject.UpdateLayout (LayoutType);
                        } catch (Exception ex) {