aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-11-04 18:01:49 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-11-04 18:01:49 +0100
commit8b4da93104f0c5e51c1fe5864fd3079c93ccd1ab (patch)
tree788e319cdf54817a1e2eee3ad46f6f1b43a24277 /src/GraphicObjects
parent1611f0aea0ec4e5d0239fb24c6db8897aace13c2 (diff)
label: compute correct text cursor when anlign is not left, ColorPicker and num control improvements
Diffstat (limited to 'src/GraphicObjects')
-rw-r--r--src/GraphicObjects/Label.cs14
-rw-r--r--src/GraphicObjects/NumericControl.cs26
2 files changed, 35 insertions, 5 deletions
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index 64ee9688..214e14ed 100644
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -265,6 +265,7 @@ namespace Crow
{
get {
return lines [CurrentLine] [CurrentColumn];
+ //return _currentCol > lines[CurrentLine].Length ? (char)0 : lines [CurrentLine] [CurrentColumn];
}
}
/// <summary>
@@ -775,6 +776,19 @@ namespace Crow
if (CurrentLine >= lines.Count)
CurrentLine = lines.Count - 1;
+ switch (TextAlignment) {
+ case Alignment.Center:
+ case Alignment.Top:
+ case Alignment.Bottom:
+ cPos+= ClientRectangle.Width - gr.TextExtents(lines [CurrentLine]).Width/2.0;
+ break;
+ case Alignment.Right:
+ case Alignment.TopRight:
+ case Alignment.BottomRight:
+ cPos += ClientRectangle.Width - gr.TextExtents(lines [CurrentLine]).Width;
+ break;
+ }
+
for (int i = 0; i < lines[CurrentLine].Length; i++)
{
string c = lines [CurrentLine].Substring (i, 1);
diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs
index 9b511831..8ab60edb 100644
--- a/src/GraphicObjects/NumericControl.cs
+++ b/src/GraphicObjects/NumericControl.cs
@@ -44,10 +44,24 @@ namespace Crow
#region private fields
double _actualValue, minValue, maxValue, smallStep, bigStep;
+ int _decimals;
#endregion
#region public properties
- [XmlAttributeAttribute()][DefaultValue(0.0)]
+ [XmlAttributeAttribute][DefaultValue(2)]
+ public int Decimals
+ {
+ get { return _decimals; }
+ set
+ {
+ if (value == _decimals)
+ return;
+ _decimals = value;
+ NotifyValueChanged("Decimals", _decimals);
+ RegisterForGraphicUpdate();
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(0.0)]
public virtual double Minimum {
get { return minValue; }
set {
@@ -59,7 +73,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue(100.0)]
+ [XmlAttributeAttribute][DefaultValue(100.0)]
public virtual double Maximum
{
get { return maxValue; }
@@ -72,7 +86,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue(1.0)]
+ [XmlAttributeAttribute][DefaultValue(1.0)]
public virtual double SmallIncrement
{
get { return smallStep; }
@@ -85,7 +99,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue(5.0)]
+ [XmlAttributeAttribute][DefaultValue(5.0)]
public virtual double LargeIncrement
{
get { return bigStep; }
@@ -98,7 +112,7 @@ namespace Crow
RegisterForRedraw ();
}
}
- [XmlAttributeAttribute()][DefaultValue(0.0)]
+ [XmlAttributeAttribute][DefaultValue(0.0)]
public double Value
{
get { return _actualValue; }
@@ -114,6 +128,8 @@ namespace Crow
else
_actualValue = value;
+ _actualValue = Math.Round (_actualValue, _decimals);
+
NotifyValueChanged("Value", _actualValue);
RegisterForGraphicUpdate();
}