Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2306


Ignore:
Timestamp:
08/21/09 17:24:31 (15 years ago)
Author:
mkommend
Message:

added check to show every view only one time, second call of ShowView leads to focus of the view (ticket #716)

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm/3.2/DockingMainForm.cs

    r2305 r2306  
    4545      if (InvokeRequired) Invoke((Action<IView>)ShowView, view);
    4646      else {
    47         base.ShowView(view);
    48         DockContent dockForm = new DockForm(view);
    49         dockForm.Activated += new EventHandler(DockFormActivated);
    50         dockForm.FormClosing += new FormClosingEventHandler(view.FormClosing);
    51         dockForm.FormClosed += new FormClosedEventHandler(DockFormClosed);
    52         foreach (IToolStripItem item in ToolStripItems)
    53           view.StateChanged += new EventHandler(item.ViewChanged);
    54         dockForm.Show(dockPanel);
     47        if (views.Contains(view)) {
     48          DockForm dockform = FindForm(view);
     49          if (dockform != null)
     50            dockform.Activate();
     51        } else {
     52          base.ShowView(view);
     53          DockContent dockForm = new DockForm(view);
     54          dockForm.Activated += new EventHandler(DockFormActivated);
     55          dockForm.FormClosing += new FormClosingEventHandler(view.FormClosing);
     56          dockForm.FormClosed += new FormClosedEventHandler(DockFormClosed);
     57          foreach (IToolStripItem item in ToolStripItems)
     58            view.StateChanged += new EventHandler(item.ViewChanged);
     59          dockForm.Show(dockPanel);
     60        }
    5561      }
    5662    }
    5763
    5864    public override void CloseView(IView view) {
    59       DockForm dockform = null;
    60       IEnumerable<DockForm> dockforms;
    61 
    62       if (dockPanel.Documents.Count() != 0) {
    63         dockforms = dockPanel.Documents.Cast<DockForm>().Where(df => df.View == view);
    64         if (dockforms.Count() == 1)
    65           dockform = dockforms.Single();
    66       }
    67       if (dockPanel.FloatWindows.Count() != 0) {
    68         foreach (FloatWindow fw in dockPanel.FloatWindows) {
    69           foreach (DockContentCollection dc in fw.NestedPanes.Select(np => np.Contents)) {
    70             dockforms = dc.Cast<DockForm>().Where(df => df.View == view);
    71             if (dockforms.Count() == 1) {
    72               dockform = dockforms.Single();
    73               break;
    74             }
    75           }
    76         }
    77       }
    78       if (dockPanel.DockWindows.Count != 0) {
    79         foreach (DockWindow dw in dockPanel.DockWindows) {
    80           foreach (DockContentCollection dc in dw.NestedPanes.Select(np => np.Contents)) {
    81             dockforms = dc.Cast<DockForm>().Where(df => df.View == view);
    82             if (dockforms.Count() == 1) {
    83               dockform = dockforms.Single();
    84               break;
    85             }
    86           }
    87         }
    88       }
     65      DockForm dockform = FindForm(view);
    8966      if (dockform != null)
    9067        dockform.Close();
     
    10885      base.ActiveView = ((DockForm)sender).View;
    10986    }
     87
     88    protected DockForm FindForm(IView view) {
     89      IEnumerable<DockForm> dockforms;
     90
     91      if (dockPanel.Documents.Count() != 0) {
     92        dockforms = dockPanel.Documents.Cast<DockForm>().Where(df => df.View == view);
     93        if (dockforms.Count() == 1)
     94          return dockforms.Single();
     95      }
     96      if (dockPanel.FloatWindows.Count() != 0) {
     97        foreach (FloatWindow fw in dockPanel.FloatWindows) {
     98          foreach (DockContentCollection dc in fw.NestedPanes.Select(np => np.Contents)) {
     99            dockforms = dc.Cast<DockForm>().Where(df => df.View == view);
     100            if (dockforms.Count() == 1)
     101              return dockforms.Single();
     102          }
     103        }
     104      }
     105      if (dockPanel.DockWindows.Count != 0) {
     106        foreach (DockWindow dw in dockPanel.DockWindows) {
     107          foreach (DockContentCollection dc in dw.NestedPanes.Select(np => np.Contents)) {
     108            dockforms = dc.Cast<DockForm>().Where(df => df.View == view);
     109            if (dockforms.Count() == 1)
     110              return dockforms.Single();
     111          }
     112        }
     113      }
     114      return null;
     115    }
    110116  }
    111117}
  • trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs

    r2305 r2306  
    114114
    115115    public virtual void ShowView(IView view) {
    116       view.MainForm = this;
    117       views.Add(view);
    118       ActiveView = view;
     116      if (!views.Contains(view)) {
     117        view.MainForm = this;
     118        views.Add(view);
     119        ActiveView = view;
     120      }
    119121    }
    120122
  • trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.cs

    r2305 r2306  
    5151      if (InvokeRequired) Invoke((Action<IView>)ShowView, view);
    5252      else {
    53         base.ShowView(view);
    54         DocumentForm form = new DocumentForm(view);
    55         form.Activated += new EventHandler(MultipleDocumentFormActivated);
    56         form.FormClosing += new FormClosingEventHandler(view.FormClosing);
    57         form.FormClosed += new FormClosedEventHandler(MultipleDocumentFormClosed);
    58         form.MdiParent = this;
    59         foreach (IToolStripItem item in ToolStripItems)
    60           view.StateChanged += new EventHandler(item.ViewChanged);
    61         form.Show();
     53        if (views.Contains(view)) {
     54          DocumentForm documentForm = FindForm(view);
     55          if (documentForm != null)
     56            documentForm.Focus();
     57        } else {
     58          base.ShowView(view);
     59          DocumentForm form = new DocumentForm(view);
     60          form.Activated += new EventHandler(MultipleDocumentFormActivated);
     61          form.FormClosing += new FormClosingEventHandler(view.FormClosing);
     62          form.FormClosed += new FormClosedEventHandler(MultipleDocumentFormClosed);
     63          form.MdiParent = this;
     64          foreach (IToolStripItem item in ToolStripItems)
     65            view.StateChanged += new EventHandler(item.ViewChanged);
     66          form.Show();
     67        }
    6268      }
    6369    }
    6470
    6571    public override void CloseView(IView view) {
    66       DocumentForm documentForm = this.MdiChildren.Cast<DocumentForm>().Where(df => df.View == view).Single();
    67       documentForm.Close();
     72      DocumentForm documentForm = FindForm(view);
     73      if (documentForm != null)
     74        documentForm.Close();
    6875    }
    6976
     
    8592        form.View.StateChanged -= new EventHandler(item.ViewChanged);
    8693    }
     94
     95    protected DocumentForm FindForm(IView view) {
     96      IEnumerable<DocumentForm> forms = this.MdiChildren.Cast<DocumentForm>().Where(df => df.View == view);
     97      if (forms.Count() == 1)
     98        return forms.Single();
     99      return null;
     100    }
    87101  }
    88102}
  • trunk/sources/HeuristicLab.MainForm/3.2/SingleDocumentMainForm.cs

    r2305 r2306  
    4545      if (InvokeRequired) Invoke((Action<IView>)ShowView, view);
    4646      else {
    47         base.ShowView(view);
    48         DocumentForm form = new DocumentForm(view);
    49         form.ShowInTaskbar = true;
    50         form.Activated += new EventHandler(DockFormActivated);
    51         form.FormClosing += new FormClosingEventHandler(view.FormClosing);
    52         form.FormClosed += new FormClosedEventHandler(DockFormClosed);
    53         foreach (IToolStripItem item in ToolStripItems)
    54           view.StateChanged += new EventHandler(item.ViewChanged);
    55         form.Show(this);
     47        if (views.Contains(view)) {
     48          DocumentForm documentForm = FindForm(view);
     49          if (documentForm != null)
     50            documentForm.Focus();
     51        } else {
     52          base.ShowView(view);
     53          DocumentForm form = new DocumentForm(view);
     54          form.ShowInTaskbar = true;
     55          form.Activated += new EventHandler(DockFormActivated);
     56          form.FormClosing += new FormClosingEventHandler(view.FormClosing);
     57          form.FormClosed += new FormClosedEventHandler(DockFormClosed);
     58          foreach (IToolStripItem item in ToolStripItems)
     59            view.StateChanged += new EventHandler(item.ViewChanged);
     60          form.Show(this);
     61        }
    5662      }
    5763    }
    5864
    5965    public override void CloseView(IView view) {
    60       DocumentForm documentForm = this.OwnedForms.Cast<DocumentForm>().Where(df => df.View == view).Single();
    61       documentForm.Close();
     66      DocumentForm documentForm = FindForm(view);
     67      if (documentForm != null)
     68        documentForm.Close();
    6269    }
    6370
     
    7986      base.ActiveView = ((DocumentForm)sender).View;
    8087    }
     88
     89    protected DocumentForm FindForm(IView view) {
     90      IEnumerable<DocumentForm> forms = this.OwnedForms.Cast<DocumentForm>().Where(df => df.View == view);
     91      if (forms.Count() == 1)
     92        return forms.Single();
     93      return null;
     94    }
    8195  }
    8296}
  • trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2304 r2306  
    5757      dlo.LoadWith<InputVariableResult>(ir => ir.Result);
    5858      dlo.LoadWith<Model>(m => m.TargetVariable);
     59      dlo.LoadWith<Model>(m => m.Algorithm);
    5960      ctx.LoadOptions = dlo;
    6061    }
Note: See TracChangeset for help on using the changeset viewer.