Exemple #1
0
 public void AddWorkspace(string name, bool select = false)
 {
     name = name.Trim();
     if (string.IsNullOrWhiteSpace(name) || this.Workspaces.ContainsKey(name))
     {
         throw new System.Exception("Invalid workspace name.");
     }
     TTSToolStripMenuItem tTSToolStripMenuItem = new TTSToolStripMenuItem(name, null, delegate(object sender, System.EventArgs e)
     {
         System.Windows.Forms.Form[] mdiChildren = this.MDIParent.MdiChildren;
         System.Windows.Forms.Form form;
         for (int i = 0; i < mdiChildren.Length; i++)
         {
             form = mdiChildren[i];
             if (form is TTSForm)
             {
                 if (this.Workspaces[name].WindowItems.Exists((WorkspaceItem.WindowItem x) => x.Window == form))
                 {
                     form.Show();
                 }
                 else
                 {
                     form.Hide();
                 }
             }
         }
         foreach (System.Windows.Forms.ToolStripItem toolStripItem in this.WorkspaceDropDown.DropDownItems)
         {
             if (toolStripItem is TTSToolStripMenuItem)
             {
                 ((TTSToolStripMenuItem)toolStripItem).Checked = false;
             }
         }
         foreach (WorkspaceItem.WindowItem current in this.Workspaces[this.CurrentWorkspace].WindowItems)
         {
             this.WindowDropDown.DropDownItems.Remove(current.WindowMenuItem);
         }
         foreach (WorkspaceItem.WindowItem current2 in this.Workspaces[name].WindowItems)
         {
             this.WindowDropDown.DropDownItems.Add(current2.WindowMenuItem);
         }
         ((TTSToolStripMenuItem)sender).Checked = true;
         this.CurrentWorkspace = name;
         this.WindowDropDown.Text = string.Format("Windows ({0})", this.Workspaces[name].WindowItems.Count);
         this.WorkspaceDropDown.Text = name;
     });
     this.WorkspaceDropDown.DropDownItems.Add(tTSToolStripMenuItem);
     this.Workspaces.Add(name, new WorkspaceItem
     {
         WorkspaceMenuItem = tTSToolStripMenuItem
     });
     if (select)
     {
         tTSToolStripMenuItem.PerformClick();
     }
 }