aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs')
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs102
1 files changed, 102 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs
new file mode 100644
index 000000000..510fd500d
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Tango.Touch.Controls
+{
+ public class TouchArcProgress : ProgressBar
+ {
+ private SharedUI.Shapes.Arc _arc;
+ private SharedUI.Shapes.Arc _arc_base;
+
+ public double RingThickness
+ {
+ get { return (double)GetValue(RingThicknessProperty); }
+ set { SetValue(RingThicknessProperty, value); }
+ }
+ public static readonly DependencyProperty RingThicknessProperty =
+ DependencyProperty.Register("RingThickness", typeof(double), typeof(TouchArcProgress), new PropertyMetadata(3.0));
+
+
+
+ public int MinArcAngle
+ {
+ get { return (int)GetValue(MinArcAngleProperty); }
+ set { SetValue(MinArcAngleProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MinArcAngle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MinArcAngleProperty =
+ DependencyProperty.Register("MinArcAngle", typeof(int), typeof(TouchArcProgress), new PropertyMetadata(40));
+
+
+
+ public int MaxArcAngle
+ {
+ get { return (int)GetValue(MaxArcAngleProperty); }
+ set { SetValue(MaxArcAngleProperty, value); }
+ }
+
+ // Using a DependencyProperty as the backing store for MaxArcAngle. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty MaxArcAngleProperty =
+ DependencyProperty.Register("MaxArcAngle", typeof(int), typeof(TouchArcProgress), new PropertyMetadata(320));
+
+
+
+ static TouchArcProgress()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchArcProgress), new FrameworkPropertyMetadata(typeof(TouchArcProgress)));
+ }
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _arc = GetTemplateChild("PART_ArcValue") as SharedUI.Shapes.Arc;
+ _arc_base = GetTemplateChild("PART_ArcBase") as SharedUI.Shapes.Arc;
+ SetArcBase();
+ SetArc();
+ }
+
+ protected override void OnValueChanged(double oldValue, double newValue)
+ {
+ base.OnValueChanged(oldValue, newValue);
+ SetArc();
+ }
+
+ protected override void OnMinimumChanged(double oldMinimum, double newMinimum)
+ {
+ base.OnMinimumChanged(oldMinimum, newMinimum);
+ SetArcBase();
+ SetArc();
+ }
+
+ protected override void OnMaximumChanged(double oldMaximum, double newMaximum)
+ {
+ base.OnMaximumChanged(oldMaximum, newMaximum);
+ SetArcBase();
+ SetArc();
+ }
+
+ private void SetArcBase()
+ {
+ if (_arc_base != null)
+ {
+ _arc_base.StartAngle = ((MaxArcAngle - MinArcAngle) * (Minimum / (Maximum - Minimum))) + MinArcAngle;
+ _arc_base.EndAngle = ((MaxArcAngle - MinArcAngle) * (Maximum / (Maximum - Minimum))) + MinArcAngle;
+ }
+ }
+
+ private void SetArc()
+ {
+ if (_arc != null)
+ {
+ _arc.StartAngle = ((MaxArcAngle - MinArcAngle) * (Minimum / (Maximum - Minimum))) + MinArcAngle;
+ _arc.EndAngle = ((MaxArcAngle - MinArcAngle) * (Value / (Maximum - Minimum))) + MinArcAngle;
+ }
+ }
+ }
+}