Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/11/17 10:00:34 (7 years ago)
Author:
pfleck
Message:

#2845 Removed Visible property and hide on "Finished".

Location:
branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.cs

    r15415 r15417  
    4848      this.content = content;
    4949
    50       UpdateButtonsState();
    51       if (content.Visible) ShowProgress();
     50      if (content.ProgressState != ProgressState.Finished)
     51        ShowProgress();
    5252      RegisterContentEvents();
    5353    }
    5454
    55     /// <summary>
    56     /// Clean up any resources being used.
    57     /// </summary>
    58     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    5955    protected override void Dispose(bool disposing) {
    6056      DeregisterContentEvents();
     
    7268      content.ProgressBarModeChanged += new EventHandler(Content_ProgressBarModeChanged);
    7369      content.ProgressValueChanged += new EventHandler(Content_ProgressValueChanged);
    74       content.VisibleChanged += new EventHandler(Content_VisibleChanged);
    7570      content.CanBeStoppedChanged += new EventHandler(Content_CanBeStoppedChanged);
    7671      content.CanBeCanceledChanged += new EventHandler(Content_CanBeCanceledChanged);
     
    8176      content.ProgressBarModeChanged -= new EventHandler(Content_ProgressBarModeChanged);
    8277      content.ProgressValueChanged -= new EventHandler(Content_ProgressValueChanged);
    83       content.VisibleChanged -= new EventHandler(Content_VisibleChanged);
    8478      content.CanBeStoppedChanged -= new EventHandler(Content_CanBeStoppedChanged);
    8579      content.CanBeCanceledChanged -= new EventHandler(Content_CanBeCanceledChanged);
     
    10296    }
    10397
    104     private void Content_VisibleChanged(object sender, EventArgs e) {
    105       if (content.Visible)
     98    private void Content_CanBeStoppedChanged(object sender, EventArgs e) {
     99      UpdateButtonsState();
     100    }
     101    private void Content_CanBeCanceledChanged(object sender, EventArgs e) {
     102      UpdateButtonsState();
     103    }
     104
     105    private void ShowProgress() {
     106      if (control.InvokeRequired) {
     107        control.Invoke((Action)ShowProgress);
     108        return;
     109      }
     110      if (Parent != null) return;
     111
     112      int height = (content.CanBeStopped || content.CanBeCanceled) ? Height : collapsedControlHeight;
     113      Left = (control.ClientRectangle.Width / 2) - (Width / 2);
     114      Top = (control.ClientRectangle.Height / 2) - (height / 2);
     115      Anchor = AnchorStyles.None;
     116
     117      UpdateProgressMessage();
     118      UpdateProgressValue();
     119      UpdateButtonsState();
     120
     121      control.Enabled = false;
     122      Parent = control.Parent;
     123      BringToFront();
     124      Visible = true;
     125    }
     126
     127    private void HideProgress() {
     128      if (control.InvokeRequired) {
     129        control.Invoke((Action)HideProgress);
     130        return;
     131      }
     132      if (Parent == null) return;
     133
     134      Visible = false;
     135      control.Enabled = true;
     136      Parent = null;
     137    }
     138
     139    private void UpdateProgressState() {
     140      if (control.InvokeRequired) {
     141        control.Invoke((Action)UpdateProgressState);
     142        return;
     143      }
     144
     145      if (content.ProgressState != ProgressState.Finished)
    106146        ShowProgress();
    107147      else
    108148        HideProgress();
    109     }
    110 
    111     private void Content_CanBeStoppedChanged(object sender, EventArgs e) {
    112       UpdateButtonsState();
    113     }
    114     private void Content_CanBeCanceledChanged(object sender, EventArgs e) {
    115       UpdateButtonsState();
    116     }
    117 
    118     private void ShowProgress() {
    119       if (control.InvokeRequired) {
    120         control.Invoke((Action)ShowProgress);
    121         return;
    122       }
    123 
    124       int height = (content.CanBeStopped || content.CanBeCanceled) ? Height : collapsedControlHeight;
    125 
    126       Left = (control.ClientRectangle.Width / 2) - (Width / 2);
    127       Top = (control.ClientRectangle.Height / 2) - (height / 2);
    128       Anchor = AnchorStyles.None;
    129 
    130       control.Enabled = false;
    131       Parent = control.Parent;
    132       BringToFront();
    133 
    134       UpdateProgressValue();
    135       UpdateProgressMessage();
    136       UpdateButtonsState();
    137       Visible = true;
    138     }
    139 
    140     private void HideProgress() {
    141       if (control.InvokeRequired) {
    142         control.Invoke((Action)HideProgress);
    143         return;
    144       }
    145 
    146       control.Enabled = true;
    147       Parent = null;
    148       Visible = false;
    149     }
    150 
    151     private void UpdateProgressState() {
    152       if (control.InvokeRequired) {
    153         control.Invoke((Action)UpdateProgressState);
    154         return;
    155       }
    156149
    157150      switch (content.ProgressState) {
    158151        case ProgressState.Started:
     152        case ProgressState.Finished:
    159153          progressBar.SetState(ProgressBarState.Normal);
    160154          break;
    161         case ProgressState.Finished:
    162           HideProgress();
    163           progressBar.SetState(ProgressBarState.Normal);
    164           break;
    165         case ProgressState.Stopped:
     155        case ProgressState.StopRequested:
    166156          progressBar.SetState(ProgressBarState.Warning);
    167157          break;
    168         case ProgressState.Canceled:
     158        case ProgressState.CancelRequested:
    169159          progressBar.SetState(ProgressBarState.Error);
    170160          break;
     
    211201
    212202      stopButton.Visible = content.CanBeStopped;
    213       stopButton.Enabled = content.ProgressState == ProgressState.Started && content.CanBeStopped;
     203      stopButton.Enabled = content.CanBeStopped && content.ProgressState == ProgressState.Started;
    214204
    215205      cancelButton.Visible = content.CanBeCanceled;
    216       cancelButton.Enabled = content.ProgressState == ProgressState.Started && content.CanBeCanceled;
     206      cancelButton.Enabled = content.CanBeCanceled && content.ProgressState == ProgressState.Started;
    217207
    218208      if (content.CanBeStopped || content.CanBeCanceled) {
  • branches/EnhancedProgress/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ProgressView.designer.cs

    r15415 r15417  
    103103      // stopButton
    104104      //
    105       this.stopButton.Dock = System.Windows.Forms.DockStyle.Left;
    106105      this.stopButton.Location = new System.Drawing.Point(193, 3);
    107106      this.stopButton.Name = "stopButton";
Note: See TracChangeset for help on using the changeset viewer.