public ActionDefinition(ActionKind kind, ActionExecutionType exec, bool question, string funcname, string code, ActionArgumentType[] args) { Kind = kind; ExecutionType = exec; IsQuestion = question; FunctionName = funcname; Code = code; Arguments = args; }
public ActionForm(ActionDeclaration a) { InitializeComponent(); foreach (TreeNode n in Program.IDE.Objects.Node.Nodes) { objectMenu.Items.Add(CreateResourceMenuItem(n, item_Click, null)); } initialsetting = true; pictureBoxAction.Image = a.Kind.Image; Text = a.Kind.Description; this.StartPosition = FormStartPosition.CenterParent; Arrows = new CheckBox[] { checkBoxSW, checkBoxS, checkBoxSE, checkBoxW, checkBoxStop, checkBoxE, checkBoxNW, checkBoxN, checkBoxNE }; ArgLabels = new Label[] { labelArg1, labelArg2, labelArg3, labelArg4, labelArg5, labelArg6 }; ArgTextBoxes = new TextBox[] { textBoxArg1, textBoxArg2, textBoxArg3, textBoxArg4, textBoxArg5, textBoxArg6 }; ArgMenus = new Button[] { buttonArg1, buttonArg2, buttonArg3, buttonArg4, buttonArg5, buttonArg6 }; action = new ActionDeclaration(a); originalAction = a; this.radioButtonSelf.Checked = a.AppliesTo == -1; this.radioButtonOther.Checked = a.AppliesTo == -2; this.radioButtonObject.Checked = a.AppliesTo >= 0; this.panel1.Visible = this.radioButtonObject.Checked; this.label1.Text = action.AppliesTo == -1 ? "self" : action.AppliesTo == -2 ? "other" : Program.Objects.ContainsKey(action.AppliesTo) ? Program.Objects[action.AppliesTo].Name : "<undefined>"; this.button1.Visible = this.radioButtonObject.Checked; this.checkBoxRelative.Checked = this.checkBoxArrowsRelative.Checked = a.Relative; this.checkBoxNot.Checked = this.checkBoxArrowsNot.Checked = a.Not; this.panelArrows.Visible = a.Kind.InterfaceKind == ActionInferfaceKind.Arrows; this.panelNormal.Visible = a.Kind.InterfaceKind == ActionInferfaceKind.Normal; this.groupBoxAppliesTo.Visible = a.Kind.ShowApplyTo; if (a.Kind.InterfaceKind == ActionInferfaceKind.Arrows) { for (int i = 0; i < 9; i++) { Arrows[i].Checked = a.Arguments[0][i] != '0'; } textBoxSpeed.Text = a.Arguments[1]; checkBoxArrowsRelative.Visible = a.Kind.ShowRelative; checkBoxArrowsNot.Visible = a.Kind.IsQuestion; } else { for (int i = 0; i < 6; i++) { if (i >= a.Arguments.Count) { ArgLabels[i].Visible = false; ArgTextBoxes[i].Visible = false; ArgMenus[i].Visible = false; } else { ArgLabels[i].Text = a.Kind.Arguments[i].Caption; if (a.Kind.Arguments[i].Type == ActionArgumentType.FontString) { string[] sl = action.Arguments[i].Split(','); int col = int.Parse(sl[2]); ArgTextBoxes[i].ForeColor = Color.FromArgb(255, col & 255, (col >> 8) & 255, (col >> 16) & 255); FontStyle fs = FontStyle.Regular; if (sl[3] == "1") { fs |= FontStyle.Bold; } if (sl[4] == "1") { fs |= FontStyle.Italic; } if (sl[5] == "1") { fs |= FontStyle.Underline; } if (sl[6] == "1") { fs |= FontStyle.Strikeout; } ArgTextBoxes[i].Font = new Font(sl[0].Replace("\"", string.Empty), float.Parse(sl[1]), fs, GraphicsUnit.Point); } ArgTextBoxes[i].Text = ArgToString(i); ActionArgumentType t = a.Kind.Arguments[i].Type; ArgTextBoxes[i].ReadOnly = t != ActionArgumentType.Expression && t != ActionArgumentType.String && t != ActionArgumentType.Both; if (a.Kind.Arguments[i].Type == ActionArgumentType.Color) { int col = int.Parse(action.Arguments[i]); ArgTextBoxes[i].BackColor = Color.FromArgb(255, col & 255, (col >> 8) & 255, (col >> 16) & 255); } else { ArgTextBoxes[i].BackColor = Color.FromKnownColor(KnownColor.Window); } ArgTextBoxes[i].Tag = (object)i; ArgMenus[i].Tag = (object)i; bool hasmenu = true; switch (a.Kind.Arguments[i].Type) { case ActionArgumentType.Expression: case ActionArgumentType.String: case ActionArgumentType.Both: ArgMenus[i].Visible = hasmenu = false; break; } if (hasmenu) { ArgTextBoxes[i].Click += new EventHandler(argument_Click); ArgMenus[i].Click += new EventHandler(argument_Click); } } } checkBoxRelative.Visible = a.Kind.ShowRelative; checkBoxNot.Visible = a.Kind.IsQuestion; } initialsetting = false; }
public ActionArgument(ActionArgumentType type) { Type = type; Value = null; }
// context.GetActionLibrary(1).DefineAction(100, normal, false, "action_xx", null, {expr, menu, object}); public void DefineAction(int actionid, ActionKind kind, ActionExecutionType execution, bool question, string func, string code, ActionArgumentType[] args) { if (!Actions.ContainsKey(actionid)) Actions.Add(actionid, new ActionDefinition(kind, execution, question, func, code, args)); }