1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765 |
- 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
- {
- /// <summary>
- /// 项目工程
- /// </summary>
- 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
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 常规操作路径
- /// </summary>
- private string NormalOperationPath = Startup.instance.configModel.NormalOperation;
- /// <summary>
- /// 通用分析路径
- /// </summary>
- private string GeneralAnalysisPath = Startup.instance.configModel.GeneralAnalysis;
- /// <summary>
- /// 专用分析路径
- /// </summary>
- private string DedicatedAnalysisPath = Startup.instance.configModel.DedicatedAnalysis;
- /// <summary>
- /// 三个根节点
- /// </summary>
- private TreeNode anime1, anime2, anime3, anime4;
- /// <summary>
- /// 新建文件夹窗口
- /// </summary>
- private CreateNameDialog createNameDialog;
- /// <summary>
- /// 新建项目窗口
- /// </summary>
- private CreateProjectDialog createProjectDialog;
- /// <summary>
- /// 1新建文件夹 2搜索
- /// </summary>
- private int createType = 1;
- /// <summary>
- /// 节点信息类,用于判断节点类型
- /// </summary>
- private class NodeInfo
- {
- /// <summary>
- /// 根节点类型 1常规 2通用 3专用 4搜索
- /// </summary>
- public int rootType;
- /// <summary>
- /// 文件夹类型 1文件夹 2项目 3内置不允许删除
- /// </summary>
- public int folderType;
- /// <summary>
- /// tag,用于拼接好的存储路径等
- /// </summary>
- public string tag;
- /// <summary>
- /// 数据库的主键(通用、专用及其下的内容)
- /// </summary>
- public int id;
- }
- public class NodeItem
- {
- /// <summary>
- /// 父级id
- /// </summary>
- public int parentId;
- /// <summary>
- /// 完整路径
- /// </summary>
- public string path;
- /// <summary>
- /// 项目编号
- /// </summary>
- 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();
- }
- /// <summary>
- /// 初始化右侧表头
- /// </summary>
- 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;
- }
- /// <summary>
- /// 初始化项目工程树形菜单
- /// </summary>
- 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);
- }
- /// <summary>
- /// 初始化项目工程详细菜单
- /// </summary>
- 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);
- }
- }
- }
- /// <summary>
- /// 常规操作
- /// </summary>
- /// <param name="anime1"></param>
- private void InitializeTreeViewDetailDataThree(TreeNode treeNode)
- {
- List<string> dirs = new List<string>(Directory.GetDirectories(NormalOperationPath, "*", System.IO.SearchOption.TopDirectoryOnly));
- foreach (var dir in dirs)
- {
- try
- {
- this.anime1.Nodes.Add(this.AddFolderTreeNode(1, dir, 0));
- }
- catch (Exception)
- {
- }
- }
- }
- /// <summary>
- /// 通用分析
- /// </summary>
- private void InitializeGeneralAnalysisTreeViewDetailData(TreeNode treeNode)
- {
- List<mic_project> 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));
- }
-
- }
- }
- }
- /// <summary>
- /// 专用分析
- /// </summary>
- private void InitializeDedicatedAnalysisPathTreeViewDetailData(TreeNode treeNode)
- {
- List<mic_project> 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;
- }
- }
- /// <summary>
- /// 初始化提示信息及按钮事件
- /// </summary>
- 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;
- }
- /// <summary>
- /// 新建文件夹
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 新建项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 新建文件夹的结果函数
- /// </summary>
- /// <param name="name"></param>
- 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<mic_project_info> infos = mic_project_info_BLL.FindAllByKey(name);
- if (infos!=null && infos.Count>0)
- {
- int[] arr = infos.Select(a => a.project_id).ToArray();
- List<mic_project> 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();
- }
- /// <summary>
- /// 新建项目的结果函数
- /// </summary>
- 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();
- }
- /// <summary>
- /// 搜索
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 刷新
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_click(object sender, EventArgs e)
- {
- this.InitializeTreeViewDetailData();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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"));
- }
- }
- /// <summary>
- /// 递归删除数据库内容
- /// </summary>
- /// <param name="id"></param>
- 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<mic_project_info_item> 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<mic_project> projects = mic_project_BLL.FindAllByParentId(id);
- if (projects!=null && projects.Count>0)
- {
- foreach (mic_project p in projects)
- {
- this.RecursionDelDbData(p.id);
- }
- }
- }
- /// <summary>
- /// 全屏
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 列表模式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_click(object sender, EventArgs e)
- {
- this.listView1.View = View.Details;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button8_click(object sender, EventArgs e)
- {
- this.listView1.View = View.LargeIcon;
- }
- /// <summary>
- /// 左侧节点点击事件,需要刷新右侧listview内容
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- }
- /// <summary>
- /// 读取文件夹的内容,展示在右侧listview中
- /// </summary>
- /// <param name="info"></param>
- 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++;
- }
- }
- }
- /// <summary>
- /// 从数据库获取项目详细信息
- /// </summary>
- /// <param name="info"></param>
- 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<mic_project_info_item> 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();
- }
- }
- }
- /// <summary>
- /// 添加内容单元格
- /// </summary>
- /// <param name="text"></param>
- /// <param name="tag"></param>
- /// <returns></returns>
- private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
- {
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = text;
- textboxcell.Tag = tag;
- return textboxcell;
- }
- /// <summary>
- /// 初始化表头
- /// </summary>
- 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;
- }
- /// <summary>
- /// listview1的双击事件,如果在item上,则尝试打开文件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<PicConfigModel>(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)
- {
- }
- }
- /// <summary>
- /// 将要展开节点时的事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<string> dirs = new List<string>(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<mic_project> 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);
- }
- }
- }
- /// <summary>
- /// 绘制节点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- }
- /// <summary>
- /// 添加到工程
- /// </summary>
- 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>(picConfigModel);
- //xml保存路径
- string filePath = ((NodeInfo)this.treeView1.SelectedNode.Tag).tag + "\\" + noExtension + ".xml";
- //保存xml
- FileOperationHelper.WriteStringToFile(userInfoXml, filePath, FileMode.Create);
- }
- }
- }
- /// <summary>
- /// 添加文件夹类型的node节点
- /// </summary>
- /// <param name="rootType"></param>
- /// <param name="dir"></param>
- /// <returns></returns>
- 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");
- }
- /// <summary>
- /// 添加项目类型的node节点
- /// </summary>
- /// <param name="rootType"></param>
- /// <param name="dir"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 获取存储路径
- /// </summary>
- /// <param name="type">1通用分析 2专用分析</param>
- /// <param name="analysis">分析的名称</param>
- /// <returns></returns>
- 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<ConfigModel>(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;
- }
- /// <summary>
- /// 通用专用分析,插入到数据库,添加节点
- /// </summary>
- /// <param name="analyzeSettingModel">分析的model</param>
- /// <param name="folder">项目编号</param>
- 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);
- }
- }
- }
- }
- }
|