Free cookie consent management tool by TermsFeed Policy Generator

Changeset 690 for branches


Ignore:
Timestamp:
10/19/08 00:43:25 (16 years ago)
Author:
gkronber
Message:

merged r675 into the 3.0 branch (#307)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/sources/HeuristicLab.OptimizationFrontend/MainForm.cs

    r662 r690  
    6363      Type[] creatables = discoveryService.GetTypes(typeof(IEditable));
    6464      string[] names = new string[creatables.Length];
    65       for (int i = 0; i < creatables.Length; i++)
     65      for(int i = 0; i < creatables.Length; i++)
    6666        names[i] = creatables[i].Name;
    6767      Array.Sort(names, creatables);
    68       foreach (Type type in creatables) {
    69         if (!type.IsAbstract) {
     68      foreach(Type type in creatables) {
     69        if(!type.IsAbstract) {
    7070          ToolStripMenuItem item = new ToolStripMenuItem();
    7171          item.Tag = type;
     
    8585    #region IControlManager Members
    8686    public void ShowControl(IControl control) {
    87       if (control is IEditor) {
     87      if(control is IEditor) {
    8888        EditorForm form = new EditorForm((IEditor)control);
    8989        form.MdiParent = this;
    9090        form.Show();
    91       } else if (control is IView) {
     91      } else if(control is IView) {
    9292        ViewForm form = new ViewForm((IView)control);
    9393        form.MdiParent = this;
     
    111111      tileVerticallyToolStripMenuItem.Enabled = false;
    112112
    113       if (ActiveMdiChild != null) {
     113      if(ActiveMdiChild != null) {
    114114        closeToolStripMenuItem.Enabled = true;
    115115        closeAllToolStripMenuItem.Enabled = true;
     
    120120        tileVerticallyToolStripMenuItem.Enabled = true;
    121121        EditorForm form = ActiveMdiChild as EditorForm;
    122         if (form != null){
    123           if (((Control)form.Editor).Enabled) {
     122        if(form != null) {
     123          if(((Control)form.Editor).Enabled) {
    124124            saveToolStripMenuItem.Enabled = true;
    125125            saveToolStripButton.Enabled = true;
     
    135135    #region Open and Save Methods
    136136    private void Open() {
    137       if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    138         lock (locker) runningTasks++;
     137      if(openFileDialog.ShowDialog(this) == DialogResult.OK) {
     138        lock(locker) runningTasks++;
    139139        Cursor = Cursors.AppStarting;
    140140        Task task = new Task(openFileDialog.FileName, null, null);
     
    149149        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe file or plugin \"" + ex.FileName + "\" is not available.\nPlease make sure you have all necessary plugins installed.",
    150150          "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    151       }
     151      } catch(TypeLoadException typeLoadEx) {
     152        MessageBox.Show("Sorry couldn't open file \"" + task.filename + "\".\nThe type \"" + typeLoadEx.TypeName + "\" is not available.\nPlease make sure that you have the correct version the plugin installed.",
     153          "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     154      }
     155
    152156      LoadFinished(task);
    153157    }
    154158    private delegate void TaskFinishedDelegate(Task task);
    155159    private void LoadFinished(Task task) {
    156       if (InvokeRequired)
     160      if(InvokeRequired)
    157161        Invoke(new TaskFinishedDelegate(LoadFinished), task);
    158162      else {
    159163        IEditor editor = null;
    160         if (task.storable != null) {
     164        if(task.storable != null) {
    161165          IEditable editable = task.storable as IEditable;
    162           if (editable != null)
     166          if(editable != null)
    163167            editor = editable.CreateEditor();
    164168        }
    165         if (editor == null)
     169        if(editor == null)
    166170          MessageBox.Show("Could not open item. The selected item doesn't provide an editor.", "Editor Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    167171        else {
     
    169173          PluginManager.ControlManager.ShowControl(editor);
    170174        }
    171         lock (locker) {
     175        lock(locker) {
    172176          runningTasks--;
    173           if (runningTasks == 0)
     177          if(runningTasks == 0)
    174178            Cursor = Cursors.Default;
    175179        }
     
    177181    }
    178182    private void Save(EditorForm form) {
    179       if (form.Editor.Filename == null)
     183      if(form.Editor.Filename == null)
    180184        SaveAs(form);
    181185      else {
    182         lock (locker) runningTasks++;
     186        lock(locker) runningTasks++;
    183187        Cursor = Cursors.AppStarting;
    184188        ((Control)form.Editor).Enabled = false;
     
    189193    }
    190194    private void SaveAs(EditorForm form) {
    191       if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {
     195      if(saveFileDialog.ShowDialog(this) == DialogResult.OK) {
    192196        form.Editor.Filename = saveFileDialog.FileName;
    193197        Save(form);
     
    200204    }
    201205    private void SaveFinished(Task task) {
    202       if (InvokeRequired)
     206      if(InvokeRequired)
    203207        Invoke(new TaskFinishedDelegate(SaveFinished), task);
    204208      else {
    205209        ((Control)task.editor).Enabled = true;
    206210        EnableDisableItems();
    207         lock (locker) {
     211        lock(locker) {
    208212          runningTasks--;
    209           if (runningTasks == 0)
     213          if(runningTasks == 0)
    210214            Cursor = Cursors.Default;
    211215        }
     
    223227      Type type = (Type)item.Tag;
    224228      IEditable editable = (IEditable)Activator.CreateInstance(type);
    225       if (editable == null) {
     229      if(editable == null) {
    226230        MessageBox.Show("The selected item is not editable.", "Editable Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    227231      } else {
    228232        IEditor editor = editable.CreateEditor();
    229         if (editor == null) {
     233        if(editor == null) {
    230234          MessageBox.Show("The selected item doesn't provide an editor.", "Editor Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    231235        } else {
     
    247251    }
    248252    private void saveAllToolStripMenuItem_Click(object sender, EventArgs e) {
    249       for (int i = 0; i < MdiChildren.Length; i++) {
     253      for(int i = 0; i < MdiChildren.Length; i++) {
    250254        EditorForm form = MdiChildren[i] as EditorForm;
    251         if (((Control)form.Editor).Enabled) Save(form);
     255        if(((Control)form.Editor).Enabled) Save(form);
    252256      }
    253257    }
     
    257261    }
    258262    private void closeAllToolStripMenuItem_Click(object sender, EventArgs e) {
    259       while (MdiChildren.Length > 0)
     263      while(MdiChildren.Length > 0)
    260264        MdiChildren[0].Close();
    261265      EnableDisableItems();
     
    297301    }
    298302    private void saveAllToolStripButton_Click(object sender, EventArgs e) {
    299       for (int i = 0; i < MdiChildren.Length; i++) {
     303      for(int i = 0; i < MdiChildren.Length; i++) {
    300304        EditorForm form = MdiChildren[i] as EditorForm;
    301         if (((Control)form.Editor).Enabled) Save(form);
     305        if(form != null && ((Control)form.Editor).Enabled) Save(form);
    302306      }
    303307    }
Note: See TracChangeset for help on using the changeset viewer.