diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/Checkbox.cs | 85 | ||||
| -rw-r--r-- | src/GraphicObjects/Expandable.cs | 21 | ||||
| -rw-r--r-- | src/GraphicObjects/Popper.cs | 28 | ||||
| -rw-r--r-- | src/GraphicObjects/RadioButton.cs | 75 |
4 files changed, 107 insertions, 102 deletions
diff --git a/src/GraphicObjects/Checkbox.cs b/src/GraphicObjects/Checkbox.cs index 863cae0c..d4deb171 100644 --- a/src/GraphicObjects/Checkbox.cs +++ b/src/GraphicObjects/Checkbox.cs @@ -19,51 +19,18 @@ namespace go [DefaultTemplate("#go.Templates.Checkbox.goml")]
public class Checkbox : TemplatedControl
{
- Label _caption;
- Image _image;
+ string caption;
+ string image;
+ bool isChecked;
+ #region CTOR
public Checkbox() : base()
{
- }
-
- protected override void loadTemplate(GraphicObject template = null)
- {
- base.loadTemplate (template);
-
- _caption = this.child.FindByName ("Caption") as Label;
- _image = this.child.FindByName ("Image") as Image;
- _image.SvgSub = "unchecked";
- }
-
-
- [XmlAttributeAttribute()][DefaultValue("Checkbox")]
- public string Caption {
- get { return _caption == null ? "" : _caption.Text; }
- set {
- if (_caption == null)
- return;
- _caption.Text = value;
- }
- }
- [XmlAttributeAttribute()][DefaultValue(false)]
- public bool IsChecked
- {
- get { return _image == null ? false :_image.SvgSub == "checked"; }
- set
- {
- if (value == IsChecked)
- return;
+ }
+ #endregion
- if (value)
- _image.SvgSub = "checked";
- else
- _image.SvgSub = "unchecked";
-
- NotifyValueChanged("IsChecked", IsChecked);
- //registerForGraphicUpdate();
- }
- }
+ #region GraphicObject overrides
[XmlAttributeAttribute()][DefaultValue(-1)]
public override int Height {
get { return base.Height; }
@@ -75,6 +42,44 @@ namespace go get { return base.Focusable; }
set { base.Focusable = value; }
}
+ #endregion
+
+ [XmlAttributeAttribute()][DefaultValue("Checkbox")]
+ public string Caption {
+ get { return caption; }
+ set {
+ if (caption == value)
+ return;
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue("#go.Images.Icons.checkbox.svg")]
+ public string Image {
+ get { return image; }
+ set {
+ if (image == value)
+ return;
+ image = value;
+ NotifyValueChanged ("Image", image);
+ }
+ }
+
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public bool IsChecked
+ {
+ get { return isChecked; }
+ set
+ {
+ isChecked = value;
+
+ NotifyValueChanged ("IsChecked", value);
+ if (isChecked)
+ NotifyValueChanged ("SvgSub", "checked");
+ else
+ NotifyValueChanged ("SvgSub", "unchecked");
+ }
+ }
public override void onMouseClick (object sender, MouseButtonEventArgs e)
{
IsChecked = !IsChecked;
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index c8490cba..f9e81c1a 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -80,30 +80,23 @@ namespace go image = value;
NotifyValueChanged ("Image", image);
}
- }
- [XmlAttributeAttribute()][DefaultValue("collapsed")]
- public string SvgSub {
- get { return IsExpanded ? "expanded" : "collapsed"; }
- }
-
+ }
[XmlAttributeAttribute()][DefaultValue(false)]
public bool IsExpanded
{
get { return _isExpanded; }
set
{
- if (value == _isExpanded)
- return;
-
_isExpanded = value;
- NotifyValueChanged ("SvgSub", SvgSub);
- if (_isExpanded)
+ if (_isExpanded) {
onExpand (this, null);
- else
- onCollapse (this, null);
+ NotifyValueChanged ("SvgSub", "expanded");
+ return;
+ }
- //registerForGraphicUpdate();
+ onCollapse (this, null);
+ NotifyValueChanged ("SvgSub", "collapsed");
}
}
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 41990247..76a12f58 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -69,10 +69,6 @@ namespace go NotifyValueChanged ("Image", image);
}
}
- [XmlAttributeAttribute()][DefaultValue("collapsed")]
- public string SvgSub {
- get { return IsPopped ? "expanded" : "collapsed"; }
- }
[XmlAttributeAttribute()][DefaultValue(false)]
public bool IsPopped
@@ -80,35 +76,39 @@ namespace go get { return _isPopped; }
set
{
- if (value == _isPopped)
- return;
-
_isPopped = value;
- NotifyValueChanged ("SvgSub", SvgSub);
- if (_isPopped)
+ if (_isPopped) {
onPop (this, null);
- else
- onUnpop (this, null);
+ NotifyValueChanged ("SvgSub", "expanded");
+ return;
+ }
- //registerForGraphicUpdate();
+ onUnpop (this, null);
+ NotifyValueChanged ("SvgSub", "collapsed");
}
}
public virtual void onPop(object sender, EventArgs e)
{
+ IGOLibHost tc = TopContainer;
+ if (tc == null)
+ return;
if (Content != null) {
Rectangle r = this.ScreenCoordinates (this.Slot);
Content.Visible = true;
Content.Left = r.Left;
Content.Top = r.Bottom;
- TopContainer.AddWidget (Content);
+ tc.AddWidget (Content);
}
Pop.Raise (this, e);
}
public virtual void onUnpop(object sender, EventArgs e)
{
- TopContainer.DeleteWidget (Content);
+ IGOLibHost tc = TopContainer;
+ if (tc == null)
+ return;
+ tc.DeleteWidget (Content);
Unpop.Raise (this, e);
}
diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs index 245fd2b2..7aa9370c 100644 --- a/src/GraphicObjects/RadioButton.cs +++ b/src/GraphicObjects/RadioButton.cs @@ -19,56 +19,62 @@ namespace go [DefaultTemplate("#go.Templates.RadioButton.goml")]
public class RadioButton : TemplatedControl
{
- Label _caption;
- Image _image;
+ string caption;
+ string image;
+ bool isChecked;
- public RadioButton() : base()
- {
- }
-
- protected override void loadTemplate(GraphicObject template = null)
+ #region CTOR
+ public RadioButton() : base(){}
+ #endregion
+
+ #region GraphicObject overrides
+ [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
+ public override bool Focusable
{
- base.loadTemplate (template);
-
- _caption = this.child.FindByName ("Caption") as Label;//TODO:should use bindings instead
- _image = this.child.FindByName ("Image") as Image;
- _image.SvgSub = "unchecked";
+ get { return base.Focusable; }
+ set { base.Focusable = value; }
}
-
[XmlAttributeAttribute()][DefaultValue(-1)]
public override int Height {
get { return base.Height; }
set { base.Height = value; }
}
- [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true
- public override bool Focusable
- {
- get { return base.Focusable; }
- set { base.Focusable = value; }
- }
+ #endregion
- [XmlAttributeAttribute][DefaultValue("RadioButton")]
+ [XmlAttributeAttribute()][DefaultValue("RadioButton")]
public string Caption {
- get { return _caption.Text; }
- set {
- _caption.Text = value;
+ get { return caption; }
+ set {
+ if (caption == value)
+ return;
+ caption = value;
+ NotifyValueChanged ("Caption", caption);
}
- }
+ }
+ [XmlAttributeAttribute()][DefaultValue("#go.Images.Icons.radiobutton.svg")]
+ public string Image {
+ get { return image; }
+ set {
+ if (image == value)
+ return;
+ image = value;
+ NotifyValueChanged ("Image", image);
+ }
+ }
+
[XmlAttributeAttribute()][DefaultValue(false)]
public bool IsChecked
{
- get { return _image == null ? false :_image.SvgSub == "checked"; }
+ get { return isChecked; }
set
{
-// if (value == IsChecked)
-// return;
-//
- if (value)
- _image.SvgSub = "checked";
+ isChecked = value;
+
+ NotifyValueChanged ("IsChecked", value);
+ if (isChecked)
+ NotifyValueChanged ("SvgSub", "checked");
else
- _image.SvgSub = "unchecked";
-
- registerForGraphicUpdate();
+ NotifyValueChanged ("SvgSub", "unchecked");
}
}
@@ -78,7 +84,8 @@ namespace go if (pg != null) {
foreach (RadioButton c in pg.Children.OfType<RadioButton>())
c.IsChecked = (c == this);
- }
+ } else
+ IsChecked = !IsChecked;
base.onMouseClick (sender, e);
}
|