public ME_Motion Copy() { ME_Motion ret = new ME_Motion(); ret.name = this.name; for (int i = 0; i < this.Events.Count; i++) { if (this.Events[i] is ME_Frame) { ret.Events.Add(((ME_Frame)this.Events[i]).Copy()); } else if (this.Events[i] is ME_Delay) { ret.Events.Add(((ME_Delay)this.Events[i]).Copy()); } else if (this.Events[i] is ME_Flag) { ret.Events.Add(((ME_Flag)this.Events[i]).Copy()); } else if (this.Events[i] is ME_Goto) { ret.Events.Add(((ME_Goto)this.Events[i]).Copy()); } else if (this.Events[i] is ME_GotoMotion) { ret.Events.Add(((ME_GotoMotion)this.Events[i]).Copy()); } else if (this.Events[i] is ME_Release) { ret.Events.Add(((ME_Release)this.Events[i]).Copy()); } else if (this.Events[i] is ME_If) { ret.Events.Add(((ME_If)this.Events[i]).Copy()); } else if (this.Events[i] is ME_Compute) { ret.Events.Add(((ME_Compute)this.Events[i]).Copy()); } } ret.frames = this.frames; ret.property = this.property; ret.moton_layer = this.moton_layer; ret.comp_range = this.comp_range; ret.control_method = this.control_method; ret.trigger_index = this.trigger_index; ret.goto_var = this.goto_var.ToList(); ret.states = this.states.ToList(); ret.used_servos = this.used_servos.ToList(); return(ret); }
public SetCommand(List <ME_Trigger> commands, Dictionary <string, string> lang_dic, ArrayList ME_List, GlobalSettings gs, Arduino arduino, string com_port, NewMotion Motion, int var_num, int board_ver86) { InitializeComponent(); this.cmd_lang_dic = lang_dic; this.global_cmd = commands; this.ME_Motionlist = ME_List; this.gs = gs; this.arduino = arduino; this.com_port = com_port; this.Motion = Motion; this.var_num = var_num; this.board_ver86 = board_ver86; for (int i = 0; i < commands.Count; i++) { local_cmd.Add(commands[i].Copy()); cmd_num = cmd_num + 1; string[] row = { cmd_num.ToString(), commands[i].name }; var cmdItem = new ListViewItem(row); CmdListView.Items.Add(cmdItem); } if (CmdListView.Items.Count > 0) { CmdListView.Items[0].Selected = true; } else { MotionConfig.Enabled = false; } accLXText.Name = "0"; accHXText.Name = "1"; accLYText.Name = "2"; accHYText.Name = "3"; accLZText.Name = "4"; accHZText.Name = "5"; accDurationText.Name = "6"; initGSpins(); initAnalog(); ps2DATCombo.Text = gs.ps2pins[0]; ps2CMDCombo.Text = gs.ps2pins[1]; ps2ATTCombo.Text = gs.ps2pins[2]; ps2CLKCombo.Text = gs.ps2pins[3]; ESP8266CHPDCombo.Text = gs.esp8266_chpd; for (int i = 0; i < ME_Motionlist.Count; i++) { ME_Motion m = (ME_Motion)ME_Motionlist[i]; if (m.trigger_index != -1 && global_cmd[m.trigger_index].used && !used_element.Contains(m)) { used_element.Add(m); tmp_element.Add(m.Copy()); } for (int j = 0; j < m.Events.Count; j++) { if (m.Events[j] is ME_If mif) { if (mif.left_var >= var_num + 58 && global_cmd[mif.left_var - var_num - 58].used && !used_element.Contains(mif)) { used_element.Add(mif); tmp_element.Add(mif.Copy()); } } } } applyLang(); }
public SetVariable(Dictionary <string, double> variables, Dictionary <string, string> lang_dic, ArrayList ME_List, List <string> used_var) { InitializeComponent(); this.var_lang_dic = lang_dic; this.global_var = variables; this.var_num = 0; this.ME_Motionlist = ME_List; this.used_var = used_var; foreach (KeyValuePair <string, double> entry in variables) { var_num = var_num + 1; string[] row = { var_num.ToString(), entry.Key }; var varItem = new ListViewItem(row); VarListView.Items.Add(varItem); } for (int i = 0; i < ME_Motionlist.Count; i++) { ME_Motion m = (ME_Motion)ME_Motionlist[i]; for (int j = 0; j < m.Events.Count; j++) { if (m.Events[j] is ME_If) { ME_If mif = (ME_If)m.Events[j]; if (mif.left_var < variables.Count && !used_element.Contains(mif)) { used_element.Add(mif); tmp_element.Add(mif.Copy()); } if (mif.right_var < variables.Count && !used_element.Contains(mif)) { used_element.Add(mif); tmp_element.Add(mif.Copy()); } } else if (m.Events[j] is ME_Compute) { ME_Compute op = (ME_Compute)m.Events[j]; if (op.left_var < variables.Count && !used_element.Contains(op)) { used_element.Add(op); tmp_element.Add(op.Copy()); } if (op.f1_var1 < variables.Count && !used_element.Contains(op)) { used_element.Add(op); tmp_element.Add(op.Copy()); } if (op.f1_var2 < variables.Count && !used_element.Contains(op)) { used_element.Add(op); tmp_element.Add(op.Copy()); } if (op.f2_var < variables.Count && !used_element.Contains(op)) { used_element.Add(op); tmp_element.Add(op.Copy()); } if (op.f3_var < variables.Count && !used_element.Contains(op)) { used_element.Add(op); tmp_element.Add(op.Copy()); } } } } }