aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CircularGauge
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-06 13:59:21 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-06 13:59:21 +0300
commite852b5a6bf11f8bf85a8f59986da170364a3319f (patch)
tree7ed02bfe8f0f5272687a69edd6193acc6c1879fc /Software/Visual_Studio/Tango.CircularGauge
parentcd92ad2dc4a8df75c1b955757b07c796b064b7e2 (diff)
downloadTango-e852b5a6bf11f8bf85a8f59986da170364a3319f.tar.gz
Tango-e852b5a6bf11f8bf85a8f59986da170364a3319f.zip
Machine Studio v2.4
Diffstat (limited to 'Software/Visual_Studio/Tango.CircularGauge')
-rw-r--r--Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs39
-rw-r--r--Software/Visual_Studio/Tango.CircularGauge/Properties/AssemblyInfo.cs2
2 files changed, 31 insertions, 10 deletions
diff --git a/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs b/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
index 7e8f1fa8c..f2068d713 100644
--- a/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
+++ b/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
@@ -61,6 +61,7 @@ namespace Tango.CircularGauge
private Double arcradius1;
private Double arcradius2;
private int animatingSpeedFactor = 6;
+ private List<FrameworkElement> _toClear;
#endregion
@@ -77,13 +78,18 @@ namespace Tango.CircularGauge
/// Dependency property to Get/Set the Minimum Value
/// </summary>
public static readonly DependencyProperty MinValueProperty =
- DependencyProperty.Register("MinValue", typeof(double), typeof(CircularGaugeControl), null);
+ DependencyProperty.Register("MinValue", typeof(double), typeof(CircularGaugeControl), new PropertyMetadata(0.0, (d, e) => (d as CircularGaugeControl).OnMinMaxChanged()));
/// <summary>
/// Dependency property to Get/Set the Maximum Value
/// </summary>
public static readonly DependencyProperty MaxValueProperty =
- DependencyProperty.Register("MaxValue", typeof(double), typeof(CircularGaugeControl), null);
+ DependencyProperty.Register("MaxValue", typeof(double), typeof(CircularGaugeControl), new PropertyMetadata(100.0, (d, e) => (d as CircularGaugeControl).OnMinMaxChanged()));
+
+ private void OnMinMaxChanged()
+ {
+ DrawScale();
+ }
/// <summary>
/// Dependency property to Get/Set the Radius of the gauge
@@ -895,6 +901,7 @@ namespace Tango.CircularGauge
public CircularGaugeControl()
{
+ _toClear = new List<FrameworkElement>();
_rangeIndicators = new List<Path>();
}
@@ -1128,15 +1135,19 @@ namespace Tango.CircularGauge
//Reset Pointer
MovePointer(ScaleStartAngle);
}
-
-
-
}
//Drawing the scale with the Scale Radius
private void DrawScale()
{
+ foreach (var item in _toClear)
+ {
+ rootGrid.Children.Remove(item);
+ }
+
+ _toClear.Clear();
+
//Calculate one major tick angle
Double majorTickUnitAngle = ScaleSweepAngle / MajorDivisionsCount;
@@ -1211,8 +1222,9 @@ namespace Tango.CircularGauge
majortickgp.Children.Add(majorticktt);
majortickrect.RenderTransform = majortickgp;
tb.RenderTransform = majorscalevaluett;
- rootGrid.Children.Add(majortickrect);
- rootGrid.Children.Add(tb);
+
+ AddToRootGrid(majortickrect);
+ AddToRootGrid(tb);
//Drawing the minor axis ticks
@@ -1247,7 +1259,7 @@ namespace Tango.CircularGauge
minortickgp.Children.Add(minorticktt);
mr.RenderTransform = minortickgp;
- rootGrid.Children.Add(mr);
+ AddToRootGrid(mr);
}
@@ -1425,11 +1437,20 @@ namespace Tango.CircularGauge
rangeIndicator.SetValue(Canvas.ZIndexProperty, 150);
// Adding the segment to the root grid
- rootGrid.Children.Add(rangeIndicator);
+ if (!rootGrid.Children.Contains(rangeIndicator))
+ {
+ rootGrid.Children.Add(rangeIndicator);
+ }
return rangeIndicator;
}
#endregion
+
+ private void AddToRootGrid(FrameworkElement element)
+ {
+ rootGrid.Children.Add(element);
+ _toClear.Add(element);
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.CircularGauge/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.CircularGauge/Properties/AssemblyInfo.cs
index 58e9b0bf3..a3183ac9e 100644
--- a/Software/Visual_Studio/Tango.CircularGauge/Properties/AssemblyInfo.cs
+++ b/Software/Visual_Studio/Tango.CircularGauge/Properties/AssemblyInfo.cs
@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Windows;
[assembly: AssemblyTitle("Tango - Circular Gauge Control")]
-[assembly: AssemblyVersion("2.0.6.1407")]
+[assembly: AssemblyVersion("2.0.7.1347")]
[assembly: ComVisible(false)]