1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095 |
- 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;
- 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 dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = 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_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
- //
- dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle22;
- this.dataGridViewTextBoxColumn2.HeaderText = "1";
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.ReadOnly = true;
- this.dataGridViewTextBoxColumn2.Width = 50;
- //
- // dataGridViewTextBoxColumn3
- //
- dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle23;
- this.dataGridViewTextBoxColumn3.HeaderText = ".5";
- this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.ReadOnly = true;
- this.dataGridViewTextBoxColumn3.Width = 50;
- //
- // dataGridViewTextBoxColumn4
- //
- dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle24;
- this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
- this.dataGridViewTextBoxColumn4.ReadOnly = true;
- this.dataGridViewTextBoxColumn4.Width = 55;
- //
- // dataGridViewTextBoxColumn5
- //
- dataGridViewCellStyle25.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle25;
- this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
- this.dataGridViewTextBoxColumn5.ReadOnly = true;
- this.dataGridViewTextBoxColumn5.Width = 69;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle26.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle26.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle26.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle26.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle26.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle26;
- 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
- //
- dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
- this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle27;
- this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
- this.dataGridViewTextBoxColumn9.ReadOnly = true;
- this.dataGridViewTextBoxColumn9.Width = 111;
- //
- // dataGridViewTextBoxColumn10
- //
- dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
- this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle28;
- 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.Location = new System.Drawing.Point(0, 0);
- this.Name = "MethodCutOffDialog";
- this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
- 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_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.matOrg == 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 = 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;
- }
- }
- }
- // 水平线
- 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)
- bool myPoint = 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);
- 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.matOrg != 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.matOrg != 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.matOrg != 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--;
- if (selectLineIndex < -1)
- selectLineIndex = -1;
- if (rectangleFs.Count == 0)
- this.dataGridView1.Rows.Clear();
- RefrashData();
- if (mouseStatus == 2)
- SelectDataRow();
- 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;
- }
- }
- }
|