Example #1
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, ":以上反复");
 }
Example #2
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public RunnablePackage()
 {
     ActionPackage pad = new ActionPackage()
     {
         nodeName = "pad",
         nodeType = ActionPackageType.NOP
     };
     this.APList.Add(pad);
 }
Example #3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public RunnablePackage()
        {
            ActionPackage pad = new ActionPackage()
            {
                nodeName = "pad",
                nodeType = ActionPackageType.NOP
            };

            this.APList.Add(pad);
        }
Example #4
0
 /// <summary>
 /// 增加一个动作
 /// </summary>
 /// <param name="ap">动作包装</param>
 /// <param name="insertLine">插入的行</param>
 /// <returns>操作成功与否</returns>
 public bool AddAction(ActionPackage ap, int insertLine)
 {
     if (insertLine >= 0 && insertLine < this.APList.Count)
     {
         this.APList.Insert(insertLine, ap);
     }
     else
     {
         return false;
     }
     return true;
 }
Example #5
0
 /// <summary>
 /// 替换指定位置的一个动作
 /// </summary>
 /// <param name="ap">新的动作包装</param>
 /// <param name="editLine">要被替换的行</param>
 /// <returns>操作成功与否</returns>
 public bool ReplaceAction(ActionPackage ap, int editLine)
 {
     if (editLine >= 0 && editLine < this.APList.Count)
     {
         this.APList[editLine] = ap;
     }
     else
     {
         return(false);
     }
     return(true);
 }
Example #6
0
 /// <summary>
 /// 增加一个动作
 /// </summary>
 /// <param name="ap">动作包装</param>
 /// <param name="insertLine">插入的行</param>
 /// <returns>操作成功与否</returns>
 public bool AddAction(ActionPackage ap, int insertLine)
 {
     if (insertLine >= 0 && insertLine < this.APList.Count)
     {
         this.APList.Insert(insertLine, ap);
     }
     else
     {
         return(false);
     }
     return(true);
 }
Example #7
0
        /// <summary>
        /// 深拷贝一份自身并返回
        /// </summary>
        /// <returns>一份深拷贝</returns>
        public ActionPackage Clone()
        {
            ActionPackage ap = new ActionPackage();

            ap.nodeName = this.nodeName;
            ap.indent   = this.indent;
            ap.nodeType = this.nodeType;
            ap.argsDict = new Dictionary <string, ArgumentPackage>();
            foreach (var kvp in this.argsDict)
            {
                ArgumentPackage argp = new ArgumentPackage()
                {
                    aType    = kvp.Value.aType,
                    valueExp = kvp.Value.valueExp
                };
                ap.argsDict.Add(kvp.Key, argp);
            }
            return(ap);
        }
Example #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 });
     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, ":分支结束");
     }
 }
Example #9
0
 /// <summary>
 /// 深拷贝一份自身并返回
 /// </summary>
 /// <returns>一份深拷贝</returns>
 public ActionPackage Clone()
 {
     ActionPackage ap = new ActionPackage();
     ap.nodeName = this.nodeName;
     ap.indent = this.indent;
     ap.nodeType = this.nodeType;
     ap.argsDict = new Dictionary<string, ArgumentPackage>();
     foreach (var kvp in this.argsDict)
     {
         ArgumentPackage argp = new ArgumentPackage()
         {
             aType = kvp.Value.aType,
             valueExp = kvp.Value.valueExp
         };
         ap.argsDict.Add(kvp.Key, argp);
     }
     return ap;
 }
 /// <summary>
 /// 执行这条指令
 /// </summary>
 public void Dash()
 {
     var ArgDict = new Dictionary<string, ArgumentPackage>();
     foreach (var kvp in this.ArgumentList)
     {
         ArgDict.Add(kvp.Key, 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.ToString()),
         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()));
 }