Changeset 3177


Ignore:
Timestamp:
03/22/10 16:43:57 (12 years ago)
Author:
swagner
Message:

Moved extension methods of Control from HeuristicLab.Core.Views to HeuristicLab.MainForm.WindowsForms and suspended/resumed repainting in some controls to improve UI response times (#887).

Location:
trunk/sources
Files:
7 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r3149 r3177  
    8787  <ItemGroup>
    8888    <None Include="HeuristicLabCoreViewsPlugin.cs.frame" />
    89     <Compile Include="ControlExtensions.cs" />
    9089    <Compile Include="VariableValueView.cs">
    9190      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.cs

    r2870 r3177  
    2626using HeuristicLab.Common;
    2727using HeuristicLab.MainForm;
     28using HeuristicLab.MainForm.WindowsForms;
    2829
    2930namespace HeuristicLab.Core.Views {
     
    5354          Initialize();
    5455        }
     56      }
     57    }
     58
     59    public new bool Enabled {
     60      get { return base.Enabled; }
     61      set {
     62        this.SuspendRepaint();
     63        base.Enabled = value;
     64        this.ResumeRepaint(true);
    5565      }
    5666    }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ControlExtensions.cs

    r3171 r3177  
    2121
    2222using System;
     23using System.Runtime.InteropServices;
    2324using System.Windows.Forms;
    24 using System.Runtime.InteropServices;
    2525
    26 namespace HeuristicLab.Core.Views {
     26namespace HeuristicLab.MainForm.WindowsForms {
    2727  public static class ControlExtensions {
    2828    [DllImport("user32.dll")]
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/HeuristicLab.MainForm.WindowsForms-3.2.csproj

    r2900 r3177  
    9393    </Compile>
    9494    <None Include="HeuristicLabMainFormWindowsFormsPlugin.cs.frame" />
     95    <Compile Include="ControlExtensions.cs" />
    9596    <Compile Include="DockForm.cs">
    9697      <SubType>Form</SubType>
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.cs

    r2962 r3177  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.ComponentModel;
    25 using System.Drawing;
    26 using System.Data;
    27 using System.Text;
    28 using System.Xml;
    2923using System.Windows.Forms;
    3024
     
    161155    protected virtual void OnInitialized(EventArgs e) {
    162156    }
     157
     158    public new bool Enabled {
     159      get { return base.Enabled; }
     160      set {
     161        SuspendRepaint();
     162        base.Enabled = value;
     163        ResumeRepaint(true);
     164      }
     165    }
     166
     167    public void SuspendRepaint() {
     168      ((Control)this).SuspendRepaint();
     169    }
     170    public void ResumeRepaint(bool refresh) {
     171      ((Control)this).ResumeRepaint(refresh);
     172    }
    163173  }
    164174}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3149 r3177  
    146146        Invoke(new EventHandler(Content_Started), sender, e);
    147147      else {
    148         this.SuspendRepaint();
    149148        SaveEnabled = false;
    150149        parameterCollectionView.Enabled = false;
     
    156155        resetButton.Enabled = false;
    157156        UpdateExecutionTimeTextBox();
    158         this.ResumeRepaint(true);
    159157      }
    160158    }
     
    163161        Invoke(new EventHandler(Content_Stopped), sender, e);
    164162      else {
    165         this.SuspendRepaint();
    166163        SaveEnabled = true;
    167164        parameterCollectionView.Enabled = true;
     
    173170        resetButton.Enabled = true;
    174171        UpdateExecutionTimeTextBox();
    175         this.ResumeRepaint(true);
    176172      }
    177173    }
     
    207203        this.Cursor = Cursors.AppStarting;
    208204        newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = false;
     205        problemViewHost.Enabled = false;
    209206
    210207        var call = new Func<string, object>(XmlParser.Deserialize);
     
    223220            else
    224221              Content.Problem = problem;
     222            problemViewHost.Enabled = true;
    225223            newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = true;
    226224            this.Cursor = Cursors.Default;
     
    234232        this.Cursor = Cursors.AppStarting;
    235233        newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = false;
     234        problemViewHost.Enabled = false;
    236235
    237236        var call = new Action<IProblem, string, int>(XmlGenerator.Serialize);
     
    246245          }
    247246          Invoke(new Action(delegate() {
     247            problemViewHost.Enabled = true;
    248248            newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = true;
    249249            this.Cursor = Cursors.Default;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/UserDefinedAlgorithmView.cs

    r2998 r3177  
    112112        this.Cursor = Cursors.AppStarting;
    113113        newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = false;
     114        operatorGraphViewHost.Enabled = false;
    114115
    115116        var call = new Func<string, object>(XmlParser.Deserialize);
     
    127128            else
    128129              Content.OperatorGraph = operatorGraph;
     130            operatorGraphViewHost.Enabled = true;
    129131            newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true;
    130132            this.Cursor = Cursors.Default;
     
    138140        this.Cursor = Cursors.AppStarting;
    139141        newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = false;
     142        operatorGraphViewHost.Enabled = false;
    140143
    141144        var call = new Action<OperatorGraph, string, int>(XmlGenerator.Serialize);
     
    150153          }
    151154          Invoke(new Action(delegate() {
     155            operatorGraphViewHost.Enabled = true;
    152156            newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true;
    153157            this.Cursor = Cursors.Default;
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r2961 r3177  
    2828using HeuristicLab.Core.Views;
    2929using HeuristicLab.MainForm;
     30using HeuristicLab.MainForm.WindowsForms;
    3031using HeuristicLab.Persistence.Default.Xml;
    3132
     
    241242    private static void DisableView(IView view) {
    242243      Invoke(delegate() {
    243         ((UserControl)view).Enabled = false;
     244        ((Control)view).SuspendRepaint();
     245        ((Control)view).Enabled = false;
     246        ((Control)view).ResumeRepaint(true);
    244247      });
    245248    }
    246249    private static void EnableView(IView view) {
    247250      Invoke(delegate() {
    248         ((UserControl)view).Enabled = true;
     251        ((Control)view).SuspendRepaint();
     252        ((Control)view).Enabled = true;
     253        ((Control)view).ResumeRepaint(true);
    249254      });
    250255    }
Note: See TracChangeset for help on using the changeset viewer.