Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11765


Ignore:
Timestamp:
01/15/15 13:45:49 (10 years ago)
Author:
jkarder
Message:

#2077:

  • added checks for InvokeRequired
  • minor code changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/CodeEditor/HeuristicLab.Scripting.Views/3.3/ScriptView.cs

    r11700 r11765  
    136136        Locked = false;
    137137        codeEditor.Focus();
    138         //OnContentChanged();
    139138      }
    140139    }
     
    172171        ch.Width = -2;
    173172    }
     173
     174    #region ProgressView
     175    private bool progressViewCreated;
     176
     177    private void AddProgressView(string progressMessage) {
     178      var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     179      mainForm.AddOperationProgressToView(this, progressMessage);
     180      progressViewCreated = true;
     181    }
     182
     183    private void RemoveProgressView() {
     184      if (!progressViewCreated) return;
     185      var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     186      mainForm.RemoveOperationProgressFromView(this);
     187      progressViewCreated = false;
     188    }
     189    #endregion
    174190    #endregion
    175191
    176192    #region Event Handlers
    177193    private void Content_CodeChanged(object sender, EventArgs e) {
    178       if (InvokeRequired)
    179         Invoke(new EventHandler(Content_CodeChanged), sender, e);
     194      if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_CodeChanged, sender, e);
    180195      else {
    181196        codeEditor.UserCode = Content.Code;
     
    203218
    204219    private void codeEditor_AssembliesLoading(object sender, EventArgs<IEnumerable<Assembly>> e) {
    205       if (e.Value.Count() <= SilentAssemblyLoadingOperationLimit) return;
    206       var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    207       mainForm.AddOperationProgressToView(this, AssembliesLoadingMessage);
     220      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesLoading, sender, e);
     221      else {
     222        int nrOfAssemblies = e.Value.Count();
     223        if (nrOfAssemblies > SilentAssemblyLoadingOperationLimit)
     224          AddProgressView(AssembliesLoadingMessage);
     225      }
    208226    }
    209227
    210228    private void codeEditor_AssembliesLoaded(object sender, EventArgs<IEnumerable<Assembly>> e) {
    211       if (e.Value.Count() <= SilentAssemblyLoadingOperationLimit) return;
    212       var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    213       mainForm.RemoveOperationProgressFromView(this);
     229      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesLoaded, sender, e);
     230      else {
     231        RemoveProgressView();
     232      }
    214233    }
    215234
    216235    private void codeEditor_AssembliesUnloading(object sender, EventArgs<IEnumerable<Assembly>> e) {
    217       if (e.Value.Count() <= SilentAssemblyLoadingOperationLimit) return;
    218       var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    219       mainForm.AddOperationProgressToView(this, AssembliesUnloadingMessage);
     236      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesUnloading, sender, e);
     237      else {
     238        int nrOfAssemblies = e.Value.Count();
     239        if (nrOfAssemblies > SilentAssemblyLoadingOperationLimit)
     240          AddProgressView(AssembliesUnloadingMessage);
     241      }
    220242    }
    221243
    222244    private void codeEditor_AssembliesUnloaded(object sender, EventArgs<IEnumerable<Assembly>> e) {
    223       if (e.Value.Count() <= SilentAssemblyLoadingOperationLimit) return;
    224       var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    225       mainForm.RemoveOperationProgressFromView(this);
     245      if (InvokeRequired) Invoke((Action<object, EventArgs<IEnumerable<Assembly>>>)codeEditor_AssembliesUnloaded, sender, e);
     246      else {
     247        RemoveProgressView();
     248      }
    226249    }
    227250  }
Note: See TracChangeset for help on using the changeset viewer.