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); }
public ActiveToolbarButton(IClickAction action, Tooltips tooltips) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionCheckedChangedHandler = new EventHandler(OnActionCheckedChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.CheckedChanged += _actionCheckedChangedHandler; this.Sensitive = _action.Enabled; this.Active = _action.IsCheckAction && _action.Checked; this.SetTooltip(tooltips, _action.Tooltip, ""); this.Clicked += OnActivated; if (_action.IconSet != null) { try { // load the tool's icon from it's assembly System.Reflection.Assembly asm = _action.Target.GetType().Assembly; Image icon = new Image(asm, asm.GetName().Name + "." + _action.IconSet.LargeIcon); // icon.Pixbuf = icon.Pixbuf.AddAlpha(true, 255, 0, 0); // make "red" transparent this.IconWidget = icon; } catch (Exception e) { // TODO the icon was either null or not found - log some helpful message } } }
private bool ProcessKeyboardMessage(KeyboardButtonMessage keyboardMessage) { //keyboard up messages are just consumed. if (keyboardMessage.ButtonAction == KeyboardButtonMessage.ButtonActions.Up) { _key = new KeyboardButtonMessage(XKeys.None, KeyboardButtonMessage.ButtonActions.Up); return(true); } _key = keyboardMessage; ReleaseCapture(true); this.CaptureMouseWheelHandler = null; IClickAction action = _shortcutManager.GetKeyboardAction(keyboardMessage.Shortcut); Trace.WriteLine(String.Format("Finding shortcut for: {0}", keyboardMessage.Shortcut)); if (action != null) { action.Click(); return(true); } return(false); }
void ExecuteTranslate(object o) { var ac = new TranslatePointsClickAction(CurrentPolygon); _currentClickableAction = ac; _currentUpdatableMouseAction = ac; ac.ActionDone += afterAction; }
// Methods public DynamicActionButton(IClickAction action) { this._action = action; base.ToolTip = action.Tooltip; this.UpdateIcon(); base.Click += new EventHandler(this.BindingAction); this.BindingActionEvents(); }
/// <summary> /// Builds a menu from the specified action model nodes. /// </summary> /// <param name="parentItemCollection"></param> /// <param name="nodes"></param> public static void BuildMenu(ToolStripItemCollection parentItemCollection, IEnumerable <ActionModelNode> nodes) { List <ActionModelNode> nodeList = CombineAdjacentSeparators(new List <ActionModelNode>(nodes)); foreach (ActionModelNode node in nodeList) { ToolStripItem toolstripItem; if (node is ActionNode) { // this is a leaf node (terminal menu item) ActionNode actionNode = (ActionNode)node; IAction action = actionNode.Action; IActionView view = CreateActionView(ToolStripKind.Menu, action, IconSize.Medium); toolstripItem = (ToolStripItem)view.GuiElement; toolstripItem.Tag = new ItemTag(node, view); parentItemCollection.Add(toolstripItem); // Determine whether we should check the parent menu items too IClickAction clickAction = actionNode.Action as IClickAction; if (clickAction != null && clickAction.CheckParents && clickAction.Checked) { CheckParentItems(toolstripItem); } } else if (node is SeparatorNode) { toolstripItem = new ToolStripSeparator(); toolstripItem.Tag = new ItemTag(node, null); parentItemCollection.Add(toolstripItem); } else { // this menu item has a sub menu toolstripItem = new ToolStripMenuItem(node.PathSegment.LocalizedText); toolstripItem.Tag = new ItemTag(node, null); parentItemCollection.Add(toolstripItem); BuildMenu(((ToolStripMenuItem)toolstripItem).DropDownItems, node.ChildNodes); } // When you get Visible, it refers to whether the object is really visible, as opposed to whether it _can_ be visible. // When you _set_ Visible, it affects whether it _can_ be visible. // For example, an item is really invisible but _can_ be visible before it is actually drawn. // This is why we use the Available property, which give us the information when we are interested in "_Could_ this be Visible?" ToolStripMenuItem parent = toolstripItem.OwnerItem as ToolStripMenuItem; if (parent != null) { SetParentAvailability(parent); toolstripItem.AvailableChanged += delegate { SetParentAvailability(parent); }; } } }
void ExecutePerformAction(object o) { if (!CanExecutePerformAction(o)) { return; } var point = FieldView.GetCurrentMousePos(); var location = zoomManager.RecalcZoomDiv(point); _currentClickableAction.Perform(location); _currentClickableAction.Dispose(); _currentClickableAction = null; }
public void UnregisterDoubleClickHandler(IClickAction clickAction) { if (clickAction == null) { return; } foreach (var handler in _owner._doubleClickHandlers) { if (handler.ClickAction.ActionID == clickAction.ActionID) { _owner._doubleClickHandlers.Remove(handler); return; } } }
public ActiveMenuItem(IClickAction action) : base(action.Label.Replace('&', '_')) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionCheckedChangedHandler = new EventHandler(OnActionCheckedChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.CheckedChanged += _actionCheckedChangedHandler; this.Sensitive = _action.Enabled; this.Active = _action.IsCheckAction && _action.Checked; this.Activated += OnActivated; }
public ActiveMenuItem(IClickAction action) :base(action.Label.Replace('&', '_')) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionCheckedChangedHandler = new EventHandler(OnActionCheckedChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.CheckedChanged += _actionCheckedChangedHandler; this.Sensitive = _action.Enabled; this.Active = _action.IsCheckAction && _action.Checked; this.Activated += OnActivated; }
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(); }; }
void ExecuteRejectAction(object o) { if (_currentClickableAction != null) { _currentClickableAction.Reject(); } _currentUpdatableMouseAction = null; if (_currentClickableAction != null) { _currentClickableAction.Dispose(); } _currentClickableAction = null; if (CurrentUpdatableMouseAction != null) { CurrentUpdatableMouseAction.Dispose(); } }
public override void Dispose() { if (_action != null) { // 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 = null; } base.Dispose(); }
void ExecuteAddNew(object o) { if (CurrentPolygon != null) { CurrentPolygon.DeselectAll(); } _currentClickableAction = new NewFieldClickAction(); _currentClickableAction.ActionDone += (sender, args) => { var poly = args.Result as IFieldPolygon; if (poly == null) { return; } commitPoly(poly); FieldView.RefreshView(); }; }
public ActiveMenuItem(IClickAction action, IconSize iconSize) { _action = action; _iconSize = iconSize; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionCheckedChangedHandler = new EventHandler(OnActionCheckedChanged); _actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged); _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged); _actionLabelChangedHandler = new EventHandler(OnActionLabelChanged); _actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.CheckedChanged += _actionCheckedChangedHandler; _action.VisibleChanged += _actionVisibleChangedHandler; _action.AvailableChanged += _actionAvailableChangedHandler; _action.LabelChanged += _actionLabelChangedHandler; _action.IconSetChanged += _actionIconSetChangedHandler; this.Text = _action.Label; this.Checked = _action.Checked; UpdateVisibility(); UpdateEnablement(); UpdateIcon(); this.Click += delegate(object sender, EventArgs e) { _action.Click(); }; try { this.ShortcutKeys = (Keys)_action.KeyStroke; } catch (Exception e) { Platform.Log(LogLevel.Debug, e); } }
private void BuildActionButtons(IAction freeTool, IAction fixedTool) { base.SuspendLayout(); IClickAction action = freeTool as IClickAction; if (action != null) { if (this._freeToolBtn == null) { this._freeToolBtn = new DynamicActionButton(action); this._freeToolBtn.Location = new Point(0x56, this.BtnSinglePrint.Location.Y); this._freeToolBtn.Size = new Size(0x2e, 0x2e); this.toolTip.SetToolTip(this._freeToolBtn, action.Tooltip); base.Controls.Add(this._freeToolBtn); } else { this._freeToolBtn.Action = action; } } IClickAction action2 = fixedTool as IClickAction; if (action2 != null) { if (this._FixedToolBtn == null) { this._FixedToolBtn = new DynamicActionButton(action2); this._FixedToolBtn.Location = new Point(13, this.BtnSinglePrint.Location.Y); this._FixedToolBtn.Size = new Size(0x2e, 0x2e); this.toolTip.SetToolTip(this._FixedToolBtn, action2.Tooltip); base.Controls.Add(this._FixedToolBtn); } else { this._FixedToolBtn.Action = action2; } } base.ResumeLayout(true); }
/// <summary> /// Processes an <paramref name="xmlAction"/> element in the XML model, deserializing the persisted values into the provided <paramref name="action"/>. /// </summary> private static void ProcessXmlAction(XmlElement xmlAction, IAction action) { string path = xmlAction.GetAttribute("path"); action.Path = new ActionPath(path, action.ResourceResolver); //The group hint from the xml never overrides the action's group hint!!! Otherwise, we can't change //the group hint of an action for the purpose of placing a new one near it. //string grouphint = xmlAction.GetAttribute("group-hint"); //action.GroupHint = new GroupHint(grouphint); bool available = true; string availableValue = xmlAction.GetAttribute("available"); if (!string.IsNullOrEmpty(availableValue)) { if (!bool.TryParse(availableValue, out available)) { available = true; } } action.Available = available; if (action is IClickAction) { IClickAction clickAction = (IClickAction)action; XKeys keyStroke = XKeys.None; string keystrokeValue = xmlAction.GetAttribute("keystroke"); if (!string.IsNullOrEmpty(keystrokeValue)) { if (!XKeysConverter.TryParseInvariant(keystrokeValue, out keyStroke)) { Platform.Log(LogLevel.Debug, "Invalid value for attribute keystroke for action {0}", action.ActionID); } } clickAction.KeyStroke = keyStroke; } }
public ActiveToolbarButton(IClickAction action, IconSize iconSize) { _action = action; _actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged); _actionCheckedChangedHandler = new EventHandler(OnActionCheckedChanged); _actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged); _actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged); _actionLabelChangedHandler = new EventHandler(OnActionLabelChanged); _actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged); _actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged); _action.EnabledChanged += _actionEnabledChangedHandler; _action.CheckedChanged += _actionCheckedChangedHandler; _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; SetTooltipText(); this.Checked = _action.Checked; UpdateVisibility(); UpdateEnablement(); UpdateIcon(); this.Click += delegate(object sender, EventArgs e) { _action.Click(); }; }
public DoubleClickHandlerRegistration(IClickAction clickAction) { _clickAction = clickAction; }
public AbstractClickAction(IClickAction concreteAction) : base(concreteAction) { _keyStroke = concreteAction.KeyStroke; }
public void RegisterDoubleClickHandler(IClickAction clickAction) { Platform.CheckForNullReference(clickAction, "clickAction"); _owner._doubleClickHandlers.Add(new DoubleClickHandlerRegistration(clickAction)); }
public ActiveToolbarButton(IClickAction action) : this(action, IconSize.Medium) { }
public AbstractActionModelTreeLeafClickAction(IClickAction clickAction) : base(clickAction) { _keyStroke = clickAction.KeyStroke; }
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(); }; }
public DropDownButtonToolbarItem(IClickAction action) : this(action, IconSize.Medium) { }
public ActiveMenuItem(IClickAction action) : this(action, Desktop.IconSize.Small) { }