Пример #1
0
        public MenuCommand Add(MenuCommand value)
        {
            // Use base class to process actual collection operation
            base.List.Add(value as object);

            return value;
        }
Пример #2
0
        private void m_tabs_PageContextMenu(Crownwood.Magic.Controls.TabbedGroups tg, Crownwood.Magic.Controls.TGContextMenuEventArgs e)
        {
            e.ContextMenu.MenuCommands.Add(new Crownwood.Magic.Menus.MenuCommand(I.T("New tab|101"), new EventHandler(m_menuNouvelOnglet_Click)));
            m_pageContextMenu = e.TabPage;

            MenuCommand command = new Crownwood.Magic.Menus.MenuCommand(I.T("Direct new pages to this tab|102"),
                                                                        new EventHandler(OnOrienterNouveauxIci));

            command.Checked = m_pageRecepteurUniverselle == m_pageContextMenu;
            e.ContextMenu.MenuCommands.Add(command);
        }
Пример #3
0
 public MpePropertyManager(MediaPortalEditor mpe)
 {
   SetStyle(ControlStyles.EnableNotifyMessage, true);
   // This call is required by the Windows.Forms Form Designer.
   InitializeComponent();
   this.mpe = mpe;
   contextMenu = new PopupMenu();
   MenuCommand category =
     new MenuCommand("Sort By Category", menuImageList, 0, new EventHandler(OnMenuCategoryClicked));
   MenuCommand name = new MenuCommand("Sort By Name", menuImageList, 1, new EventHandler(OnMenuNameClicked));
   contextMenu.MenuCommands.AddRange(new MenuCommand[] {category, name});
   propertyGrid.CommandsVisibleIfAvailable = true;
 }
 public DrawCommand(Rectangle drawRect, bool expansion)
 {
     _row = -1;
     _col = -1;
     _mnemonic = '0';
     _enabled = true;
     _subMenu = false;
     _expansion = expansion;
     _separator = !expansion;
     _vertSeparator = !expansion;
     _topBorder = false;
     _bottomBorder = false;
     _infrequent = false;
     _chevron = false;
     _drawRect = drawRect;
     _selectRect = drawRect;
     _command = null;
 }
        ///<summary>
        /// Set each ToolBarButton to a specific MenuItem
        ///</summary>
        public void SetButtonMenuItem( Component pComponent, MenuCommand pMenuItem )
        {
            if( ! m_Dictionary.Contains( pComponent ))
            {
                m_Dictionary.Add( pComponent, pMenuItem );

                if( m_ToolBar == null )
                {
                    ToolBarButton pToolBarButton = pComponent as ToolBarButton;

                    if( pToolBarButton != null )
                    {
                        m_ToolBar = pToolBarButton.Parent as ToolBar;

                        if( m_ToolBar != null )
                            m_ToolBar.ButtonClick += new ToolBarButtonClickEventHandler( Handle_ToolbarButtonClick );
                    }
                }
            }
            else
            {
                m_Dictionary[ pComponent ] = pMenuItem;
            }
        }
Пример #6
0
        public PhoenixTabControl()
        {
            tabList = new List<TabPageInfo>();
            hiddenTabList = new List<string>();

            Config.Profile.InternalSettings.Loaded += new EventHandler(Settings_Loaded);
            Config.Profile.InternalSettings.Saving += new EventHandler(Settings_Saving);

            tabControl = new Crownwood.Magic.Controls.TabControl();
            tabControl.Style = Crownwood.Magic.Common.VisualStyle.IDE;
            tabControl.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument;
            tabControl.IDEPixelArea = false;
            tabControl.IDEPixelBorder = false;
            tabControl.Dock = DockStyle.Fill;
            tabControl.ClosePressed += new EventHandler(tabControl_ClosePressed);

            popupMenu = new PopupMenu();
            popupMenu.Animate = Animate.System;
            popupMenu.AnimateStyle = Animation.Blend;
            popupMenu.Style = Crownwood.Magic.Common.VisualStyle.IDE;

            shrinkMenuCommand = new MenuCommand("Shrink Labels");
            shrinkMenuCommand.Click += new EventHandler(shrinkMenuCommand_Click);

            multilineMenuCommand = new MenuCommand("Multiline");
            multilineMenuCommand.Click += new EventHandler(multilineMenuCommand_Click);

            hideTextMenuCommand = new MenuCommand("Hide Text");
            hideTextMenuCommand.Click += new EventHandler(hideTextMenuCommand_Click);

            tabControl.ContextPopupMenu = popupMenu;

            Controls.Add(tabControl);

            UpdateTabs();
        }
Пример #7
0
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.MainTabs = new Crownwood.Magic.Controls.TabControl();
            this.GameTab = new Crownwood.Magic.Controls.TabPage();
            this.RenderTarget = new System.Windows.Forms.Panel();
            this.MainMenu = new Crownwood.Magic.Menus.MenuControl();
            this.FileMenu = new Crownwood.Magic.Menus.MenuCommand();
            this.FileSave = new Crownwood.Magic.Menus.MenuCommand();
            this.FileQuit = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewMenu = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewLog = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewConnect = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewWhoList = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewSkillList = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewChat = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewCommand = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewFirstPerson = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewChaseCam = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewMiniMap = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewOptions = new Crownwood.Magic.Menus.MenuCommand();
            this.ViewAdmin = new Crownwood.Magic.Menus.MenuCommand();
            this.MainStatus = new System.Windows.Forms.StatusBar();
            this.AreaInformation = new System.Windows.Forms.StatusBarPanel();
            this.Information = new System.Windows.Forms.StatusBarPanel();
            this.Coords = new System.Windows.Forms.StatusBarPanel();
            this.GameTab.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.AreaInformation)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Information)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Coords)).BeginInit();
            this.SuspendLayout();
            // 
            // MainTabs
            // 
            this.MainTabs.Dock = System.Windows.Forms.DockStyle.Fill;
            this.MainTabs.Location = new System.Drawing.Point(2, 27);
            this.MainTabs.Name = "MainTabs";
            this.MainTabs.SelectedIndex = 0;
            this.MainTabs.SelectedTab = this.GameTab;
            this.MainTabs.Size = new System.Drawing.Size(888, 715);
            this.MainTabs.TabIndex = 0;
            this.MainTabs.TabPages.AddRange(new Crownwood.Magic.Controls.TabPage[] {
            this.GameTab});
            // 
            // GameTab
            // 
            this.GameTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.GameTab.Controls.Add(this.RenderTarget);
            this.GameTab.Location = new System.Drawing.Point(0, 0);
            this.GameTab.Name = "GameTab";
            this.GameTab.Size = new System.Drawing.Size(888, 690);
            this.GameTab.TabIndex = 0;
            this.GameTab.Title = "Game";
            // 
            // RenderTarget
            // 
            this.RenderTarget.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.RenderTarget.Location = new System.Drawing.Point(0, 0);
            this.RenderTarget.Name = "RenderTarget";
            this.RenderTarget.Size = new System.Drawing.Size(782, 427);
            this.RenderTarget.TabIndex = 1;
            // 
            // MainMenu
            // 
            this.MainMenu.AnimateStyle = Crownwood.Magic.Menus.Animation.System;
            this.MainMenu.AnimateTime = 100;
            this.MainMenu.Cursor = System.Windows.Forms.Cursors.Arrow;
            this.MainMenu.Direction = Crownwood.Magic.Common.Direction.Horizontal;
            this.MainMenu.Dock = System.Windows.Forms.DockStyle.Top;
            this.MainMenu.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
            this.MainMenu.HighlightTextColor = System.Drawing.SystemColors.MenuText;
            this.MainMenu.Location = new System.Drawing.Point(2, 2);
            this.MainMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
            this.FileMenu,
            this.ViewMenu});
            this.MainMenu.Name = "MainMenu";
            this.MainMenu.Size = new System.Drawing.Size(888, 25);
            this.MainMenu.Style = Crownwood.Magic.Common.VisualStyle.IDE;
            this.MainMenu.TabIndex = 0;
            this.MainMenu.TabStop = false;
            // 
            // FileMenu
            // 
            this.FileMenu.Description = "The File menu";
            this.FileMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
            this.FileSave,
            this.FileQuit});
            this.FileMenu.Text = "&File";
            // 
            // FileSave
            // 
            this.FileSave.Description = "MenuItem";
            this.FileSave.Text = "Save";
            this.FileSave.Click += new System.EventHandler(this.FileSave_Click);
            // 
            // FileQuit
            // 
            this.FileQuit.Description = "MenuItem";
            this.FileQuit.Text = "Quit";
            this.FileQuit.Click += new System.EventHandler(this.FileQuit_Click);
            // 
            // ViewMenu
            // 
            this.ViewMenu.Description = "MenuItem";
            this.ViewMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
            this.ViewLog,
            this.ViewConnect,
            this.ViewWhoList,
            this.ViewSkillList,
            this.ViewChat,
            this.ViewCommand,
            this.ViewFirstPerson,
            this.ViewChaseCam,
            this.ViewMiniMap,
            this.ViewOptions,
            this.ViewAdmin});
            this.ViewMenu.Text = "&View";
            // 
            // ViewLog
            // 
            this.ViewLog.Description = "MenuItem";
            this.ViewLog.Text = "Log";
            this.ViewLog.Click += new System.EventHandler(this.ViewLog_Click);
            // 
            // ViewConnect
            // 
            this.ViewConnect.Description = "MenuItem";
            this.ViewConnect.Text = "Connect";
            this.ViewConnect.Click += new System.EventHandler(this.ViewConnect_Click);
            // 
            // ViewWhoList
            // 
            this.ViewWhoList.Description = "MenuItem";
            this.ViewWhoList.Text = "Who";
            this.ViewWhoList.Click += new System.EventHandler(this.ViewWhoList_Click);
            // 
            // ViewSkillList
            // 
            this.ViewSkillList.Description = "MenuItem";
            this.ViewSkillList.Text = "Skills";
            this.ViewSkillList.Click += new System.EventHandler(this.ViewSkillList_Click);
            // 
            // ViewChat
            // 
            this.ViewChat.Description = "View Chat";
            this.ViewChat.Text = "Chat";
            this.ViewChat.Click += new System.EventHandler(this.ViewChat_Click);
            // 
            // ViewCommand
            // 
            this.ViewCommand.Description = "View Command";
            this.ViewCommand.Text = "Command";
            this.ViewCommand.Click += new System.EventHandler(this.ViewCommand_Click);
            // 
            // ViewFirstPerson
            // 
            this.ViewFirstPerson.Description = "First Person Mode";
            this.ViewFirstPerson.Text = "First Person Mode";
            this.ViewFirstPerson.Click += new System.EventHandler(this.ViewFirstPerson_Click);
            // 
            // ViewChaseCam
            // 
            this.ViewChaseCam.Description = "Chase Camera";
            this.ViewChaseCam.Text = "Chase Camera";
            this.ViewChaseCam.Click += new System.EventHandler(this.ViewChaseCam_Click);
            // 
            // ViewMiniMap
            // 
            this.ViewMiniMap.Description = "MenuItem";
            this.ViewMiniMap.Text = "Mini Map";
            this.ViewMiniMap.Click += new System.EventHandler(this.ViewMiniMap_Click);
            // 
            // ViewOptions
            // 
            this.ViewOptions.Description = "Options";
            this.ViewOptions.Text = "Options";
            this.ViewOptions.Click += new System.EventHandler(this.ViewOptions_Click);
            // 
            // ViewAdmin
            // 
            this.ViewAdmin.Description = "ViewAdmin";
            this.ViewAdmin.Text = "ViewAdmin";
            this.ViewAdmin.Click += new System.EventHandler(this.ViewAdmin_Click);
            // 
            // MainStatus
            // 
            this.MainStatus.Location = new System.Drawing.Point(2, 742);
            this.MainStatus.Name = "MainStatus";
            this.MainStatus.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
            this.AreaInformation,
            this.Information,
            this.Coords});
            this.MainStatus.ShowPanels = true;
            this.MainStatus.Size = new System.Drawing.Size(888, 40);
            this.MainStatus.TabIndex = 1;
            // 
            // AreaInformation
            // 
            this.AreaInformation.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
            this.AreaInformation.Name = "AreaInformation";
            this.AreaInformation.Width = 10;
            // 
            // Information
            // 
            this.Information.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
            this.Information.Name = "Information";
            this.Information.Text = "statusBarPanel1";
            this.Information.Width = 851;
            // 
            // Coords
            // 
            this.Coords.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
            this.Coords.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
            this.Coords.Name = "Coords";
            this.Coords.Width = 10;
            // 
            // Main
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
            this.ClientSize = new System.Drawing.Size(892, 784);
            this.Controls.Add(this.MainTabs);
            this.Controls.Add(this.MainMenu);
            this.Controls.Add(this.MainStatus);
            this.Name = "Main";
            this.Padding = new System.Windows.Forms.Padding(2);
            this.Text = "";
            this.Closing += new System.ComponentModel.CancelEventHandler(this.Main_Closing);
            this.Load += new System.EventHandler(this.Load_Form);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Main_KeyDown);
            this.GameTab.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.AreaInformation)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Information)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Coords)).EndInit();
            this.ResumeLayout(false);

		}
        protected bool ProcessKeyRight()
        {
            // Are we the first submenu of a parent control?
            bool autoRight = (_parentControl != null);
            bool checkKeys = false;
            bool ret = false;

            // Is an item currently selected?
            if (_trackItem != -1)
            {
                DrawCommand dc = _drawCommands[_trackItem] as DrawCommand;

                // Does this item have a submenu?
                if (dc.SubMenu)
                {
                    // Handle the submenu
                    OperateSubMenu(_trackItem, true);

                    ret = true;
                }
                else
                {
                    // Grab the current column/row values
                    int col = dc.Col;
                    int row = dc.Row;

                    // If not in the first column then move left one
                    int newItem = -1;
                    int newRow = -1;
                    int findCol = col + 1;
                    DrawCommand newDc = null;

                    for(int i=0; i<_drawCommands.Count; i++)
                    {
                        DrawCommand listDc = _drawCommands[i] as DrawCommand;

                        // Interesting in cells in the required column
                        if (listDc.Col == findCol)
                        {
                            // Is this Row nearer to the one required than those found so far?
                            if ((listDc.Row <= row) && (listDc.Row > newRow) &&
                                !listDc.Separator && listDc.Enabled)
                            {
                                // Remember this item
                                newRow = listDc.Row;
                                newDc = listDc;
                                newItem = i;
                            }
                        }
                    }

                    if (newDc != null)
                    {
                        // Track the new item
                        // Modify the display of the two items
                        SwitchSelection(_trackItem, newItem, false, false);
                    }
                    else
                        checkKeys = true;
                }
            }
            else
            {
                if (_parentMenu != null)
                {
                    if (!ProcessKeyDown())
                        checkKeys = true;
                }
                else
                    checkKeys = true;
            }

            // If we have a parent control and nothing to move right into
            if (autoRight && checkKeys)
            {
                _returnCommand = null;

                // Finish processing messages
                _timer.Stop();
                _exitLoop = true;

                _returnDir = 1;
            }

            return ret;
        }
Пример #9
0
 public virtual void OnSelected(MenuCommand mc)
 {
     // Any attached event handlers?
     if (Selected != null)
         Selected(mc);
 }
Пример #10
0
 protected void OnCommandChanged(MenuCommand item, MenuCommand.Property prop)
 {
     Recalculate();
     Invalidate();
 }
Пример #11
0
 public int IndexOf(MenuCommand value)
 {
     // Find the 0 based index of the requested entry
     return base.List.IndexOf(value);
 }
Пример #12
0
 public void Insert(int index, MenuCommand value)
 {
     // Use base class to process actual collection operation
     base.List.Insert(index, value as object);
 }
Пример #13
0
 public void AddRange(MenuCommand[] values)
 {
     // Use existing method to add each array entry
     foreach(MenuCommand page in values)
         Add(page);
 }
Пример #14
0
        private void InitializeMenu()
        {
            menuIcons.Images.Add(Resources.FolderOpened);
            menuIcons.Images.Add(Resources.FolderClosed);

            fileMenu = new PopupMenu();
            MenuCommand edit = new MenuCommand("Edit");

            edit.ImageList = menuIcons;

            edit.Click += new EventHandler(edit_Click);

            fileMenu.MenuCommands.Add(edit);
            fileMenu.MenuCommands.Add(new MenuCommand("-"));
            AddDefaultCommands(fileMenu);
            fileMenu.MenuCommands["Paste"].Visible = false;

            dirMenu = new PopupMenu();
            MenuCommand add = new MenuCommand("Add");
            MenuCommand open = new MenuCommand("Open");
            MenuCommand expandAll = new MenuCommand("Expand All");
            MenuCommand collapseAll = new MenuCommand("Collapse All");

            add.ImageList = menuIcons;
            open.ImageList = menuIcons;
            expandAll.ImageList = menuIcons;
            collapseAll.ImageList = menuIcons;

            open.ImageIndex = 0;

            open.Click += new EventHandler(open_Click);
            expandAll.Click += new EventHandler(expandAll_Click);
            collapseAll.Click += new EventHandler(collapseAll_Click);

            MenuCommand addFile = new MenuCommand("New File");
            MenuCommand addExisting = new MenuCommand("Existing File");
            MenuCommand addFolder = new MenuCommand("New Folder");

            addFile.ImageList = menuIcons;
            addExisting.ImageList = menuIcons;
            addFolder.ImageList = menuIcons;

            addFolder.ImageIndex = 1;

            addFile.Click += new EventHandler(addFile_Click);
            addExisting.Click += new EventHandler(addExisting_Click);
            addFolder.Click += new EventHandler(addFolder_Click);

            add.MenuCommands.Add(addFile);
            add.MenuCommands.Add(addExisting);
            add.MenuCommands.Add(addFolder);

            dirMenu.MenuCommands.Add(add);
            dirMenu.MenuCommands.Add(open);
            dirMenu.MenuCommands.Add(new MenuCommand("-"));
            dirMenu.MenuCommands.Add(expandAll);
            dirMenu.MenuCommands.Add(collapseAll);
            dirMenu.MenuCommands.Add(new MenuCommand("-"));
            AddDefaultCommands(dirMenu);
        }
Пример #15
0
        private void AddDefaultCommands(PopupMenu menu)
        {
            MenuCommand cut = new MenuCommand("Cut");
            MenuCommand copy = new MenuCommand("Copy");
            MenuCommand paste = new MenuCommand("Paste");
            MenuCommand delete = new MenuCommand("Delete");
            MenuCommand rename = new MenuCommand("Rename");
            MenuCommand reload = new MenuCommand("Reload");
            MenuCommand showAllFiles = new MenuCommand("Show All Files");

            cut.ImageList = menuIcons;
            copy.ImageList = menuIcons;
            paste.ImageList = menuIcons;
            delete.ImageList = menuIcons;
            rename.ImageList = menuIcons;
            reload.ImageList = menuIcons;
            showAllFiles.ImageList = menuIcons;

            cut.Click += new EventHandler(cut_Click);
            copy.Click += new EventHandler(copy_Click);
            paste.Click += new EventHandler(paste_Click);
            delete.Click += new EventHandler(delete_Click);
            rename.Click += new EventHandler(rename_Click);
            reload.Click += new EventHandler(reload_Click);
            showAllFiles.Click += new EventHandler(showAllFiles_Click);

            menu.MenuCommands.Add(cut);
            menu.MenuCommands.Add(copy);
            menu.MenuCommands.Add(paste);
            menu.MenuCommands.Add(delete);
            menu.MenuCommands.Add(rename);
            menu.MenuCommands.Add(new MenuCommand("-"));
            menu.MenuCommands.Add(reload);
            menu.MenuCommands.Add(showAllFiles);
        }
        protected void DefinePopupMenuForControl(Controls.TabControl tabControl)
        {
            PopupMenu pm = new PopupMenu();

            // Add all the standard menus we manage
            _mcClose = new MenuCommand("", new EventHandler(OnClose));
            _mcSep1 = new MenuCommand("-");
            _mcProm = new MenuCommand("", new EventHandler(OnToggleProminent));
            _mcReba = new MenuCommand("", new EventHandler(OnRebalance));
            _mcSep2 = new MenuCommand("-");
            _mcHorz = new MenuCommand("", _internalImages, _imageHorzSplit, new EventHandler(OnNewVertical));
            _mcVert = new MenuCommand("", _internalImages, _imageVertSplit, new EventHandler(OnNewHorizontal));
            _mcNext = new MenuCommand("", new EventHandler(OnMoveNext));
            _mcPrev = new MenuCommand("", new EventHandler(OnMovePrevious));

            // Prominent is a radio checked item
            _mcProm.RadioCheck = true;

            // Use the provided context menu
            tabControl.ContextPopupMenu = pm;

            // Update command states when shown
            tabControl.PopupMenuDisplay += new CancelEventHandler(OnPopupMenuDisplay);
        }
Пример #17
0
    protected MenuControl CreateTopMenu()
    {
      MenuControl menu = new MenuControl();
      menu.Style = style;
      menu.MultiLine = false;

      fileMenu = new MenuCommand("&File");
      editMenu = new MenuCommand("&Edit");
      helpMenu = new MenuCommand("&Help");
      viewMenu = new MenuCommand("&View");
      menu.MenuCommands.AddRange(new MenuCommand[] {fileMenu, editMenu, viewMenu, helpMenu});
      // File
      MenuCommand newMenu = new MenuCommand("&New...", Shortcut.CtrlN, new EventHandler(OnMenuNew));
      MenuCommand openMenu = new MenuCommand("&Open...", menuImageList, 0, Shortcut.CtrlO, new EventHandler(OnMenuOpen));
      MenuCommand closeMenu = new MenuCommand("&Close", new EventHandler(OnMenuClose));
      closeMenu.Enabled = false;
      MenuCommand exitMenu = new MenuCommand("E&xit", new EventHandler(OnMenuExit));
      MenuCommand saveMenu = new MenuCommand("&Save", menuImageList, 1, Shortcut.CtrlS, new EventHandler(OnMenuSave));
      saveMenu.Enabled = false;
      MenuCommand saveAllMenu =
        new MenuCommand("Save A&ll", menuImageList, 2, Shortcut.CtrlShiftS, new EventHandler(OnMenuSaveAll));
      saveAllMenu.Enabled = false;
      fileMenu.MenuCommands.AddRange(
        new MenuCommand[]
          {
            newMenu, openMenu, new MenuCommand("-"), saveMenu, saveAllMenu, new MenuCommand("-"), closeMenu,
            new MenuCommand("-"), exitMenu
          });

      // Edit
      MenuCommand cutMenu = new MenuCommand("Cu&t", Shortcut.CtrlX, new EventHandler(OnMenuCut));
      MenuCommand copyMenu = new MenuCommand("&Copy", Shortcut.CtrlC, new EventHandler(OnMenuCopy));
      MenuCommand pasteMenu = new MenuCommand("&Paste", Shortcut.CtrlV, new EventHandler(OnMenuPaste));
      MenuCommand preferencesMenu = new MenuCommand("&Preferences", new EventHandler(OnMenuPreferences));
      editMenu.MenuCommands.AddRange(
        new MenuCommand[] {cutMenu, copyMenu, pasteMenu, new MenuCommand("-"), preferencesMenu});

      // View
      MenuCommand skinExplorerMenu =
        new MenuCommand("&Explorer", menuImageList, 4, Shortcut.F3, new EventHandler(OnMenuView));
      skinExplorerMenu.Tag = "Explorer";
      MenuCommand propertiesMenu =
        new MenuCommand("&Properties", menuImageList, 3, Shortcut.F4, new EventHandler(OnMenuView));
      propertiesMenu.Tag = "Properties";
      viewMenu.MenuCommands.AddRange(new MenuCommand[] {skinExplorerMenu, propertiesMenu});

      // Help
      MenuCommand aboutMenu = new MenuCommand("&About", new EventHandler(OnMenuAbout));
      MenuCommand helpCommand = new MenuCommand("&Help", menuImageList, 5, new EventHandler(OnMenuView));
      helpCommand.Tag = "Help";
      helpMenu.MenuCommands.AddRange(new MenuCommand[] {helpCommand, new MenuCommand("-"), aboutMenu});

      menu.Dock = DockStyle.Top;
      Controls.Add(menu);

      return menu;
    }
Пример #18
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.MainTabs        = new Crownwood.Magic.Controls.TabControl();
     this.GameTab         = new Crownwood.Magic.Controls.TabPage();
     this.RenderTarget    = new System.Windows.Forms.Panel();
     this.MainMenu        = new Crownwood.Magic.Menus.MenuControl();
     this.FileMenu        = new Crownwood.Magic.Menus.MenuCommand();
     this.FileSave        = new Crownwood.Magic.Menus.MenuCommand();
     this.FileQuit        = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewMenu        = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewLog         = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewConnect     = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewWhoList     = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewSkillList   = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewChat        = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewCommand     = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewFirstPerson = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewChaseCam    = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewMiniMap     = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewOptions     = new Crownwood.Magic.Menus.MenuCommand();
     this.ViewAdmin       = new Crownwood.Magic.Menus.MenuCommand();
     this.MainStatus      = new System.Windows.Forms.StatusBar();
     this.AreaInformation = new System.Windows.Forms.StatusBarPanel();
     this.Information     = new System.Windows.Forms.StatusBarPanel();
     this.Coords          = new System.Windows.Forms.StatusBarPanel();
     this.GameTab.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.AreaInformation)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.Information)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.Coords)).BeginInit();
     this.SuspendLayout();
     //
     // MainTabs
     //
     this.MainTabs.Dock          = System.Windows.Forms.DockStyle.Fill;
     this.MainTabs.Location      = new System.Drawing.Point(2, 27);
     this.MainTabs.Name          = "MainTabs";
     this.MainTabs.SelectedIndex = 0;
     this.MainTabs.SelectedTab   = this.GameTab;
     this.MainTabs.Size          = new System.Drawing.Size(888, 715);
     this.MainTabs.TabIndex      = 0;
     this.MainTabs.TabPages.AddRange(new Crownwood.Magic.Controls.TabPage[] {
         this.GameTab
     });
     //
     // GameTab
     //
     this.GameTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                  | System.Windows.Forms.AnchorStyles.Left)
                                                                 | System.Windows.Forms.AnchorStyles.Right)));
     this.GameTab.Controls.Add(this.RenderTarget);
     this.GameTab.Location = new System.Drawing.Point(0, 0);
     this.GameTab.Name     = "GameTab";
     this.GameTab.Size     = new System.Drawing.Size(888, 690);
     this.GameTab.TabIndex = 0;
     this.GameTab.Title    = "Game";
     //
     // RenderTarget
     //
     this.RenderTarget.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                       | System.Windows.Forms.AnchorStyles.Left)
                                                                      | System.Windows.Forms.AnchorStyles.Right)));
     this.RenderTarget.Location = new System.Drawing.Point(0, 0);
     this.RenderTarget.Name     = "RenderTarget";
     this.RenderTarget.Size     = new System.Drawing.Size(782, 427);
     this.RenderTarget.TabIndex = 1;
     //
     // MainMenu
     //
     this.MainMenu.AnimateStyle       = Crownwood.Magic.Menus.Animation.System;
     this.MainMenu.AnimateTime        = 100;
     this.MainMenu.Cursor             = System.Windows.Forms.Cursors.Arrow;
     this.MainMenu.Direction          = Crownwood.Magic.Common.Direction.Horizontal;
     this.MainMenu.Dock               = System.Windows.Forms.DockStyle.Top;
     this.MainMenu.Font               = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
     this.MainMenu.HighlightTextColor = System.Drawing.SystemColors.MenuText;
     this.MainMenu.Location           = new System.Drawing.Point(2, 2);
     this.MainMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
         this.FileMenu,
         this.ViewMenu
     });
     this.MainMenu.Name     = "MainMenu";
     this.MainMenu.Size     = new System.Drawing.Size(888, 25);
     this.MainMenu.Style    = Crownwood.Magic.Common.VisualStyle.IDE;
     this.MainMenu.TabIndex = 0;
     this.MainMenu.TabStop  = false;
     //
     // FileMenu
     //
     this.FileMenu.Description = "The File menu";
     this.FileMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
         this.FileSave,
         this.FileQuit
     });
     this.FileMenu.Text = "&File";
     //
     // FileSave
     //
     this.FileSave.Description = "MenuItem";
     this.FileSave.Text        = "Save";
     this.FileSave.Click      += new System.EventHandler(this.FileSave_Click);
     //
     // FileQuit
     //
     this.FileQuit.Description = "MenuItem";
     this.FileQuit.Text        = "Quit";
     this.FileQuit.Click      += new System.EventHandler(this.FileQuit_Click);
     //
     // ViewMenu
     //
     this.ViewMenu.Description = "MenuItem";
     this.ViewMenu.MenuCommands.AddRange(new Crownwood.Magic.Menus.MenuCommand[] {
         this.ViewLog,
         this.ViewConnect,
         this.ViewWhoList,
         this.ViewSkillList,
         this.ViewChat,
         this.ViewCommand,
         this.ViewFirstPerson,
         this.ViewChaseCam,
         this.ViewMiniMap,
         this.ViewOptions,
         this.ViewAdmin
     });
     this.ViewMenu.Text = "&View";
     //
     // ViewLog
     //
     this.ViewLog.Description = "MenuItem";
     this.ViewLog.Text        = "Log";
     this.ViewLog.Click      += new System.EventHandler(this.ViewLog_Click);
     //
     // ViewConnect
     //
     this.ViewConnect.Description = "MenuItem";
     this.ViewConnect.Text        = "Connect";
     this.ViewConnect.Click      += new System.EventHandler(this.ViewConnect_Click);
     //
     // ViewWhoList
     //
     this.ViewWhoList.Description = "MenuItem";
     this.ViewWhoList.Text        = "Who";
     this.ViewWhoList.Click      += new System.EventHandler(this.ViewWhoList_Click);
     //
     // ViewSkillList
     //
     this.ViewSkillList.Description = "MenuItem";
     this.ViewSkillList.Text        = "Skills";
     this.ViewSkillList.Click      += new System.EventHandler(this.ViewSkillList_Click);
     //
     // ViewChat
     //
     this.ViewChat.Description = "View Chat";
     this.ViewChat.Text        = "Chat";
     this.ViewChat.Click      += new System.EventHandler(this.ViewChat_Click);
     //
     // ViewCommand
     //
     this.ViewCommand.Description = "View Command";
     this.ViewCommand.Text        = "Command";
     this.ViewCommand.Click      += new System.EventHandler(this.ViewCommand_Click);
     //
     // ViewFirstPerson
     //
     this.ViewFirstPerson.Description = "First Person Mode";
     this.ViewFirstPerson.Text        = "First Person Mode";
     this.ViewFirstPerson.Click      += new System.EventHandler(this.ViewFirstPerson_Click);
     //
     // ViewChaseCam
     //
     this.ViewChaseCam.Description = "Chase Camera";
     this.ViewChaseCam.Text        = "Chase Camera";
     this.ViewChaseCam.Click      += new System.EventHandler(this.ViewChaseCam_Click);
     //
     // ViewMiniMap
     //
     this.ViewMiniMap.Description = "MenuItem";
     this.ViewMiniMap.Text        = "Mini Map";
     this.ViewMiniMap.Click      += new System.EventHandler(this.ViewMiniMap_Click);
     //
     // ViewOptions
     //
     this.ViewOptions.Description = "Options";
     this.ViewOptions.Text        = "Options";
     this.ViewOptions.Click      += new System.EventHandler(this.ViewOptions_Click);
     //
     // ViewAdmin
     //
     this.ViewAdmin.Description = "ViewAdmin";
     this.ViewAdmin.Text        = "ViewAdmin";
     this.ViewAdmin.Click      += new System.EventHandler(this.ViewAdmin_Click);
     //
     // MainStatus
     //
     this.MainStatus.Location = new System.Drawing.Point(2, 742);
     this.MainStatus.Name     = "MainStatus";
     this.MainStatus.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
         this.AreaInformation,
         this.Information,
         this.Coords
     });
     this.MainStatus.ShowPanels = true;
     this.MainStatus.Size       = new System.Drawing.Size(888, 40);
     this.MainStatus.TabIndex   = 1;
     //
     // AreaInformation
     //
     this.AreaInformation.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
     this.AreaInformation.Name     = "AreaInformation";
     this.AreaInformation.Width    = 10;
     //
     // Information
     //
     this.Information.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
     this.Information.Name     = "Information";
     this.Information.Text     = "statusBarPanel1";
     this.Information.Width    = 851;
     //
     // Coords
     //
     this.Coords.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
     this.Coords.AutoSize  = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
     this.Coords.Name      = "Coords";
     this.Coords.Width     = 10;
     //
     // Main
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 16);
     this.ClientSize        = new System.Drawing.Size(892, 784);
     this.Controls.Add(this.MainTabs);
     this.Controls.Add(this.MainMenu);
     this.Controls.Add(this.MainStatus);
     this.Name     = "Main";
     this.Padding  = new System.Windows.Forms.Padding(2);
     this.Text     = "";
     this.Closing += new System.ComponentModel.CancelEventHandler(this.Main_Closing);
     this.Load    += new System.EventHandler(this.Load_Form);
     this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Main_KeyDown);
     this.GameTab.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this.AreaInformation)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.Information)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.Coords)).EndInit();
     this.ResumeLayout(false);
 }
 public virtual void OnSelected(MenuCommand mc)
 {
     // If initiated by a MenuControl item then let the control handle this
     if (_parentControl != null)
         _parentControl.OnSelected(mc);
     else
     {
         // If we have an event defined then fire it
         if (Selected != null)
             Selected(mc);
         else
         {
             // Maybe our parent has an event defined instead
             if (_parentMenu != null)
                 _parentMenu.OnSelected(mc);
         }
     }
 }
Пример #20
0
        private void InitializeMenu()
        {
            popupMenu = new PopupMenu();

            copyAllMenuCommand = new MenuCommand("Copy All", new EventHandler(copyAllMenuCommand_Click));
            clearMenuCommand = new MenuCommand("Clear", new EventHandler(clearMenuCommand_Click));
            forecolorMenuCommand = new MenuCommand("ForeColor", new EventHandler(forecolorMenuCommand_Click));
            backroundMenuCommand = new MenuCommand("BackColor", new EventHandler(backroundMenuCommand_Click));
            wordWrapMenuCommand = new MenuCommand("WordWrap", new EventHandler(wordWrapMenuCommand_Click));
            filterMenuCommand = new MenuCommand("Filter", new EventHandler(filterMenuCommand_Click));
            autoScrollCommand = new MenuCommand("AutoScroll", new EventHandler(autoScrollCommand_Click));

            popupMenu.MenuCommands.Add(copyAllMenuCommand);
            popupMenu.MenuCommands.Add(clearMenuCommand);
            popupMenu.MenuCommands.Add(new MenuCommand("-"));
            popupMenu.MenuCommands.Add(forecolorMenuCommand);
            popupMenu.MenuCommands.Add(backroundMenuCommand);
            popupMenu.MenuCommands.Add(wordWrapMenuCommand);
            popupMenu.MenuCommands.Add(new MenuCommand("-"));
            popupMenu.MenuCommands.Add(filterMenuCommand);
            popupMenu.MenuCommands.Add(autoScrollCommand);
        }
        protected void OnWM_OPERATE_SUBMENU(ref Message m)
        {
            int popupItem = (int)m.WParam;
            bool selectFirst = (m.LParam != IntPtr.Zero);

            _popupItem = popupItem;
            _childMenu = new PopupMenu();

            DrawCommand dc = _drawCommands[popupItem] as DrawCommand;

            // Find screen coordinate of Top right of item cell
            Win32.POINT screenPosTR;
            screenPosTR.x = dc.DrawRect.Right;
            screenPosTR.y = dc.DrawRect.Top;
            User32.ClientToScreen(this.Handle, ref screenPosTR);

            // Find screen coordinate of top left of item cell
            Win32.POINT screenPosTL;
            screenPosTL.x = dc.DrawRect.Left;
            screenPosTL.y = dc.DrawRect.Top;
            User32.ClientToScreen(this.Handle, ref screenPosTL);

            // Ensure the child has the same properties as ourself
            _childMenu.Style = this.Style;
            _childMenu.Font = this.Font;
            _childMenu.BackColor = this.BackColor;
            _childMenu.TextColor = this.TextColor;
            _childMenu.HighlightTextColor = this.HighlightTextColor;
            _childMenu.HighlightColor = this.HighlightColor;
            _childMenu.Animate = this.Animate;
            _childMenu.AnimateStyle = this.AnimateStyle;
            _childMenu.AnimateTime = this.AnimateTime;

            // Record keyboard direction
            int returnDir = 0;

            // Propogate the remembering of expansion state
            _childMenu.RememberExpansion = _rememberExpansion;

            // Honour the collections request for showing infrequent items
            _childMenu._showInfrequent = dc.MenuCommand.MenuCommands.ShowInfrequent;

            // Propogate the highlight property
            _childMenu.HighlightInfrequent = _highlightInfrequent;

            // Generate event so that caller has chance to modify MenuCommand contents
            dc.MenuCommand.OnPopupStart();

            _returnCommand = _childMenu.InternalTrackPopup(new Point(screenPosTR.x, screenPosTR.y),
                                                           new Point(screenPosTL.x, screenPosTL.y),
                                                           dc.MenuCommand.MenuCommands,
                                                           this,
                                                           selectFirst,
                                                           _parentControl,
                                                           _popupRight,
                                                           _popupDown,
                                                           _animateFirst,
                                                           ref returnDir);

            // Generate event so that caller has chance to modify MenuCommand contents
            dc.MenuCommand.OnPopupEnd();

            _popupItem = -1;;
            _childMenu = null;

            // Subsequent times a submenu is shown we do not want it to animate
            _animateFirst = false;

            if ((_returnCommand != null) || (returnDir != 0))
            {
                // Finish processing messages
                _timer.Stop();
                _exitLoop = true;
                _returnDir = returnDir;
            }
        }
Пример #22
0
 private void pop_Deselected(MenuCommand item)
 {
     // TODO: Update status bar with string.Empty
 }
Пример #23
0
 public void Remove(MenuCommand value)
 {
     // Use base class to process actual collection operation
     base.List.Remove(value as object);
 }
Пример #24
0
 private void pop_Selected(MenuCommand item)
 {
     // TODO: Update status bar with item.Description
 }
Пример #25
0
 public bool Contains(MenuCommand value)
 {
     // Use base class to process actual collection operation
     return base.List.Contains(value as object);
 }
Пример #26
0
        private void _lv_HeaderMenuEvent(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            ContainerListView listView = sender as ContainerListView;

            PopupMenu pop = new PopupMenu();
            pop.Selected += new CommandHandler(pop_Selected);
            pop.Deselected += new CommandHandler(pop_Deselected);

            MenuCommand sortBy = pop.MenuCommands.Add(new MenuCommand("Sort &By"));
            pop.MenuCommands.Add(new MenuCommand("-"));
            bool isAscending = true;
            for(int idx = 0; idx < listView.Columns.Count; ++idx)
            {
                ContainerListViewColumnHeader hdr = listView.Columns[idx];
                MenuCommand sortByItem = new MenuCommand(hdr.Text);

                sortByItem.Description = string.Format("Sort By the '{1}' column from this grid", (hdr.Visible ? "Shows" : "Hides"), hdr.Text);
                sortByItem.RadioCheck = true;
                sortByItem.Checked = hdr.SortOrder != SortOrder.None;
                sortByItem.Tag = new object[] { listView, idx };
                //				sortByItem.Click += new EventHandler(sortByItem_Click);

                if(sortByItem.Checked)
                    isAscending = hdr.SortOrder == SortOrder.Ascending;

                sortBy.MenuCommands.Add(sortByItem);
            }

            sortBy.MenuCommands.Add(new MenuCommand("-"));
            MenuCommand ascending = sortBy.MenuCommands.Add(new MenuCommand("&Ascending"));
            ascending.RadioCheck = true;
            ascending.Checked = isAscending;
            ascending.Tag = new object[] { listView, SortOrder.Ascending };
            //			ascending.Click += new EventHandler(sortOrder_Click);

            MenuCommand descending = sortBy.MenuCommands.Add(new MenuCommand("&Descending"));
            descending.RadioCheck = true;
            descending.Checked = !isAscending;
            descending.Tag = new object[] { listView, SortOrder.Descending };
            //			descending.Click += new EventHandler(sortOrder_Click);

            bool allShown = true;
            for(int idx = 0; idx < listView.Columns.Count; ++idx)
            {
                ContainerListViewColumnHeader hdr = listView.Columns[idx];
                MenuCommand checkable = new MenuCommand(hdr.Text);

                checkable.Description = string.Format("{0} the '{1}' column from this grid", (hdr.Visible ? "Shows" : "Hides"), hdr.Text);
                checkable.Checked = hdr.Visible;
                checkable.Tag = hdr;

                pop.MenuCommands.Add(checkable);
                allShown &= hdr.Visible;
            }

            pop.MenuCommands.Add(new MenuCommand("-"));
            pop.MenuCommands.Add(new MenuCommand("Show &All")).Enabled = !allShown;

            MenuCommand result = pop.TrackPopup(listView.PointToScreen(new Point(e.X, e.Y)));
            if(result != null && result.Tag is ContainerListViewColumnHeader)
                (result.Tag as ContainerListViewColumnHeader).Visible = !result.Checked;
        }
Пример #27
0
        public MenuControl()
        {
            // Set default values
            lastX = -1;
            lastY = -1;
            _trackItem = -1;
            _oldFocus = IntPtr.Zero;
            _minButton = null;
            _popupMenu = null;
            _activeChild = null;
            _closeButton = null;
            _controlLPen = null;
            _mdiContainer = null;
            _restoreButton = null;
            _controlLBrush = null;
            _chevronStartCommand = null;
            _animateFirst = true;
            _exitLoop = false;
            _selected = false;
            _multiLine = false;
            _mouseOver = false;
            _defaultFont = true;
            _manualFocus = false;
            _drawUpwards = false;
            _plainAsBlock = false;
            _clientSubclass = null;
            _ignoreMouseMove = false;
            _deselectReset = true;
            _expandAllTogether = true;
            _rememberExpansion = true;
            _highlightInfrequent = true;
            _dismissTransfer = false;
            _style = VisualStyle.IDE;
            _direction = Direction.Horizontal;
            _menuCommands = new MenuCommandCollection();
            _glyphFading = GlyphFading.Default;
            this.Dock = DockStyle.Top;
            this.Cursor = System.Windows.Forms.Cursors.Arrow;

            // Animation details
            _animateTime = 100;
            _animate = Animate.System;
            _animateStyle = Animation.System;

            // Prevent flicker with double buffering and all painting inside WM_PAINT
            SetStyle(ControlStyles.DoubleBuffer |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.UserPaint, true);

            // Should not be allowed to select this control
            SetStyle(ControlStyles.Selectable, false);

            // Hookup to collection events
            _menuCommands.Cleared += new CollectionClear(OnCollectionCleared);
            _menuCommands.Inserted += new CollectionChange(OnCollectionInserted);
            _menuCommands.Removed += new CollectionChange(OnCollectionRemoved);

            // Need notification when the MenuFont is changed
            Microsoft.Win32.SystemEvents.UserPreferenceChanged +=
                new UserPreferenceChangedEventHandler(OnPreferenceChanged);

            DefineColors();

            // Set the starting Font
            DefineFont(SystemInformation.MenuFont);

            // Do not allow tab key to select this control
            this.TabStop = false;

            // Default to one line of items
            this.Height = _rowHeight;

            // Add ourself to the application filtering list
            Application.AddMessageFilter(this);
        }
        protected void OnWM_YBUTTONUP(int xPos, int yPos)
        {
            // Convert from screen to client coordinates
            xPos -= _currentPoint.X;
            yPos -= _currentPoint.Y;

            Point pos = new Point(xPos, yPos);

            for(int i=0; i<_drawCommands.Count; i++)
            {
                DrawCommand dc = _drawCommands[i] as DrawCommand;

                if (dc.DrawRect.Contains(pos))
                {
                    // Is there a change in selected item?
                    if (_trackItem != i)
                    {
                        // Modify the display of the two items
                        SwitchSelection(_trackItem, i, false, false);
                    }
                }
            }

            // Is an item selected?
            if (_trackItem != -1)
            {
                DrawCommand dc = _drawCommands[_trackItem] as DrawCommand;

                // Does this item have a submenu?
                if (dc.SubMenu)
                {
                    // If we are not already showing this submenu...
                    if (_popupItem != _trackItem)
                    {
                        // Is a submenu for a different item showing?
                        if (_childMenu != null)
                        {
                            // Inform the child menu it is no longer needed
                            User32.PostMessage(_childMenu.Handle, WM_DISMISS, 0, 0);
                        }

                        // Handle the submenu
                        OperateSubMenu(_trackItem, false);
                    }
                }
                else
                {
                    if (dc.Expansion)
                        RegenerateExpansion();
                    else
                    {
                        // Kill any child menus open
                        if (_childMenu != null)
                        {
                            // Inform the child menu it is no longer needed
                            User32.PostMessage(_childMenu.Handle, WM_DISMISS, 0, 0);
                        }

                        // Define the selection to return to caller
                        _returnCommand = dc.MenuCommand;

                        // Finish processing messages
                        _timer.Stop();
                        _exitLoop = true;
                    }
                }
            }
        }
Пример #29
0
        protected void Recalculate()
        {
            int length;

            if (_direction == Direction.Horizontal)
                length = this.Width;
            else
                length = this.Height;

            // Is there space for any commands?
            if (length > 0)
            {
                // Count the number of rows needed
                int rows = 0;

                // Number of items on this row
                int columns = 0;

                // Create a collection of drawing objects
                _drawCommands = new ArrayList();

                // Minimum length is a gap on either side of the text
                int cellMinLength = _lengthGap * 2;

                // Each cell is as broad as the whole control
                int cellBreadth = this.Height;

                // Accumulate starting position of each cell
                int lengthStart = 0;

                // Allow enough space to draw a chevron
                length -= (cellMinLength + _chevronLength);

                bool showPendant = ((rows == 0) && (_activeChild != null));

                // If we are showing on a single line but the active child is not
                // currently maximized then we can show a menu item in pendant space
                if (showPendant && !_multiLine && (_activeChild.WindowState != FormWindowState.Maximized))
                    showPendant = false;

                // Pendant positioning information
                int xPos = 0;
                int yPos = 0;
                int xInc = 0;
                int yInc = 0;

                // First line needs extra space for pendant
                if (showPendant)
                {
                    length -= (_pendantLength + _pendantOffset + _shadowGap);

                    bool popupStyle = (_style == VisualStyle.IDE);
                    int borderWidth = (_style == VisualStyle.IDE) ? 1 : 2;

                    // Define the correct visual style
                    _minButton.PopupStyle = popupStyle;
                    _restoreButton.PopupStyle = popupStyle;
                    _closeButton.PopupStyle = popupStyle;

                    // Define correct border width
                    _minButton.BorderWidth = borderWidth;
                    _restoreButton.BorderWidth = borderWidth;
                    _closeButton.BorderWidth = borderWidth;

                    if (_direction == Direction.Horizontal)
                    {
                        xPos = this.Width - _pendantOffset - _buttonLength;
                        yPos = _pendantOffset;
                        xInc = -_buttonLength;
                    }
                    else
                    {
                        xPos = _pendantOffset;
                        yPos = this.Height - _pendantOffset - _buttonLength;
                        yInc = -_buttonLength;
                    }
                }

                // Assume chevron is not needed by default
                _chevronStartCommand = null;

                using(Graphics g = this.CreateGraphics())
                {
                    // Count the item we are processing
                    int index = 0;

                    foreach(MenuCommand command in _menuCommands)
                    {
                        // Give the command a chance to update its state
                        command.OnUpdate(EventArgs.Empty);

                        // Ignore items that are marked as hidden
                        if (!command.Visible)
                            continue;

                        int cellLength = 0;

                        // Is this a separator?
                        if (command.Text == "-")
                            cellLength = _separatorWidth;
                        else
                        {
                            // Calculate the text width of the cell
                            SizeF dimension = g.MeasureString(command.Text, this.Font);

                            // Always add 1 to ensure that rounding is up and not down
                            cellLength = cellMinLength + (int)dimension.Width + 1;
                        }

                        Rectangle cellRect;

                        // Create a new position rectangle
                        if (_direction == Direction.Horizontal)
                            cellRect = new Rectangle(lengthStart, _rowHeight * rows, cellLength, _rowHeight);
                        else
                            cellRect = new Rectangle(_rowWidth * rows, lengthStart, _rowWidth, cellLength);

                        lengthStart += cellLength;
                        columns++;

                        // If this item is overlapping the control edge and it is not the first
                        // item on the line then we should wrap around to the next row.
                        if ((lengthStart > length) && (columns > 1))
                        {
                            if (_multiLine)
                            {
                                // Move to next row
                                rows++;

                                // Reset number of items on this column
                                columns = 1;

                                // Reset starting position of next item
                                lengthStart = cellLength;

                                // Reset position of this item
                                if (_direction == Direction.Horizontal)
                                {
                                    cellRect.X = 0;
                                    cellRect.Y += _rowHeight;
                                }
                                else
                                {
                                    cellRect.X += _rowWidth;
                                    cellRect.Y = 0;
                                }

                                // Only the first line needs extra space for pendant
                                if (showPendant && (rows == 1))
                                    length += (_pendantLength + _pendantOffset);
                            }
                            else
                            {
                                // Is a tracked item being make invisible
                                if (index <= _trackItem)
                                {
                                    // Need to remove tracking of this item
                                    RemoveItemTracking();
                                }

                                // Remember which item is first for the chevron submenu
                                _chevronStartCommand = command;

                                if (_direction == Direction.Horizontal)
                                {
                                    cellRect.Y = 0;
                                    cellRect.Width = cellMinLength + _chevronLength;
                                    cellRect.X = this.Width - cellRect.Width;
                                    cellRect.Height = _rowHeight;
                                    xPos -= cellRect.Width;
                                }
                                else
                                {
                                    cellRect.X = 0;
                                    cellRect.Height = cellMinLength + _chevronLength;
                                    cellRect.Y = this.Height - (cellMinLength + _chevronLength);
                                    cellRect.Width = _rowWidth;
                                    yPos -= cellRect.Height;
                                }

                                // Create a draw command for this chevron
                                _drawCommands.Add(new DrawCommand(cellRect));

                                // Exit, do not add the current item or any afterwards
                                break;
                            }
                        }

                        Rectangle selectRect = cellRect;

                        // Selection rectangle differs from drawing rectangle with IDE, because pressing the
                        // mouse down causes the menu to appear and because the popup menu appears drawn slightly
                        // over the drawing area the mouse up might select the first item in the popup.
                        if (_style == VisualStyle.IDE)
                        {
                            // Modify depending on orientation
                            if (_direction == Direction.Horizontal)
                                selectRect.Height -= (_lengthGap + 2);
                            else
                                selectRect.Width -= _breadthGap;
                        }

                        // Create a drawing object
                        _drawCommands.Add(new DrawCommand(command, cellRect, selectRect));

                        index++;
                    }
                }

                // Position the pendant buttons
                if (showPendant)
                {
                    if (_activeChild.WindowState == FormWindowState.Maximized)
                    {
                        // Window maximzied, must show the buttons
                        if (!_minButton.Visible)
                        {
                            _minButton.Show();
                            _restoreButton.Show();
                            _closeButton.Show();
                        }

                        // Only enabled minimize box if child is allowed to be minimized
                        _minButton.Enabled = _activeChild.MinimizeBox;

                        _closeButton.Location = new Point(xPos, yPos);

                        xPos += xInc; yPos += yInc;
                        _restoreButton.Location = new Point(xPos, yPos);

                        xPos += xInc; yPos += yInc;
                        _minButton.Location = new Point(xPos, yPos);
                    }
                    else
                    {
                        // No window is maximized, so hide the buttons
                        if (_minButton.Visible)
                        {
                            _minButton.Hide();
                            _restoreButton.Hide();
                            _closeButton.Hide();
                        }
                    }
                }
                else
                {
                    // No window is maximized, so hide the buttons
                    if ((_minButton != null) && _minButton.Visible)
                    {
                        _minButton.Hide();
                        _restoreButton.Hide();
                        _closeButton.Hide();
                    }
                }

                if (_direction == Direction.Horizontal)
                {
                    int controlHeight = (rows + 1) * _rowHeight;

                    // Ensure the control is the correct height
                    if (this.Height != controlHeight)
                        this.Height = controlHeight;
                }
                else
                {
                    int controlWidth = (rows + 1) * _rowWidth;

                    // Ensure the control is the correct width
                    if (this.Width != controlWidth)
                        this.Width = controlWidth;
                }
            }
        }
Пример #30
0
        private void UpdateTabs()
        {
            tabControl.TabPages.Clear();
            popupMenu.MenuCommands.Clear();

            popupMenu.MenuCommands.Add(shrinkMenuCommand);
            popupMenu.MenuCommands.Add(multilineMenuCommand);
            popupMenu.MenuCommands.Add(hideTextMenuCommand);
            popupMenu.MenuCommands.Add(new MenuCommand("-"));

            tabList.Sort(new Comparison<TabPageInfo>(TabPageInfo.Compare));

            foreach (TabPageInfo tabRef in tabList) {
                bool visible = !hiddenTabList.Contains(tabRef.TabPage.Title);

                if (visible)
                    tabControl.TabPages.Add(tabRef.TabPage);

                MenuCommand cmd = new MenuCommand(tabRef.TabPage.Title);
                cmd.Checked = visible;
                cmd.Click += new EventHandler(cmd_Click);
                popupMenu.MenuCommands.Add(cmd);
            }

            if (tabControl.TabPages.Count > 0) {
                tabControl.SelectedIndex = 0;
            }
        }
Пример #31
0
        public virtual void OnShowContextMenu(Point screenPos)
        {
            PopupMenu context = new PopupMenu();

            // The order of Content displayed in the context menu is not the same as
            // the order of Content in the _contents collection. The latter has its
            // ordering changed to enable Restore functionality to work.
            ContentCollection temp = new ContentCollection();

            foreach(Content c in _contents)
            {
                int count = temp.Count;
                int index = 0;

                // Find best place to add into the temp collection
                for(; index<count; index++)
                {
                    if (c.Order < temp[index].Order)
                        break;
                }

                temp.Insert(index, c);
            }

            // Create a context menu entry per Content
            foreach(Content t in temp)
            {
                MenuCommand mc = new MenuCommand(t.Title, new EventHandler(OnToggleContentVisibility));
                mc.Checked = t.Visible;
                mc.Tag = t;

                context.MenuCommands.Add(mc);
            }

            // Add a separator
            context.MenuCommands.Add(new MenuCommand("-"));

            // Add fixed entries to end to effect all content objects
            context.MenuCommands.Add(new MenuCommand("Show All", new EventHandler(OnShowAll)));
            context.MenuCommands.Add(new MenuCommand("Hide All", new EventHandler(OnHideAll)));

            // Ensure menu has same style as the docking windows
            context.Style = _visualStyle;

            if (OnContextMenu(context))
            {
                // Show it!
                context.TrackPopup(screenPos, true);
            }
        }
        protected void ProcessKeyLeft()
        {
            // Are we the first submenu of a parent control?
            bool autoLeft = (_parentMenu != null) || (_parentControl != null);
            bool checkKeys = false;

            if (_trackItem != -1)
            {
                // Get the col this item is in
                DrawCommand dc = _drawCommands[_trackItem] as DrawCommand;

                // Grab the current column/row values
                int col = dc.Col;
                int row = dc.Row;

                // If not in the first column then move left one
                if (col > 0)
                {
                    int newItem = -1;
                    int newRow = -1;
                    int findCol = col - 1;
                    DrawCommand newDc = null;

                    for(int i=0; i<_drawCommands.Count; i++)
                    {
                        DrawCommand listDc = _drawCommands[i] as DrawCommand;

                        // Interested in cells in the required column
                        if (listDc.Col == findCol)
                        {
                            // Is this Row nearer to the one required than those found so far?
                            if ((listDc.Row <= row) && (listDc.Row > newRow) &&
                                !listDc.Separator && listDc.Enabled)
                            {
                                // Remember this item
                                newRow = listDc.Row;
                                newDc = listDc;
                                newItem = i;
                            }
                        }
                    }

                    if (newDc != null)
                    {
                        // Track the new item
                        // Modify the display of the two items
                        SwitchSelection(_trackItem, newItem, false, false);
                    }
                    else
                        checkKeys = true;
                }
                else
                    checkKeys = true;
            }
            else
            {
                if (_parentMenu != null)
                {
                    if (!ProcessKeyUp())
                        checkKeys = true;
                }
                else
                    checkKeys = true;
            }

            // If we have a parent control and nothing to move right into
            if (autoLeft && checkKeys)
            {
                _returnCommand = null;

                // Finish processing messages
                _timer.Stop();
                _exitLoop = true;

                // Only a top level PopupMenu should cause the MenuControl to select the
                // next left menu command. A submenu should just become dismissed.
                if (_parentMenu == null)
                    _returnDir = -1;
            }
        }