using Microsoft.WindowsAPICodePack.Shell; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.Functionodel; using PaintDotNet.Base.SettingModel; using PaintDotNet.CustomControl; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Windows.Forms; using static PaintDotNet.Base.Functionodel.AnalyzeSettingModel; namespace PaintDotNet.Instrument { /// /// 项目工程 /// internal class ProjectEngineering : FloatingToolForm { #region 控件 private Panel panel3; private ToolTip toolTip1; private IContainer components; private Button button8; private Button button7; private Button button6; private Button button5; private Button button4; private Button button3; private Button button2; private Button button1; private TreeView treeView1; private ListView listView1; private GroupBox groupBox1; private GroupBox groupBox2; private GroupBox groupBox3; private Label label1; private Label label2; private Label label3; private Label label4; private Label label5; private Label label6; private Label label8; private Label label7; private Label label12; private Label label11; private Label label10; private Label label9; private DataGridView dataGridView1; private ImageList imageList1; private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.thebasicinformationofproject.text"); this.label2.Text = PdnResources.GetString("Menu.Ratingdate.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.projectnumber.text") + ":"; this.groupBox2.Text = PdnResources.GetString("Menu.Inspectioninformation.text"); this.label6.Text = PdnResources.GetString("Menu.Inspectiondate.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.inspectiondepartment.text") + ":"; this.label4.Text = PdnResources.GetString("Menu.Contactperson.text") + ":"; this.label3.Text = PdnResources.GetString("Menu.Sender.text") + ":"; this.groupBox3.Text = PdnResources.GetString("Menu.other.text"); this.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text"); } private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.panel3 = new System.Windows.Forms.Panel(); this.button8 = new System.Windows.Forms.Button(); this.button7 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.treeView1 = new System.Windows.Forms.TreeView(); this.listView1 = new System.Windows.Forms.ListView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label8 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label12 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.panel3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // panel3 // this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel3.Controls.Add(this.button8); this.panel3.Controls.Add(this.button7); this.panel3.Controls.Add(this.button6); this.panel3.Controls.Add(this.button5); this.panel3.Controls.Add(this.button4); this.panel3.Controls.Add(this.button3); this.panel3.Controls.Add(this.button2); this.panel3.Controls.Add(this.button1); this.panel3.Location = new System.Drawing.Point(13, 12); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(255, 37); this.panel3.TabIndex = 0; // // button8 // this.button8.Location = new System.Drawing.Point(222, 5); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(25, 25); this.button8.TabIndex = 13; this.button8.UseVisualStyleBackColor = true; this.button8.Click += new System.EventHandler(this.button8_click); // // button7 // this.button7.Location = new System.Drawing.Point(191, 5); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(25, 25); this.button7.TabIndex = 14; this.button7.UseVisualStyleBackColor = true; this.button7.Click += new System.EventHandler(this.button7_click); // // button6 // this.button6.Location = new System.Drawing.Point(160, 5); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(25, 25); this.button6.TabIndex = 15; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_click); // // button5 // this.button5.Location = new System.Drawing.Point(129, 5); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(25, 25); this.button5.TabIndex = 16; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_click); // // button4 // this.button4.Location = new System.Drawing.Point(98, 5); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(25, 25); this.button4.TabIndex = 18; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_click); // // button3 // this.button3.Location = new System.Drawing.Point(67, 5); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(25, 25); this.button3.TabIndex = 20; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_click); // // button2 // this.button2.Location = new System.Drawing.Point(36, 5); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(25, 25); this.button2.TabIndex = 19; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_click); // // button1 // this.button1.Location = new System.Drawing.Point(5, 5); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(25, 25); this.button1.TabIndex = 12; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_click); // // treeView1 // this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.treeView1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText; this.treeView1.HideSelection = false; this.treeView1.Location = new System.Drawing.Point(12, 55); this.treeView1.Name = "treeView1"; this.treeView1.Size = new System.Drawing.Size(256, 445); this.treeView1.TabIndex = 3; this.treeView1.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView1_BeforeExpand); this.treeView1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView1_DrawNode); this.treeView1.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick); // // listView1 // this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView1.HideSelection = false; this.listView1.LargeImageList = this.imageList1; this.listView1.Location = new System.Drawing.Point(283, 12); this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(856, 371); this.listView1.TabIndex = 4; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick); // // imageList1 // this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; this.imageList1.ImageSize = new System.Drawing.Size(48, 48); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.groupBox1.BackColor = System.Drawing.Color.White; this.groupBox1.Controls.Add(this.label8); this.groupBox1.Controls.Add(this.label7); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Location = new System.Drawing.Point(283, 389); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(228, 111); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = "项目基本信息"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(81, 70); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(41, 12); this.label8.TabIndex = 3; this.label8.Text = "label8"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(79, 38); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(41, 12); this.label7.TabIndex = 2; this.label7.Text = "label7"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(7, 70); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(65, 12); this.label2.TabIndex = 1; this.label2.Text = "评级日期:"; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(7, 38); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(65, 12); this.label1.TabIndex = 0; this.label1.Text = "项目编号:"; // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.groupBox2.BackColor = System.Drawing.Color.White; this.groupBox2.Controls.Add(this.label12); this.groupBox2.Controls.Add(this.label11); this.groupBox2.Controls.Add(this.label10); this.groupBox2.Controls.Add(this.label9); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Location = new System.Drawing.Point(517, 389); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(373, 111); this.groupBox2.TabIndex = 6; this.groupBox2.TabStop = false; this.groupBox2.Text = "送检信息"; // // label12 // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(251, 69); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(47, 12); this.label12.TabIndex = 7; this.label12.Text = "label12"; // // label11 // this.label11.AutoEllipsis = true; this.label11.Location = new System.Drawing.Point(250, 37); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(113, 12); this.label11.TabIndex = 6; this.label11.Text = "label11"; // // label10 // this.label10.AutoEllipsis = true; this.label10.Location = new System.Drawing.Point(69, 69); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(117, 12); this.label10.TabIndex = 5; this.label10.Text = "label10"; // // label9 // this.label9.AutoEllipsis = true; this.label9.Location = new System.Drawing.Point(67, 37); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(117, 12); this.label9.TabIndex = 4; this.label9.Text = "label9"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(192, 69); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(65, 12); this.label6.TabIndex = 3; this.label6.Text = "送检日期:"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(7, 69); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(65, 12); this.label5.TabIndex = 2; this.label5.Text = "送检单位:"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(190, 37); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(53, 12); this.label4.TabIndex = 1; this.label4.Text = "联系人:"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(7, 37); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(53, 12); this.label3.TabIndex = 0; this.label3.Text = "送检人:"; // // groupBox3 // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox3.BackColor = System.Drawing.Color.White; this.groupBox3.Controls.Add(this.dataGridView1); this.groupBox3.Location = new System.Drawing.Point(896, 389); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(243, 111); this.groupBox3.TabIndex = 7; this.groupBox3.TabStop = false; this.groupBox3.Text = "其它"; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.Color.White; this.dataGridView1.GridColor = System.Drawing.SystemColors.Control; this.dataGridView1.Location = new System.Drawing.Point(6, 14); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(231, 91); this.dataGridView1.TabIndex = 0; // // ProjectEngineering // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1151, 512); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.listView1); this.Controls.Add(this.treeView1); this.Controls.Add(this.panel3); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; this.MinimumSize = new System.Drawing.Size(295, 39); this.Name = "ProjectEngineering"; this.Text = "项目工程"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ProjectEngineering_FormClosing); this.Controls.SetChildIndex(this.panel3, 0); this.Controls.SetChildIndex(this.treeView1, 0); this.Controls.SetChildIndex(this.listView1, 0); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.panel3.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// 主控件 /// private AppWorkspace appWorkspace; /// /// 常规操作路径 /// private string NormalOperationPath = Startup.instance.configModel.NormalOperation; /// /// 通用分析路径 /// private string GeneralAnalysisPath = Startup.instance.configModel.GeneralAnalysis; /// /// 专用分析路径 /// private string DedicatedAnalysisPath = Startup.instance.configModel.DedicatedAnalysis; /// /// 三个根节点 /// private TreeNode anime1, anime2, anime3, anime4; /// /// 新建文件夹窗口 /// private CreateNameDialog createNameDialog; /// /// 新建项目窗口 /// private CreateProjectDialog createProjectDialog; /// /// 1新建文件夹 2搜索 /// private int createType = 1; /// /// 节点信息类,用于判断节点类型 /// private class NodeInfo { /// /// 根节点类型 1常规 2通用 3专用 4搜索 /// public int rootType; /// /// 文件夹类型 1文件夹 2项目 3内置不允许删除 /// public int folderType; /// /// tag,用于拼接好的存储路径等 /// public string tag; /// /// 数据库的主键(通用、专用及其下的内容) /// public int id; } public class NodeItem { /// /// 父级id /// public int parentId; /// /// 完整路径 /// public string path; /// /// 项目编号 /// public string code; } public ProjectEngineering(AppWorkspace appWorkspace) { this.appWorkspace = appWorkspace; InitializeComponent(); InitializeLanguageText(); InitializeButtonBackgroudImage(); InitializeToolTipAndEvent(); InitializeTreeViewRootData(); InitializeTreeViewDetailData(); InitListViewHeader(); ClearLabelAndDataGridView(); InitGridHeader(); } private void InitializeButtonBackgroudImage() { this.button1.FlatStyle = FlatStyle.Flat; this.button1.FlatAppearance.BorderSize = 0; this.button1.BackgroundImageLayout = ImageLayout.Center; this.button1.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Folder.png").Reference; this.button2.FlatStyle = FlatStyle.Flat; this.button2.FlatAppearance.BorderSize = 0; this.button2.BackgroundImageLayout = ImageLayout.Center; this.button2.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Project.png").Reference; this.button3.FlatStyle = FlatStyle.Flat; this.button3.FlatAppearance.BorderSize = 0; this.button3.BackgroundImageLayout = ImageLayout.Center; this.button3.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Search.png").Reference; this.button4.FlatStyle = FlatStyle.Flat; this.button4.FlatAppearance.BorderSize = 0; this.button4.BackgroundImageLayout = ImageLayout.Center; this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Refresh.png").Reference; this.button5.FlatStyle = FlatStyle.Flat; this.button5.FlatAppearance.BorderSize = 0; this.button5.BackgroundImageLayout = ImageLayout.Center; this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.Delete.png").Reference; this.button6.FlatStyle = FlatStyle.Flat; this.button6.FlatAppearance.BorderSize = 0; this.button6.BackgroundImageLayout = ImageLayout.Center; this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.FullScreen.png").Reference; this.button7.FlatStyle = FlatStyle.Flat; this.button7.FlatAppearance.BorderSize = 0; this.button7.BackgroundImageLayout = ImageLayout.Center; this.button7.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.ListMode.png").Reference; this.button8.FlatStyle = FlatStyle.Flat; this.button8.FlatAppearance.BorderSize = 0; this.button8.BackgroundImageLayout = ImageLayout.Center; this.button8.BackgroundImage = PdnResources.GetImageResource("Icons.ProjectEngineering.PicMode.png").Reference; } private void ClearLabelAndDataGridView() { this.label7.Text = ""; this.label8.Text = ""; this.label9.Text = ""; this.label10.Text = ""; this.label11.Text = ""; this.label12.Text = ""; this.dataGridView1.Rows.Clear(); } /// /// 初始化右侧表头 /// private void InitListViewHeader() { /*ColumnHeader header = new ColumnHeader(); header.Text = "缩略图"; header.Width = this.listView1.Width / 3 - 7; this.listView1.Columns.Add(header);*/ ColumnHeader header = new ColumnHeader(); header.Text = PdnResources.GetString("Menu.name.text"); header.Width = this.listView1.Width / 3 - 7; this.listView1.Columns.Add(header); header = new ColumnHeader(); header.Text = PdnResources.GetString("Menu.user.text"); header.Width = this.listView1.Width / 3 - 7; this.listView1.Columns.Add(header); header = new ColumnHeader(); header.Text = PdnResources.GetString("Menu.Createtime.text"); header.Width = this.listView1.Width / 3 - 7; this.listView1.Columns.Add(header); this.listView1.View = View.Details; } /// /// 初始化项目工程树形菜单 /// private void InitializeTreeViewRootData() { NodeInfo info1 = new NodeInfo(); info1.rootType = 1; info1.tag = NormalOperationPath; anime1 = new TreeNode(); anime1.Text = PdnResources.GetString("Menu.Normaloperation.text"); anime1.Tag = info1; this.treeView1.Nodes.Add(anime1); NodeInfo info2 = new NodeInfo(); info2.rootType = 2; info2.tag = GeneralAnalysisPath; anime2 = new TreeNode(); anime2.Text = PdnResources.GetString("Menu.GeneralAnalysis.Text"); anime2.Tag = info2; this.treeView1.Nodes.Add(anime2); NodeInfo info3 = new NodeInfo(); info3.rootType = 3; info3.tag = DedicatedAnalysisPath; anime3 = new TreeNode(); anime3.Text = PdnResources.GetString("Menu.DedicatedAnalysis.Text"); anime3.Tag = info3; this.treeView1.Nodes.Add(anime3); NodeInfo info4 = new NodeInfo(); info4.rootType = 4; anime4 = new TreeNode(); anime4.Text = PdnResources.GetString("Menu.searchresults.text"); anime4.Tag = info4; this.treeView1.Nodes.Add(anime4); } /// /// 初始化项目工程详细菜单 /// public void InitializeTreeViewDetailData() { this.NormalOperationPath = Startup.instance.configModel.NormalOperation; this.GeneralAnalysisPath = Startup.instance.configModel.GeneralAnalysis; this.DedicatedAnalysisPath = Startup.instance.configModel.DedicatedAnalysis; this.treeView1.Nodes[0].Nodes.Clear(); this.treeView1.Nodes[1].Nodes.Clear(); this.treeView1.Nodes[2].Nodes.Clear(); this.listView1.Items.Clear(); if (NormalOperationPath != null && !NormalOperationPath.Equals("")) { if (!System.IO.Directory.Exists(NormalOperationPath)) { string root = System.IO.Directory.GetDirectoryRoot(NormalOperationPath); if (System.IO.Directory.Exists(root)) System.IO.Directory.CreateDirectory(NormalOperationPath); } else { InitializeTreeViewDetailDataThree(anime1); } } if (GeneralAnalysisPath != null && !GeneralAnalysisPath.Equals("")) { if (!System.IO.Directory.Exists(GeneralAnalysisPath)) { string root = System.IO.Directory.GetDirectoryRoot(GeneralAnalysisPath); if (System.IO.Directory.Exists(root)) System.IO.Directory.CreateDirectory(GeneralAnalysisPath); } else { InitializeGeneralAnalysisTreeViewDetailData(anime2); } } if (DedicatedAnalysisPath != null && !DedicatedAnalysisPath.Equals("")) { if (!System.IO.Directory.Exists(DedicatedAnalysisPath)) { string root = System.IO.Directory.GetDirectoryRoot(DedicatedAnalysisPath); if (System.IO.Directory.Exists(root)) System.IO.Directory.CreateDirectory(DedicatedAnalysisPath); } else { InitializeDedicatedAnalysisPathTreeViewDetailData(anime3); } } } /// /// 常规操作 /// /// private void InitializeTreeViewDetailDataThree(TreeNode treeNode) { List dirs = new List(Directory.GetDirectories(NormalOperationPath, "*", System.IO.SearchOption.TopDirectoryOnly)); foreach (var dir in dirs) { try { this.anime1.Nodes.Add(this.AddFolderTreeNode(1, dir, 0)); } catch (Exception) { } } } /// /// 通用分析 /// private void InitializeGeneralAnalysisTreeViewDetailData(TreeNode treeNode) { List mic_Projects = mic_project_BLL.FindAllByParentId(1); if (mic_Projects != null && mic_Projects.Count > 0) { foreach (mic_project mic_Project in mic_Projects) { if (mic_Project.project_path == null) { this.anime2.Nodes.Add(this.AddProjectTreeNode(3, 2, GeneralAnalysisPath + "\\" + PdnResources.GetString(mic_Project.project_name), mic_Project)); } else { this.anime2.Nodes.Add(this.AddProjectTreeNode(3, 2, GeneralAnalysisPath + "\\" + mic_Project.project_name, mic_Project)); } } } } /// /// 专用分析 /// private void InitializeDedicatedAnalysisPathTreeViewDetailData(TreeNode treeNode) { List mic_Projects = mic_project_BLL.FindAllByParentId(2); if (mic_Projects != null && mic_Projects.Count > 0) { foreach (mic_project mic_Project in mic_Projects) { if (mic_Project.project_path == null) { this.anime3.Nodes.Add(this.AddProjectTreeNode(3, 3, DedicatedAnalysisPath + "\\" + PdnResources.GetString(mic_Project.project_name), mic_Project)); } else { this.anime3.Nodes.Add(this.AddProjectTreeNode(3, 3, DedicatedAnalysisPath + "\\" + mic_Project.project_name, mic_Project)); } } } } public TreeNode TreeNode { get { return this.treeView1.SelectedNode; } } /// /// 初始化提示信息及按钮事件 /// private void InitializeToolTipAndEvent() { this.toolTip1 = new ToolTip(); this.toolTip1.SetToolTip(this.button1, PdnResources.GetString("Menu.Newfolder.Text")); this.toolTip1.SetToolTip(this.button2, PdnResources.GetString("Menu.Newproject.Text")); this.toolTip1.SetToolTip(this.button3, PdnResources.GetString("Menu.Itemsearch.Text")); this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Refresh.text")); this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Delete.Text")); this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Fullscreen.Text")); this.toolTip1.SetToolTip(this.button7, PdnResources.GetString("Menu.tool.Templatemanent.Listmode.text")); this.toolTip1.SetToolTip(this.button8, PdnResources.GetString("Menu.tool.Templategement.Thumbnailmode.text")); this.toolTip1.ShowAlways = true; } /// /// 新建文件夹 /// /// /// private void button1_click(object sender, EventArgs e) { if (this.treeView1.SelectedNode == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text")); return; } if (this.treeView1.SelectedNode.Index == 0 && this.treeView1.SelectedNode.Parent==null) { if (NormalOperationPath == null || NormalOperationPath.Equals("")) { MessageBox.Show(PdnResources.GetString("Menu.Pleasesavepathorchivefilefirst.Text")); return; } } this.createType = 1; this.createNameDialog = new CreateNameDialog(this); this.createNameDialog.Text = PdnResources.GetString("Menu.Newfolder.Text"); this.createNameDialog.StartPosition = FormStartPosition.CenterScreen; this.createNameDialog.ShowDialog(); } /// /// 新建项目 /// /// /// private void button2_click(object sender, EventArgs e) { if (this.treeView1.SelectedNode == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text")); return; } this.createProjectDialog = new CreateProjectDialog(this); this.createProjectDialog.parentId = ((NodeInfo)this.treeView1.SelectedNode.Tag).id; this.createProjectDialog.Text = PdnResources.GetString("Menu.Newproject.Text"); this.createProjectDialog.StartPosition = FormStartPosition.CenterScreen; this.createProjectDialog.ShowDialog(); } /// /// 新建文件夹的结果函数 /// /// public override void GetCreateName(string name) { if(this.createType==1) { //如果是常规操作 if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1) { string newPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + name; if (!System.IO.Directory.Exists(newPath)) { System.IO.Directory.CreateDirectory(newPath); this.treeView1.SelectedNode.Nodes.Add(this.AddFolderTreeNode(1, newPath, 0)); //this.treeView1.Nodes[0].Nodes.Clear(); //InitializeTreeViewDetailDataThree(anime1); } else { MessageBox.Show("已经存在同名文件夹"); } } //如果是通用、专用分析 else { //文件夹内可以建文件夹,项目内不允许建文件夹 //如果不是项目,则允许创建文件夹 if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 1 || ((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3) { string parentPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag; if (!System.IO.Directory.Exists(parentPath)) { System.IO.Directory.CreateDirectory(parentPath); } string newPath = parentPath + "\\" + name; if (!System.IO.Directory.Exists(newPath)) { //创建文件夹 System.IO.Directory.CreateDirectory(newPath); //添加到数据库 mic_project project = new mic_project(); project.parent_id = ((NodeInfo)this.treeView1.SelectedNode.Tag).id; project.project_name = name; project.project_path = newPath; project.project_type = 3; mic_project_BLL.Add(project); this.treeView1.SelectedNode.Nodes.Add(this.AddFolderTreeNode(((NodeInfo)this.treeView1.SelectedNode.Tag).rootType, newPath, project.id)); } else { MessageBox.Show("已经存在同名文件夹"); } } } } //如果是进行搜索 else if(this.createType == 2) { //先清空搜索节点的数据 this.treeView1.Nodes[3].Nodes.Clear(); //搜索 if (!string.IsNullOrEmpty(name)) { List infos = mic_project_info_BLL.FindAllByKey(name); if (infos!=null && infos.Count>0) { int[] arr = infos.Select(a => a.project_id).ToArray(); List mic_Projects = mic_project_BLL.FindAllByIds(arr); if (mic_Projects!=null && mic_Projects.Count>0) { foreach (mic_project mic_Project in mic_Projects) { this.anime4.Nodes.Add(this.AddProjectTreeNode(2, 4, mic_Project.project_path, mic_Project)); } } } else { MessageBox.Show("没有搜索结果"); } } if(this.treeView1.Nodes[3].Nodes.Count>0) { this.treeView1.Nodes[3].Expand(); } } this.createNameDialog.Close(); } /// /// 新建项目的结果函数 /// public override void CreateProjectName(AnalyzeSettingModel model, int id) { if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType > 1) { //文件夹内可以建项目,项目内不能建项目 if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 1 || ((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3) { string parentPath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag; if (!System.IO.Directory.Exists(parentPath)) { System.IO.Directory.CreateDirectory(parentPath); } string newPath = parentPath + "\\" + model.itemNumber; if (!System.IO.Directory.Exists(newPath)) { //创建文件夹 System.IO.Directory.CreateDirectory(newPath); //获取数据 mic_project project = mic_project_BLL.FindDefault(id); project.project_path = newPath; mic_project_BLL.Update(project); this.treeView1.SelectedNode.Nodes.Add(this.AddProjectTreeNode(2, ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType, newPath, project)); } else { MessageBox.Show("已经存在同名项目"); } } } if (createProjectDialog != null && !createProjectDialog.IsDisposed) createProjectDialog.Close(); } /// /// 搜索 /// /// /// private void button3_click(object sender, EventArgs e) { this.createType = 2; this.createNameDialog = new CreateNameDialog(this); this.createNameDialog.Text = PdnResources.GetString("Menu.Itemsearch.Text"); this.createNameDialog.StartPosition = FormStartPosition.CenterScreen; this.createNameDialog.ShowDialog(); } /// /// 刷新 /// /// /// private void button4_click(object sender, EventArgs e) { this.InitializeTreeViewDetailData(); } /// /// 删除 /// /// /// private void button5_click(object sender, EventArgs e) { if (this.treeView1.SelectedNode == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectnode.Text")); return; } if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1) { if (MessageBox.Show(PdnResources.GetString("Menu.Areyousurethecurrentfolder.Text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes) { //删除文件夹及其内部的文件 FileOperationHelper.DeleteFolder(((NodeInfo)this.treeView1.SelectedNode.Tag).tag); //移除node this.treeView1.SelectedNode.Remove(); } } else if(((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 2 || ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 3) { if (this.treeView1.SelectedNode.Parent == null) { MessageBox.Show(PdnResources.GetString("Menu.easeselectanothernodeTherootno.Text")); } else { if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType == 3) { MessageBox.Show(PdnResources.GetString("Menu.eselectnothernodeStandardnodecannotbedele.Text")); } else { if (MessageBox.Show(PdnResources.GetString("Menu.Areyousurethecurrentfolder.Text")+"?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes) { NodeInfo info = ((NodeInfo)this.treeView1.SelectedNode.Tag); //删除数据库 this.RecursionDelDbData(info.id); //删除文件夹及其内部的文件 FileOperationHelper.DeleteFolder(info.tag); //移除node this.treeView1.SelectedNode.Remove(); } } } } else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 4) { MessageBox.Show(PdnResources.GetString("Menu.Searchandsearchresutsnodescannotbedeleted.Text")); } } /// /// 递归删除数据库内容 /// /// private void RecursionDelDbData(int id) { mic_project project = mic_project_BLL.FindDefault(id); mic_project_info project_info = mic_project_info_BLL.FindByProjectCode(project.project_name); if (project_info != null) { List items = mic_project_info_item_BLL.FindAllByInfoId(project_info.id); foreach (mic_project_info_item item in items) { mic_project_info_item_BLL.Del(item.id); } mic_project_info_BLL.Del(project_info.id); } mic_project_BLL.Del(project.id); List projects = mic_project_BLL.FindAllByParentId(id); if (projects!=null && projects.Count>0) { foreach (mic_project p in projects) { this.RecursionDelDbData(p.id); } } } /// /// 全屏 /// /// /// private void button6_click(object sender, EventArgs e) { if(this.WindowState == FormWindowState.Maximized) { this.WindowState = FormWindowState.Normal; } else { this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); this.WindowState = FormWindowState.Maximized; } } /// /// 列表模式 /// /// /// private void button7_click(object sender, EventArgs e) { this.listView1.View = View.Details; } /// /// /// /// /// private void button8_click(object sender, EventArgs e) { this.listView1.View = View.LargeIcon; } /// /// 左侧节点点击事件,需要刷新右侧listview内容 /// /// /// private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { this.listView1.Items.Clear(); this.imageList1.Images.Clear(); //如果是常规操作,则不允许建立项目,不允许删除,从文件夹读取内容 if (e.Node.Index==0 && e.Node.Parent==null) { this.button1.Enabled = true; this.button2.Enabled = false; this.button5.Enabled = false; this.showFileList(e.Node.Tag); } //如果是抖索结果,则什么都不允许操作 else if (e.Node.Index == 3 && e.Node.Parent == null) { this.button1.Enabled = false; this.button2.Enabled = false; this.button5.Enabled = false; } //如果是常规操作下的文件夹,从文件夹读取内容 else if(((NodeInfo)e.Node.Tag).rootType == 1) { this.button1.Enabled = true; this.button2.Enabled = false; this.button5.Enabled = true; this.showFileList(e.Node.Tag); } else { //如果是通用分析和专用分析根节点,就什么都不干 if (e.Node.Parent==null) { this.button1.Enabled = false; this.button2.Enabled = false; this.button5.Enabled = false; } //如果是通用分析或专用下内置的标准,则不读取内容 else if (((NodeInfo)e.Node.Tag).folderType == 3) { this.button1.Enabled = true; this.button2.Enabled = true; this.button5.Enabled = false; } //如果是通用分析或专用下的文件夹,则从文件夹读取内容 else if (((NodeInfo)e.Node.Tag).folderType == 1) { this.button1.Enabled = true; this.button2.Enabled = true; this.button5.Enabled = true; this.showFileList(e.Node.Tag); } //如果是通用分析或专用下的项目,则从文件夹读取内容 else if (((NodeInfo)e.Node.Tag).folderType == 2) { this.button1.Enabled = false; this.button2.Enabled = false; this.button5.Enabled = true; this.showFileList(e.Node.Tag); this.showProjectDetail(e.Node.Tag); } //如果是常规操作下,则从文件夹里面读 else { this.button1.Enabled = true; this.button2.Enabled = false; this.button5.Enabled = true; this.showFileList(e.Node.Tag); } } } /// /// 读取文件夹的内容,展示在右侧listview中 /// /// private void showFileList(Object info) { NodeInfo nodeInfo = (NodeInfo)info; string path = nodeInfo.tag; if (path!=null && !path.Equals("")) { if (!System.IO.Directory.Exists(path)) { MessageBox.Show(PdnResources.GetString("Menu.Thefolderdoesnotexistorwasremo.Text")); return; } /*if (nodeInfo.folderType == 3) { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } }*/ DirectoryInfo TheFolder = new DirectoryInfo(path); int j = 0; foreach (FileInfo NextFile in TheFolder.GetFiles()) { /*if (NextFile.Extension.Equals(".doc") || NextFile.Extension.Equals(".docx")) { this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeWordA.png").Reference); } else if (NextFile.Extension.Equals(".xls") || NextFile.Extension.Equals(".xlsx")) { this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeExcelA.png").Reference); } else { this.imageList1.Images.Add("img" + j, PdnResources.GetImageResource("Icons.TypeOtherA.png").Reference); }*/ ShellFile shellFile = ShellFile.FromFilePath(NextFile.FullName); this.imageList1.Images.Add("img" + j, shellFile.Thumbnail.SmallBitmap); this.listView1.Items.Add(NextFile.Name, j); this.listView1.Items[j].ImageIndex = j; this.listView1.Items[j].SubItems.Add(FileOperationHelper.ReadFileOwner(NextFile.FullName)); this.listView1.Items[j].SubItems.Add(NextFile.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")); j++; } } } /// /// 从数据库获取项目详细信息 /// /// private void showProjectDetail(Object info) { int id = ((NodeInfo)info).id; mic_project project = mic_project_BLL.FindDefault(id); mic_project_info project_info = mic_project_info_BLL.FindByProjectCodeAndProjectId(project.project_name, project.id); this.ClearLabelAndDataGridView(); if (project_info!=null) { this.label7.Text = project_info.project_code; this.label8.Text = project_info.project_rating.ToString(); this.label9.Text = project_info.project_sender; this.label11.Text = project_info.project_contact; this.label10.Text = project_info.project_company; this.label12.Text = project_info.project_date.ToString(); List items = mic_project_info_item_BLL.FindAllByInfoId(project_info.id); if (items!=null && items.Count>0) { foreach (mic_project_info_item item in items) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(CreateTextBoxCell(item.item_key, "name")); row.Cells.Add(CreateTextBoxCell(item.item_value, "content")); this.dataGridView1.Rows.Add(row); } this.dataGridView1.ClearSelection(); } } } /// /// 添加内容单元格 /// /// /// /// private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag) { DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell(); textboxcell.Value = text; textboxcell.Tag = tag; return textboxcell; } /// /// 初始化表头 /// private void InitGridHeader() { this.dataGridView1.ColumnHeadersHeight = 25; DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn(); h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h1.Width = 200; DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn(); h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h2.Width = 200; this.dataGridView1.Columns.Add(h1); this.dataGridView1.Columns.Add(h2); DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1); helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.name.text"))); helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.content.text"))); this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[0].ReadOnly = true; this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[1].ReadOnly = true; this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.AllowUserToResizeColumns = false; } /// /// listview1的双击事件,如果在item上,则尝试打开文件 /// /// /// private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { try { ListViewHitTestInfo info = this.listView1.HitTest(e.X, e.Y); if (info.Item != null) { string path = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag; if (info.Item.Text.IndexOf("jpg") > 0 || info.Item.Text.IndexOf("png") > 0 || info.Item.Text.IndexOf("BMP") > 0) { //Image img = new Bitmap(path + "\\" + info.Item.Text); //Document document = Document.FromImage(img); OpenCvSharp.Mat imageMat = new OpenCvSharp.Mat(path + "\\" + info.Item.Text); Document document = Document.FromImageMat(imageMat); DocumentWorkspace documentWorkspace = this.appWorkspace.AddNewDocumentWorkspace(); documentWorkspace.fileText = info.Item.Text; documentWorkspace.Document = document; //判断是否存在xml,进行读取 PicConfigModel configModel = null; string fileName = path + "\\" + info.Item.Text; string xmlPath = path + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".xml"; //如果xml存在 if (System.IO.File.Exists(xmlPath)) { configModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(xmlPath, FileMode.Open)); documentWorkspace.RuleAttribute(configModel); if (configModel != null) { this.appWorkspace.RestoreLabelAndMeasure(configModel, documentWorkspace); } } //如果不存在,则判断 //(1)是否自动添加ZEN标尺 //(2)是否自动添加AxioVision标尺 else { documentWorkspace.xmlSaveModel = Startup.instance.ruleDB; documentWorkspace.InitRulerInfo(); } this.appWorkspace.ActiveDocumentWorkspace = documentWorkspace; } else if (info.Item.Text.IndexOf(".xlsx") > 0 || info.Item.Text.IndexOf(".docx") > 0 || info.Item.Text.IndexOf(".xls") > 0 || info.Item.Text.IndexOf(".doc") > 0) { if (!OfficeFileHandleHelper.OpenOfficeFile(path + "\\" + info.Item.Text)) MessageBox.Show(PdnResources.GetString("Menu.Fileopenfailed.Text")); } //MessageBox.Show(info.Item.Text); } } catch(Exception) { } } /// /// 将要展开节点时的事件 /// /// /// private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { //如果不是顶级节点 if(e.Node.Parent != null) { if(e.Node.Nodes.Count==1) { if(((NodeInfo)e.Node.Tag).rootType == 1) { List dirs = new List(Directory.GetDirectories(((NodeInfo)e.Node.Tag).tag, "*", System.IO.SearchOption.TopDirectoryOnly)); foreach (var dir in dirs) { try { NodeInfo nodeInfo = new NodeInfo(); nodeInfo.rootType = ((NodeInfo)e.Node.Tag).rootType; nodeInfo.folderType = 1; nodeInfo.tag = dir; TreeNode node = new TreeNode(); node.Text = Path.GetFileName(dir); node.Tag = nodeInfo; if (Directory.GetDirectories(dir).Length > 0) { TreeNode temp = new TreeNode(); temp.Text = ""; node.Nodes.Add(temp); } e.Node.Nodes.Add(node); } catch (Exception) { } } } else if (((NodeInfo)e.Node.Tag).rootType == 2 || ((NodeInfo)e.Node.Tag).rootType == 3) { //从数据库读取下级 List list = mic_project_BLL.FindAllByParentId(((NodeInfo)e.Node.Tag).id); if(list!=null && list.Count>0) { foreach (mic_project p in list) { int folderType = (p.project_type == 4)? 2 : 1; e.Node.Nodes.Add(this.AddProjectTreeNode(folderType, ((NodeInfo)e.Node.Tag).rootType, p.project_path, p)); } } } e.Node.Nodes.RemoveAt(0); } } } /// /// 绘制节点事件 /// /// /// private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e) { if ((e.State & TreeNodeStates.Selected) != 0) { //绿底白字 e.Graphics.FillRectangle(Brushes.Green, e.Node.Bounds); Font nodeFont = e.Node.NodeFont; if (nodeFont == null) nodeFont = ((TreeView)sender).Font; e.Graphics.DrawString(e.Node.Text, nodeFont, Brushes.White, Rectangle.Inflate(e.Bounds, 2, 0)); } else { e.DrawDefault = true; } if ((e.State & TreeNodeStates.Focused) != 0) { using (Pen focusPen = new Pen(Color.Black)) { focusPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; Rectangle focusBounds = e.Node.Bounds; focusBounds.Size = new System.Drawing.Size(focusBounds.Width - 1, focusBounds.Height - 1); e.Graphics.DrawRectangle(focusPen, focusBounds); } } } /// /// 添加到工程 /// public void AddToProject() { if(((NodeInfo)this.treeView1.SelectedNode.Tag).tag==null || ((NodeInfo)this.treeView1.SelectedNode.Tag).tag.Equals("")) { MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text") + PdnResources.GetString("Menu.Set.Generalsettings.Thearchivefilesavesthepath.text")); return; } //如果选择的节点是常规操作,选择什么路径就存储到什么路径 if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 1) { this.saveBitmapToFolder(); //刷新节点 this.listView1.Items.Clear(); this.imageList1.Images.Clear(); this.showFileList(this.treeView1.SelectedNode.Tag); } //如果选择的节点是通用分析、专用分析 else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 2 || ((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 3) { if (this.treeView1.SelectedNode.Parent==null) { MessageBox.Show(PdnResources.GetString("Menu.selewhichcannotbetoredintheroot.Text")); } else { if (((NodeInfo)this.treeView1.SelectedNode.Tag).folderType==3) { MessageBox.Show(PdnResources.GetString("Menu.selectanothernodewhtbestoredinhestan.Text")); } else { this.saveBitmapToFolder(); //刷新节点 this.listView1.Items.Clear(); this.imageList1.Images.Clear(); this.showFileList(this.treeView1.SelectedNode.Tag); } } } //如果选择的节点是搜索结果,则提示用户,不能添加到这里 else if (((NodeInfo)this.treeView1.SelectedNode.Tag).rootType == 4) { MessageBox.Show(PdnResources.GetString("Menu.dwhichcannotbestoredinthesearchresu.Text")); } } private void saveBitmapToFolder() { if (this.appWorkspace.ActiveDocumentWorkspace == null) return; using (Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap()) { //获取文件后缀名 string extension = Path.GetExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName()); //获取不带后缀的文件名 string noExtension = Path.GetFileNameWithoutExtension(this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName()); using (Bitmap dstBitmap = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), bitmap.PixelFormat)) { //保存图片 ImageCodecInfo icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Jpeg); if (extension.Equals(".jpg")) { icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Jpeg); } else if (extension.Equals(".bmp")) { icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Bmp); } else if (extension.Equals(".tiff")) { icf = FileOperationHelper.GetImageCodecInfo(ImageFormat.Tiff); } EncoderParameters parms = new EncoderParameters(1); EncoderParameter parm = new EncoderParameter(Encoder.Quality, 100L); parms.Param[0] = parm; dstBitmap.Save(((NodeInfo)this.treeView1.SelectedNode.Tag).tag +"\\"+ this.appWorkspace.ActiveDocumentWorkspace.GetFriendlyName(), icf, parms); //组织配置文件的数据 PicConfigModel picConfigModel = new PicConfigModel(); picConfigModel.rule = new PicConfigModel.Rule(); if (this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel != null && this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length != 0) { picConfigModel.rule.ruler_name = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_name; picConfigModel.rule.gain_multiple = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.gain_multiple; picConfigModel.rule.pixel_length = (int)this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.pixel_length; picConfigModel.rule.physical_length = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.physical_length; picConfigModel.rule.ruler_units = this.appWorkspace.ActiveDocumentWorkspace.xmlSaveModel.ruler_units; } //按路径和名称保存xml文件 string userInfoXml = XmlSerializeHelper.XmlSerialize(picConfigModel); //xml保存路径 string filePath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + noExtension + ".xml"; //保存xml FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create); } } } /// /// 添加文件夹类型的node节点 /// /// /// /// private TreeNode AddFolderTreeNode(int rootType, string dir, int id) { NodeInfo info = new NodeInfo(); info.rootType = rootType; info.folderType = 1; info.tag = dir; info.id = id; TreeNode node = new TreeNode(); node.Text = Path.GetFileName(dir); node.Tag = info; if (Directory.GetDirectories(dir).Length > 0) { TreeNode temp = new TreeNode(); temp.Text = ""; node.Nodes.Add(temp); } return node; } private void ProjectEngineering_FormClosing(object sender, FormClosingEventArgs e) { this.appWorkspace.toolBar.RefreshBtnSelect(false, "OpenProject"); this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "OpenProject"); } /// /// 添加项目类型的node节点 /// /// /// /// private TreeNode AddProjectTreeNode(int folderType, int rootType, string path, mic_project mic_Project) { NodeInfo info = new NodeInfo(); info.rootType = rootType; info.folderType = folderType; info.tag = path; info.id = mic_Project.id; TreeNode node = new TreeNode(); if (mic_Project.project_path == null) { node.Text = PdnResources.GetString(mic_Project.project_name); } else { node.Text = mic_Project.project_name; } node.Tag = info; if (folderType==3 && !System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path); //这里应该判断是否再数据库中有下级 if(mic_project_BLL.FindCountByParentId(mic_Project.id)>0) //if (Directory.GetDirectories(path).Length > 0) { TreeNode temp = new TreeNode(); temp.Text = ""; node.Nodes.Add(temp); } return node; } /// /// 获取存储路径 /// /// 1通用分析 2专用分析 /// 分析的名称 /// public NodeItem GetProjectPath(int type, string analysis, string originPath) { // TODO ZYH 这里数据库内应该存储多语言的key,创建的文件夹也应该是相应位置 //获取数据库信息 string languagePath = PdnResources.GetString(analysis); if (string.IsNullOrEmpty(languagePath)) return null; mic_project mic_Project = mic_project_BLL.FindItenByNameAndPath(Path.GetFileName(originPath), originPath); if (mic_Project == null) { MessageBox.Show("项目目录不存在,请检查!"); return null; } //创建一个编号 int num = Startup.instance.configModel.ProjectCodeNum; int addNum = 1000000 + num; string code = "P" + addNum; //获取路径 //string parentPath = ""; //if (type == 1) parentPath = GeneralAnalysisPath; //if (type == 2) parentPath = DedicatedAnalysisPath; //创建相应文件夹 //string path = parentPath + "\\" + PdnResources.GetString(analysis) + "\\" + code; string path = originPath + "\\" + code; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } //更新配置文件编号+1 Startup.instance.configModel.ProjectCodeNum += 1; string configXml = XmlSerializeHelper.XmlSerialize(Startup.instance.configModel); string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\Config.xml"; FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create); NodeItem info = new NodeItem(); info.path = path; info.code = code; info.parentId = mic_Project.id; return info; } /// /// 通用专用分析,插入到数据库,添加节点 /// /// 分析的model /// 项目编号 public void InsertIntoDB(AnalyzeSettingModel analyzeSettingModel, NodeItem item) { //添加目录主表 mic_project mic_Project = new mic_project(); mic_Project.parent_id = item.parentId; mic_Project.project_name = item.code; mic_Project.project_path = item.path; mic_Project.project_type = 4; mic_project_BLL.Add(mic_Project); //添加项目主表 mic_project_info mic_Project_Info = new mic_project_info(); mic_Project_Info.project_code = item.code; mic_Project_Info.project_company = analyzeSettingModel.inspectionDepartment; mic_Project_Info.project_contact = analyzeSettingModel.contact; mic_Project_Info.project_date = analyzeSettingModel.inspectionDate; mic_Project_Info.project_id = mic_Project.id; mic_Project_Info.project_rating = analyzeSettingModel.ratingDate; mic_Project_Info.project_sender = analyzeSettingModel.inspectionPerson; mic_project_info_BLL.Add(mic_Project_Info); //添加项目子表 if (analyzeSettingModel.otherList!=null && analyzeSettingModel.otherList.Count>0) { foreach (OthersInfo othersInfo in analyzeSettingModel.otherList) { mic_project_info_item s = new mic_project_info_item(); s.info_id = mic_Project_Info.id; s.item_key = othersInfo.name; s.item_value = othersInfo.content; mic_project_info_item_BLL.Add(s); } } } } }