Changeset 9867
- Timestamp:
- 08/07/13 15:36:28 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs
r9865 r9867 29 29 public partial class ProgressView : AsynchronousContentView { 30 30 private const int DefaultCancelTimeoutMs = 3000; 31 private readonly IView parentView;31 private readonly IView view; 32 32 33 33 [Category("Custom"), Description("The time that the process is allowed to exit.")] … … 42 42 43 43 private Control Control { 44 get { return (Control) parentView; }44 get { return (Control)view; } 45 45 } 46 46 47 47 public bool DisposeOnFinish { get; set; } 48 48 49 public ProgressView( ) {49 public ProgressView(IView view) { 50 50 InitializeComponent(); 51 } 52 public ProgressView(IProgress progress) 53 : this() { 51 if (view == null) throw new ArgumentNullException("view", "The view is null."); 52 if (!(view is Control)) throw new ArgumentException("The view is not a control.", "view"); 53 this.view = view; 54 } 55 public ProgressView(IView view, IProgress progress) 56 : this(view) { 54 57 Content = progress; 55 58 } 56 public ProgressView(IView parentView) 57 : this() { 58 if (parentView == null) throw new ArgumentNullException("parentView", "The parent view is null."); 59 if (!(parentView is Control)) throw new ArgumentException("The parent view is not a control.", "parentView"); 60 this.parentView = parentView; 61 } 62 public ProgressView(IView parentView, IProgress progress) 63 : this(parentView) { 64 Content = progress; 65 } 66 67 public static ProgressView Attach(IView parentView, IProgress progress, bool disposeOnFinish = false) { 68 return new ProgressView(parentView, progress) { 59 60 public static ProgressView Attach(IView view, IProgress progress, bool disposeOnFinish = false) { 61 return new ProgressView(view, progress) { 69 62 DisposeOnFinish = disposeOnFinish 70 63 }; … … 106 99 if (InvokeRequired) Invoke((Action)ShowProgress); 107 100 else { 108 if ( parentView != null) {109 this.Left = (Control.ClientRectangle.Width / 2) - (this.Width / 2);110 this.Top = (Control.ClientRectangle.Height / 2) - (this.Height / 2);111 this.Anchor = AnchorStyles.None;101 if (view != null) { 102 Left = (Control.ClientRectangle.Width / 2) - (Width / 2); 103 Top = (Control.ClientRectangle.Height / 2) - (Height / 2); 104 Anchor = AnchorStyles.None; 112 105 113 106 LockBackground(); 114 115 if (!Control.Controls.Contains(this)) 116 Control.Controls.Add(this); 117 107 Parent = Control.Parent; 118 108 BringToFront(); 119 109 } … … 127 117 if (InvokeRequired) Invoke((Action)HideProgress); 128 118 else { 129 if (parentView != null) { 130 if (Control.Controls.Contains(this)) 131 Control.Controls.Remove(this); 132 119 if (view != null) { 120 Parent = null; 133 121 UnlockBackground(); 134 122 } … … 164 152 165 153 private void LockBackground() { 166 if (InvokeRequired) { 167 Invoke((Action)LockBackground); 168 } else { 169 foreach (Control c in Control.Controls) 170 c.Enabled = false; 171 Enabled = true; 154 if (InvokeRequired) Invoke((Action)LockBackground); 155 else { 156 view.Enabled = false; 172 157 } 173 158 } … … 176 161 if (InvokeRequired) Invoke((Action)UnlockBackground); 177 162 else { 178 foreach (Control c in Control.Controls) 179 c.Enabled = true; 180 Enabled = false; 163 view.Enabled = true; 181 164 } 182 165 }
Note: See TracChangeset
for help on using the changeset viewer.