Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/21/09 14:18:29 (15 years ago)
Author:
mkommend
Message:

added possibility to programmatically close views (ticket #716)

Location:
trunk/sources/HeuristicLab.MainForm/3.2
Files:
5 edited

Legend:

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

    r2297 r2305  
    5656    }
    5757
     58    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      }
     89      if (dockform != null)
     90        dockform.Close();
     91    }
     92
    5893    private void DockFormClosed(object sender, FormClosedEventArgs e) {
    5994      DockForm dockForm = (DockForm)sender;
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IMainForm.cs

    r2300 r2305  
    3939    Type UserInterfaceItemType { get; }
    4040    void ShowView(IView view);
     41    void CloseView(IView view);
     42    void CloseAllViews();
    4143    void Close();
    4244  }
  • trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs

    r2302 r2305  
    117117      views.Add(view);
    118118      ActiveView = view;
     119    }
     120
     121    public virtual void CloseView(IView view) {
     122    }
     123
     124    public virtual void CloseAllViews() {
     125      foreach (IView view in views.ToArray())
     126        CloseView(view);
    119127    }
    120128
  • trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.cs

    r2297 r2305  
    6363    }
    6464
     65    public override void CloseView(IView view) {
     66      DocumentForm documentForm = this.MdiChildren.Cast<DocumentForm>().Where(df => df.View == view).Single();
     67      documentForm.Close();
     68    }
     69
    6570    private void MultipleDocumentFormActivated(object sender, EventArgs e) {
    6671      base.ActiveView = ((DocumentForm)sender).View;
  • trunk/sources/HeuristicLab.MainForm/3.2/SingleDocumentMainForm.cs

    r2297 r2305  
    5757    }
    5858
     59    public override void CloseView(IView view) {
     60      DocumentForm documentForm = this.OwnedForms.Cast<DocumentForm>().Where(df => df.View == view).Single();
     61      documentForm.Close();
     62    }
     63
    5964    private void DockFormClosed(object sender, FormClosedEventArgs e) {
    6065      DocumentForm form = (DocumentForm)sender;
Note: See TracChangeset for help on using the changeset viewer.