Example #1
0
 public void Dispose()
 {
     this.windowMenuItemCount = 0;
     this.ResizeLists();
     if (this.mdiParent != null)
     {
         this.mdiParent.MdiChildActivate -= new EventHandler(mdiParent_MdiChildActivate);
     }
     this.windowMenu = null;
     this.mdiParent  = null;
 }
Example #2
0
 /// <summary>
 /// Resizes the lists associated to the menu items which denote the last active MDI Children.
 /// </summary>
 private void ResizeLists()
 {
     if (windowMenuItemCount == 0)
     {
         if (separator != null)
         {
             windowMenu.Items.Remove(separator);
             separator.Dispose();
             separator = null;
         }
         for (int i = 0; i < windowMenuItems.Length; i++)
         {
             if (windowMenuItems[i] != null)
             {
                 windowMenu.Items.Remove(windowMenuItems[i]);
                 windowMenuItems[i].Dispose();
             }
         }
         if (moreWindows != null)
         {
             windowMenu.Items.Remove(moreWindows);
             moreWindows.Dispose();
             moreWindows = null;
         }
     }
     this.windowMenuItems       = RedimPreserveArray(windowMenuItemCount, windowMenuItems);
     this.lastActiveMDIChildren = RedimPreserveArray(windowMenuItemCount, lastActiveMDIChildren);
     if (windowMenuItemCount > 0)
     {
         if (separator == null)
         {
             separator      = (ImageMenuItem)Activator.CreateInstance(windowMenu.GetType());//new ImageMenuItem("-Windows");
             separator.Text = "-Windows";
             windowMenu.Items.Add(separator);
         }
         for (int i = 0; i < windowMenuItems.Length; i++)
         {
             if (windowMenuItems[i] == null)
             {
                 windowMenuItems[i] = (ImageMenuItem)Activator.CreateInstance(windowMenu.GetType());
                 windowMenu.Items.Add(windowMenuItems[i]);
                 windowMenuItems[i].Click += new EventHandler(windowMenuItemsAtI_Click);
             }
         }
         if (moreWindows == null)
         {
             moreWindows      = (ImageMenuItem)Activator.CreateInstance(windowMenu.GetType());//new ImageMenuItem("&Windows...");
             moreWindows.Text = "&Windows...";
             windowMenu.Items.Add(moreWindows);
             moreWindows.Click += new EventHandler(moreWindows_Click);
         }
     }
 }
Example #3
0
 public MDIListHandler(ImageMenuItem windowMenu, Form mdiParent)
 {
     this.mdiParent  = mdiParent;
     this.windowMenu = windowMenu;
     this.mdiParent.MdiChildActivate += new EventHandler(mdiParent_MdiChildActivate);
     ResizeLists();
     if (windowMenu != null && windowMenu.GetMainMenu() != null && windowMenu.GetMainMenu().GetForm() != null)
     {
         activeCache.AddRange(windowMenu.GetMainMenu().GetForm().MdiChildren);
     }
     PushActive(null);
 }
Example #4
0
 void windowMenuItemsAtI_Click(object sender, EventArgs e)
 {
     if (sender is ImageMenuItem)
     {
         ImageMenuItem clickedItem = (ImageMenuItem)sender;
         if (clickedItem == null)
         {
             return;
         }
         if (clickedItem.Tag is Form)
         {
             Form clickedForm = (Form)clickedItem.Tag;
             clickedForm.Activate();
         }
     }
 }