/// <summary>
        /// 执行这条指令
        /// </summary>
        public void Dash()
        {
            // 构造参数字典
            var ArgDict = this.ArgumentList.ToDictionary(kvp => kvp.Key, kvp => new ArgumentPackage()
            {
                aType = kvp.Value.Key, valueExp = kvp.Value.Value
            });
            // 构造新的动作包装
            ActionPackage ap = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = ArgDict,
                nodeName = String.Format("{0}@{1}", this.commandLine, this.apType),
                nodeType = this.apType
            };

            // 缓存编辑前的动作
            this.LastAP = this.parent.GetAction(this.commandLine);
            // 更新后台
            this.parent.ReplaceAction(ap, this.commandLine);
            // 更新前端
            HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent,
                                                     String.Format("◆{0}{1}{2}", ap.GetActionName(), ap.GetSpace(), ap.GetParaDescription()));
        }
 /// <summary>
 /// 撤销这条指令
 /// </summary>
 public void Undo()
 {
     // 更新后台
     this.parent.ReplaceAction(this.LastAP, this.commandLine);
     // 更新前端
     HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
     HalationViewCommand.AddItemToCodeListbox(this.commandLine, this.LastAP.indent,
                                              String.Format("◆{0}{1}{2}", this.LastAP.GetActionName(), this.LastAP.GetSpace(), this.LastAP.GetParaDescription()));
 }
Esempio n. 3
0
 /// <summary>
 /// 重载撤销命令
 /// </summary>
 public void Undo()
 {
     // 这里没错,因为删除后下标变化了
     for (int i = 0; i < 3; i++)
     {
         this.parent.DeleteAction(this.commandLine);
         HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
     }
 }
 public static bool RemoveItemFromCodeListbox(int removeLine)
 {
     if (removeLine >= 0 && removeLine < HalationViewCommand.LineCount())
     {
         Halation.mainView.codeListBox.Items.RemoveAt(removeLine);
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
        /// <summary>
        /// 重载撤销命令
        /// </summary>
        public void Undo()
        {
            // 这里没错,因为删除后下标变化了
            int bound = this.isContainElse ? 5 : 3;

            for (int i = 0; i < bound; i++)
            {
                this.parent.DeleteAction(this.commandLine);
                HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
            }
        }
Esempio n. 6
0
 public static bool RemoveItemFromCodeListbox(int removeLine)
 {
     if (removeLine >= 0 && removeLine < HalationViewCommand.LineCount())
     {
         Halation.mainView.codeListBox.Items.RemoveAt(removeLine);
         Halation.mainView.codeGroupBox.Text =
             $@"脚本 [{Halation.currentScriptName}] (Line: {Halation.currentCodePackage.GetAction().Count})";
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// 执行这条指令
        /// </summary>
        public void Dash()
        {
            var ArgDict = this.ArgumentList.ToDictionary(kvp => kvp.Key, kvp => new ArgumentPackage()
            {
                aType = kvp.Value.Key, valueExp = kvp.Value.Value
            });
            ActionPackage ap = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = ArgDict,
                nodeName = String.Format("{0}@{1}", this.commandLine, this.apType),
                nodeType = this.apType
            };

            this.parent.AddAction(ap, this.commandLine);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent,
                                                     String.Format("◆{0}{1}{2}", ap.GetActionName(), ap.GetSpace(), ap.GetParaDescription()));
        }
Esempio n. 8
0
        /// <summary>
        /// 重载执行命令
        /// </summary>
        public void Dash()
        {
            // IF节点
            Dictionary <string, ArgumentPackage> ifArgDict = new Dictionary <string, ArgumentPackage>();

            ifArgDict.Add("op1", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operand1
            });
            ifArgDict.Add("op2", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operand2
            });
            ifArgDict.Add("opr", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operateMode
            });
            ifArgDict.Add("expr", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.condExpr
            });
            ifArgDict.Add("?elseflag", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.isContainElse.ToString()
            });
            ActionPackage ap1 = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = ifArgDict,
                nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_if.ToString()),
                nodeType = ActionPackageType.act_if
            };

            // 缓存编辑前的动作
            this.LastAP = this.parent.GetAction(this.commandLine);
            // 更新后台
            this.parent.ReplaceAction(ap1, this.commandLine);
            // 更新前端
            HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap1.indent,
                                                     String.Format("◆{0}{1}{2}", ap1.GetActionName(), ap1.GetSpace(), ap1.GetParaDescription()));
        }
        public static bool AddItemToCodeListbox(int insertLine, int indent, string text)
        {
            StringBuilder indentSb = new StringBuilder();

            for (int i = 0; i < indent; i++)
            {
                indentSb.Append(" ");
            }
            if (insertLine >= 0 && insertLine <= HalationViewCommand.LineCount())
            {
                Halation.mainView.codeListBox.Items.Insert(insertLine, indentSb.ToString() + text);
                return(true);
            }
            else if (insertLine == -1)
            {
                Halation.mainView.codeListBox.Items.Add(indentSb.ToString() + text);
                return(true);
            }
            return(false);
        }
Esempio n. 10
0
        public static bool AddItemToCodeListbox(int insertLine, int indent, string text)
        {
            StringBuilder indentSb = new StringBuilder();

            for (int i = 0; i < indent; i++)
            {
                indentSb.Append(" ");
            }
            if (insertLine >= 0 && insertLine <= HalationViewCommand.LineCount())
            {
                Halation.mainView.codeListBox.Items.Insert(insertLine, indentSb.ToString() + text);
                Halation.mainView.codeGroupBox.Text =
                    $@"脚本 [{Halation.currentScriptName}] (Line: {Halation.currentCodePackage.GetAction().Count})";
                return(true);
            }
            else if (insertLine == -1)
            {
                Halation.mainView.codeListBox.Items.Add(indentSb.ToString() + text);
                Halation.mainView.codeGroupBox.Text =
                    $@"脚本 [{Halation.currentScriptName}] (Line: {Halation.currentCodePackage.GetAction().Count})";
                return(true);
            }
            return(false);
        }
Esempio n. 11
0
        /// <summary>
        /// 重载执行命令
        /// </summary>
        public void Dash()
        {
            // FOR节点
            ActionPackage ap = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = new Dictionary <string, ArgumentPackage>(),
                nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_for.ToString()),
                nodeType = ActionPackageType.act_for
            };

            this.parent.AddAction(ap, this.commandLine);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap.indent, "◆循环");
            // PAD节点
            ActionPackage ap2 = new ActionPackage()
            {
                indent   = this.indent + 2,
                argsDict = new Dictionary <string, ArgumentPackage>(),
                nodeName = "pad",
                nodeType = ActionPackageType.NOP
            };

            this.parent.AddAction(ap2, this.commandLine + 1);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine + 1, ap2.indent, "◆");
            // ENDFOR节点
            ActionPackage ap3 = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = new Dictionary <string, ArgumentPackage>(),
                nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endfor.ToString()),
                nodeType = ActionPackageType.act_endfor
            };

            this.parent.AddAction(ap3, this.commandLine + 2);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap3.indent, ":以上反复");
        }
Esempio n. 12
0
        /// <summary>
        /// 重载执行命令
        /// </summary>
        public void Dash()
        {
            // IF节点
            Dictionary <string, ArgumentPackage> ifArgDict = new Dictionary <string, ArgumentPackage>();

            ifArgDict.Add("op1", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operand1
            });
            ifArgDict.Add("op2", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operand2
            });
            ifArgDict.Add("opr", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.operateMode
            });
            ifArgDict.Add("expr", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.condExpr
            });
            ifArgDict.Add("?elseflag", new ArgumentPackage()
            {
                aType = ArgType.unknown, valueExp = this.isContainElse.ToString()
            });
            ActionPackage ap1 = new ActionPackage()
            {
                indent   = this.indent,
                argsDict = ifArgDict,
                nodeName = String.Format("{0}@{1}", this.commandLine, ActionPackageType.act_if.ToString()),
                nodeType = ActionPackageType.act_if
            };

            this.parent.AddAction(ap1, this.commandLine);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine, ap1.indent,
                                                     String.Format("◆{0}{1}{2}", ap1.GetActionName(), ap1.GetSpace(), ap1.GetParaDescription()));
            // PAD节点
            ActionPackage ap2 = new ActionPackage()
            {
                indent   = this.indent + 2,
                argsDict = new Dictionary <string, ArgumentPackage>(),
                nodeName = "pad",
                nodeType = ActionPackageType.NOP
            };

            this.parent.AddAction(ap2, this.commandLine + 1);
            HalationViewCommand.AddItemToCodeListbox(this.commandLine + 1, ap2.indent, "◆");
            // 考虑ELSE子句
            if (this.isContainElse)
            {
                // ELSE节点
                ActionPackage ap3 = new ActionPackage()
                {
                    indent   = this.indent,
                    argsDict = new Dictionary <string, ArgumentPackage>(),
                    nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_else.ToString()),
                    nodeType = ActionPackageType.act_else
                };
                this.parent.AddAction(ap3, this.commandLine + 2);
                HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap3.indent, ":除此以外的情况");
                // PAD节点
                ActionPackage ap4 = new ActionPackage()
                {
                    indent   = this.indent + 2,
                    argsDict = new Dictionary <string, ArgumentPackage>(),
                    nodeName = "pad",
                    nodeType = ActionPackageType.NOP
                };
                this.parent.AddAction(ap4, this.commandLine + 3);
                HalationViewCommand.AddItemToCodeListbox(this.commandLine + 3, ap4.indent, "◆");
                // ENDIF节点
                ActionPackage ap5 = new ActionPackage()
                {
                    indent   = this.indent,
                    argsDict = new Dictionary <string, ArgumentPackage>(),
                    nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endif.ToString()),
                    nodeType = ActionPackageType.act_endif
                };
                this.parent.AddAction(ap5, this.commandLine + 4);
                HalationViewCommand.AddItemToCodeListbox(this.commandLine + 4, ap5.indent, ":分支结束");
            }
            else
            {
                // ENDIF节点(这里不能与上面的endif合并,因为commandline有变化)
                ActionPackage ap6 = new ActionPackage()
                {
                    indent   = this.indent,
                    argsDict = new Dictionary <string, ArgumentPackage>(),
                    nodeName = String.Format("{0}@{1}", this.commandLine + 2, ActionPackageType.act_endif.ToString()),
                    nodeType = ActionPackageType.act_endif
                };
                this.parent.AddAction(ap6, this.commandLine + 2);
                HalationViewCommand.AddItemToCodeListbox(this.commandLine + 2, ap6.indent, ":分支结束");
            }
        }
 /// <summary>
 /// 撤销这条指令
 /// </summary>
 public void Undo()
 {
     this.parent.DeleteAction(this.commandLine);
     HalationViewCommand.RemoveItemFromCodeListbox(this.commandLine);
 }