| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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 SummaryModule.Controls;
- /// <summary>
- /// Interaction logic for ValueBar.xaml
- /// </summary>
- public partial class ValueBar : UserControl
- {
- public ValueBar()
- {
- InitializeComponent();
- }
- public float MaxValue
- {
- get { return (float)GetValue(MaxValueProperty); }
- set { SetValue(MaxValueProperty, value); }
- }
- public static readonly DependencyProperty MaxValueProperty =
- DependencyProperty.Register(nameof(MaxValue), typeof(float), typeof(ValueBar), new PropertyMetadata(100f));
- public float Value
- {
- get { return (float)GetValue(ValueProperty); }
- set { SetValue(ValueProperty, value); }
- }
- public static readonly DependencyProperty ValueProperty =
- DependencyProperty.Register(nameof(Value), typeof(float), typeof(ValueBar), new PropertyMetadata(0f, PropertyChangedCallback));
- static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (d is not ValueBar valueBar)
- return;
- if (e.NewValue is not float value)
- return;
- switch (value)
- {
- case >= 0:
- valueBar.pos.Value = value;
- valueBar.neg.Value = 0;
- break;
- case < 0:
- valueBar.pos.Value = 0;
- valueBar.neg.Value = Math.Abs(value);
- break;
- }
- }
- }
|