aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs
new file mode 100644
index 000000000..f1d323a3a
--- /dev/null
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/RangeProgressBar.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.SharedUI.Controls
+{
+ public class RangeProgressBar : Control
+ {
+ private Border _innerBorder;
+ private Border _outerBorder;
+
+ static RangeProgressBar()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(RangeProgressBar), new FrameworkPropertyMetadata(typeof(RangeProgressBar)));
+ }
+
+ public Brush FillBrush
+ {
+ get { return (Brush)GetValue(FillBrushProperty); }
+ set { SetValue(FillBrushProperty, value); }
+ }
+ public static readonly DependencyProperty FillBrushProperty =
+ DependencyProperty.Register("FillBrush", typeof(Brush), typeof(RangeProgressBar), new PropertyMetadata(Brushes.Red));
+
+ public double Maximum
+ {
+ get { return (double)GetValue(MaximumProperty); }
+ set { SetValue(MaximumProperty, value); }
+ }
+ public static readonly DependencyProperty MaximumProperty =
+ DependencyProperty.Register("Maximum", typeof(double), typeof(RangeProgressBar), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender));
+
+ public double LowerValue
+ {
+ get { return (double)GetValue(LowerValueProperty); }
+ set { SetValue(LowerValueProperty, value); }
+ }
+ public static readonly DependencyProperty LowerValueProperty =
+ DependencyProperty.Register("LowerValue", typeof(double), typeof(RangeProgressBar), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender));
+
+ public double UpperValue
+ {
+ get { return (double)GetValue(UpperValueProperty); }
+ set { SetValue(UpperValueProperty, value); }
+ }
+ public static readonly DependencyProperty UpperValueProperty =
+ DependencyProperty.Register("UpperValue", typeof(double), typeof(RangeProgressBar), new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsRender));
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _innerBorder = GetTemplateChild("PART_InnerBorder") as Border;
+ _outerBorder = GetTemplateChild("PART_OuterBorder") as Border;
+ }
+
+ public RangeProgressBar()
+ {
+ SizeChanged += RangeProgressBar_SizeChanged;
+ }
+
+ private void RangeProgressBar_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ PlaceInnerBorder();
+ }
+
+ private void PlaceInnerBorder()
+ {
+ if (_innerBorder != null && !double.IsNaN(_outerBorder.ActualWidth) && _outerBorder.ActualWidth > 0 && Maximum > 0)
+ {
+ _innerBorder.Margin = new Thickness(LowerValue / Maximum * _outerBorder.ActualWidth, 0, _outerBorder.ActualWidth - (UpperValue / Maximum * _outerBorder.ActualWidth), 0);
+ }
+ }
+
+ protected override void OnRender(DrawingContext drawingContext)
+ {
+ base.OnRender(drawingContext);
+
+ PlaceInnerBorder();
+ }
+ }
+}