/// <summary> /// 获取全面程序组名 /// </summary> /// <returns></returns> private List <string> GetProgram() { List <string> program = new List <string>(); foreach (var temp in this.treeListViewOper.Objects) { ElectrodeCAMTreeInfo ele = temp as ElectrodeCAMTreeInfo; program.Add(ele.ProgramName); } return(program); }
/// <summary> /// 通过名字获取treeInfo /// </summary> /// <param name="name"></param> /// <returns></returns> private ElectrodeCAMTreeInfo GetInfoForProgramName(string name) { List <ElectrodeCAMTreeInfo> info = this.treeListViewOper.Objects as List <ElectrodeCAMTreeInfo>; foreach (var temp in this.treeListViewOper.Objects) { ElectrodeCAMTreeInfo ele = temp as ElectrodeCAMTreeInfo; if (ele.ProgramName.Equals(name, StringComparison.CurrentCultureIgnoreCase)) { return(ele); } } return(null); }
private void butAdd_Click(object sender, EventArgs e) { string progName = this.comboBoxProgram.Text; string toolName = this.comboBoxTool.Text; string refName = this.comboBoxRefTool.Text; if (refName != null && !refName.Equals("")) { if (this.addOper is TwiceRoughCreateOperation) { (this.addOper as TwiceRoughCreateOperation).SetReferencetool(refName); } if (this.addOper is FlowCutCreateOperation) { (this.addOper as FlowCutCreateOperation).SetReferencetool(refName); } } if (progName != null && !progName.Equals("") && this.addOper != null) { ElectrodeCAMTreeInfo info = GetInfoForProgramName(progName); if (info != null && info.Program is ProgramOperationName) { ProgramOperationName pn = (info.Program as ProgramOperationName); if (!pn.ToolName.Equals(toolName, StringComparison.CurrentCultureIgnoreCase)) { pn.ToolName = toolName; if (!pn.Oper.Exists(a => a.Equals(this.addOper))) { this.addOper.SetToolName(toolName); this.addOper.SetProgramName(progName); this.operInfo.AddOperation(this.addOper, info); this.addOper = null; } } else { if (!pn.Oper.Exists(a => a.Equals(this.addOper))) { this.addOper.SetToolName(toolName); this.addOper.SetProgramName(progName); this.operInfo.AddOperation(this.addOper, info); this.addOper = null; } } ShowTreeInfo(this.operInfo.TreeInfo); } } }
/// <summary> /// 添加程序 /// </summary> private void AddGrogram() { ElectrodeCAMTreeInfo tree = this.treeListViewOper.SelectedObject as ElectrodeCAMTreeInfo; this.comboBoxProgram.Items.Clear(); this.comboBoxRefTool.Items.Clear(); this.comboBoxTool.Items.Clear(); if (tree.Program is ProgramOperationName) { this.groupAddOper.Enabled = true; if (this.addOper != null) { this.groupParameter.Enabled = true; this.comboBoxProgram.Items.AddRange(GetProgram().ToArray()); this.comboBoxProgram.Text = (tree.ProgramName); // this.comboBoxProgram.Enabled = false; this.comboBoxTool.Items.AddRange(this.addOper.GetAllToolName().ToArray()); this.comboBoxTool.Text = (tree.Program as ProgramOperationName).ToolName; List <string> refTool = this.addOper.GetRefToolName(); if (refTool.Count > 0) { this.comboBoxRefTool.Show(); this.labelRefTool.Show(); this.comboBoxRefTool.Items.AddRange(refTool.ToArray()); } else { this.comboBoxRefTool.Hide(); this.labelRefTool.Hide(); } } else { this.groupParameter.Enabled = false; } this.label.Text = "添加刀路"; } else if (tree.Program is AbstractCreateOperation) { addOper = tree.Program as AbstractCreateOperation; this.groupParameter.Enabled = true; this.groupAddOper.Enabled = false; this.comboBoxProgram.Items.AddRange(GetProgram().ToArray()); this.comboBoxProgram.Text = (tree.Parent.Program as ProgramOperationName).Program; this.comboBoxTool.Items.AddRange(this.addOper.GetAllToolName().ToArray()); this.comboBoxTool.Text = tree.ToolName; List <string> refTool = this.addOper.GetRefToolName(); if (refTool.Count > 0) { this.comboBoxRefTool.Show(); this.labelRefTool.Show(); this.comboBoxRefTool.Items.AddRange(refTool.ToArray()); if (addOper is TwiceRoughCreateOperation) { this.comboBoxRefTool.Text = (addOper as TwiceRoughCreateOperation).ReferenceTool; } if (addOper is FlowCutCreateOperation) { this.comboBoxRefTool.Text = (addOper as FlowCutCreateOperation).ReferencetoolName; } } else { this.comboBoxRefTool.Hide(); this.labelRefTool.Hide(); } this.label.Text = "修改刀路"; } }