예제 #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && _action != null)
            {
                OnParentChanged(this.Parent, null);

                ToolStripBuilder.Clear(this.DropDownItems);

                // VERY IMPORTANT: instances of this class will be created and discarded frequently
                // throughout the lifetime of the application
                // therefore is it extremely important that the event handlers are disconnected
                // from the underlying _action events
                // otherwise, this object will hang around for the entire lifetime of the _action object,
                // even though this object is no longer needed
                _action.EnabledChanged   -= _actionEnabledChangedHandler;
                _action.CheckedChanged   -= _actionCheckedChangedHandler;
                _action.VisibleChanged   -= _actionVisibleChangedHandler;
                _action.AvailableChanged -= _actionAvailableChangedHandler;
                _action.LabelChanged     -= _actionLabelChangedHandler;
                _action.TooltipChanged   -= _actionTooltipChangedHandler;
                _action.IconSetChanged   -= _actionIconSetChangedHandler;

                _action = null;
            }

            base.Dispose(disposing);
        }
예제 #2
0
        /// <summary>
        /// Called to build menus and toolbars.  Override this method to customize menu and toolbar building.
        /// </summary>
        /// <remarks>
        /// The default implementation simply clears and re-creates the toolstrip using methods on the
        /// utility class <see cref="ToolStripBuilder"/>.
        /// </remarks>
        /// <param name="kind"></param>
        /// <param name="toolStrip"></param>
        /// <param name="actionModel"></param>
        protected virtual void BuildToolStrip(ToolStripBuilder.ToolStripKind kind, ToolStrip toolStrip, ActionModelNode actionModel)
        {
            // avoid flicker
            toolStrip.SuspendLayout();
            // very important to clean up the existing ones first
            ToolStripBuilder.Clear(toolStrip.Items);

            if (actionModel != null)
            {
                if (actionModel.ChildNodes.Count > 0)
                {
                    // Toolstrip should only be visible if there are items on it
                    if (kind == ToolStripBuilder.ToolStripKind.Toolbar)
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes, ToolStripBuilder.ToolStripBuilderStyle.GetDefault(), ToolStripSettings.Default.IconSize);
                    }
                    else
                    {
                        ToolStripBuilder.BuildToolStrip(kind, toolStrip.Items, actionModel.ChildNodes);
                    }
                }
            }

            toolStrip.ResumeLayout();
        }
예제 #3
0
 private void InitializeMenu()
 {
     ToolStripBuilder.Clear(_contextMenu.Items);
     if (_menuModel != null)
     {
         ToolStripBuilder.BuildMenu(_contextMenu.Items, _menuModel.ChildNodes);
     }
 }
예제 #4
0
 private void InitializeToolStrip()
 {
     ToolStripBuilder.Clear(_toolStrip.Items);
     if (_toolbarModel != null)
     {
         ToolStripBuilder.BuildToolbar(_toolStrip.Items, _toolbarModel.ChildNodes);
     }
 }
예제 #5
0
 private void InitializeContextMenu()
 {
     ToolStripBuilder.Clear(_contextMenu.Items);
     if (_component != null && _component.MenuModel != null)
     {
         ToolStripBuilder.BuildMenu(_contextMenu.Items, _component.MenuModel.ChildNodes);
     }
 }
예제 #6
0
        private void OnDropDownOpening(object sender, EventArgs e)
        {
            ToolStripBuilder.Clear(this.DropDownItems);

            ActionModelNode model = ((IDropDownAction)_action).DropDownMenuModel;

            if (model != null)
            {
                ToolStripBuilder.BuildMenu(this.DropDownItems, model.ChildNodes);
            }
        }
예제 #7
0
        private void InitializeToolStrip()
        {
            ToolStripBuilder.Clear(_toolStrip.Items);

            if (_component != null && _component.ToolbarModel != null)
            {
                ToolStripBuilder.BuildToolbar(_toolStrip.Items, _component.ToolbarModel.ChildNodes);
                if (_toolStrip.Items.Count > 0)
                {
                    _toolStrip.Visible = true;
                }
            }
        }