123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115 |
- using OpenCvSharp;
- using PaintDotNet.Base.SettingModel;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Windows.Forms;
- using GroupBox = System.Windows.Forms.GroupBox;
- using CheckBox = System.Windows.Forms.CheckBox;
- using Button = System.Windows.Forms.Button;
- using System.Data;
- using PaintDotNet.Base.CommTool;
- using System.Drawing.Drawing2D;
- using PaintDotNet.Annotation.Enum;
- namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.ManualMethod
- {
- internal class MethodCutOffDialog : GrainSizeStandardDialog
- {
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsFormGrid;
- private Panel panelC;
- /// <summary>
- /// 鼠标状态(0:添加 1:删除 2:选择)
- /// </summary>
- private int mouseStatus = -1;
- /// <summary>
- /// 测量线类型(0:全方位 1:水平 2:垂直)
- /// </summary>
- private int lineStyle = 0;
- /// <summary>
- /// 线条矩形
- /// </summary>
- private Dictionary<PointF[], int> rectangleFsLines = new Dictionary<PointF[], int>();
- private int selectLineIndex = -1;
- private PointF movePointStart;
- bool canMove = false;
- int movePointIndex = -1;
- bool canAdd = false;
- private int defaultIndex = -1;
- private bool canChange = false;
- /// <summary>
- /// 标尺
- /// </summary>
- private double unitLength;
- /// <summary>
- /// 数据展示
- /// </summary>
- private DataTable dataTable;
- /// <summary>
- /// 存在视场标记
- /// </summary>
- private bool existViewFlag = false;
- /// <summary>
- /// 线条绘制点矩形集合
- /// </summary>
- private Dictionary<RectangleF[], int> rectangleFs = new Dictionary<RectangleF[], int>();
- /// <summary>
- /// 线条绘制点矩形
- /// </summary>
- private RectangleF[] rectangleFsArr = new RectangleF[2];
- /// <summary>
- /// 线条矩形
- /// </summary>
- private PointF[] pointFsLine = new PointF[4];
- /// <summary>
- /// 测定结果暂存
- /// </summary>
- private List<DataTable> dataTable1s = new List<DataTable>();
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- private Dictionary<string, List<Bitmap>> bitCeDingDic = new Dictionary<string, List<Bitmap>>();
- protected static string ParamKey_MainFontSize = "MainFontSize";//字号
- protected static string ParamKey_MainFontColor = "MainFontColor"; // 字体颜色
- protected static string ParamKey_MainLineWidth = "MainLineWidth";
- protected static string ParamKey_MainLineColor = "MainLineColor";
- #region 组件
- private GroupBox groupBox11;
- private CheckBox checkBox3_0;
- private DataGridViewTextBoxColumn ColumnTotal1;
- private DataGridViewTextBoxColumn ColumnTotal2;
- private DataGridViewTextBoxColumn ColumnTotal3;
- private DataGridViewTextBoxColumn ColumnTotal4;
- private DataGridViewTextBoxColumn ColumnTotal5;
- private DataGridViewTextBoxColumn ColumnTotal6;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn Graisize;
- private DataGridViewTextBoxColumn Grainnumber;
- private DataGridViewTextBoxColumn Grainintercept;
- private DataGridViewTextBoxColumn Graingrade;
- private GroupBox groupBox1;
- private Button button10;
- private Button button7_0;
- private GroupBox groupBox2;
- private Label label4;
- private Label label3;
- private Label label5;
- private DataGridViewTextBoxColumn Column11;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
- private Label label8;
- private Label label7;
- private Label label6;
- private Label label1;
- private Panel panel2;
- private Panel panel1;
- private NumericUpDown numericUpDown3;
- private NumericUpDown numericUpDown4;
- private Button button2;
- private DataGridView dataGridView1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
- private Label labelNum;
- private Label labelMin;
- private Label labelMax;
- private DataGridViewTextBoxColumn Column6;
- #endregion 组件
- #region 构造函数
- public MethodCutOffDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, null, 0)
- {
- //
- //初始化色板
- //
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
- getSonData();
- }
- #endregion 构造函数
- #region 初始化组件
- private void InitializeComponentText()
- {
- //this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
- }
- private void InitializeComponent()
- {
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox11 = new System.Windows.Forms.GroupBox();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.panel2 = new System.Windows.Forms.Panel();
- this.panel1 = new System.Windows.Forms.Panel();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.checkBox3_0 = new System.Windows.Forms.CheckBox();
- this.Graisize = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Grainnumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Grainintercept = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Graingrade = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button10 = new System.Windows.Forms.Button();
- this.button7_0 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.labelNum = new System.Windows.Forms.Label();
- this.labelMin = new System.Windows.Forms.Label();
- this.labelMax = 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.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox_img.SuspendLayout();
- this.groupBox_analysisResult1.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox11.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox11
- //
- this.groupBox11.Controls.Add(this.numericUpDown4);
- this.groupBox11.Controls.Add(this.numericUpDown3);
- this.groupBox11.Controls.Add(this.panel2);
- this.groupBox11.Controls.Add(this.panel1);
- this.groupBox11.Controls.Add(this.label8);
- this.groupBox11.Controls.Add(this.label7);
- this.groupBox11.Controls.Add(this.label6);
- this.groupBox11.Controls.Add(this.label1);
- this.groupBox11.Controls.Add(this.checkBox3_0);
- this.groupBox11.Location = new System.Drawing.Point(178, 364);
- this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(356, 83);
- this.groupBox11.TabIndex = 39;
- this.groupBox11.TabStop = false;
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(60, 37);
- this.numericUpDown4.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.numericUpDown4.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown4.TabIndex = 30;
- this.numericUpDown4.Value = new decimal(new int[] {
- 20,
- 0,
- 0,
- 0});
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(60, 59);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 9999,
- 0,
- 0,
- 0});
- this.numericUpDown3.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown3.TabIndex = 29;
- this.numericUpDown3.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // panel2
- //
- this.panel2.BackColor = System.Drawing.Color.Blue;
- this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel2.Location = new System.Drawing.Point(218, 60);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(49, 17);
- this.panel2.TabIndex = 28;
- this.panel2.Click += new System.EventHandler(this.panelC_Click);
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.Color.Yellow;
- this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- this.panel1.Location = new System.Drawing.Point(218, 39);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(49, 17);
- this.panel1.TabIndex = 27;
- this.panel1.Click += new System.EventHandler(this.panelC_Click);
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(147, 63);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(65, 12);
- this.label8.TabIndex = 8;
- this.label8.Text = "截距颜色:";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(147, 42);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(65, 12);
- this.label7.TabIndex = 7;
- this.label7.Text = "字体颜色:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(13, 63);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(41, 12);
- this.label6.TabIndex = 6;
- this.label6.Text = "线宽:";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(13, 42);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(41, 12);
- this.label1.TabIndex = 5;
- this.label1.Text = "字号:";
- //
- // checkBox3_0
- //
- this.checkBox3_0.AutoSize = true;
- this.checkBox3_0.Checked = true;
- this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox3_0.Location = new System.Drawing.Point(15, 19);
- this.checkBox3_0.Name = "checkBox3_0";
- this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
- this.checkBox3_0.TabIndex = 0;
- this.checkBox3_0.UseVisualStyleBackColor = true;
- this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
- //
- // Graisize
- //
- this.Graisize.Name = "Graisize";
- this.Graisize.ReadOnly = true;
- //
- // Grainnumber
- //
- this.Grainnumber.Name = "Grainnumber";
- this.Grainnumber.ReadOnly = true;
- //
- // Grainintercept
- //
- this.Grainintercept.Name = "Grainintercept";
- this.Grainintercept.ReadOnly = true;
- //
- // Graingrade
- //
- this.Graingrade.Name = "Graingrade";
- this.Graingrade.ReadOnly = true;
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button10);
- this.groupBox1.Controls.Add(this.button7_0);
- this.groupBox1.Location = new System.Drawing.Point(179, 315);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(356, 43);
- this.groupBox1.TabIndex = 40;
- this.groupBox1.TabStop = false;
- //
- // button2
- //
- this.button2.BackColor = System.Drawing.SystemColors.Control;
- this.button2.Location = new System.Drawing.Point(215, 12);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(95, 26);
- this.button2.TabIndex = 14;
- this.button2.UseVisualStyleBackColor = false;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button10
- //
- this.button10.BackColor = System.Drawing.SystemColors.Control;
- this.button10.Location = new System.Drawing.Point(114, 12);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(95, 26);
- this.button10.TabIndex = 13;
- this.button10.UseVisualStyleBackColor = false;
- this.button10.Click += new System.EventHandler(this.button10_Click);
- //
- // button7_0
- //
- this.button7_0.BackColor = System.Drawing.SystemColors.Control;
- this.button7_0.Location = new System.Drawing.Point(13, 12);
- this.button7_0.Name = "button7_0";
- this.button7_0.Size = new System.Drawing.Size(95, 26);
- this.button7_0.TabIndex = 12;
- this.button7_0.UseVisualStyleBackColor = false;
- this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
- this.button7_0.LostFocus += new System.EventHandler(this.button7_0_LostFocus);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.labelNum);
- this.groupBox2.Controls.Add(this.labelMin);
- this.groupBox2.Controls.Add(this.labelMax);
- 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(179, 446);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(356, 39);
- this.groupBox2.TabIndex = 41;
- this.groupBox2.TabStop = false;
- //
- // labelNum
- //
- this.labelNum.AutoSize = true;
- this.labelNum.Location = new System.Drawing.Point(309, 17);
- this.labelNum.Name = "labelNum";
- this.labelNum.Size = new System.Drawing.Size(0, 12);
- this.labelNum.TabIndex = 7;
- //
- // labelMin
- //
- this.labelMin.AutoSize = true;
- this.labelMin.Location = new System.Drawing.Point(176, 17);
- this.labelMin.Name = "labelMin";
- this.labelMin.Size = new System.Drawing.Size(0, 12);
- this.labelMin.TabIndex = 6;
- //
- // labelMax
- //
- this.labelMax.AutoSize = true;
- this.labelMax.Location = new System.Drawing.Point(57, 17);
- this.labelMax.Name = "labelMax";
- this.labelMax.Size = new System.Drawing.Size(0, 12);
- this.labelMax.TabIndex = 5;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(13, 17);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(41, 12);
- this.label5.TabIndex = 4;
- this.label5.Text = "最大:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(129, 17);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(41, 12);
- this.label4.TabIndex = 3;
- this.label4.Text = "最小:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(262, 17);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(41, 12);
- this.label3.TabIndex = 2;
- this.label3.Text = "数量:";
- //
- // Column11
- //
- this.Column11.Name = "Column11";
- //
- // dataGridViewTextBoxColumn1
- //
- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
- //
- // dataGridViewTextBoxColumn2
- //
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle1;
- this.dataGridViewTextBoxColumn2.HeaderText = "1";
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.ReadOnly = true;
- this.dataGridViewTextBoxColumn2.Width = 50;
- //
- // dataGridViewTextBoxColumn3
- //
- dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle2;
- this.dataGridViewTextBoxColumn3.HeaderText = ".5";
- this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.ReadOnly = true;
- this.dataGridViewTextBoxColumn3.Width = 50;
- //
- // dataGridViewTextBoxColumn4
- //
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle3;
- this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
- this.dataGridViewTextBoxColumn4.ReadOnly = true;
- this.dataGridViewTextBoxColumn4.Width = 55;
- //
- // dataGridViewTextBoxColumn5
- //
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle4;
- this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
- this.dataGridViewTextBoxColumn5.ReadOnly = true;
- this.dataGridViewTextBoxColumn5.Width = 69;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.dataGridViewTextBoxColumn9,
- this.dataGridViewTextBoxColumn10});
- this.dataGridView1.Location = new System.Drawing.Point(178, 487);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.ReadOnly = true;
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView1.Size = new System.Drawing.Size(356, 101);
- this.dataGridView1.TabIndex = 42;
- this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
- //
- // dataGridViewTextBoxColumn9
- //
- dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle6;
- this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
- this.dataGridViewTextBoxColumn9.ReadOnly = true;
- this.dataGridViewTextBoxColumn9.Width = 111;
- //
- // dataGridViewTextBoxColumn10
- //
- dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle7;
- this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
- this.dataGridViewTextBoxColumn10.ReadOnly = true;
- this.dataGridViewTextBoxColumn10.Width = 242;
- //
- // MethodCutOffDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1127, 810);
- this.Controls.Add(this.dataGridView1);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox11);
- this.KeyPreview = true;
- this.Name = "MethodCutOffDialog";
- this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MethodCutOffDialog_KeyDown);
- this.Controls.SetChildIndex(this.groupBox11, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
- this.Controls.SetChildIndex(this.groupBox_img, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
- this.Controls.SetChildIndex(this.groupBox_report, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.dataGridView1, 0);
- this.groupBox_img.ResumeLayout(false);
- this.groupBox_analysisResult1.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox11.ResumeLayout(false);
- this.groupBox11.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion 初始化组件
- #region 需继承方法
- /// <summary>
- /// 保存参数
- /// </summary>
- protected override void saveSonData()
- {
- saveParamValue(ParamKey_displaygrainboundaries, checkBox3_0.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);
- saveParamValue(ParamKey_MainFontSize, numericUpDown4.Value.ToString(), (int)Base.Dtryt.Interger);
- saveParamValue(ParamKey_MainFontColor, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);
- saveParamValue(ParamKey_MainLineWidth, numericUpDown3.Value.ToString(), (int)Base.Dtryt.Interger);
- saveParamValue(ParamKey_MainLineColor, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);
- }
- /// <summary>
- /// 获取参数
- /// </summary>
- protected override void getSonData()
- {
- object ShowGrainBoundry;
- if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))
- checkBox3_0.Checked = Convert.ToInt32(ShowGrainBoundry) == 0 ? true : false;
- if (GetParamValue1(ParamKey_MainFontSize, out ShowGrainBoundry))
- numericUpDown4.Value = Convert.ToInt32(ShowGrainBoundry);
- if (GetParamValue1(ParamKey_MainFontColor, out ShowGrainBoundry))
- panel1.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
- if (GetParamValue1(ParamKey_MainLineWidth, out ShowGrainBoundry))
- numericUpDown3.Value = Convert.ToInt32(ShowGrainBoundry);
- if (GetParamValue1(ParamKey_MainLineColor, out ShowGrainBoundry))
- panel2.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
- {
- //if (this.listView1.SelectedItems.Count == 0)
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- // return;
- //}
- //if (this.dataGridView1.Rows.Count == 0)
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Noresultdata.text") + "!");
- // return;
- //}
- //string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
- //string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
- //DataTable dataTable = new DataTable();
- //bool replace = false;
- //int add = 0;
- //foreach (ListViewItem item in this.listView2.Items)
- //{
- // if (item.Tag.Equals(tag))
- // {
- // add++;
- // DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- // if (dr == DialogResult.OK)
- // {
- // replace = true;
- // this.listView2.Items.Remove(item);
- // }
- // break;
- // }
- //}
- //if (replace || this.listView2.Items.Count == 0 || add == 0)
- //{
- // ListViewItem listViewItem = new ListViewItem();
- // listViewItem.SubItems[0].Text = imgName;
- // listViewItem.Tag = "" + tag;
- // if (this.listView2.Items.Count == 0)
- // this.listView2.Items.Add(listViewItem);
- // else
- // this.listView2.Items.Insert(0, listViewItem);
- // this.dataGridView4.Rows.Clear();
- // for (int i = 0; i < this.dataTable.Rows.Count; i++)
- // {
- // DataGridViewRow dgvr = new DataGridViewRow();
- // dgvr.Tag = tag;
- // foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- // {
- // dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- // }
- // dgvr.Cells[0].Value = imgName;
- // dgvr.Cells[1].Value = this.dataTable.Rows[i][0];
- // dgvr.Cells[2].Value = Math.Round(Convert.ToDouble(this.dataTable.Rows[i][1]), Convert.ToInt32(this.numericUpDown1.Value));
- // this.dataGridView4.Rows.Add(dgvr);
- // }
- // dataTable.TableName = tag;
- // foreach (System.Data.DataTable dataTable1 in dataTables)
- // {
- // if (dataTable1.TableName.Equals(dataTable.TableName))
- // {
- // dataTables.Remove(dataTable1);
- // break;
- // }
- // }
- // foreach (DataGridViewColumn c in this.dataGridView4.Columns)
- // {
- // dataTable.Columns.Add(c.HeaderText);
- // }
- // for (int i = 0; i < this.dataTable.Rows.Count; i++)
- // {
- // DataRow dataRow = dataTable.NewRow();
- // dataRow[0] = imgName;
- // dataRow[1] = this.dataTable.Rows[i][0];
- // dataRow[2] = this.dataTable.Rows[i][1];
- // dataTable.Rows.Add(dataRow);
- // }
- // this.dataTables.Add(dataTable);
- // if (this.allShow)
- // AllShow();
- // this.listView2.Items[0].Selected = true;
- // if (this.documentWorkspace.PhaseModels[0].mat != null)
- // {
- // //保存处理后的图片
- // List<Bitmap> tempBit = new List<Bitmap>();
- // Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- // tempBit.Add(originalBit);
- // Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
- // Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- // Graphics graphics = Graphics.FromImage(newBit);
- // graphics.DrawImage(processedBit, new PointF(0, 0));
- // Draw(graphics);
- // tempBit.Add(newBit);
- // if (bitDic.ContainsKey(tag))
- // bitDic[tag] = tempBit;
- // else
- // bitDic.Add(tag, tempBit);
- // }
- // //拼接中间数据
- // List<List<string>> dataList = new List<List<string>>();
- // List<string> columnName = new List<string>();
- // columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
- // columnName.Add(PdnResources.GetString("Menu.Linelength.text") + "(μm)");
- // columnName.Add(PdnResources.GetString("Menu.Startingcoordinates.text"));
- // columnName.Add(PdnResources.GetString("Menu.Endpointcoordinates.Text"));
- // dataList.Add(columnName);
- // int no = 0;
- // foreach (var item in rectangleFs)
- // {
- // double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 10) * unitLength;
- // no++;
- // List<string> strList = new List<string>();
- // strList.Add("" + no);
- // strList.Add("" + length);
- // strList.Add("(" + (Convert.ToInt32(item.Key[0].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[0].Y) + 6).ToString() + ")");
- // strList.Add("(" + (Convert.ToInt32(item.Key[1].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[1].Y) + 6).ToString() + ")");
- // dataList.Add(strList);
- // }
- // bool isExist = false;//是否已存在进行替换
- // int modelIndex = -1;//要替换的下标
- // for (int j = 0; j < tempDataModel.Count; j++)
- // {
- // if (tempDataModel[j].tagName.Equals(tag))
- // {
- // isExist = true;
- // modelIndex = j;
- // break;
- // }
- // }
- // if (isExist && modelIndex > -1)
- // tempDataModel[modelIndex].dataList = dataList;
- // else
- // {
- // ExportProjectModel newModel = new ExportProjectModel();
- // newModel.tagName = tag;
- // newModel.picName = imgName;
- // newModel.dataList = dataList;
- // tempDataModel.Add(newModel);
- // }
- //}
- if (this.imageMat == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- return;
- }
- if (this.dataGridView1.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
- return;
- }
- //if (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
- // return;
- //}
- double value4Total = this.dataGridView1.Rows.Count - 1;// 0;
- //foreach (DataGridViewRow Row in this.dataGridView1.Rows)
- //{
- // value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
- //}
- if (value4Total < 1)
- {
- MessageBox.Show("请添加截距后保存结果");
- return;
- }
- string imgName = getCurrentWorkspace().GetFriendlyName();
- string tag = getCurrentWorkTag();
- DataTable dataTable = new DataTable();
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- add++;
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- break;
- }
- }
- if (replace || this.listView2.Items.Count == 0 || add == 0)
- {
- if (!replace)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + tag;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- }
- this.dataGridView2.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = tag;
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = imgName;
- //DataGridViewRow firRow = this.dataGridView1.Rows[0];
- //object value1 = firRow.Cells[0].Value;//网格
- //object value2 = firRow.Cells[1].Value;//网格长度
- //object value3 = firRow.Cells[2].Value;//网格条数
- //double value2Total = 0;
- //foreach (DataGridViewRow Row in this.dataGridView1.Rows)
- //{
- // value2Total += (double.Parse(Row.Cells[1].Value.ToString()) * double.Parse(Row.Cells[2].Value.ToString()));//网格总长度
- //}
- ////double value4Total = 0;
- ////foreach (DataGridViewRow Row in this.dataGridView1.Rows)
- ////{
- //// value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
- ////}
- ////if (value4Total == 0)//###20791
- ////{
- //// MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
- //// return;
- ////}
- //////double value4Per = value4Total / this.dataGridView1.Rows.Count;
- dgvr.Cells[1].Value = this.labelNum.Text;// value1;
- dgvr.Cells[2].Value = this.labelMax.Text;// value2Total;
- dgvr.Cells[3].Value = this.labelMin.Text;// value4Total;
- //dgvr.Cells[4].Value = value4Per;//级别
- decimal M = 1;// this.getGainMultiple();
- DataGridViewRow lastRow = this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1];
- double small_l = double.Parse(lastRow.Cells[1].Value.ToString());// value2Total / (value4Total * (double)M);
- dgvr.Cells[4].Value = small_l;
- ////毫米转微米
- //decimal A = Convert.ToDecimal(small_l * 1);
- ////dgvr.Cells[4].Value = small_l;// Math.Round(A, Convert.ToInt32(this.numericUpDown1_0.Value));
- //double[] lengths = {453, 320 , 269, 226, 190, 177, 160, 135, 113, 106,
- // 95.0, 89.0, 80.0, 67.3, 62.0, 56.6, 53.2, 47.6, 44.3, 40.0, 35.4, 33.6, 31.0,
- // 28.3, 26.6 , 23.8, 22.2, 20.0, 17.7, 16.8, 14.1, 13.3, 11.9,
- // 10.0, 8.86, 8.41, 7.98, 7.07, 6.20, 5.95, 5.32, 5.00, 4.43, 4.20, 3.54, 2.97
- //, 2.66, 2.50, 2.22};
- //// 差值
- //decimal differenceNew;
- //decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 1.22, (double)A - 454)));
- //int first = 0;
- //if ((double)A < lengths[lengths.Length - 1])
- // first = lengths.Length - 1;
- //else
- // for (int firstI = 0; firstI < lengths.Length; firstI++)
- // {
- // double item = lengths[firstI];
- // differenceNew = Math.Abs(A - Convert.ToDecimal(item));
- // if (differenceNew < differenceOld)
- // {
- // differenceOld = Math.Abs(A - Convert.ToDecimal(item));
- // first = firstI;
- // }
- // }
- //string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5"/**/, "2.0", "2.5", "3.0", "3.0",
- // "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
- // "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
- // "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
- //, "13.5", "14.0", "14.0"};
- dgvr.Cells[5].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;// valueG[first];
- this.dataGridView2.Rows.Add(dgvr);
- dataTable.TableName = tag;
- foreach (System.Data.DataTable dataTable1 in dataTables)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTables.Remove(dataTable1);
- break;
- }
- }
- for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
- {
- dataTable.Columns.Add("" + i);
- }
- DataRow dataRow = dataTable.NewRow();
- dataRow["0"] = imgName;
- dataRow["1"] = dgvr.Cells[1].Value;// "网格1";
- dataRow["2"] = dgvr.Cells[2].Value;
- dataRow["3"] = dgvr.Cells[3].Value;
- dataRow["4"] = dgvr.Cells[4].Value;
- dataRow["5"] = dgvr.Cells[5].Value;
- //dataRow["6"] = dgvr.Cells[6].Value;
- dataTable.Rows.Add(dataRow);
- this.dataTables.Add(dataTable);
- if (this.allShow)
- AllShow();
- this.RefreshDataGridView4();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.selectPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);// this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- //if (true)
- //{ }//0914###18810
- if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- Mat targetMat = this.PhaseModel0Mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass/*Draw*/(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- ////保存处理后的图片
- //List<Bitmap> tempBit = new List<Bitmap>();
- ////Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- ////tempBit.Add(originalBit);
- ////Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- ////Graphics graphics = Graphics.FromImage(newBit);
- ////Draw(graphics);
- ////tempBit.Add(newBit);
- //foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitCeDingDic)
- //{
- // tempBit.Add(kv.Value[0]);
- // tempBit.Add(kv.Value[1]);
- //}
- //if (bitDic.ContainsKey(tag))
- // bitDic[tag] = tempBit;
- //else
- // bitDic.Add(tag, tempBit);
- //中间数据-拼接中间数据
- List<List<string>> dataList = new List<List<string>>();
- List<string> columnName = new List<string>();
- columnName.Add("编号"/*PdnResources.GetString("Menu.Tools.GridLine.Text")*/);
- columnName.Add("截距长度"/*PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text")*/);
- //columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text"));
- //columnName.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
- dataList.Add(columnName);
- foreach (DataGridViewRow Row in this.dataGridView1.Rows)
- {
- List<string> strList = new List<string>();
- strList.Add(Row.Cells[0].Value.ToString());
- strList.Add(Row.Cells[1].Value.ToString());
- //strList.Add(Row.Cells[2].Value.ToString());
- //strList.Add(Row.Cells[3].Value.ToString());
- dataList.Add(strList);
- }
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(tag))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
- newModel.tagName = tag;
- newModel.picName = imgName;
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- }
- /// <summary>
- /// 是否显示晶界
- /// </summary>
- /// <returns></returns>
- protected override Boolean ShowGrainBoundryChecked()
- {
- return checkBox3_0.Checked;
- }
- //是否绘制辅助线
- protected override bool showGridChecked()
- {
- return false;// checkBox4.Checked;
- }
- //是否绘制截点
- protected override bool drawGuidePoints()
- {
- return false;// (matOrg != null && this.checkBox5_0.Checked);
- }
- //是否显示截点
- protected override Boolean drawDisplaySections()//##1
- {
- return false;// this.checkBox5_0.Checked;
- }
- //辅助线类型
- protected override string[] getTypeNames()
- {
- return new string[] {
- PdnResources.GetString("Menu.Verticalauxiliaryline.text"),
- PdnResources.GetString("Menu.Horizontalauxiliaryline.text"),
- PdnResources.GetString("Menu.Singlecircleauxiliaryline.text"),
- PdnResources.GetString("Menu.Three-circleauxiliaryline.text"),
- PdnResources.GetString("Menu.Compositeauxiliaryline.text")};
- }
- protected override string getTemplateName()
- {
- return "Template.Manager.item3.GrainSizeCutOffManualMethod";// "Template.Manager.item3.GrainSizeCutOff6394Method";
- }
- protected override string getProjectEngineeringName()
- {
- return "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text";
- }
- protected override string getModelName()
- {
- return "GrainSizeGuideStyleModel.xml";
- }
- protected override void SubclassInitialize()
- {
- InitializeComponent();
- InitializeComponentText();
- DetailListNotDoubleIndex.Add(0);
- //DetailListNotDoubleIndex.Add(1);
- IndexChangedFromIndex.Clear();
- IndexChangedToIndex.Clear();
- IndexChangedFromIndex.Add(1);
- IndexChangedFromIndex.Add(2);
- IndexChangedFromIndex.Add(3);
- IndexChangedFromIndex.Add(4);
- IndexChangedFromIndex.Add(5);
- IndexChangedToIndex.Add(0, new int[] { 2, 0 });//平均
- IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//求和
- IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
- IndexChangedToIndex.Add(3, new int[] { 2/*3*/, 3 });//级别
- IndexChangedToIndex.Add(4, new int[] { 2, 4 });//平均
- for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
- {
- this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- }
- //for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
- //{
- // this.dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- //}
- //for (int i = 0; i < this.dataGridView4.Columns.Count; i++)
- //{
- // this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
- //}
- }
- #endregion
- private void MethodCutOffDialog_Load(object sender, EventArgs e)
- {
- this.button_ApplyToAll.Visible = false;
- this.button_SaveAll.Visible = false;
- this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
- this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
- object ShowGrainBoundry;
- if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
- this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
- //if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
- // this.checkBox4.Checked = (bool)ShowGrainBoundry;
- //if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
- // this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
- this.groupBox3.Visible = false;
- this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.ColumnTotal2,
- this.ColumnTotal3,
- this.ColumnTotal4,
- this.ColumnTotal5,
- this.ColumnTotal6});
- //
- // ColumnTotal1
- //
- this.ColumnTotal1.Name = "ColumnTotal1";
- this.ColumnTotal1.ReadOnly = true;
- //
- // ColumnTotal2
- //
- this.ColumnTotal2.Name = "ColumnTotal2";
- this.ColumnTotal2.ReadOnly = true;
- //
- // ColumnTotal3
- //
- this.ColumnTotal3.Name = "ColumnTotal3";
- this.ColumnTotal3.ReadOnly = true;
- //
- // ColumnTotal4
- //
- this.ColumnTotal4.Name = "ColumnTotal4";
- this.ColumnTotal4.ReadOnly = true;
- //
- // ColumnTotal5
- //
- this.ColumnTotal5.Name = "ColumnTotal5";
- this.ColumnTotal5.ReadOnly = true;
- //
- // ColumnTotal6
- //
- this.ColumnTotal6.Name = "ColumnTotal6";
- this.ColumnTotal6.ReadOnly = true;
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4,
- this.Column5,
- this.Column6});
- //
- // Column1
- //
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
- // Column3
- //
- this.Column3.Name = "Graisize";
- this.Column3.ReadOnly = true;
- //
- // Column4
- //
- this.Column4.Name = "Grainnumber";
- this.Column4.ReadOnly = true;
- //
- // Column5
- //
- this.Column5.Name = "Grainintercept";
- this.Column5.ReadOnly = true;
- //
- // Column6
- //
- this.Column6.Name = "Graingrade";
- this.Column6.ReadOnly = true;
- this.dataGridViewTextBoxColumn9.HeaderText = "编号";// PdnResources.GetString("Menu.packet.text");
- this.dataGridViewTextBoxColumn10.HeaderText = "截距长度";// PdnResources.GetString("Menu.Depthofnitridinglayer.text");
- //this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
- //this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
- this.button2.Text = "选择截距";
- this.button10.Text = "删除截距";
- this.button7_0.Text = "添加截距";
- this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
- //this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
- //this.checkBox4.Text = PdnResources.GetString("Menu.displaygrid.text");
- this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
- this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Intersectinggrainnumber.Text");
- this.ColumnTotal2.HeaderText = "截距数量";//PdnResources.GetString("Menu.Numberofgrainsingrid.Text");
- this.ColumnTotal3.HeaderText = "最大截距";// PdnResources.GetString("Menu.Totalmeshlength.Text") + "(μm)";
- this.ColumnTotal4.HeaderText = "最小截距";// PdnResources.GetString("Menu.umberofpoints.Text");
- this.ColumnTotal5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";
- this.ColumnTotal6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
- this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.Column2.HeaderText = "截距数量";// PdnResources.GetString("Menu.Tools.GridLine.Text");
- this.Column3.HeaderText = "最大截距";// PdnResources.GetString("Menu.Gridlength.text") + "(μm)";
- this.Column4.HeaderText = "最小截距";// PdnResources.GetString("Menu.Thenumberofsections.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";// "平均截距";//
- this.Column6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");// "";//
- this.Text = "手动测量";// "GBT6394_2017(" + PdnResources.GetString("Menu.sectionmethod.text") + ")";
- //this.groupBox_img.Size = new System.Drawing.Size(158, 722);
- //this.groupBox_review.Size = new System.Drawing.Size(575, 722);
- //this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 800);
- //this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 800);
- //this.groupBox_report.Location = new System.Drawing.Point(974, 800);
- }
- ///// <summary>
- ///// 是否显示网格
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void checkBox4_CheckedChanged(object sender, EventArgs e)
- //{
- // this.documentWorkspace.Refresh();
- //}
- ///// <summary>
- ///// 是否显示截点
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
- //{
- // if (!this.checkBox4.Checked)
- // MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
- // this.documentWorkspace.Refresh();
- //}
- /// <summary>
- /// 是否显示晶界
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
- {
- if (this.documentWorkspace.PhaseModels.Count > 0)
- {
- if (!bcOriginChecked() && getGrainBoundryChecked() && checkBox3_0.Checked)
- {
- this.documentWorkspace.PhaseModels[1].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[1].choise = false;
- }
- }
- this.documentWorkspace.Refresh();
- }
- protected override void refreshWhileImgChanged()
- {
- object ShowGrainBoundry;
- if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
- this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
- //base.refreshWhileImgChanged();
- if (getCurrentWorkspace() != null/* && this.listView1.FocusedItem.Selected*/)
- this.unitLength = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
- rectangleFs.Clear();
- ////二值化集成4
- //binaryClass.listView1_SelectedIndexChanged(this.bitmap);
- rectangleFsArr = new RectangleF[] { };
- rectangleFs.Clear();
- pointFsLine = new PointF[] { };
- this.dataGridView1.Rows.Clear();
- selectLineIndex = -1;
- rectangleFsLines.Clear();
- }
- protected override void onMouseUp(object sender, MouseEventArgs e)
- {
- //base.onMouseUp(sender, e);
- canAdd = false;
- canMove = false;
- movePointIndex = -1;
- RefrashData();
- if (mouseStatus == 2)
- SelectDataRow();
- }
- /// <summary>
- /// 相颜色点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panelC_Click(object sender, EventArgs e)
- {
- this.panelC = (Panel)sender;
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
- this.colorsFormGrid.ShowDialog();
- }
- /// <summary>
- /// PanelC的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gridColorChanged(object sender, EventArgs e)
- {
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panelC.BackColor = color;
- this.documentWorkspace.Refresh();
- //关闭色板
- this.colorsFormGrid.Close();
- }
- private void SelectDataRow()
- {
- if (this.dataGridView1.Rows.Count > selectLineIndex && selectLineIndex >= 0)
- this.dataGridView1.Rows[selectLineIndex].Selected = true;
- if (dataGridView1.SelectedRows.Count > 0)
- selectLineIndex = dataGridView1.SelectedRows[0].Index;
- }
- /// <summary>
- /// 刷新数据展示
- /// </summary>
- private void RefrashData()
- {
- canChange = true;
- if (this.rectangleFs.Count == 0)
- return;
- this.dataGridView1.Rows.Clear();
- int count = 0;
- double lengthMax = 0;
- double lengthMin = 0;
- if (rectangleFs.Count > 0)
- {
- foreach (var item in rectangleFs)
- {
- lengthMin = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
- break;
- }
- }
- foreach (var item in rectangleFs)
- {
- count++;
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
- dgvr.Cells[0].Value = ""/*"L"*/ + count;
- if (length < lengthMin)
- lengthMin = length;
- if (length > lengthMax)
- lengthMax = length;
- dgvr.Cells[1].Value = this.DecnumString(length.ToString());// Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView1.Rows.Add(dgvr);
- }
- labelMax.Text = this.DecnumString(lengthMax.ToString());
- labelMin.Text = this.DecnumString(lengthMin.ToString());
- labelNum.Text = rectangleFs.Count.ToString();
- dataTable = new DataTable();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dataTable.Columns.Add(Column.HeaderText);
- }
- count = 0;
- foreach (var item in rectangleFs)
- {
- count++;
- DataRow dataRow = dataTable.NewRow();
- double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
- dataRow[0] = ""/*"L"*/ + count;
- dataRow[1] = length;
- this.dataTable.Rows.Add(dataRow);
- }
- double allLength = 0;
- for (int i = 0; i < dataTable.Rows.Count; i++)
- {
- allLength += Convert.ToDouble(dataTable.Rows[i][1]);
- }
- DataGridViewRow dgvr1 = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dgvr1.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr1.Cells[0].Value = PdnResources.GetString("Menu.Image.Average.Text");
- dgvr1.Cells[1].Value = this.DecnumString(allLength / this.dataTable.Rows.Count + "");// Math.Round(allLength / this.dataTable.Rows.Count, Convert.ToInt32(this.numericUpDown1.Value));
- this.dataGridView1.Rows.Add(dgvr1);
- canChange = false;
- if (this.dataGridView1.DisplayedRowCount(false) == this.dataGridView1.RowCount)//#####################
- {
- //没有
- this.dataGridViewTextBoxColumn10.Width = 242;
- }
- else
- {
- //有
- this.dataGridViewTextBoxColumn10.Width = 227;
- }
- }
- PointF point1;
- protected override void onMouseMove(object sender, MouseEventArgs e)
- {
- base.onMouseMove(sender, e);
- // 换算后的点
- this.point1 = documentWorkspace.GetScalePoint(e.Location);
- // 全方位线
- if (lineStyle == 0)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- PointF startPoint = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + 6);
- PointF endPoint = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + 6);
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- System.Drawing.Point point3 = new System.Drawing.Point();
- System.Drawing.Point point4 = new System.Drawing.Point();
- System.Drawing.Point point5 = new System.Drawing.Point();
- System.Drawing.Point point6 = new System.Drawing.Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- pointFsLine[0] = point3;
- pointFsLine[1] = point4;
- pointFsLine[2] = point6;
- pointFsLine[3] = point5;
- }
- }
- // 水平线
- else if (lineStyle == 1)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(point1.X - 6, rectangleFsArr[0].Y, 12, 12);
- pointFsLine[0] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
- pointFsLine[1] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
- pointFsLine[3] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
- pointFsLine[2] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
- }
- }
- // 垂直线
- else if (lineStyle == 2)
- {
- if (mouseStatus == 0 && canAdd)
- {
- rectangleFsArr[1] = new RectangleF(rectangleFsArr[0].X, point1.Y - 6, 12, 12);
- pointFsLine[0] = new PointF(rectangleFsArr[0].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, rectangleFsArr[0].Y + 6);
- pointFsLine[1] = new PointF(rectangleFsArr[0].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, rectangleFsArr[0].Y + 6);
- pointFsLine[3] = new PointF(rectangleFsArr[1].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, rectangleFsArr[1].Y + 6);
- pointFsLine[2] = new PointF(rectangleFsArr[1].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, rectangleFsArr[1].Y + 6);
- }
- }
- if (this.mouseStatus == 2 && canMove)
- {
- if (this.selectLineIndex != -1)
- {
- int indexRectangleFs = -1;
- foreach (var item in rectangleFs)
- {
- indexRectangleFs++;
- if (selectLineIndex == indexRectangleFs)
- {
- // 全方位线
- if (item.Value == 0)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
- PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- System.Drawing.Point point3 = new System.Drawing.Point();
- System.Drawing.Point point4 = new System.Drawing.Point();
- System.Drawing.Point point5 = new System.Drawing.Point();
- System.Drawing.Point point6 = new System.Drawing.Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- int indexRectangleFsLines = -1;
- foreach (var item1 in rectangleFsLines)
- {
- indexRectangleFsLines++;
- if (indexRectangleFsLines == indexRectangleFs)
- {
- item1.Key[0] = point3;
- item1.Key[1] = point4;
- item1.Key[2] = point6;
- item1.Key[3] = point5;
- //item1.Key[0] = new PointF(point3.X + 6, point3.Y + 9);
- //item1.Key[1] = new PointF(point4.X + 6, point3.Y - 9);
- //item1.Key[2] = new PointF(point6.X + 6, point6.Y + 9);
- //item1.Key[3] = new PointF(point5.X + 6, point3.Y - 9);
- }
- }
- }
- // 水平线
- else if (item.Value == 1)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(point1.X - 6, item.Key[1].Y, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(point1.X - 6, item.Key[0].Y, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- int selectIndex = -1;
- foreach (var item1 in rectangleFsLines)
- {
- selectIndex++;
- if (selectIndex == selectLineIndex)
- {
- item1.Key[0] = new PointF(item.Key[0].X + 6, item.Key[0].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
- item1.Key[1] = new PointF(item.Key[0].X + 6, item.Key[0].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
- item1.Key[3] = new PointF(item.Key[1].X + 6, item.Key[1].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
- item1.Key[2] = new PointF(item.Key[1].X + 6, item.Key[1].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
- }
- }
- }
- // 垂直线
- else if (item.Value == 2)
- {
- // 线条起始点移动
- if (movePointIndex == 0)
- {
- item.Key[0] = new RectangleF(item.Key[1].X, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 1)
- {
- item.Key[1] = new RectangleF(item.Key[0].X, point1.Y - 6, 12, 12);
- }
- else if (movePointIndex == 2)
- {
- item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
- movePointStart = point1;
- }
- int selectIndex = -1;
- foreach (var item1 in rectangleFsLines)
- {
- selectIndex++;
- if (selectIndex == selectLineIndex)
- {
- item1.Key[0] = new PointF(item.Key[0].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, item.Key[0].Y + 6);
- item1.Key[1] = new PointF(item.Key[0].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, item.Key[0].Y + 6);
- item1.Key[3] = new PointF(item.Key[1].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, item.Key[1].Y + 6);
- item1.Key[2] = new PointF(item.Key[1].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, item.Key[1].Y + 6);
- }
- }
- }
- }
- }
- }
- }
- this.documentWorkspace.Refresh();
- }
- protected override void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
- {
- //base.drawSubclass(graphics);
- Pen linePen = new Pen(this.panel2.BackColor, Convert.ToInt32(this.numericUpDown3.Value));
- Pen linePen1 = new Pen(this.panel1.BackColor, Convert.ToInt32(this.numericUpDown3.Value));
- //linePen.CustomStartCap = lineCap;
- //linePen.CustomEndCap = lineCap;
- int drawIndex = -1;
- foreach (var item in rectangleFs)
- {
- drawIndex++;
- if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
- {
- linePen.DashStyle = DashStyle.DashDot;
- }
- else
- linePen.DashStyle = DashStyle.Solid;
- graphics.DrawLine(linePen, new PointF(item.Key[0].X + 6, item.Key[0].Y + 6), new PointF(item.Key[1].X + 6, item.Key[1].Y + 6));
- PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
- PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
- double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(startPoint.X) + 6, Convert.ToInt32(startPoint.Y) + 6), new System.Drawing.Point(Convert.ToInt32(endPoint.X) + 6, Convert.ToInt32(endPoint.Y) + 6), getNumericUpDown1Value()) * unitLength;
- //计算需要旋转的角度
- double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
- if (item.Value == 0)
- {
- //
- // 绘制两侧竖线
- //
- double sAngle1 = 270 + angle;
- double eAngle1 = 90 + angle;
- System.Drawing.Point point3 = new System.Drawing.Point();
- System.Drawing.Point point4 = new System.Drawing.Point();
- System.Drawing.Point point5 = new System.Drawing.Point();
- System.Drawing.Point point6 = new System.Drawing.Point();
- if (sAngle1 is double.NaN && eAngle1 is double.NaN)
- {
- }
- else
- {
- point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
- point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
- point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
- point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
- }
- graphics.DrawLine(linePen1, point3, point4);
- graphics.DrawLine(linePen1, point5, point6);
- SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF((point3.X + point5.X) / 2, (point3.Y + point5.Y) / 2);
- PointF cen2 = new PointF((point4.X + point6.X) / 2, (point4.Y + point6.Y) / 2);
- PointF drawP1 = new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2);
- PointF drawP2 = new PointF(cen2.X - sizeF.Width / 2, cen2.Y - sizeF.Height / 2);
- PointF drawP3;
- if (angle < 90)
- drawP3 = drawP1;
- else
- drawP3 = drawP2;
- Matrix mtxSave = graphics.Transform;
- Matrix matrix = graphics.Transform;
- // 画布旋转
- if (angle < 90)
- {
- matrix.RotateAt((float)angle, new PointF(cen1.X, cen1.Y));
- graphics.Transform = matrix;
- }
- else
- {
- angle = BasicCalculationHelper.Angle(endPoint, startPoint, new PointF(endPoint.X, startPoint.Y));
- matrix.RotateAt((float)angle, new PointF(cen2.X, cen2.Y));
- graphics.Transform = matrix;
- }
- graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(this.panel1.BackColor/*Color.Black*/), drawP3);
- //还原为原始旋转矩阵
- graphics.Transform = mtxSave;
- matrix.Dispose();
- }
- else if (item.Value == 1)
- {
- graphics.DrawLine(linePen1, new PointF(startPoint.X, startPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/)
- , new PointF(startPoint.X, startPoint.Y/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/));
- graphics.DrawLine(linePen1, new PointF(endPoint.X, endPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/)
- , new PointF(endPoint.X, endPoint.Y/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/));
- SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF((startPoint.X + endPoint.X) / 2, startPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/);
- graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
- }
- else if (item.Value == 2)
- {
- graphics.DrawLine(linePen1, new PointF(startPoint.X/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/, startPoint.Y)
- , new PointF(startPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, startPoint.Y));
- graphics.DrawLine(linePen1, new PointF(endPoint.X/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/, endPoint.Y)
- , new PointF(endPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, endPoint.Y));
- SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
- PointF cen1 = new PointF(startPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, (startPoint.Y + endPoint.Y) / 2);
- Matrix mtxSave = graphics.Transform;
- Matrix matrix = graphics.Transform;
- matrix.RotateAt((float)90, new PointF(cen1.X, cen1.Y));
- graphics.Transform = matrix;
- graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
- //还原为原始旋转矩阵
- graphics.Transform = mtxSave;
- matrix.Dispose();
- }
- if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
- {
- graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[0]);
- graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[1]);
- }
- }
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int selectIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- selectIndex++;
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //graphics.FillRegion(new SolidBrush(Color.Black), myRegion);
- }
- linePen.Dispose();
- linePen1.Dispose();
- }
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- protected override void OnMouseDown(object sender, MouseEventArgs e)
- {
- if (this.documentWorkspace.CompositionSurface == null)
- return;
- //// 换算后的点
- //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- //if (point1.X <= this.documentWorkspace.CompositionSurface.Width
- // && point1.X >= 0
- // && point1.Y >= 0
- // && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
- //{
- // RectangleF rectangleF;
- // // 复合辅助线
- // int add = GSSClass.GuideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
- // if (add == 0 && GSSClass.styleClass.PointKb > 0)
- // rectangleF = GSSClass.GuideClass.RectangleFLine;
- // //手动添加截点
- // if (this.documentWorkspace.ActiveTool == Annotation.Enum.DrawToolType.InclusionNoEffect && GSSClass.styleClass.OnMouseDownNext(point1, sender, e))
- // GSSClass.styleClass.OnMouseDownFirst(point1, rectangleF, GSSClass.linePointList, e);
- //}
- //if (GSSClass.styleClass.PointKb == 0)
- //{
- // //辅助线缩放
- // GSSClass.GuideClass.OnMouseDown(point1, sender, e);
- // //辅助线移动
- // base.OnMouseDown(sender, e);//##
- //}
- if (e.Button == MouseButtons.Left)
- {
- // 换算后的点
- PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- selectLineIndex = -1;
- if (mouseStatus == 0)
- {
- canAdd = true;
- rectangleFsArr = new RectangleF[2];
- pointFsLine = new PointF[4];
- rectangleFsArr[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
- Dictionary<RectangleF[], int> rectangleFs1 = new Dictionary<RectangleF[], int>();
- foreach (var item in rectangleFs)
- {
- rectangleFs1.Add(item.Key, item.Value);
- }
- rectangleFs = new Dictionary<RectangleF[], int>();
- rectangleFs = rectangleFs1;
- if (lineStyle == 0)
- rectangleFs.Add(rectangleFsArr, 0);
- else if (lineStyle == 1)
- rectangleFs.Add(rectangleFsArr, 1);
- else if (lineStyle == 2)
- rectangleFs.Add(rectangleFsArr, 2);
- if (lineStyle == 0)
- rectangleFsLines.Add(pointFsLine, 0);
- else if (lineStyle == 1)
- rectangleFsLines.Add(pointFsLine, 1);
- else if (lineStyle == 2)
- rectangleFsLines.Add(pointFsLine, 2);
- }
- if (mouseStatus == 2)
- {
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int selectIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- selectIndex++;
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //返回判断点是否在多边形里
- //RectangleF rectangleF = myRegion.GetBounds(rag)
- double L = BasicCalculationHelper.GetDisFromPointToLine(item.Key[0], item.Key[2], point1);
- bool myPoint = L < 10 /*myRegion.IsVisible(point1)*/;
- if (myPoint)
- {
- selectLineIndex = selectIndex;
- break;
- }
- }
- if (selectLineIndex == -1)
- {
- selectIndex = -1;
- foreach (var item in rectangleFs)
- {
- selectIndex++;
- if (item.Key[0].Contains(point1))
- {
- selectLineIndex = selectIndex;
- break;
- }
- else if (item.Key[1].Contains(point1))
- {
- selectLineIndex = selectIndex;
- break;
- }
- }
- }
- //else
- // {
- // if(this.dataGridView1.Rows.Count > selectLineIndex)
- // this.dataGridView1.Rows[selectLineIndex].Selected = true;
- //}
- }
- if (mouseStatus == 2)
- {
- int indexRectangleFs = -1;
- foreach (var item in rectangleFs)
- {
- indexRectangleFs++;
- System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
- Region myRegion;
- int indexRectangleFsLines = -1;
- bool myPoint = false;
- foreach (var item1 in rectangleFsLines)
- {
- indexRectangleFsLines++;
- if (indexRectangleFs == indexRectangleFsLines)
- {
- myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- myRegion = new Region();
- myGraphicsPath.Reset();
- myGraphicsPath.AddPolygon(new PointF[] { item1.Key[0], item1.Key[1], item1.Key[2], item1.Key[3] });
- myRegion.MakeEmpty();
- myRegion.Union(myGraphicsPath);
- //返回判断点是否在多边形里
- //myPoint = myRegion.IsVisible(point1);
- double L = BasicCalculationHelper.GetDisFromPointToLine(item1.Key[0], item1.Key[2], point1);
- myPoint = L < 10 /*myRegion.IsVisible(point1)*/;
- if (myPoint)
- {
- break;
- }
- }
- }
- if (item.Key[0].Contains(point1))
- {
- movePointStart = point1;
- movePointIndex = 0;
- canMove = true;
- }
- else if (item.Key[1].Contains(point1))
- {
- movePointStart = point1;
- movePointIndex = 1;
- canMove = true;
- }
- else if (myPoint)
- {
- movePointStart = point1;
- movePointIndex = 2;
- canMove = true;
- }
- }
- }
- }
- }
- private void AllShow()
- {
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.Tag = this.dataTables[i].TableName;
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
- {
- //if (c > 2 && c < 4)
- // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
- //else
- dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- private void button6_0_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- {
- //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
- GSSClass.styleClass.PointKb = 1;
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- }
- }
- private void button7_0_LostFocus(object sender, EventArgs e)
- {
- this.mouseStatus = -1;
- }
- /// <summary>
- /// 添加测量线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_0_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- {
- this.mouseStatus = 0;
- this.selectLineIndex = -1;
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- }
- }
- private void button8_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- {
- //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
- GSSClass.styleClass.PointKb = 3;
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- }
- }
- /// <summary>
- /// 选择截距
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.mouseStatus = 2;
- this.selectLineIndex = -1;
- }
- /// <summary>
- /// 删除截距
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button10_Click(object sender, EventArgs e)
- {
- this.mouseStatus = 1;
- if (this.mouseStatus == 1)
- {
- if (selectLineIndex == -1)
- {
- MessageBox.Show("请先选择要删除的测量线!");
- return;
- }
- int deleteIndex = -1;
- foreach (var item in rectangleFs)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFs.Remove(item.Key);
- break;
- }
- }
- deleteIndex = -1;
- foreach (var item in rectangleFsLines)
- {
- deleteIndex++;
- if (deleteIndex == selectLineIndex)
- {
- rectangleFsLines.Remove(item.Key);
- break;
- }
- }
- selectLineIndex = 0;
- if (selectLineIndex < -1)
- selectLineIndex = -1;
- if (rectangleFs.Count == 0)
- this.dataGridView1.Rows.Clear();
- if (mouseStatus == 2)
- SelectDataRow();
- RefrashData();
- this.documentWorkspace.Refresh();
- }
- }
- private void dataGridView1_SelectionChanged(object sender, EventArgs e)
- {
- //canChange = true;
- if (!canChange)
- {
- SelectDataRow();
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 获取参数
- /// </summary>
- protected override object saveRecordingData(string key)
- {
- object value = null;
- switch (key)
- {
- case "MainFontSize":
- value = numericUpDown4.Value;
- break;
- case "MainFontColor":
- value = panel1.BackColor.ToArgb();
- break;
- case "MainLineWidth":
- value = numericUpDown3.Value;
- break;
- case "MainLineColor":
- value = panel2.BackColor.ToArgb();
- break;
- }
- return value;
- }
- private void MethodCutOffDialog_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Delete)
- {
- button10_Click(null, null);
- e.Handled = true;
- }
- }
- }
- }
|