123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using OpenCvSharp;
- using OpenCvSharp.Extensions;
- using PaintDotNet.Annotation;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.Data.Param;
- using PaintDotNet.GeneralAnalysis.Artwork;
- using PaintDotNet.Processing;
- using static PaintDotNet.GeneralAnalysis.Artwork.ImageTools;
- namespace PaintDotNet.GeneralAnalysis
- {
- internal class ArtworkSettingEditDialog : PdnBaseForm
- {
- #region
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
- #region Windows Form Designer generated code
- private void InitializeLanguageText()
- {
- this.Text = PdnResources.GetString("Menu.Setting.Text");
- this.label5.Text = PdnResources.GetString("Menu.Thecoordinateofthecenterpoin.Text") + ":";
- this.label4.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Xcoordinateofcenterpoint.text") + ":";
- this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Position.text") + "2";
- this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
- this.label8.Text = PdnResources.GetString("Menu.Thecoordinateofthecenterpoin.Text") + ":";
- this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Xcoordinateofcenterpoint.text") + ":";
- this.groupBox6.Text = PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text");
- this.chkScrapIsDel.Text = PdnResources.GetString("Menu.Clasticdelete.text") + ":";
- this.label12.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
- this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Extractionrange.text") + ":";
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.btnSave.Text = PdnResources.GetString("Menu.imagecapture.timelapse.SaveSettings.text");
- this.btnFromDisk.Text = PdnResources.GetString("Menu.harddisk.text");
- this.btnFromGallery.Text = PdnResources.GetString("Menu.Gallery.text");
- this.label1.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Processdrawingname.text") + ":";
- this.groupBox2.Text = PdnResources.GetString("Menu.Previewpicture.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Definetheshape.text");
- this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Sidelength.text") + ":";
- this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Position.text") + "1";
- this.label6.Text = PdnResources.GetString("Menu.color.text") + ":";
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.btnSave = new System.Windows.Forms.Button();
- this.btnFromDisk = new System.Windows.Forms.Button();
- this.btnFromGallery = new System.Windows.Forms.Button();
- this.txtName = new System.Windows.Forms.TextBox();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.pnlTools = new System.Windows.Forms.Panel();
- this.panel4 = new System.Windows.Forms.Panel();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.nudLineWidth = new System.Windows.Forms.NumericUpDown();
- this.nudSide = new System.Windows.Forms.NumericUpDown();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.nudPoint1Y = new System.Windows.Forms.NumericUpDown();
- this.nudPoint1X = new System.Windows.Forms.NumericUpDown();
- this.panel1 = new System.Windows.Forms.Panel();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.nudPoint2Y = new System.Windows.Forms.NumericUpDown();
- this.nudPoint2X = new System.Windows.Forms.NumericUpDown();
- this.panel2 = new System.Windows.Forms.Panel();
- this.label7 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.panel3 = new System.Windows.Forms.Panel();
- this.label13 = new System.Windows.Forms.Label();
- this.nudScrapMax = new System.Windows.Forms.NumericUpDown();
- this.nudScrapMin = new System.Windows.Forms.NumericUpDown();
- this.chkScrapIsDel = new System.Windows.Forms.CheckBox();
- this.label12 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.nudTowValueMax = new System.Windows.Forms.NumericUpDown();
- this.nudTowValueMin = new System.Windows.Forms.NumericUpDown();
- this.label10 = new System.Windows.Forms.Label();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudLineWidth)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudSide)).BeginInit();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint1Y)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint1X)).BeginInit();
- this.groupBox5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint2Y)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint2X)).BeginInit();
- this.groupBox6.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudScrapMax)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudScrapMin)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMax)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMin)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.btnSave);
- this.groupBox1.Controls.Add(this.btnFromDisk);
- this.groupBox1.Controls.Add(this.btnFromGallery);
- this.groupBox1.Controls.Add(this.txtName);
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1018, 90);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // btnSave
- //
- this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnSave.Location = new System.Drawing.Point(900, 33);
- this.btnSave.Name = "btnSave";
- this.btnSave.Size = new System.Drawing.Size(91, 31);
- this.btnSave.TabIndex = 4;
- this.btnSave.Text = "保存设置";
- this.btnSave.UseVisualStyleBackColor = true;
- this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
- //
- // btnFromDisk
- //
- this.btnFromDisk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnFromDisk.Location = new System.Drawing.Point(794, 33);
- this.btnFromDisk.Name = "btnFromDisk";
- this.btnFromDisk.Size = new System.Drawing.Size(75, 31);
- this.btnFromDisk.TabIndex = 3;
- this.btnFromDisk.Text = "硬盘";
- this.btnFromDisk.UseVisualStyleBackColor = true;
- this.btnFromDisk.Click += new System.EventHandler(this.btnFromDisk_Click);
- //
- // btnFromGallery
- //
- this.btnFromGallery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnFromGallery.Location = new System.Drawing.Point(688, 33);
- this.btnFromGallery.Name = "btnFromGallery";
- this.btnFromGallery.Size = new System.Drawing.Size(75, 31);
- this.btnFromGallery.TabIndex = 2;
- this.btnFromGallery.Text = "图库";
- this.btnFromGallery.UseVisualStyleBackColor = true;
- this.btnFromGallery.Click += new System.EventHandler(this.btnFromGallery_Click);
- //
- // txtName
- //
- this.txtName.Location = new System.Drawing.Point(141, 37);
- this.txtName.Name = "txtName";
- this.txtName.Size = new System.Drawing.Size(218, 21);
- this.txtName.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(38, 44);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(77, 12);
- this.label1.TabIndex = 0;
- this.label1.Text = "工艺图名称:";
- //
- // groupBox2
- //
- this.groupBox2.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.groupBox2.Controls.Add(this.pnlTools);
- this.groupBox2.Controls.Add(this.panel4);
- this.groupBox2.Location = new System.Drawing.Point(12, 119);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(1018, 502);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "图片预览";
- //
- // pnlTools
- //
- this.pnlTools.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
- this.pnlTools.BackColor = System.Drawing.SystemColors.Control;
- this.pnlTools.Location = new System.Drawing.Point(433, 460);
- this.pnlTools.Name = "pnlTools";
- this.pnlTools.Size = new System.Drawing.Size(169, 36);
- this.pnlTools.TabIndex = 1;
- //
- // panel4
- //
- this.panel4.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.panel4.Location = new System.Drawing.Point(17, 24);
- this.panel4.Name = "panel4";
- this.panel4.Size = new System.Drawing.Size(984, 430);
- this.panel4.TabIndex = 0;
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox3.Controls.Add(this.nudLineWidth);
- this.groupBox3.Controls.Add(this.nudSide);
- this.groupBox3.Controls.Add(this.label3);
- this.groupBox3.Controls.Add(this.label2);
- this.groupBox3.Location = new System.Drawing.Point(12, 636);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(191, 137);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "定义外形";
- //
- // nudLineWidth
- //
- this.nudLineWidth.Location = new System.Drawing.Point(76, 61);
- this.nudLineWidth.Maximum = new decimal(new int[] {
- 20,
- 0,
- 0,
- 0});
- this.nudLineWidth.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.nudLineWidth.Name = "nudLineWidth";
- this.nudLineWidth.Size = new System.Drawing.Size(74, 21);
- this.nudLineWidth.TabIndex = 5;
- this.nudLineWidth.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.nudLineWidth.ValueChanged += new System.EventHandler(this.nudLineWidth_ValueChanged);
- this.nudLineWidth.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudLineWidth_KeyUp);
- //
- // nudSide
- //
- this.nudSide.Location = new System.Drawing.Point(76, 28);
- this.nudSide.Minimum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.nudSide.Name = "nudSide";
- this.nudSide.Size = new System.Drawing.Size(74, 21);
- this.nudSide.TabIndex = 3;
- this.nudSide.Value = new decimal(new int[] {
- 20,
- 0,
- 0,
- 0});
- this.nudSide.ValueChanged += new System.EventHandler(this.nudSide_ValueChanged);
- this.nudSide.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudSide_KeyUp);
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(18, 66);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(41, 12);
- this.label3.TabIndex = 4;
- this.label3.Text = "线宽:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(18, 30);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(41, 12);
- this.label2.TabIndex = 3;
- this.label2.Text = "边长:";
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox4.Controls.Add(this.nudPoint1Y);
- this.groupBox4.Controls.Add(this.nudPoint1X);
- this.groupBox4.Controls.Add(this.panel1);
- this.groupBox4.Controls.Add(this.label6);
- this.groupBox4.Controls.Add(this.label5);
- this.groupBox4.Controls.Add(this.label4);
- this.groupBox4.Location = new System.Drawing.Point(220, 636);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(216, 137);
- this.groupBox4.TabIndex = 3;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "定位1";
- //
- // nudPoint1Y
- //
- this.nudPoint1Y.Location = new System.Drawing.Point(123, 59);
- this.nudPoint1Y.Maximum = new decimal(new int[] {
- 99999999,
- 0,
- 0,
- 0});
- this.nudPoint1Y.Name = "nudPoint1Y";
- this.nudPoint1Y.Size = new System.Drawing.Size(78, 21);
- this.nudPoint1Y.TabIndex = 11;
- this.nudPoint1Y.ValueChanged += new System.EventHandler(this.nudPoint1Y_ValueChanged);
- this.nudPoint1Y.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint1Y_KeyUp);
- //
- // nudPoint1X
- //
- this.nudPoint1X.Location = new System.Drawing.Point(123, 24);
- this.nudPoint1X.Maximum = new decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.nudPoint1X.Name = "nudPoint1X";
- this.nudPoint1X.Size = new System.Drawing.Size(78, 21);
- this.nudPoint1X.TabIndex = 10;
- this.nudPoint1X.ValueChanged += new System.EventHandler(this.nudPoint1X_ValueChanged);
- this.nudPoint1X.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint1X_KeyUp);
- //
- // panel1
- //
- this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel1.Location = new System.Drawing.Point(82, 95);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(105, 26);
- this.panel1.TabIndex = 9;
- this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged);
- this.panel1.Click += new System.EventHandler(this.panel1_Click);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(22, 99);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(41, 12);
- this.label6.TabIndex = 8;
- this.label6.Text = "颜色:";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(22, 64);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(83, 12);
- this.label5.TabIndex = 6;
- this.label5.Text = "中心点Y坐标:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(22, 29);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(83, 12);
- this.label4.TabIndex = 4;
- this.label4.Text = "中心点X坐标:";
- //
- // groupBox5
- //
- this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox5.Controls.Add(this.nudPoint2Y);
- this.groupBox5.Controls.Add(this.nudPoint2X);
- this.groupBox5.Controls.Add(this.panel2);
- this.groupBox5.Controls.Add(this.label7);
- this.groupBox5.Controls.Add(this.label8);
- this.groupBox5.Controls.Add(this.label9);
- this.groupBox5.Location = new System.Drawing.Point(458, 636);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(216, 137);
- this.groupBox5.TabIndex = 4;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "定位2";
- //
- // nudPoint2Y
- //
- this.nudPoint2Y.Location = new System.Drawing.Point(132, 57);
- this.nudPoint2Y.Maximum = new decimal(new int[] {
- 99999999,
- 0,
- 0,
- 0});
- this.nudPoint2Y.Name = "nudPoint2Y";
- this.nudPoint2Y.Size = new System.Drawing.Size(78, 21);
- this.nudPoint2Y.TabIndex = 17;
- this.nudPoint2Y.ValueChanged += new System.EventHandler(this.nudPoint2Y_ValueChanged);
- this.nudPoint2Y.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint2Y_KeyUp);
- //
- // nudPoint2X
- //
- this.nudPoint2X.Location = new System.Drawing.Point(132, 23);
- this.nudPoint2X.Maximum = new decimal(new int[] {
- 99999999,
- 0,
- 0,
- 0});
- this.nudPoint2X.Name = "nudPoint2X";
- this.nudPoint2X.Size = new System.Drawing.Size(78, 21);
- this.nudPoint2X.TabIndex = 16;
- this.nudPoint2X.ValueChanged += new System.EventHandler(this.nudPoint2X_ValueChanged);
- this.nudPoint2X.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint2X_KeyUp);
- //
- // panel2
- //
- this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel2.Location = new System.Drawing.Point(86, 93);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(105, 26);
- this.panel2.TabIndex = 15;
- this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(26, 99);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(41, 12);
- this.label7.TabIndex = 14;
- this.label7.Text = "颜色:";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(26, 62);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(83, 12);
- this.label8.TabIndex = 12;
- this.label8.Text = "中心点Y坐标:";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(26, 27);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(83, 12);
- this.label9.TabIndex = 10;
- this.label9.Text = "中心点X坐标:";
- //
- // groupBox6
- //
- this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6.Controls.Add(this.panel3);
- this.groupBox6.Controls.Add(this.label13);
- this.groupBox6.Controls.Add(this.nudScrapMax);
- this.groupBox6.Controls.Add(this.nudScrapMin);
- this.groupBox6.Controls.Add(this.chkScrapIsDel);
- this.groupBox6.Controls.Add(this.label12);
- this.groupBox6.Controls.Add(this.label11);
- this.groupBox6.Controls.Add(this.nudTowValueMax);
- this.groupBox6.Controls.Add(this.nudTowValueMin);
- this.groupBox6.Controls.Add(this.label10);
- this.groupBox6.Location = new System.Drawing.Point(691, 636);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(339, 137);
- this.groupBox6.TabIndex = 5;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "二值提取";
- //
- // panel3
- //
- this.panel3.BackColor = System.Drawing.Color.Red;
- this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel3.Location = new System.Drawing.Point(136, 57);
- this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(105, 26);
- this.panel3.TabIndex = 16;
- this.panel3.BackColorChanged += new System.EventHandler(this.panel3_BackColorChanged);
- this.panel3.Click += new System.EventHandler(this.panel3_Click);
- //
- // label13
- //
- this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(223, 101);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(11, 12);
- this.label13.TabIndex = 13;
- this.label13.Text = "~";
- //
- // nudScrapMax
- //
- this.nudScrapMax.Location = new System.Drawing.Point(252, 91);
- this.nudScrapMax.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.nudScrapMax.Name = "nudScrapMax";
- this.nudScrapMax.Size = new System.Drawing.Size(74, 21);
- this.nudScrapMax.TabIndex = 12;
- this.nudScrapMax.ValueChanged += new System.EventHandler(this.nudScrapMax_ValueChanged);
- this.nudScrapMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudScrapMax_KeyUp);
- //
- // nudScrapMin
- //
- this.nudScrapMin.Location = new System.Drawing.Point(136, 91);
- this.nudScrapMin.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.nudScrapMin.Name = "nudScrapMin";
- this.nudScrapMin.Size = new System.Drawing.Size(74, 21);
- this.nudScrapMin.TabIndex = 11;
- this.nudScrapMin.ValueChanged += new System.EventHandler(this.nudScrapMin_ValueChanged);
- this.nudScrapMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudScrapMin_KeyUp);
- //
- // chkScrapIsDel
- //
- this.chkScrapIsDel.AutoSize = true;
- this.chkScrapIsDel.Location = new System.Drawing.Point(26, 98);
- this.chkScrapIsDel.Name = "chkScrapIsDel";
- this.chkScrapIsDel.Size = new System.Drawing.Size(72, 16);
- this.chkScrapIsDel.TabIndex = 10;
- this.chkScrapIsDel.Text = "碎屑删除";
- this.chkScrapIsDel.UseVisualStyleBackColor = true;
- this.chkScrapIsDel.CheckedChanged += new System.EventHandler(this.chkScrapIsDel_CheckedChanged);
- //
- // label12
- //
- this.label12.AutoSize = true;
- this.label12.Location = new System.Drawing.Point(23, 61);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(53, 12);
- this.label12.TabIndex = 9;
- this.label12.Text = "相颜色:";
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(223, 34);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(11, 12);
- this.label11.TabIndex = 8;
- this.label11.Text = "~";
- //
- // nudTowValueMax
- //
- this.nudTowValueMax.Location = new System.Drawing.Point(252, 24);
- this.nudTowValueMax.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.nudTowValueMax.Name = "nudTowValueMax";
- this.nudTowValueMax.Size = new System.Drawing.Size(74, 21);
- this.nudTowValueMax.TabIndex = 7;
- this.nudTowValueMax.ValueChanged += new System.EventHandler(this.nudTowValue_ValueChanged);
- this.nudTowValueMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudTowValueMax_KeyUp);
- //
- // nudTowValueMin
- //
- this.nudTowValueMin.Location = new System.Drawing.Point(136, 26);
- this.nudTowValueMin.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.nudTowValueMin.Name = "nudTowValueMin";
- this.nudTowValueMin.Size = new System.Drawing.Size(74, 21);
- this.nudTowValueMin.TabIndex = 6;
- this.nudTowValueMin.ValueChanged += new System.EventHandler(this.nudTowValue_ValueChanged);
- this.nudTowValueMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudTowValueMin_KeyUp);
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(23, 30);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(65, 12);
- this.label10.TabIndex = 0;
- this.label10.Text = "提取范围:";
- //
- // ArtworkSettingEditDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1042, 785);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Name = "ArtworkSettingEditDialog";
- this.Text = "工艺图设定";
- this.Resize += new System.EventHandler(this.ArtworkSettingEditDialog_Resize);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudLineWidth)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudSide)).EndInit();
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint1Y)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint1X)).EndInit();
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint2Y)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudPoint2X)).EndInit();
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nudScrapMax)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudScrapMin)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMax)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMin)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button btnSave;
- private System.Windows.Forms.Button btnFromDisk;
- private System.Windows.Forms.Button btnFromGallery;
- private System.Windows.Forms.TextBox txtName;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.NumericUpDown nudLineWidth;
- private System.Windows.Forms.NumericUpDown nudSide;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Panel panel2;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.NumericUpDown nudTowValueMax;
- private System.Windows.Forms.NumericUpDown nudTowValueMin;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.Label label13;
- private System.Windows.Forms.NumericUpDown nudScrapMax;
- private System.Windows.Forms.NumericUpDown nudScrapMin;
- private System.Windows.Forms.CheckBox chkScrapIsDel;
- private System.Windows.Forms.Label label12;
- private System.Windows.Forms.Panel panel3;
- private System.Windows.Forms.Panel panel4;
- private System.Windows.Forms.NumericUpDown nudPoint1Y;
- private System.Windows.Forms.NumericUpDown nudPoint1X;
- private System.Windows.Forms.NumericUpDown nudPoint2Y;
- private System.Windows.Forms.NumericUpDown nudPoint2X;
- private System.Windows.Forms.Panel pnlTools;
- #endregion
- private ArtworkModel m_artworkModel;
- private List<ArtworkModel.Item> m_artworkLists = new List<ArtworkModel.Item>();
- private ArtworkModel.Item m_artwork;
- /// <summary>
- /// 网格调色板
- /// </summary>
- PaintDotNet.ColorsForm colorsFormGrid;
- /// <summary>
- /// 图片选择窗口
- /// </summary>
- private InterImagePickerDialog imagePickerDialog;
- private string m_filePath = Application.StartupPath + "\\Artwork\\";
- private int m_index;
- private AppWorkspace m_appWorkspace;
- private DocumentWorkspaceWindow m_documentWorkspace;
- private ArtworkControlButtons m_controlButtons;
- private int m_width;
- private int m_height;
- private Bitmap m_bitmap;
- private string m_picName;
- private string m_originalPicName;
- private string m_thumbnailName;
- private object m_currentSender;
- private Form m_parentForm;
- /// <summary>
- /// 单位标尺
- /// </summary>
- private double unitLength = 1;
- /// <summary>
- /// 二值图像
- /// </summary>
- private Mat m_mat;
- /// <summary>
- /// 处理程序
- /// </summary>
- private ParamObject action = new Data.Action.Action901();
- /// <summary>
- /// 初始系统参数配置值
- /// </summary>
- private BinaryExtractionModel binaryExtractionModel;
- private int m_angle = 0;
- public ArtworkSettingEditDialog(Form form, AppWorkspace workspace, int index)
- {
- m_parentForm = form;
- m_appWorkspace = workspace;
- m_index = index;
- if (!Directory.Exists(m_filePath))
- {
- Directory.CreateDirectory(m_filePath);//不存在就创建目录
- }
- this.binaryExtractionModel = XmlSerializeHelper.DESerializer<BinaryExtractionModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\Default.xml", FileMode.Open));
- InitializeComponent();
- InitializeLanguageText();
- InitializeData();
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- InitializeTools();
-
- }
- private void InitializeData()
- {
- this.m_documentWorkspace = new DocumentWorkspaceWindow(m_appWorkspace);
- this.m_documentWorkspace.AppWorkspaceTop = m_appWorkspace;
- this.m_documentWorkspace.Visible = true;
- this.m_documentWorkspace.Dock = DockStyle.Fill;
- this.panel4.Controls.Add(this.m_documentWorkspace);
- //
- //初始化相
- //
- PhaseModel model = new PhaseModel();
- model.choise = true;
- model.mat = null;
- model.color = panel3.BackColor.ToArgb();
- model.position = this.m_documentWorkspace.PhaseModels.Count + 1;
- model.name = PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text");
- this.m_documentWorkspace.PhaseModels.Add(model);
- this.m_documentWorkspace.GraphicsList = new GraphicsList(this.m_documentWorkspace);
- this.m_documentWorkspace.GraphicsList.SelectChanged += GraphicsList_SelectChanged;
- m_artworkModel = Startup.instance.artworkModel;
- m_artworkLists = m_artworkModel.items;
- if (m_index == -1)
- {
- m_artwork = new ArtworkModel.Item();
- //m_bitmap = new Bitmap(100, 100);
- m_picName = System.Guid.NewGuid().ToString("N") + ".Png";
- m_thumbnailName = System.Guid.NewGuid().ToString("N") + ".Png";
- m_originalPicName = System.Guid.NewGuid().ToString("N") + ".Png";
- panel3.BackColor = Color.Blue;
- }
- else
- {
- m_artwork = m_artworkLists[m_index];
- if (System.IO.File.Exists(m_filePath + m_artwork.originalPic))
- {
- Image bitmap1 = Image.FromFile(m_filePath + m_artwork.originalPic);
- m_bitmap = new Bitmap(bitmap1);
- bitmap1.Dispose();
- }
- else
- {
- m_bitmap = new Bitmap(100, 100);
- }
- this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
- m_picName = m_artwork.pic;
- m_thumbnailName = m_artwork.thumbnail;
- m_originalPicName = m_artwork.originalPic;
- txtName.Text = m_artwork.artworkName;
- nudSide.Value = m_artwork.side;
- nudLineWidth.Value = m_artwork.lineWidth;
- nudPoint1X.Value = m_artwork.point1X;
- nudPoint1Y.Value = m_artwork.point1Y;
- panel1.BackColor = ColorTranslator.FromHtml(m_artwork.point1Color);
- nudPoint2X.Value = m_artwork.point2X;
- nudPoint2Y.Value = m_artwork.point2Y;
- panel2.BackColor = ColorTranslator.FromHtml(m_artwork.point2Color);
- nudTowValueMin.Value = m_artwork.twoValueGetMin;
- nudTowValueMax.Value = m_artwork.twoValueGetMax;
- panel3.BackColor = ColorTranslator.FromHtml(m_artwork.twoValueColor);
- chkScrapIsDel.Checked = m_artwork.scrapIsDel;
- nudScrapMin.Value = m_artwork.scrapMin;
- nudScrapMax.Value = m_artwork.scrapMax;
- }
- //先修改参数
- foreach (Args args in action.Lists)
- {
- switch (args.Key)
- {
- case "phaseColor":
- args.Value = panel3.BackColor.ToArgb();
- break;
- case "debrisRemoval":
- args.Value = chkScrapIsDel.Checked;
- break;
- case "scope1":
- ((List<double>)args.Value)[0] = (int)nudTowValueMin.Value;
- ((List<double>)args.Value)[1] = (int)nudTowValueMax.Value;
- break;
- case "scope4":
- ((List<double>)args.Value)[0] = (double)nudScrapMin.Value;
- ((List<double>)args.Value)[1] = (double)nudScrapMax.Value;
- break;
- }
- }
- this.binaryExtractionModel.DebrisRemoval = chkScrapIsDel.Checked;
- this.binaryExtractionModel.DebrisAreaStart = (int)nudScrapMin.Value;
- this.binaryExtractionModel.DebrisAreaEnd = (int)nudScrapMax.Value;
- this.binaryExtractionModel.ColorOneStart = (int)nudTowValueMin.Value;
- this.binaryExtractionModel.ColorOneEnd = (int)nudTowValueMax.Value;
- this.binaryExtractionModel.PhaseColor = panel3.BackColor.ToArgb();
- }
- private void GraphicsList_SelectChanged(object sender, EventArgs e)
- {
- GraphicsList graphicsList = (GraphicsList)sender;
- if (graphicsList.Count < 2)
- {
- return;
- }
- for (int i = 0; i < graphicsList.Count; i++)
- {
- RectangleF rectangle = graphicsList[i].GetBoundingBox();
- if (((DrawObject)graphicsList[i]).ID == 0)
- {
- nudPoint1X.Value = (int)rectangle.X + nudSide.Value / 2;
- nudPoint1Y.Value = (int)rectangle.Y + nudSide.Value / 2;
- }
- else
- {
- nudPoint2X.Value = (int)rectangle.X + nudSide.Value / 2;
- nudPoint2Y.Value = (int)rectangle.Y + nudSide.Value / 2;
- }
- }
- }
- private void InitializeTools()
- {
- this.m_controlButtons = new ArtworkControlButtons();
- this.m_controlButtons.Dock = DockStyle.Top;
- this.m_controlButtons.Height = 30;
- this.m_controlButtons.HideMovingDirection();
- this.m_controlButtons.turnLeftButton.Visible = true;
- this.m_controlButtons.turnRightButton.Visible = true;
- this.pnlTools.Controls.Add(m_controlButtons);
-
- this.m_controlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.m_controlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.m_controlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.m_controlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.m_controlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.m_controlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- this.m_controlButtons.turnLeftButton.Click += new EventHandler(turnLeftButton_Click);
- this.m_controlButtons.turnRightButton.Click += new EventHandler(turnRightButton_Click);
- //
- //获取系统标尺-微米
- //
- this.m_appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
- //this.m_appWorkspace.ActiveDocumentWorkspace.GetRuler(MeasurementUnit.Micron);
- }
- private void turnRightButton_Click(object sender, EventArgs e)
- {
- if (m_bitmap == null)
- {
- return;
- }
- m_angle += 1;
- if(m_angle == 4)
- {
- m_angle = 0;
- }
- m_bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
- this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
- this.applyButtonImpl();
- }
- private void turnLeftButton_Click(object sender, EventArgs e)
- {
- if (m_bitmap == null)
- {
- return;
- }
- m_angle -= 1;
- if (m_angle == -4)
- {
- m_angle = 0;
- }
- m_bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
- this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
- this.applyButtonImpl();
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- if (this.m_documentWorkspace.CompositionSurface != null)
- {
- this.m_documentWorkspace.ZoomToWindow();
- }
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- if (this.m_documentWorkspace.CompositionSurface != null)
- {
- this.m_documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.m_documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.m_documentWorkspace.CompositionSurface != null)
- this.m_documentWorkspace.ZoomOut();
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if (this.m_documentWorkspace.CompositionSurface != null)
- this.m_documentWorkspace.ZoomIn();
- }
- private void MovePointReceived(int index, int x, int y)
- {
- if(index ==0)
- {
- this.Invoke(new Action(() =>
- {
- nudPoint1X.Value = x;
- nudPoint1Y.Value = y;
- }));
- }
- else
- {
- this.Invoke(new Action(() =>
- {
- nudPoint2X.Value = x;
- nudPoint2Y.Value = y;
- }));
- }
- }
- private void SetBitmap(Bitmap bitmap)
- {
- m_bitmap = bitmap;
- m_width = bitmap.Width;
- m_height = bitmap.Height;
- this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
- this.applyButtonImpl();
- // 新添加
- if (m_index == -1)
- {
- int side = Convert.ToInt32(nudSide.Value / 2);
- Random ran = new Random();
- nudPoint1X.Value = ran.Next(side, m_width - side);
- nudPoint1Y.Value = ran.Next(side, m_height - side);
- nudPoint2X.Value = ran.Next(side, m_width - side);
- nudPoint2Y.Value = ran.Next(side, m_height - side);
- panel1.BackColor = Color.Green;
- panel2.BackColor = Color.Red;
- }
- }
- private void btnFromDisk_Click(object sender, EventArgs e)
- {
-
- Bitmap newBit1 = ChooseImageFromHardDisk();//暂时接收一下,如果为空则不替换原有的原图对象
- if (newBit1 != null)
- {
- this.SetBitmap(newBit1);
- }
- }
- /// <summary>
- /// 从硬盘选择图片
- /// </summary>
- /// <returns></returns>
- private Bitmap ChooseImageFromHardDisk()
- {
- OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
- DialogResult result = openFileDialog.ShowDialog();
- if (result == DialogResult.OK)
- {
- Image image = Image.FromFile(openFileDialog.FileName);
- Bitmap newBit = new Bitmap(image);
- return newBit;
- }
- else
- {
- return null;
- }
- }
- private void btnFromGallery_Click(object sender, EventArgs e)
- {
- ImagePickerDialog(sender);
- }
- /// <summary>
- /// 弹出图库选择窗口
- /// </summary>
- /// <param name="sender"></param>
- private void ImagePickerDialog(object sender)
- {
- if (imagePickerDialog == null)
- {
- imagePickerDialog = new InterImagePickerDialog(m_appWorkspace);
- imagePickerDialog.StartPosition = FormStartPosition.Manual;
- if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
- {
- imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
- }
- else
- {
- imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
- }
- imagePickerDialog.Top = ((Button)sender).Bottom + 50 ;
- imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
- imagePickerDialog.Show();
- }
- else
- {
- if (!imagePickerDialog.IsDisposed)
- {
- imagePickerDialog.WindowState = FormWindowState.Normal;
- }
- else
- {
- imagePickerDialog = new InterImagePickerDialog(m_appWorkspace);
- imagePickerDialog.StartPosition = FormStartPosition.Manual;
- if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
- {
- imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
- }
- else
- {
- imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
- }
- imagePickerDialog.Top = ((Button)sender).Bottom + 50;
- imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
- imagePickerDialog.Show();
- }
- }
- }
- /// <summary>
- /// 从图库选择待对照图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void inputMat_ValueChanged(object sender, EventArgs e)
- {
- if (sender is DocumentWorkspace)
- {
- Bitmap bitmap1 = ((DocumentWorkspace)sender).CompositionSurface.CreateAliasedBitmap();
- if (bitmap1 != null)
- {
- this.SetBitmap(bitmap1);
- }
- }
- }
- private void ShowColorsForm(object sender)
- {
- Panel panel = (Panel)sender;
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(panel.BackColor);
- this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
- this.colorsFormGrid.ShowDialog();
- }
- /// <summary>
- /// 网格Panel的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gridColorChanged(object sender, EventArgs e)
- {
- Panel panel = (Panel)m_currentSender;
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- panel.BackColor = color;
- this.colorsFormGrid.Close();
- }
- /// <summary>
- /// 定位1颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel1_Click(object sender, EventArgs e)
- {
- m_currentSender = sender;
- ShowColorsForm(sender);
- }
- /// <summary>
- /// 定位2颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel2_Click(object sender, EventArgs e)
- {
- m_currentSender = sender;
- ShowColorsForm(sender);
- }
- /// <summary>
- /// 二值提取颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel3_Click(object sender, EventArgs e)
- {
- m_currentSender = sender;
- ShowColorsForm(sender);
- }
- private void DrawRectangle(int index, Color color, int lineWidth, int x, int y, int width, int height)
- {
- for(int i= 0; i< this.m_documentWorkspace.GraphicsList.Count; i++)
- {
- if(((DrawObject)this.m_documentWorkspace.GraphicsList[i]).ID == index)
- {
- this.m_documentWorkspace.GraphicsList.RemoveObj((DrawObject)this.m_documentWorkspace.GraphicsList[i]);
- }
- }
- Rectangle rectangle1 = new Rectangle(x, y, width, height);
- Pen pen = new Pen(color, lineWidth);
- this.m_documentWorkspace.ActiveTool = DrawToolType.DrawArtworkRectangle;
- this.m_documentWorkspace.CreateArtworkRectangle(index, pen, rectangle1);
- }
- private void DrawPoint1()
- {
- Color color = panel1.BackColor;
- int lineWidth = Convert.ToInt32(nudLineWidth.Value);
- int X = Convert.ToInt32(nudPoint1X.Value);
- int Y = Convert.ToInt32(nudPoint1Y.Value);
- int width = Convert.ToInt32(nudSide.Value);
- int height = width;
- int x = X - width / 2;
- int y = Y - height / 2;
- DrawRectangle(0, color, lineWidth, x, y, width, height);
- }
- private void DrawPoint2()
- {
- Color color = panel2.BackColor;
- int lineWidth = Convert.ToInt32(nudLineWidth.Value);
- int X = Convert.ToInt32(nudPoint2X.Value);
- int Y = Convert.ToInt32(nudPoint2Y.Value);
- int width = Convert.ToInt32(nudSide.Value);
- int height = width;
- int x = X - width / 2;
- int y = Y - height / 2;
- DrawRectangle(1, color, lineWidth, x, y, width, height);
- }
- private void panel1_BackColorChanged(object sender, EventArgs e)
- {
- DrawPoint1();
- }
- private void nudPoint1X_ValueChanged(object sender, EventArgs e)
- {
- if (m_width <= 0 || m_height <= 0)
- {
- return;
- }
- int X = Convert.ToInt32(nudPoint1X.Value);
- int width = Convert.ToInt32(nudSide.Value);
- if (X - width / 2 < 0)
- {
- nudPoint1X.Value = width / 2;
- }
- else if (X + width / 2 > m_width)
- {
- nudPoint1X.Value = (m_width - width / 2);
- }
- DrawPoint1();
- }
- private void nudPoint1Y_ValueChanged(object sender, EventArgs e)
- {
- if (m_width <= 0 || m_height <= 0)
- {
- return;
- }
- int Y = Convert.ToInt32(nudPoint1Y.Value);
- int height = Convert.ToInt32(nudSide.Value);
- if (Y - height / 2 < 0)
- {
- nudPoint1Y.Value = (height / 2);
- }
- else if (Y + height / 2 > m_height)
- {
- nudPoint1Y.Value = (m_height - height / 2);
- }
- DrawPoint1();
- }
- private void panel2_BackColorChanged(object sender, EventArgs e)
- {
- DrawPoint2();
- }
- private void nudLineWidth_ValueChanged(object sender, EventArgs e)
- {
- DrawPoint1();
- DrawPoint2();
- }
- private void nudSide_ValueChanged(object sender, EventArgs e)
- {
- DrawPoint1();
- DrawPoint2();
- }
- private void nudPoint2X_ValueChanged(object sender, EventArgs e)
- {
- if (m_width <= 0 || m_height <= 0)
- {
- return;
- }
- int X = Convert.ToInt32(nudPoint2X.Value);
- int width = Convert.ToInt32(nudSide.Value);
- if (X - width / 2 < 0)
- {
- nudPoint2X.Value = (width / 2);
- }
- else if (X + width / 2 > m_width)
- {
- nudPoint2X.Value = (m_width - width / 2);
- }
- DrawPoint2();
- }
- private void nudPoint2Y_ValueChanged(object sender, EventArgs e)
- {
- if (m_width <= 0 || m_height <= 0)
- {
- return;
- }
- int Y = Convert.ToInt32(nudPoint2Y.Value);
- int height = Convert.ToInt32(nudSide.Value);
- if (Y - height / 2 < 0)
- {
- nudPoint2Y.Value = (height / 2);
- }
- else if (Y + height / 2 > m_height)
- {
- nudPoint2Y.Value = (m_height - height / 2);
- }
- DrawPoint2();
- }
-
- private void btnSave_Click(object sender, EventArgs e)
- {
- string artworkName = txtName.Text.Trim();
- if (string.IsNullOrEmpty(artworkName))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasefillisdrawing.text"));
- return;
- }
- if (m_bitmap == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseaddaprocessdrawing.text"));
- return;
- }
-
- if (System.IO.File.Exists(m_filePath + m_picName))
- {
- System.IO.File.Delete(m_filePath + m_picName);
- }
- if (System.IO.File.Exists(m_filePath + m_thumbnailName))
- {
- System.IO.File.Delete(m_filePath + m_thumbnailName);
- }
- if (System.IO.File.Exists(m_filePath + m_originalPicName))
- {
- System.IO.File.Delete(m_filePath + m_originalPicName);
- }
- m_bitmap.Save(m_filePath + m_originalPicName, System.Drawing.Imaging.ImageFormat.Png);
- m_artwork.originalPic = m_originalPicName;
- if (m_mat != null)
- {
- // 二值图像
- Bitmap image1 = BitmapConverter.ToBitmap(m_mat);
- Bitmap[] bitmaps = new Bitmap[2];
- bitmaps[0] = m_bitmap;
- bitmaps[1] = image1;
- m_bitmap = ImageTools.Overlap(bitmaps, m_bitmap.Width, m_bitmap.Height, OverlapType.TOPLEFT);
- image1.Dispose();
- }
- m_bitmap.Save(m_filePath + m_picName, System.Drawing.Imaging.ImageFormat.Png);
- m_artwork.pic = m_picName;
-
- Surface surface = Surface.CopyFromBitmap(m_bitmap);
- surface.CreateThumbnail();
- Bitmap image = surface.Thumbnail;
- image.Save(m_filePath + m_thumbnailName, System.Drawing.Imaging.ImageFormat.Png);
- m_artwork.thumbnail = m_thumbnailName;
-
- m_artwork.artworkName = artworkName;
- m_artwork.side = Convert.ToInt32(nudSide.Value);
- m_artwork.lineWidth = Convert.ToInt32(nudLineWidth.Value);
- m_artwork.point1X = Convert.ToInt32(nudPoint1X.Value);
- m_artwork.point1Y = Convert.ToInt32(nudPoint1Y.Value);
- m_artwork.point1Color = ColorTranslator.ToHtml(panel1.BackColor);
- m_artwork.point2X = Convert.ToInt32(nudPoint2X.Value);
- m_artwork.point2Y = Convert.ToInt32(nudPoint2Y.Value);
- m_artwork.point2Color = ColorTranslator.ToHtml(panel2.BackColor);
- m_artwork.twoValueGetMin = Convert.ToInt32(nudTowValueMin.Value);
- m_artwork.twoValueGetMax = Convert.ToInt32(nudTowValueMax.Value);
- m_artwork.twoValueColor = ColorTranslator.ToHtml(panel3.BackColor);
- m_artwork.scrapIsDel = chkScrapIsDel.Checked;
- m_artwork.scrapMin = Convert.ToInt32(nudScrapMin.Value);
- m_artwork.scrapMax = Convert.ToInt32(nudScrapMax.Value);
- if (m_index == -1)
- {
- m_artworkLists.Add(m_artwork);
- }
- string stageModelXml = XmlSerializeHelper.XmlSerialize<ArtworkModel>(m_artworkModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ArtworkModel.xml";
- if (FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create))
- {
- Startup.instance.artworkModel = m_artworkModel;
- ((ArtworkSettingDialog)m_parentForm).ArtworkListLoad();
- //MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
- m_bitmap.Dispose();
- this.Close();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Savefailed.text"));
- }
- }
- private void applyButtonImpl()
-
- {
- if (m_bitmap == null)
- {
- return;
- }
- long start = Cv2.GetTickCount();
- //判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
- if (this.m_documentWorkspace.GraphicsList.IsExsitView())
- {
- this.m_documentWorkspace.PhaseModels[0].mat = action.PerformProcess(
- PaintDotNet.Camera.Tools.ToMat(this.m_documentWorkspace.GetFullSizeWithRegion()),
- PaintDotNet.Camera.Tools.ToMat(this.m_bitmap));
- this.m_documentWorkspace.PhaseModels[0].color = this.panel3.BackColor.ToArgb();
- this.m_documentWorkspace.Refresh();
- }
- else
- {
- m_mat = action.PerformProcess(PaintDotNet.Camera.Tools.ToMat(this.m_bitmap));
- this.m_documentWorkspace.PhaseModels[0].mat = m_mat;
- this.m_documentWorkspace.PhaseModels[0].color = this.panel3.BackColor.ToArgb();
- this.m_documentWorkspace.Refresh();
- }
- double time = (Cv2.GetTickCount() - start) / Cv2.GetTickFrequency();
- System.Console.WriteLine("执行时间:" + time);
- }
- private void panel3_BackColorChanged(object sender, EventArgs e)
- {
- Color color = this.panel3.BackColor;
- //先修改参数
- foreach (Args args in action.Lists)
- {
- if (args.Key == "phaseColor")
- {
- args.Value = color.ToArgb();
- break;
- }
- }
- //改变配置文件里面的相颜色
- this.binaryExtractionModel.PhaseColor = color.ToArgb();
- this.applyButtonImpl();
- }
- private void nudTowValue_ValueChanged(object sender, EventArgs e)
- {
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "scope1")
- {
- ((List<double>)args.Value)[0] = (int)this.nudTowValueMin.Value;
- ((List<double>)args.Value)[1] = (int)this.nudTowValueMax.Value;
- break;
- }
- }
- this.binaryExtractionModel.ColorOneStart = (int)(this.nudTowValueMin.Value);
- this.binaryExtractionModel.ColorOneEnd = (int)(this.nudTowValueMax.Value);
- this.applyButtonImpl();
- }
- /// <summary>
- /// 碎屑面积起始值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void nudScrapMin_ValueChanged(object sender, EventArgs e)
- {
- nudScrapMax.Value = Math.Max(nudScrapMax.Value, nudScrapMin.Value);
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "scope4")
- {
- ((List<double>)args.Value)[0] = (double)nudScrapMin.Value / unitLength / unitLength;
- ((List<double>)args.Value)[1] = (double)nudScrapMax.Value / unitLength / unitLength;
- break;
- }
- }
- this.binaryExtractionModel.DebrisAreaStart = (int)((double)nudScrapMin.Value / unitLength / unitLength);
- this.binaryExtractionModel.DebrisAreaEnd = (int)((double)nudScrapMax.Value / unitLength / unitLength);
- this.applyButtonImpl();
- }
- /// <summary>
- /// 碎屑面积截止值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void nudScrapMax_ValueChanged(object sender, EventArgs e)
- {
- nudScrapMin.Value = Math.Min(nudScrapMin.Value, nudScrapMax.Value);
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "scope4")
- {
- ((List<double>)args.Value)[0] = (double)nudScrapMin.Value / unitLength / unitLength;
- ((List<double>)args.Value)[1] = (double)nudScrapMax.Value / unitLength / unitLength;
- break;
- }
- }
- this.binaryExtractionModel.DebrisAreaStart = (int)((double)nudScrapMin.Value / unitLength / unitLength);
- this.binaryExtractionModel.DebrisAreaEnd = (int)((double)nudScrapMax.Value / unitLength / unitLength);
- this.applyButtonImpl();
- }
- private void chkScrapIsDel_CheckedChanged(object sender, EventArgs e)
- {
- //参数改变
- foreach (Args args in action.Lists)
- {
- if (args.Key == "debrisRemoval")
- {
- args.Value = this.chkScrapIsDel.Checked;
- break;
- }
- }
- this.binaryExtractionModel.DebrisRemoval = this.chkScrapIsDel.Checked;
- this.applyButtonImpl();
- }
- private void ArtworkSettingEditDialog_Resize(object sender, EventArgs e)
- {
- this.pnlTools.Left = panel4.Left + (panel4.Width - pnlTools.Width) / 2;
- }
- private void nudTowValueMin_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudTowValueMin.Value = Convert.ToInt32(this.nudTowValueMin.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudTowValueMax_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudTowValueMax.Value = Convert.ToInt32(this.nudTowValueMax.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudScrapMin_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudScrapMin.Value = Convert.ToInt32(this.nudScrapMin.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudScrapMax_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudScrapMax.Value = Convert.ToInt32(this.nudScrapMax.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudSide_KeyUp(object sender, KeyEventArgs e)
- {
- try
- {
- nudSide.Value = Convert.ToInt32(this.nudSide.Text);
- }
- catch (Exception)
- {
- }
-
- }
- private void nudLineWidth_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudLineWidth.Value = Convert.ToInt32(this.nudLineWidth.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudPoint1X_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudPoint1X.Value = Convert.ToInt32(this.nudPoint1X.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudPoint1Y_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudPoint1Y.Value = Convert.ToInt32(this.nudPoint1Y.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudPoint2X_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudPoint2X.Value = Convert.ToInt32(this.nudPoint2X.Text);
- }
- catch (Exception)
- {
- }
- }
- private void nudPoint2Y_KeyUp(object sender, KeyEventArgs e)
- {
-
- try
- {
- nudPoint2Y.Value = Convert.ToInt32(this.nudPoint2Y.Text);
- }
- catch (Exception)
- {
- }
- }
- }
- }
|