123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Windows.Controls;
- using System.Windows.Threading;
- namespace PackageUploader
- {
- /// <summary>
- /// WinMFMUploadProcress.xaml 的交互逻辑
- /// </summary>
- public partial class WinMFMUploadProcress :INotifyPropertyChanged
- {
- private double m_ProgressLeft;
- public WinMFMUploadProcress()
- {
- InitializeComponent();
- m_ProgressLeft=Canvas.GetLeft(progressBar);
- this.DataContext = this;
- //var lblwidth = lblpresent.Width;
- //Canvas.SetLeft(lblpresent, m_ProgressLeft - (lblwidth / 2.0));
- }
- private string m_FloorName;
- public string FloorName
- {
- get { return m_FloorName; }
- set
- {
- m_FloorName = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("FloorName"));
- }
- }
- private string m_LabelPath;
- public string LabelPath
- {
- get { return m_LabelPath; }
- set
- {
- m_LabelPath = value;
- PropertyChanged?.Invoke(this,new PropertyChangedEventArgs("LabelPath"));
- }
- }
- private string m_Present;
- public string Present
- {
- get { return m_Present; }
- set
- {
- m_Present = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Present"));
- }
- }
- //public string FloorName
- //{
- // set { txtFloorName.Content = value; }
- //}
- //public string LabelPath
- //{
- // set { txtPath.Text = value; }
- //}
- public int Count { get; set; }
- public int Cur { get; set; }
- public event PropertyChangedEventHandler PropertyChanged;
- public void Update(string currentData)
- {
- //lblpresent.Content = Present;
- //Present = currentData;
- this.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; }, DispatcherPriority.Background);
- //DispatcherFrame nestedFrame = new DispatcherFrame();
- //DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);
- //Dispatcher.PushFrame(nestedFrame);
- //if (exitOperation.Status !=
- // DispatcherOperationStatus.Completed)
- //{
- // exitOperation.Abort();
- //}
- //lblpresent.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; },
- // DispatcherPriority.Background);
- //this.Dispatcher.Invoke(() => { lblpresent.Content = currentData + "%"; }, DispatcherPriority.Background);
- //var progresswidth = progressBar.Width;
- //var progressleft = Canvas.GetLeft(progressBar);
- //var lblwidth = lblpresent.Width;
- ////Canvas.SetLeft(lblpresent, progressleft + progresswidth * (currentData / 100.0) - (lblwidth / 2.0))), DispatcherPriority.Background
- //Dispatcher.Invoke(
- // new Action(() =>
- // {
- // lblpresent_Total.Content = $"({Cur}/{Count})";
- // lblpresent.Content = currentData + "%";
- // } ), DispatcherPriority.Background);
- //Dispatcher.Invoke(
- // new Action(() => Canvas.SetLeft(lblpresent, progressleft + progresswidth * (currentData / 100.0) - (lblwidth / 2.0))),DispatcherPriority.Background);
- //Canvas.SetLeft(lblpresent, progressleft+progresswidth*(currentData/100.0)-(lblwidth/2.0));
- //Dispatcher.Invoke(
- // new Action<DependencyProperty, object>((db, value) => this.progressBar.SetValue(db, value)),
- // System.Windows.Threading.DispatcherPriority.Background,
- // RangeBase.ValueProperty, Convert.ToDouble(currentData));
- }
- private static DispatcherOperationCallback exitFrameCallback = new DispatcherOperationCallback(ExitFrame);
- private static Object ExitFrame(Object state)
- {
- DispatcherFrame frame = state as
- DispatcherFrame;
- frame.Continue = false;
- return null;
- }
- }
- }
|