//记录的点击事件 public string RecodeClick() { Program.MainForm.axMxDrawX1.SaveDwgFile(Program.MainForm.axMxDrawX1.DwgFilePath); if (_TreeView.SelectedNode != null) { if (Program.MainForm.Tag != null) { string id = _TreeView.SelectedNode.Tag.ToString(); Project_Manage project = _HLT.Project_Manage_Tree.Find(x => x.id == id); if (project.type != Project_type.记录) { return(""); } XRecord record = _HLT.XRecords.Find(x => x.id == project.xrecord_id); Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x => x.id == record.Drawing_Manage_id); if (drawing == null) { return(""); } dynamic Propath = Program.MainForm.Tag; string file = $@"{Propath.path}\src\{drawing.name}.dwg"; if (!File.Exists(file)) { return(""); } return(file); } } return(""); }
//重命名图纸 public void DrawRename() { if (_DrawView.SelectedNode != null) { ReNameDialog reName = new ReNameDialog { Text = "重命名" }; reName.transf += ((string result) => { string id = _DrawView.SelectedNode.Tag.ToString(); Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x => x.id == id); if (drawing.name == result) { return; } dynamic pro = Program.MainForm.Tag; if (File.Exists($@"{pro.path}\src\{drawing.name}.dwg")) { File.Move($@"{pro.path}\src\{drawing.name}.dwg", $@"{pro.path}\src\{result}.dwg"); } drawing.name = result; _DrawView.SelectedNode.Text = result; }); reName.ShowDialog(); } }
//删除图纸 public void DrawDelete() { if (_DrawView.SelectedNode != null) { string id = _DrawView.SelectedNode.Tag.ToString(); Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x => x.id == id); dynamic pro = Program.MainForm.Tag; if (File.Exists($@"{pro.path}\src\{drawing.name}.dwg")) { File.Delete($@"{pro.path}\src\{drawing.name}.dwg"); } _HLT.Drawing_Manage_Tree.Remove(drawing); _DrawView.SelectedNode.Remove(); } }
//编辑 只有记录能编辑 public void EditRecode() { //编辑记录 RecodeDialog recode = new RecodeDialog(); recode.Text = "编辑记录"; string id = _TreeView.SelectedNode.Tag.ToString(); Project_Manage project = _HLT.Project_Manage_Tree.Find(x => x.id == id); recode.Tag = new { name = project.name, oner = new List <Drawing_Manage>(_HLT.Drawing_Manage_Tree.ToArray()), path = "", }; recode.transf += (dynamic result) => { project.name = result.name; XRecord record = _HLT.XRecords.Find(x => x.id == project.xrecord_id); if (result.file != "") { FileInfo file = new FileInfo(result.file); string name = file.Name.Substring(0, file.Name.LastIndexOf('.')); string ext = file.Name.Substring(file.Name.LastIndexOf('.') + 1, file.Name.Length - file.Name.LastIndexOf('.') - 1); //Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x=>x.id==record.Drawing_Manage_id); Drawing_Manage drawing = new Drawing_Manage { id = Guid.NewGuid().ToString(), pid = _DrawView.Nodes[0].FirstNode.Tag.ToString(), type = Drawing_type.文件, name = name, ext = ext }; record.Drawing_Manage_id = drawing.id; _HLT.Drawing_Manage_Tree.Add(drawing); _DrawView.Nodes[0].FirstNode.Nodes.Add(new TreeNode { Text = name, Tag = drawing.id }); } if (result.combo != "") { record.Drawing_Manage_id = result.combo; } _TreeView.SelectedNode.Text = result.name; }; recode.ShowDialog(); }
//修改构造 public void DrawEditStruct() { GouzaoRecord record = new GouzaoRecord(); string id = _DrawView.SelectedNode.Tag.ToString(); record.Tag = new { type = "Edit", id = _HLT.Drawing_Manage_Tree.Find(x => x.id == id).id }; record.transf += (dynamic result) => { _DrawView.SelectedNode.Text = result.name; Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x => x.id == id); drawing.name = result.name; }; record.ShowDialog(); }
//创建子项菜单(图纸) public ContextMenuStrip CreateDrawMenu() { string id = _DrawView.SelectedNode.Tag.ToString(); Drawing_Manage drawing = _HLT.Drawing_Manage_Tree.Find(x => x.id == id); ContextMenuStrip contextMenu = new ContextMenuStrip(); if (drawing.type == Drawing_type.资源类型) { ToolStripMenuItem AddDrawing = new ToolStripMenuItem("添加"); AddDrawing.Click += new EventHandler(Draw_AddDrawing_Click); contextMenu.Items.Add(AddDrawing); } if (drawing.type == Drawing_type.文件) { ToolStripMenuItem Rename = new ToolStripMenuItem("重命名"); Rename.Click += new EventHandler(Draw_Rename_Click); ToolStripMenuItem Delete = new ToolStripMenuItem("删除"); Delete.Click += new EventHandler(Draw_Delete_Click); contextMenu.Items.Add(Rename); contextMenu.Items.Add(Delete); } if (drawing.type == Drawing_type.构造配置) { ToolStripMenuItem CreateNew = new ToolStripMenuItem("新建"); CreateNew.Click += new EventHandler(Draw_CreateNew_Click); contextMenu.Items.Add(CreateNew); } if (drawing.type == Drawing_type.配置) { ToolStripMenuItem EditItem = new ToolStripMenuItem("编辑"); EditItem.Click += new EventHandler(Draw_Edit_Click); ToolStripMenuItem ReNameItem = new ToolStripMenuItem("重命名"); ReNameItem.Click += new EventHandler(Draw_Rename_Click); ToolStripMenuItem RemoveItem = new ToolStripMenuItem("删除"); RemoveItem.Click += new EventHandler(Draw_Delete_Click); contextMenu.Items.Add(EditItem); contextMenu.Items.Add(ReNameItem); contextMenu.Items.Add(RemoveItem); } return(contextMenu); }
private void beam_smart_Load(object sender, EventArgs e) { select_range.SelectedIndex = 0; Line_Get.SelectedIndex = 0; wiff_Get.SelectedIndex = 0; Msg_Get.SelectedIndex = 0; if (this.Tag != null) { dynamic tag = this.Tag; List <Drawing_Manage> ComboSource = ((List <Drawing_Manage>)tag.list).Where(x => x.type == Drawing_type.配置).ToList(); combox_peizhi.DataSource = ComboSource; combox_peizhi.ValueMember = "id"; combox_peizhi.DisplayMember = "name"; if (tag.json != "null") { beam = JsonConvert.DeserializeObject <Beam_XRrecord>(tag.json); //tag.json as Beam_XRrecord; if (beam.pto != null) { select_range.Text = "显示"; transf("Range"); } //if (beam.side_lines != null) Line_Get.Text = "显示"; //if (beam.dim_texts != null) wiff_Get.Text = "显示"; //if (beam.seat_lines != null) Msg_Get.Text = "显示"; combox_Hnt.Text = beam.Concrete_type; combox_Lzj.Text = beam.Rebar_type; combox_Lgj.Text = beam.Strup_type; combox_kzdj.Text = beam.earth_type; Drawing_Manage Dlist = ComboSource.Find(x => x.id == beam.Drawing_Manage_id); combox_peizhi.Text = Dlist == null ? "" : Dlist.name; if (beam.overmm != null) { check_gj.Checked = true; over_box.Text = beam.overmm; } if (beam.Rebar_overmm != null) { combox_Gjcy.Text = beam.Rebar_overmm; } } } }
//创建记录 public void CreateRecode() { //创建记录 RecodeDialog recode = new RecodeDialog(); recode.Tag = new { name = "", oner = new List <Drawing_Manage>(_HLT.Drawing_Manage_Tree.ToArray()), path = "", }; recode.transf += (dynamic result) => { Project_Manage project = new Project_Manage { id = Guid.NewGuid().ToString(), pid = _TreeView.SelectedNode.Tag.ToString(), name = result.name, type = Project_type.记录, xrecord_type = Xrecord_type.梁 }; XRecord record = new XRecord(); if (result.file != "" && result.combo == "")//导入的 { FileInfo file = new FileInfo(result.file); string name = file.Name.Substring(0, file.Name.LastIndexOf('.')); string ext = file.Name.Substring(file.Name.LastIndexOf('.') + 1, file.Name.Length - file.Name.LastIndexOf('.') - 1); Drawing_Manage drawing = new Drawing_Manage { id = Guid.NewGuid().ToString(), pid = _DrawView.Nodes[0].FirstNode.Tag.ToString(), name = name, type = Drawing_type.文件, ext = ext }; record = new XRecord { id = Guid.NewGuid().ToString(), Drawing_Manage_id = drawing.id, type = Xrecord_type.梁 }; _DrawView.Nodes[0].FirstNode.Nodes.Add(new TreeNode { Text = name, Tag = drawing.id }); _HLT.Drawing_Manage_Tree.Add(drawing); } if (result.file == "" && result.combo != "")//基于图纸的 { record = new XRecord { id = Guid.NewGuid().ToString(), Drawing_Manage_id = result.combo, type = Xrecord_type.梁 }; } if (_HLT.XRecords == null) { _HLT.XRecords = new List <XRecord> { record } } ; else { _HLT.XRecords.Add(record); } project.xrecord_id = record.id; _HLT.Project_Manage_Tree.Add(project); TreeNode node = new TreeNode(); node.Tag = project.id; node.Text = project.name; _TreeView.SelectedNode.Nodes.Add(node); //Program.MainForm.axMxDrawX1.OpenDwgFile(); _TreeView.SelectedNode = node; Program.MainForm.axMxDrawX1.OpenDwgFile(RecodeClick()); }; recode.ShowDialog(); }