示例#1
0
        public DropDownToolbarItem(IDropDownAction action, IconSize iconSize)
        {
            _action = action;

            _actionEnabledChangedHandler   = new EventHandler(OnActionEnabledChanged);
            _actionVisibleChangedHandler   = new EventHandler(OnActionVisibleChanged);
            _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged);
            _actionLabelChangedHandler     = new EventHandler(OnActionLabelChanged);
            _actionTooltipChangedHandler   = new EventHandler(OnActionTooltipChanged);
            _actionIconSetChangedHandler   = new EventHandler(OnActionIconSetChanged);

            _action.EnabledChanged   += _actionEnabledChangedHandler;
            _action.VisibleChanged   += _actionVisibleChangedHandler;
            _action.AvailableChanged += _actionAvailableChangedHandler;
            _action.LabelChanged     += _actionLabelChangedHandler;
            _action.TooltipChanged   += _actionTooltipChangedHandler;
            _action.IconSetChanged   += _actionIconSetChangedHandler;

            _iconSize = iconSize;

            this.Text        = _action.Label;
            this.Enabled     = _action.Enabled;
            this.Visible     = _action.Visible;
            this.ToolTipText = _action.Tooltip;

            UpdateVisibility();
            UpdateEnablement();
            UpdateIcon();

            this.ShowDropDownArrow = true;

            this.DropDown = new ContextMenuStrip();
            this.DropDown.ImageScalingSize = StandardIconSizes.Small;
            this.DropDownOpening          += new EventHandler(OnDropDownOpening);
        }
示例#2
0
		public DropDownToolbarItem(IDropDownAction action, IconSize iconSize)
		{
			_action = action;

			_actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged);
			_actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged);
			_actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged);
			_actionLabelChangedHandler = new EventHandler(OnActionLabelChanged);
			_actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged);
			_actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged);

			_action.EnabledChanged += _actionEnabledChangedHandler;
			_action.VisibleChanged += _actionVisibleChangedHandler;
			_action.AvailableChanged += _actionAvailableChangedHandler;
			_action.LabelChanged += _actionLabelChangedHandler;
			_action.TooltipChanged += _actionTooltipChangedHandler;
			_action.IconSetChanged += _actionIconSetChangedHandler;

			_iconSize = iconSize;

			this.Text = _action.Label;
			this.Enabled = _action.Enabled;
			this.Visible = _action.Visible;
			this.ToolTipText = _action.Tooltip;

			UpdateVisibility();
			UpdateEnablement();
			UpdateIcon();

			this.ShowDropDownArrow = true;

			this.DropDown = new ContextMenuStrip();
			this.DropDown.ImageScalingSize = StandardIconSizes.Small;
			this.DropDownOpening += new EventHandler(OnDropDownOpening);
		}
        public DropDownButtonToolbarItem(IClickAction action, IconSize iconSize)
            : base()
        {
            IDropDownAction dropAction = (IDropDownAction)action;

            _fakeButton = new FakeToolstripButton(this);
            base.DropDownButtonWidth = 15;

            _action = action;

            _actionEnabledChangedHandler   = new EventHandler(OnActionEnabledChanged);
            _actionVisibleChangedHandler   = new EventHandler(OnActionVisibleChanged);
            _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged);
            _actionLabelChangedHandler     = new EventHandler(OnActionLabelChanged);
            _actionTooltipChangedHandler   = new EventHandler(OnActionTooltipChanged);
            _actionIconSetChangedHandler   = new EventHandler(OnActionIconSetChanged);
            _actionCheckedChangedHandler   = new EventHandler(OnActionCheckedChanged);

            _action.EnabledChanged   += _actionEnabledChangedHandler;
            _action.VisibleChanged   += _actionVisibleChangedHandler;
            _action.AvailableChanged += _actionAvailableChangedHandler;
            _action.LabelChanged     += _actionLabelChangedHandler;
            _action.TooltipChanged   += _actionTooltipChangedHandler;
            _action.IconSetChanged   += _actionIconSetChangedHandler;
            _action.CheckedChanged   += _actionCheckedChangedHandler;

            _iconSize = iconSize;

            this.DropDown = new ContextMenuStrip();
            this.DropDown.ImageScalingSize = StandardIconSizes.Small;
            this.DropDownOpening          += new EventHandler(OnDropDownOpening);

            this.Text    = _action.Label;
            this.Enabled = _action.Enabled;
            this.Visible = _action.Visible;
            SetTooltipText();

            UpdateCheckedState();
            UpdateVisibility();
            UpdateEnablement();
            UpdateIcon();

            this.ButtonClick += delegate(object sender, EventArgs e)
            {
                _action.Click();
            };
        }
示例#4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && _action != 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.VisibleChanged   -= _actionVisibleChangedHandler;
                _action.AvailableChanged -= _actionAvailableChangedHandler;
                _action.LabelChanged     -= _actionLabelChangedHandler;
                _action.TooltipChanged   -= _actionTooltipChangedHandler;
                _action.IconSetChanged   -= _actionIconSetChangedHandler;

                _action = null;
            }
            base.Dispose(disposing);
        }
示例#5
0
		public DropDownToolbarItem(IDropDownAction action)
			: this(action, IconSize.Medium)
		{
		}
示例#6
0
		protected override void Dispose(bool disposing)
		{
			if (disposing && _action != 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.VisibleChanged -= _actionVisibleChangedHandler;
				_action.AvailableChanged -= _actionAvailableChangedHandler;
				_action.LabelChanged -= _actionLabelChangedHandler;
				_action.TooltipChanged -= _actionTooltipChangedHandler;
				_action.IconSetChanged -= _actionIconSetChangedHandler;

				_action = null;
			}
			base.Dispose(disposing);
		}
示例#7
0
 public DropDownToolbarItem(IDropDownAction action)
     : this(action, IconSize.Medium)
 {
 }