123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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 PDF_Office.CustomControl
- {
- /// <summary>
- /// BatchStatus.xaml 的交互逻辑
- /// </summary>
- public partial class BatchStatus : UserControl
- {
- public BatchStatus()
- {
- InitializeComponent();
- }
- public int MaxStatusValue
- {
- get { return (int)GetValue(MaxStatusValueProperty); }
- set
- {
- SetValue(MaxStatusValueProperty, value);
- }
- }
- // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty MaxStatusValueProperty =
- DependencyProperty.Register("MaxStatusValue", typeof(int), typeof(BatchStatus), new PropertyMetadata(10));
- public string StatusValue
- {
- get { return (string)GetValue(StatusValueProperty); }
- set
- {
- SetValue(StatusValueProperty, value);
- }
- }
- // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty StatusValueProperty =
- DependencyProperty.Register("StatusValue", typeof(string), typeof(BatchStatus), new PropertyMetadata("wait",
- new PropertyChangedCallback(OnPropertyChanged), // 第3个值回调位置
- new CoerceValueCallback(OnCoerceValueCallback) // 第2个强制回调位置
- )
- , new ValidateValueCallback(OnValidateValueCallBack));
- static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- (d as BatchStatus).CalculateProgress(e.NewValue.ToString());
-
- }
- static object OnCoerceValueCallback(DependencyObject d, object obj)
- {
-
- return obj;
- }
- static bool OnValidateValueCallBack(object obj)
- {
-
- return true;
- }
- void CalculateProgress(string value)
- {
- if (value == "wait")
- {
- this.wait.Visibility = Visibility.Visible;
- this.complete.Visibility = Visibility.Hidden;
- this.error.Visibility = Visibility.Hidden;
- this.progress.Visibility = Visibility.Hidden;
- }
- if (value == "complete")
- {
- this.complete.Visibility = Visibility.Visible;
- this.wait.Visibility = Visibility.Hidden;
- this.error.Visibility = Visibility.Hidden;
- this.progress.Visibility = Visibility.Hidden;
- }
- if (value == "error")
- {
- this.error.Visibility = Visibility.Visible;
- this.wait.Visibility = Visibility.Hidden;
- this.complete.Visibility = Visibility.Hidden;
- this.progress.Visibility = Visibility.Hidden;
- }
- if (int.TryParse(value, out _))
- {
- this.progress.Visibility = Visibility.Visible;
- this.wait.Visibility = Visibility.Hidden;
- this.complete.Visibility = Visibility.Hidden;
- this.error.Visibility = Visibility.Hidden;
- double step = (double.Parse(value) / (double)MaxStatusValue) * Math.PI;
- progressBar.StrokeDashArray = new DoubleCollection() { step, 10000 };
- }
- }
-
-
- }
- }
|