aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-06-06 11:37:41 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-06-06 11:37:42 +0200
commit0128eebf85f3a0c29b2e6b63f966ddd27205818c (patch)
treeb431e74f6a747c26dc7a0db03b0427943567370f /src/GraphicObjects
parenta7363d1f7e4eb1611e4ab522c8cf381b70570b7e (diff)
- generic conversion through Parse method for custom type xml
attribute
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/Container.cs2
-rw-r--r--src/GraphicObjects/GraphicObject.cs55
-rwxr-xr-xsrc/GraphicObjects/Image.cs1
-rwxr-xr-xsrc/GraphicObjects/Label.cs7
-rw-r--r--src/GraphicObjects/NumericControl.cs2
5 files changed, 36 insertions, 31 deletions
diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs
index 298f1873..66e3b9e4 100644
--- a/src/GraphicObjects/Container.cs
+++ b/src/GraphicObjects/Container.cs
@@ -63,7 +63,7 @@ namespace go
}
protected override Size measureRawSize ()
{
- return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));
+ return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));
}
protected override void OnLayoutChanges (LayoutingType layoutType)
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 0a402f12..9e55d1cf 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -213,7 +213,7 @@ namespace go
registerForGraphicUpdate ();
}
}
- [XmlAttributeAttribute()][DefaultValue(2)]
+ [XmlAttributeAttribute()][DefaultValue(2.0)]
public virtual double CornerRadius {
get { return _cornerRadius; }
set {
@@ -314,23 +314,21 @@ namespace go
DefaultValueAttribute dv = o as DefaultValueAttribute;
if (dv != null) {
- if (pi.PropertyType == typeof(Color))
- pi.SetValue (this, Color.Parse ((string)dv.Value), null);
- else if (pi.PropertyType == typeof(Font))
- pi.SetValue (this, Font.Parse ((string)dv.Value), null);
- else if (pi.PropertyType == typeof(Picture))
- pi.SetValue (this, Picture.Parse ((string)dv.Value), null);
- else if (pi.PropertyType == typeof(Size))
- pi.SetValue (this, Size.Parse ((string)dv.Value), null);
- else
- pi.SetValue (this, dv.Value, null);
- continue;
- }
-
- //Debug.WriteLine (o.ToString ());
+ object defaultValue = dv.Value;
+ //avoid system types automaticaly converted by parser
+ if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {
+ if (pi.PropertyType != defaultValue.GetType()) {
+ MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);
+ if (miParse != null) {
+ pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);
+ continue;
+ }
+ }
+ }
+ pi.SetValue (this, defaultValue, null);
+ }
}
}
-
}
public virtual GraphicObject FindByName(string nameToFind){
@@ -749,18 +747,21 @@ namespace go
string v = reader.GetAttribute (name);
if (string.IsNullOrEmpty (v)) {
- //TODO: maybe find another way to convert correctely colors default values
- if (pi.PropertyType == typeof(Color))
- pi.SetValue (this, Color.Parse ((string)defaultValue), null);
- else if (pi.PropertyType == typeof(Font))
- pi.SetValue (this, Font.Parse ((string)defaultValue), null);
- else if (pi.PropertyType == typeof(Picture))
- pi.SetValue (this, Picture.Parse ((string)defaultValue), null);
- else if (pi.PropertyType == typeof(Size))
- pi.SetValue (this, Size.Parse ((string)defaultValue), null);
- else
- pi.SetValue (this, defaultValue, null);
+ //avoid system types automaticaly converted by parser
+ if (defaultValue != null && !pi.PropertyType.Namespace.StartsWith("System")) {
+ if (pi.PropertyType != defaultValue.GetType()) {
+ MethodInfo miParse = pi.PropertyType.GetMethod ("Parse", BindingFlags.Static | BindingFlags.Public);
+ if (miParse != null) {
+ pi.SetValue (this, miParse.Invoke (null, new object[]{ defaultValue }), null);
+ continue;
+ }
+ }
+ }
+
+ pi.SetValue (this, defaultValue, null);
+
} else {
+
if (v.StartsWith("{")) {
//binding
if (!v.EndsWith("}"))
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index 2cb70446..9806c992 100755
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -20,6 +20,7 @@ namespace go
get { return _pic == null ? null : _pic.Path; }
set {
LoadImage (value);
+ _pic.KeepProportions = true;
}
}
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index c128929f..1e5332ca 100755
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -405,14 +405,16 @@ namespace go
if (HasFocus)
{
//TODO:
- gr.Color = Color.White;
+ gr.Color = Foreground;
gr.LineWidth = 1.5;
gr.MoveTo(new PointD(textCursorPos + rText.X, rText.Y + currentLine * fe.Height));
gr.LineTo(new PointD(textCursorPos + rText.X, rText.Y + (currentLine + 1) * fe.Height));
gr.Stroke();
}
#endregion
-
+
+ //*******************
+ //debug selection
// gr.Color = Color.Green;
// Rectangle R = new Rectangle(
// rText.X + (int)SelEndCursorPos-10,
@@ -429,6 +431,7 @@ namespace go
// (int)fe.Height);
// gr.Rectangle(R);
// gr.Fill();
+ //*******************
gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs
index c904712b..247b4e92 100644
--- a/src/GraphicObjects/NumericControl.cs
+++ b/src/GraphicObjects/NumericControl.cs
@@ -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 {