TestUpdateForm.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Y.Test.Commons;
  10. using Y.Utils.AppUtils.UpdateUtils;
  11. using Y.Utils.DataUtils.JsonUtils;
  12. using Y.Utils.DelegateUtils;
  13. using Y.Utils.IOUtils.TxtUtils;
  14. namespace Y.Test.Views
  15. {
  16. public partial class TestUpdateForm : Form
  17. {
  18. public TestUpdateForm()
  19. {
  20. InitializeComponent();
  21. }
  22. private void TestUpdateForm_Load(object sender, EventArgs e)
  23. {
  24. }
  25. private void button1_Click(object sender, EventArgs e)
  26. {
  27. AppUpdateTool aut = new AppUpdateTool();
  28. aut.Update("Oreo.NetMan", new Version(Application.ProductVersion),
  29. "http://localhost:20001/Update/Get?name=lalala",
  30. R.Paths.Temp, R.Paths.Relative,
  31. UIDownProgress, null, UIUnpackProgress, null);
  32. }
  33. private void UIDownProgress(object sender, ProgressEventArgs e)
  34. {
  35. BeginInvoke(new Action(() =>
  36. {
  37. progressBar1.Value = (int)(e.Current * 100 / e.Total);
  38. }));
  39. }
  40. private void UIUnpackProgress(object sender, ProgressEventArgs e)
  41. {
  42. BeginInvoke(new Action(() =>
  43. {
  44. progressBar2.Value = (int)(e.Current * 100 / e.Total);
  45. }));
  46. }
  47. }
  48. }