Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6827


Ignore:
Timestamp:
09/25/11 21:02:58 (13 years ago)
Author:
ascheibe
Message:

#1652

  • added MainForms for Single and Multiple Documents to Optimizer
  • moved cursor handling code up to MainForm
  • added a configuration dialog for switching between different MainForms
Location:
trunk/sources
Files:
12 added
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r5463 r6827  
    3131  public partial class MainForm : Form, IMainForm {
    3232    private bool initialized;
     33    private int appStartingCursors;
     34    private int waitingCursors;
    3335
    3436    protected MainForm()
     
    3941      this.initialized = false;
    4042      this.showContentInViewHost = false;
     43      appStartingCursors = 0;
     44      waitingCursors = 0;
    4145    }
    4246
     
    447451    }
    448452    #endregion
     453
     454    #region Cursor Handling
     455    public void SetAppStartingCursor() {
     456      if (InvokeRequired)
     457        Invoke(new Action(SetAppStartingCursor));
     458      else {
     459        appStartingCursors++;
     460        SetCursor();
     461      }
     462    }
     463    public void ResetAppStartingCursor() {
     464      if (InvokeRequired)
     465        Invoke(new Action(ResetAppStartingCursor));
     466      else {
     467        appStartingCursors--;
     468        SetCursor();
     469      }
     470    }
     471    public void SetWaitCursor() {
     472      if (InvokeRequired)
     473        Invoke(new Action(SetWaitCursor));
     474      else {
     475        waitingCursors++;
     476        SetCursor();
     477      }
     478    }
     479    public void ResetWaitCursor() {
     480      if (InvokeRequired)
     481        Invoke(new Action(ResetWaitCursor));
     482      else {
     483        waitingCursors--;
     484        SetCursor();
     485      }
     486    }
     487    private void SetCursor() {
     488      if (waitingCursors > 0) Cursor = Cursors.WaitCursor;
     489      else if (appStartingCursors > 0) Cursor = Cursors.AppStarting;
     490      else Cursor = Cursors.Default;
     491    }
     492    #endregion
    449493  }
    450494}
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r5445 r6827  
    6060      if (openFileDialog.ShowDialog() == DialogResult.OK) {
    6161        foreach (string filename in openFileDialog.FileNames) {
    62           ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
     62          ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    6363          ContentManager.LoadAsync(filename, LoadingCompleted);
    6464        }
     
    7676      }
    7777      finally {
    78         ((OptimizerMainForm)MainFormManager.MainForm).ResetAppStartingCursor();
     78        ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor();
    7979      }
    8080    }
     
    9292          SaveAs(view);
    9393        else {
    94           ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
     94          ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    9595          SetEnabledStateOfContentViews(content, false);
    9696          ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
     
    117117
    118118        if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    119           ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
     119          ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();
    120120          SetEnabledStateOfContentViews(content, false);
    121121          if (saveFileDialog.FilterIndex == 1) {
     
    131131        SetEnabledStateOfContentViews(content, true);
    132132        if (error != null) throw error;
    133         MainFormManager.GetMainForm<OptimizerMainForm>().UpdateTitle();
     133        MainFormManager.GetMainForm<OptimizerDockingMainForm>().UpdateTitle();
    134134      }
    135135      catch (Exception ex) {
     
    137137      }
    138138      finally {
    139         ((OptimizerMainForm)MainFormManager.MainForm).ResetAppStartingCursor();
     139        ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor();
    140140      }
    141141    }
    142142
    143143    private static void SetEnabledStateOfContentViews(IStorableContent content, bool enabled) {
    144       OptimizerMainForm mainForm = MainFormManager.GetMainForm<OptimizerMainForm>();
     144      OptimizerDockingMainForm mainForm = MainFormManager.GetMainForm<OptimizerDockingMainForm>();
    145145      if (mainForm.InvokeRequired)
    146146        mainForm.Invoke((Action<IStorableContent, bool>)SetEnabledStateOfContentViews, content, enabled);
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r6092 r6827  
    117117    <EmbeddedResource Include="Documents\VNS_TSP.hl" />
    118118    <EmbeddedResource Include="Documents\PSO_Schwefel.hl" />
     119    <EmbeddedResource Include="MainFormTypeSelectionDialog.resx">
     120      <DependentUpon>MainFormTypeSelectionDialog.cs</DependentUpon>
     121    </EmbeddedResource>
     122    <EmbeddedResource Include="OptimizerDockingMainForm.resx">
     123      <DependentUpon>OptimizerDockingMainForm.cs</DependentUpon>
     124    </EmbeddedResource>
    119125    <None Include="HeuristicLabOptimizerPlugin.cs.frame" />
     126    <Compile Include="OptimizerSingleDocumentMainForm.cs">
     127      <SubType>Form</SubType>
     128    </Compile>
     129    <Compile Include="OptimizerSingleDocumentMainForm.Designer.cs">
     130      <DependentUpon>OptimizerSingleDocumentMainForm.cs</DependentUpon>
     131    </Compile>
     132    <Compile Include="MainFormTypeSelectionDialog.cs">
     133      <SubType>Form</SubType>
     134    </Compile>
     135    <Compile Include="MainFormTypeSelectionDialog.Designer.cs">
     136      <DependentUpon>MainFormTypeSelectionDialog.cs</DependentUpon>
     137    </Compile>
     138    <Compile Include="MenuItems\ChangeMainFormTypeMenuItem.cs" />
     139    <Compile Include="MenuItems\ChangeMainFormTypeSeperator.cs" />
     140    <Compile Include="OptimizerMultipleDocumentMainForm.cs">
     141      <SubType>Form</SubType>
     142    </Compile>
     143    <Compile Include="OptimizerMultipleDocumentMainForm.Designer.cs">
     144      <DependentUpon>OptimizerMultipleDocumentMainForm.cs</DependentUpon>
     145    </Compile>
    120146    <Compile Include="CreateExperimentDialog.cs">
    121147      <SubType>Form</SubType>
     
    160186      <DependentUpon>NewItemDialog.cs</DependentUpon>
    161187    </Compile>
    162     <Compile Include="OptimizerMainForm.cs">
    163       <SubType>Form</SubType>
    164     </Compile>
    165     <Compile Include="OptimizerMainForm.Designer.cs">
    166       <DependentUpon>OptimizerMainForm.cs</DependentUpon>
     188    <Compile Include="OptimizerDockingMainForm.cs">
     189      <SubType>Form</SubType>
     190    </Compile>
     191    <Compile Include="OptimizerDockingMainForm.Designer.cs">
     192      <DependentUpon>OptimizerDockingMainForm.cs</DependentUpon>
    167193    </Compile>
    168194    <Compile Include="Properties\AssemblyInfo.cs" />
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLabOptimizerPlugin.cs.frame

    r6548 r6827  
    2121
    2222using System.Windows.Forms;
     23using HeuristicLab.Optimizer.Properties;
    2324using HeuristicLab.PluginInfrastructure;
    2425
     
    4243  internal class HeuristicLabOptimizerApplication : ApplicationBase {
    4344    public override void Run() {
    44       OptimizerMainForm mainForm = new OptimizerMainForm(typeof(IOptimizerUserInterfaceItemProvider));
    45       mainForm.ShowContentInViewHost = true;
    46       Application.Run(mainForm);
     45     HeuristicLab.MainForm.WindowsForms.MainForm mainForm = null;
     46
     47      if (Settings.Default.MainFormType == OptimizerMainFormTypes.DockingMainForm) {
     48        mainForm = new OptimizerDockingMainForm(typeof(IOptimizerUserInterfaceItemProvider));
     49      } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.MultipleDocumentMainForm) {
     50        mainForm = new OptimizerMultipleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
     51      } else if (Settings.Default.MainFormType == OptimizerMainFormTypes.SingleDocumentMainForm) {
     52        mainForm = new OptimizerSingleDocumentMainForm(typeof(IOptimizerUserInterfaceItemProvider));
     53      }
     54
     55      if (mainForm != null) {
     56        mainForm.ShowContentInViewHost = true;
     57        Application.Run(mainForm);
     58      } else {
     59        MessageBox.Show("Error loading setting for the MainForm Type. Please check your configuration file!", "HeuristicLab", MessageBoxButtons.OK, MessageBoxIcon.Error);
     60      }
    4761    }
    4862  }
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/ClipboardMenuItem.cs

    r5445 r6827  
    6868
    6969    public override void Execute() {
    70       IView clipboard = ((OptimizerMainForm)MainFormManager.MainForm).Clipboard;
    71       if (clipboard.IsShown) {
    72         clipboard.Hide();
    73       } else {
    74         clipboard.Show();
     70      IView clipboard = null;
     71      if (MainFormManager.MainForm is OptimizerDockingMainForm) {
     72        clipboard = ((OptimizerDockingMainForm)MainFormManager.MainForm).Clipboard;
     73      } else if (MainFormManager.MainForm is OptimizerMultipleDocumentMainForm) {
     74        clipboard = ((OptimizerMultipleDocumentMainForm)MainFormManager.MainForm).Clipboard;
     75      } else if (MainFormManager.MainForm is OptimizerSingleDocumentMainForm) {
     76        clipboard = ((OptimizerSingleDocumentMainForm)MainFormManager.MainForm).Clipboard;
     77      }
     78
     79      if (clipboard != null) {
     80        if (clipboard.IsShown) {
     81          clipboard.Hide();
     82        } else {
     83          clipboard.Show();
     84        }
    7585      }
    7686    }
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CopyToClipboardMenuItem.cs

    r5445 r6827  
    5151
    5252    public override void Execute() {
     53      Clipboard<IItem> clipboard = null;
    5354      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
     55
    5456      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IItem) && !activeView.Locked) {
    55         Clipboard<IItem> clipboard = ((OptimizerMainForm)MainFormManager.MainForm).Clipboard;
    56         IItem content = (IItem)activeView.Content;
    57         clipboard.AddItem((IItem)content.Clone());
     57        if (MainFormManager.MainForm is OptimizerDockingMainForm) {
     58          clipboard = ((OptimizerDockingMainForm)MainFormManager.MainForm).Clipboard;
     59        } else if (MainFormManager.MainForm is OptimizerMultipleDocumentMainForm) {
     60          clipboard = ((OptimizerMultipleDocumentMainForm)MainFormManager.MainForm).Clipboard;
     61        } else if (MainFormManager.MainForm is OptimizerSingleDocumentMainForm) {
     62          clipboard = ((OptimizerSingleDocumentMainForm)MainFormManager.MainForm).Clipboard;
     63        }
     64
     65        if (clipboard != null) {
     66          IItem content = (IItem)activeView.Content;
     67          clipboard.AddItem((IItem)content.Clone());
     68        }
    5869      }
    5970    }
  • trunk/sources/HeuristicLab.Optimizer/3.3/Properties/Settings.Designer.cs

    r4065 r6827  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.1
     4//     Runtime Version:4.0.30319.237
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    9595            }
    9696        }
     97       
     98        [global::System.Configuration.UserScopedSettingAttribute()]
     99        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     100        [global::System.Configuration.DefaultSettingValueAttribute("DockingMainForm")]
     101        public global::HeuristicLab.Optimizer.OptimizerMainFormTypes MainFormType {
     102            get {
     103                return ((global::HeuristicLab.Optimizer.OptimizerMainFormTypes)(this["MainFormType"]));
     104            }
     105            set {
     106                this["MainFormType"] = value;
     107            }
     108        }
    97109    }
    98110}
  • trunk/sources/HeuristicLab.Optimizer/3.3/Properties/Settings.settings

    r3768 r6827  
    2121      <Value Profile="(Default)">False</Value>
    2222    </Setting>
     23    <Setting Name="MainFormType" Type="HeuristicLab.Optimizer.OptimizerMainFormTypes" Scope="User">
     24      <Value Profile="(Default)">DockingMainForm</Value>
     25    </Setting>
    2326  </Settings>
    2427</SettingsFile>
  • trunk/sources/HeuristicLab.Optimizer/3.3/app.config

    r3768 r6827  
    2626                <value>False</value>
    2727            </setting>
     28            <setting name="MainFormType" serializeAs="String">
     29                <value>DockingMainForm</value>
     30            </setting>
    2831        </HeuristicLab.Optimizer.Properties.Settings>
    2932    </userSettings>
Note: See TracChangeset for help on using the changeset viewer.