aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/Image.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/GraphicObjects/Image.cs')
-rw-r--r--src/GraphicObjects/Image.cs79
1 files changed, 49 insertions, 30 deletions
diff --git a/src/GraphicObjects/Image.cs b/src/GraphicObjects/Image.cs
index fa036b97..281011ad 100644
--- a/src/GraphicObjects/Image.cs
+++ b/src/GraphicObjects/Image.cs
@@ -11,66 +11,81 @@ namespace Crow
{
Picture _pic;
string _svgSub;
- bool scaled;
- [XmlAttributeAttribute()][DefaultValue(true)]
+ bool scaled, keepProps;
+
+ #region Public properties
+ [XmlAttributeAttribute][DefaultValue(true)]
public virtual bool Scaled {
get { return scaled; }
set {
if (scaled == value)
return;
- scaled = value;
+ scaled = value;
NotifyValueChanged ("Scaled", scaled);
if (_pic == null)
return;
_pic.Scaled = scaled;
RegisterForGraphicUpdate ();
}
- }
- bool keepProps;
- [XmlAttributeAttribute()][DefaultValue(true)]
+ }
+ [XmlAttributeAttribute][DefaultValue(true)]
public virtual bool KeepProportions {
get { return keepProps; }
set {
if (keepProps == value)
return;
- keepProps = value;
+ keepProps = value;
NotifyValueChanged ("KeepProportions", keepProps);
if (_pic == null)
return;
_pic.KeepProportions = keepProps;
RegisterForGraphicUpdate ();
}
- }
- [XmlAttributeAttribute("Path")]
+ }
+ [XmlAttributeAttribute]
public string Path {
- get { return _pic == null ? null : _pic.Path; }
- set {
+ get { return _pic == null ? "" : _pic.Path; }
+ set {
+ if (value == Path)
+ return;
try {
- if (string.IsNullOrEmpty(value)){
- _pic = null;
- return;
- }
- lock(CurrentInterface.LayoutMutex){
- LoadImage (value);
- _pic.Scaled = scaled;
- _pic.KeepProportions = keepProps;
+ if (string.IsNullOrEmpty(value))
+ Picture = null;
+ else {
+ lock(CurrentInterface.LayoutMutex){
+ LoadImage (value);
+ }
}
} catch (Exception ex) {
Debug.WriteLine (ex.Message);
_pic = null;
}
+ NotifyValueChanged ("Path", Path);
}
}
-
- [XmlAttributeAttribute()][DefaultValue(null)]
+ [XmlAttributeAttribute]
public string SvgSub {
get { return _svgSub; }
set {
+ if (_svgSub == value)
+ return;
_svgSub = value;
RegisterForGraphicUpdate ();
}
}
-
+ [XmlAttributeAttribute]
+ public Picture Picture {
+ get { return _pic; }
+ set {
+ if (_pic == value)
+ return;
+ _pic = value;
+ NotifyValueChanged ("Picture", _pic);
+ RegisterForGraphicUpdate ();
+ }
+ }
+ #endregion
+
#region CTOR
public Image () : base()
{
@@ -80,14 +95,17 @@ namespace Crow
#region Image Loading
public void LoadImage (string path)
{
+ Picture pic;
+ if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
+ pic = new SvgPicture ();
+ else
+ pic = new BmpPicture ();
- if (path.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
- _pic = new SvgPicture ();
- else
- _pic = new BmpPicture ();
+ pic.LoadImage (path);
+ pic.Scaled = scaled;
+ pic.KeepProportions = keepProps;
- _pic.LoadImage (path);
- RegisterForGraphicUpdate ();
+ Picture = pic;
}
#endregion
@@ -95,12 +113,13 @@ namespace Crow
protected override int measureRawSize (LayoutingType lt)
{
if (_pic == null)
- _pic = "#Crow.Images.Icons.IconAlerte.svg";
+ return 2 * Margin;
+ //_pic = "#Crow.Images.Icons.IconAlerte.svg";
//TODO:take scalling in account
if (lt == LayoutingType.Width)
return _pic.Dimensions.Width + 2 * Margin;
else
- return _pic.Dimensions.Height + 2 * Margin;
+ return _pic.Dimensions.Height + 2 * Margin;
}
protected override void onDraw (Context gr)
{