星火微课系统客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AppUpdateWin.xaml.cs 3.0KB

il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
il y a 4 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. ProcessStartInfo psi = new ProcessStartInfo(filepath);
  73. Process pro = new Process
  74. {
  75. StartInfo = psi
  76. };
  77. pro.Start();
  78. Dispatcher.Invoke(new Action(() =>
  79. {
  80. System.Environment.Exit(0);
  81. }));
  82. Close();
  83. }
  84. public void downloadError(int position, string msg)
  85. {
  86. MessageWindow.Show(msg);
  87. }
  88. }
  89. }