private void method_1(string string_0, IHatchClass ihatchClass_0, TreeView treeView_0) { TreeNode node = new TreeNode(string_0) { Tag = ihatchClass_0 }; treeView_0.Nodes.Add(node); IEnumHatchDefinition enumHatchDefinitions = ihatchClass_0.HatchTemplate.EnumHatchDefinitions; enumHatchDefinitions.Reset(); IHatchDefinition pHatchDefinition = null; int pHatchInterval = 0; enumHatchDefinitions.Next(ref pHatchInterval, ref pHatchDefinition); while (pHatchDefinition != null) { TreeNode node2 = new TreeNode("Hatch Def(" + pHatchInterval.ToString() + ")") { Tag = new HatchDef(pHatchInterval, pHatchDefinition) }; node.Nodes.Add(node2); enumHatchDefinitions.Next(ref pHatchInterval, ref pHatchDefinition); } }
private void txtHatchInt_LostFocus(object sender, EventArgs e) { int multipleHatchInterval = int.Parse(this.txtHatchInt.Text); if (this.hatchDefinitionCtrl1.HatchInterval != multipleHatchInterval) { TreeNode selectedNode = this.treeView1.SelectedNode; IEnumHatchDefinition enumHatchDefinitions = (selectedNode.Parent.Tag as IHatchClass).HatchTemplate.EnumHatchDefinitions; enumHatchDefinitions.Reset(); IHatchDefinition pHatchDefinition = null; int pHatchInterval = 0; enumHatchDefinitions.Next(ref pHatchInterval, ref pHatchDefinition); int index = 0; bool flag = true; while (pHatchDefinition != null) { if (multipleHatchInterval == this.hatchDefinitionCtrl1.HatchInterval) { if (MessageBox.Show("指定的刻度已存在,是否覆盖?", "刻度", MessageBoxButtons.YesNo) != DialogResult.Yes) { this.txtHatchInt.Text = this.hatchDefinitionCtrl1.HatchInterval.ToString(); return; } (selectedNode.Parent.Tag as IHatchClass).HatchTemplate.RemoveHatchDefinition(index); (selectedNode.Parent.Tag as IHatchClass).HatchTemplate.AddHatchDefinition( multipleHatchInterval, this.hatchDefinitionCtrl1.HatchDefinition); flag = false; break; } index++; enumHatchDefinitions.Next(ref pHatchInterval, ref pHatchDefinition); } int num5 = 0; while (pHatchDefinition != null) { if (pHatchInterval == this.hatchDefinitionCtrl1.HatchInterval) { (selectedNode.Parent.Tag as IHatchClass).HatchTemplate.RemoveHatchDefinition(index); break; } num5++; enumHatchDefinitions.Next(ref pHatchInterval, ref pHatchDefinition); } if (flag) { (selectedNode.Parent.Tag as IHatchClass).HatchTemplate.AddHatchDefinition(multipleHatchInterval, this.hatchDefinitionCtrl1.HatchDefinition); } TreeNode parent = selectedNode.Parent; this.method_2(selectedNode.Parent.Tag as IHatchClass, parent); this.treeView1.SelectedNode = parent; } }