星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppUpdateWin.xaml.cs 3.3KB

4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Windows;
  5. using System.Windows.Input;
  6. using XHWK.Model;
  7. using XHWK.WKTool.Helpers;
  8. using static XHWK.WKTool.Helpers.ZJDownloadUtil;
  9. namespace XHWK.WKTool
  10. {
  11. /// <summary>
  12. /// AppUpdateWin.xaml 的交互逻辑
  13. /// </summary>
  14. public partial class AppUpdateWin : Window, ZJDownloadCallback
  15. {
  16. private readonly AppUpdatePageModel pageData = new AppUpdatePageModel();
  17. public AppUpdateWin(Model_App app)
  18. {
  19. InitializeComponent();
  20. pageData.appModel = app;
  21. DataContext = pageData;
  22. }
  23. private void btnDown_Click(object sender, RoutedEventArgs e)
  24. {
  25. Close();
  26. }
  27. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  28. {
  29. DragMove();
  30. }
  31. public class AppUpdatePageModel : NotifyModel
  32. {
  33. public Model_App appModel { get; set; }
  34. }
  35. private void Button_Click(object sender, RoutedEventArgs e)
  36. {
  37. Close();
  38. }
  39. private void gengxinClick(object sender, RoutedEventArgs e)
  40. {
  41. string fileUrl = APP.showImageUrl + pageData.appModel.versionpath;
  42. string temp = System.Environment.GetEnvironmentVariable("TEMP");
  43. DirectoryInfo info = new DirectoryInfo(temp);
  44. if (!info.Exists)
  45. {
  46. info.Create();
  47. }
  48. //System.Console.WriteLine("fileUrl:" + fileUrl);
  49. string filename = fileUrl.Substring(fileUrl.LastIndexOf("/") + 1);
  50. if (filename != null)
  51. {
  52. ZJDownloadUtil.downloadFileWithCallback(fileUrl, 999, Dispatcher, this);
  53. }
  54. }
  55. public void downloadBegin(int position)
  56. {
  57. progress_sp.Visibility = Visibility.Visible;
  58. content_sv.Visibility = Visibility.Collapsed;
  59. button_bottom.Visibility = Visibility.Collapsed;
  60. }
  61. public void downloadProgress(int position, int progress)
  62. {
  63. mprogress.Value = progress;
  64. parogress_tb.Text = $"正在更新,已下载{progress}%";
  65. }
  66. public void downloadEnd(int position, string filepath)
  67. {
  68. //System.Console.WriteLine("filepath:" + filepath);
  69. progress_sp.Visibility = Visibility.Collapsed;
  70. content_sv.Visibility = Visibility.Visible;
  71. button_bottom.Visibility = Visibility.Visible;
  72. try
  73. {
  74. using (Process process = new Process())
  75. {
  76. process.StartInfo.FileName = filepath;
  77. process.StartInfo.CreateNoWindow = true;
  78. process.StartInfo.UseShellExecute = false;
  79. process.StartInfo.RedirectStandardOutput = true;
  80. process.StartInfo.RedirectStandardError = true;
  81. process.Start();
  82. }
  83. }
  84. catch (Exception)
  85. {
  86. }
  87. Dispatcher.Invoke(new Action(() =>
  88. {
  89. Environment.Exit(0);
  90. }));
  91. Close();
  92. }
  93. public void downloadError(int position, string msg)
  94. {
  95. MessageWindow.Show(msg);
  96. }
  97. }
  98. }