コード例 #1
0
        AddMenuItems
        (
            ToolStripDropDownItem parentDropDownItem
        )
        {
            const String MethodName = "AddMenuItems";

            this.ArgumentChecker.CheckArgumentNotNull(
                MethodName, "parentDropDownItem", parentDropDownItem);

            AssertValid();

            if (m_aoMenuItems != null)
            {
                this.ArgumentChecker.ThrowArgumentException(MethodName,
                                                            "parentDropDownItem",
                                                            "This method has already been called.  Don't call it twice."
                                                            );
            }

            Int32 iMenuItems = Enum.GetValues(typeof(LayoutType)).Length;

            m_aoMenuItems = new ToolStripMenuItem[iMenuItems];

            // AllLayouts.GetAllLayouts() returns one array entry for each layout
            // in the LayoutType enumeration.  There may be additional entries that
            // are set to the LayoutGroupSeparator constant.

            foreach (LayoutInfo oLayoutInfo in AllLayouts.GetAllLayouts())
            {
                if (oLayoutInfo == AllLayouts.LayoutGroupSeparator)
                {
                    AddMenuItemSeparator(parentDropDownItem);
                }
                else
                {
                    m_aoMenuItems[(Int32)oLayoutInfo.Layout] = AddMenuItem(
                        parentDropDownItem, oLayoutInfo.Layout,
                        oLayoutInfo.MenuText, oLayoutInfo.Description
                        );
                }
            }

            // Check the menu item corresponding to the current layout.

            m_aoMenuItems[(Int32)this.Layout].Checked = true;

        #if DEBUG
            // Verify that AllLayouts.GetAllLayouts() returned one array entry for
            // each layout in the LayoutType enumeration.

            for (Int32 i = 0; i < m_aoMenuItems.Length; i++)
            {
                Debug.Assert(m_aoMenuItems[i] != null);
            }
        #endif
        }
コード例 #2
0
        AddItems
        (
            ToolStripSplitButton toolStripSplitButton
        )
        {
            const String MethodName = "AddItems";

            this.ArgumentChecker.CheckArgumentNotNull(
                MethodName, "toolStripSplitButton", toolStripSplitButton);

            AssertValid();

            if (m_oToolStripSplitButton != null)
            {
                this.ArgumentChecker.ThrowArgumentException(MethodName,
                                                            "toolStripSplitButton",
                                                            "This method has already been called.  Don't call it twice."
                                                            );
            }

            m_oToolStripSplitButton = toolStripSplitButton;

            m_oToolStripSplitButton.ButtonClick += new EventHandler(
                this.m_oToolStripSplitButton_ButtonClick);

            ToolStripItemCollection oItems = m_oToolStripSplitButton.DropDownItems;
            Int32 iInsertionIndex          = 0;

            foreach (LayoutInfo oLayoutInfo in AllLayouts.GetAllLayouts())
            {
                ToolStripItem oToolStripItem;

                if (oLayoutInfo == AllLayouts.LayoutGroupSeparator)
                {
                    oToolStripItem = new ToolStripSeparator();
                }
                else
                {
                    oToolStripItem = new ToolStripMenuItem(oLayoutInfo.Text, null,
                                                           new EventHandler(this.OnLayoutMenuItemClick));

                    oToolStripItem.Tag = oLayoutInfo;

                    oToolStripItem.ToolTipText =
                        oLayoutInfo.Description.TrimEnd('.');
                }

                // Don't call ToolStripItemCollection.Add(), because the
                // ToolStripSplitButton may already have items added to it by the
                // caller.  The items added here should precede any existing items.

                oItems.Insert(iInsertionIndex, oToolStripItem);
                iInsertionIndex++;
            }
        }
コード例 #3
0
ファイル: LayoutManager.cs プロジェクト: yesbb12/NetMap
        CreateLayout()
        {
            AssertValid();

            return(AllLayouts.CreateLayout(m_eLayout));
        }