FormProgress.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //======================================================================
  2. //
  3. //
  4. //
  5. // CLR 版本: 4.0.30319.1
  6. // 命名空间: Tofly.AutoUpdateSystem.Win
  7. // 类 名: FormProgress
  8. // 创 建 人: 汤云伟
  9. // 创建时间: 2017/03/15
  10. // 修 改 人:
  11. // 修改时间:
  12. //
  13. //======================================================================
  14. using System;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Drawing;
  19. using System.Text;
  20. using System.Windows.Forms;
  21. using Tofly.AutoUpdateSystemLibrary;
  22. namespace Tofly.AutoUpdateSystem.Win
  23. {
  24. /// <summary>
  25. /// 单进度窗口
  26. /// </summary>
  27. public partial class FormProgress : Form, Tofly.AutoUpdateSystemLibrary.IFormProgress
  28. {
  29. /// <summary>
  30. /// 是否显示动态消息
  31. /// </summary>
  32. private bool _bShowDynamicInfo = false, _bAutoProgress = true;
  33. #region IFormProgress 接口实现
  34. /// <summary>
  35. /// 是否已按下‘取消’按钮
  36. /// </summary>
  37. public bool HasCanceled { get; private set; }
  38. /// <summary>
  39. /// 是否包含(显示)‘取消’按钮(默认 false)
  40. /// </summary>
  41. public bool HasCancelButton
  42. {
  43. set
  44. {
  45. this.btnCancel.Visible = value;
  46. }
  47. }
  48. /// <summary>
  49. /// 执行了取消操作
  50. /// </summary>
  51. public event CompleteProcessEventHandler DoCancelOperation;
  52. /// <summary>
  53. /// 更新标题文字
  54. /// </summary>
  55. public void UpdateTitle(string content)
  56. {
  57. try
  58. {
  59. if (this._bShowDynamicInfo)
  60. {
  61. this.Text = content;
  62. }
  63. }
  64. catch { }
  65. }
  66. #endregion
  67. private FormProgress()
  68. {
  69. InitializeComponent();
  70. }
  71. /// <summary>
  72. ///
  73. /// </summary>
  74. /// <param name="progressType">进度类型</param>
  75. /// <param name="showDynamicInfo">是否显示动态消息</param>
  76. /// <param name="autoProgress">是否自动进度更新</param>
  77. public FormProgress(bool showDynamicInfo = false, bool autoProgress = true)
  78. : this()
  79. {
  80. this.Text = "";
  81. this.lblError.Text = "";
  82. this.lblProgressInfo.Text = "正在进行处理,请稍候...";
  83. this._bShowDynamicInfo = showDynamicInfo;
  84. this._bAutoProgress = autoProgress;
  85. }
  86. private void btnCancel_Click(object sender, EventArgs e)
  87. {
  88. this.HasCanceled = true;
  89. if (this.DoCancelOperation != null)
  90. {
  91. this.DoCancelOperation();
  92. }
  93. }
  94. }
  95. }