星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

AppUpdateWin.xaml.cs 3.3KB

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