From f86efbca4aac00a1a4e6d290feca1a0236c2d828 Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 23 Apr 2023 12:00:02 +0300 Subject: ArcProgress Control. --- .../Tango.Touch/Controls/TouchArcProgress.cs | 102 +++++++++++++++++++++ .../Tango.Touch/Controls/TouchArcProgress.xaml | 24 +++++ 2 files changed, 126 insertions(+) create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml (limited to 'Software/Visual_Studio/Tango.Touch/Controls') 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; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml new file mode 100644 index 000000000..518b3632c --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file -- cgit v1.3.1