using BPA.Helper;
using BPASmartClient.Update.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
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 BPASmartClient.Update
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.grProgressbar.Visibility = Visibility.Collapsed;
}
private void cancel_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private async void ok_Click(object sender, RoutedEventArgs e)
{
this.cancel.Visibility = Visibility.Collapsed;
this.grProgressbar.Visibility = Visibility.Visible;
await Task.Run(() =>
{
App.Current.Dispatcher.Invoke(() =>
{
this.progressbar.Value = 25;
this.tb.Text = "当前更新进度:1/4";
});
Thread.Sleep(2000);
App.Current.Dispatcher.Invoke(() =>
{
this.progressbar.Value = 50;
this.tb.Text = "当前更新进度:2/4";
});
Thread.Sleep(1500);
App.Current.Dispatcher.Invoke(() =>
{
this.progressbar.Value = 75;
this.tb.Text = "当前更新进度:3/4";
});
Thread.Sleep(3000);
App.Current.Dispatcher.Invoke(() =>
{
this.progressbar.Value = 100;
this.tb.Text = "当前更新进度:4/4";
});
Thread.Sleep(1500);
App.Current.Dispatcher.Invoke(() =>
{
this.progressbar.Value = 100;
this.tb.Text = "当前更新进度:更新完成";
});
Thread.Sleep(1500);
});
string directory = AppDomain.CurrentDomain.BaseDirectory;
Process.Start($"{directory}BPASmartClient.DosingSystem.exe");
Json.Save();
this.Close();
}
}
}