Changeset 13621


Ignore:
Timestamp:
02/16/16 18:20:33 (4 years ago)
Author:
mkommend
Message:

#2578: Fixed default ctor of Mainform w.r.t. UI creation.

File:
1 edited

Legend:

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

    r12012 r13621  
    456456    #region create menu and toolbar
    457457    private void CreateGUI() {
    458       IEnumerable<object> allUserInterfaceItems = ApplicationManager.Manager.GetInstances(userInterfaceItemType);
    459 
    460       IEnumerable<IPositionableUserInterfaceItem> toolStripMenuItems =
    461         from mi in allUserInterfaceItems
    462         where (mi is IPositionableUserInterfaceItem) &&
    463               (mi is IMenuItem || mi is IMenuSeparatorItem)
    464         orderby ((IPositionableUserInterfaceItem)mi).Position
    465         select (IPositionableUserInterfaceItem)mi;
    466 
    467       foreach (IPositionableUserInterfaceItem menuItem in toolStripMenuItems) {
    468         if (menuItem is IMenuItem)
    469           AddToolStripMenuItem((IMenuItem)menuItem);
    470         else if (menuItem is IMenuSeparatorItem)
    471           AddToolStripMenuItem((IMenuSeparatorItem)menuItem);
    472       }
    473 
    474       IEnumerable<IPositionableUserInterfaceItem> toolStripButtonItems =
    475         from bi in allUserInterfaceItems
    476         where (bi is IPositionableUserInterfaceItem) &&
    477               (bi is IToolBarItem || bi is IToolBarSeparatorItem)
    478         orderby ((IPositionableUserInterfaceItem)bi).Position
    479         select (IPositionableUserInterfaceItem)bi;
    480 
    481       foreach (IPositionableUserInterfaceItem toolStripButtonItem in toolStripButtonItems) {
    482         if (toolStripButtonItem is IToolBarItem)
    483           AddToolStripButtonItem((IToolBarItem)toolStripButtonItem);
    484         else if (toolStripButtonItem is IToolBarSeparatorItem)
    485           AddToolStripButtonItem((IToolBarSeparatorItem)toolStripButtonItem);
    486       }
    487 
     458      if (userInterfaceItemType != null) {
     459        IEnumerable<object> allUserInterfaceItems = ApplicationManager.Manager.GetInstances(userInterfaceItemType);
     460
     461        IEnumerable<IPositionableUserInterfaceItem> toolStripMenuItems =
     462          from mi in allUserInterfaceItems
     463          where (mi is IPositionableUserInterfaceItem) &&
     464                (mi is IMenuItem || mi is IMenuSeparatorItem)
     465          orderby ((IPositionableUserInterfaceItem)mi).Position
     466          select (IPositionableUserInterfaceItem)mi;
     467
     468        foreach (IPositionableUserInterfaceItem menuItem in toolStripMenuItems) {
     469          if (menuItem is IMenuItem)
     470            AddToolStripMenuItem((IMenuItem)menuItem);
     471          else if (menuItem is IMenuSeparatorItem)
     472            AddToolStripMenuItem((IMenuSeparatorItem)menuItem);
     473        }
     474
     475        IEnumerable<IPositionableUserInterfaceItem> toolStripButtonItems =
     476          from bi in allUserInterfaceItems
     477          where (bi is IPositionableUserInterfaceItem) &&
     478                (bi is IToolBarItem || bi is IToolBarSeparatorItem)
     479          orderby ((IPositionableUserInterfaceItem)bi).Position
     480          select (IPositionableUserInterfaceItem)bi;
     481
     482        foreach (IPositionableUserInterfaceItem toolStripButtonItem in toolStripButtonItems) {
     483          if (toolStripButtonItem is IToolBarItem)
     484            AddToolStripButtonItem((IToolBarItem)toolStripButtonItem);
     485          else if (toolStripButtonItem is IToolBarSeparatorItem)
     486            AddToolStripButtonItem((IToolBarSeparatorItem)toolStripButtonItem);
     487        }
     488
     489      }
    488490      this.AdditionalCreationOfGuiElements();
     491
     492      if (menuStrip.Items.Count == 0) menuStrip.Visible = false;
     493      if (toolStrip.Items.Count == 0) toolStrip.Visible = false;
    489494    }
    490495
     
    555560      try {
    556561        ((IActionUserInterfaceItem)item.Tag).Execute();
    557       } catch (Exception ex) {
     562      }
     563      catch (Exception ex) {
    558564        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    559565      }
Note: See TracChangeset for help on using the changeset viewer.