protected void addAction <C>(WhiskeyAction action) where C : ToolStripItem { Actions.Add(action); C btn = action.generateControl <C>(); ToolStrip.Items.Add(btn); }
/// <summary> /// Run an action /// </summary> /// <param name="action"></param> public void run(WhiskeyAction action, Object src) { if (action == null) { throw new ArgumentNullException("Action"); } // actions.Enqueue(action); //TODO: put the action on a thread system (so that only one runs at a time) action.Progress = 0; ActionChanged(this, new ActionChangedEventArgs(action)); ActionChangedEventHandler actionHand = new ActionChangedEventHandler((s, a) => { ActionChanged(this, a); }); action.Changed += actionHand; Thread actionThread = new Thread(() => { action.Effect(src); action.Changed -= actionHand; action.Progress = 1; ActionChanged(this, new ActionChangedEventArgs(action)); ActionChanged(this, new ActionChangedEventArgs(null)); }); actionThread.Name = "ACTION: " + action.Name; actionThread.SetApartmentState(ApartmentState.STA); actionThread.Start(); }
protected void addAction(WhiskeyAction action) { Actions.Add(action); ToolStripButton btn = action.generateControl <ToolStripButton>(); ToolStrip.Items.Add(btn); }
private void initControls() { WhiskeyPropertyListGrid.PropertyList = Descriptor.getPropertySet(); remPropertyActions = new List <WhiskeyAction>(); WhiskeyPropertyListGrid.PropertyAdapter.PropertyValueChanged += updateFile; WhiskeyPropertyListGrid.PropertyGrid.PropertyValueChanged += updateFile; addPropertyAction = new AddPropertyAction(Descriptor, WhiskeyPropertyListGrid); ToolStripItems.Add(addPropertyAction.generateControl <ToolStripButton>()); dropDownBtn = new ToolStripDropDownButton("Remove", Assets.AssetManager.ICON_MINUS); //updateItems(); // dropDownBtn.DropDownItems.Add(removeBox); dropDownBtn.DropDownDirection = ToolStripDropDownDirection.BelowRight; dropDownBtn.DropDown.AutoSize = false; dropDownBtn.DropDown.Width = 200; dropDownOpeningHandler = new EventHandler(onDropDownOpening); propRemovedHandler = new PropertyRemovedEventHandler(onPropRemoved); dropDownBtn.DropDownOpening += dropDownOpeningHandler; // Descriptor.PropertyRemoved += propRemovedHandler; //removeBox.Alignment = ToolStripItemAlignment.Right; //removeBox.ImageIndex = 1; //removeBox.DropDownStyle = ComboBoxStyle.DropDownList; ToolStripItems.Add(dropDownBtn); editScriptsAction = new AddRemoveTypeScriptsAction(Descriptor, this); ToolStripItems.Add(editScriptsAction.generateControl()); }
public ActionChangedEventArgs(WhiskeyAction action) { Action = action; }