using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using OpenCvSharp; using PaintDotNet.Annotation; using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.Measure; using PaintDotNet.Annotation.relationModel; using PaintDotNet.Base.CommTool; using static PaintDotNet.Annotation.relationModel.MeasureRelationModel; using Point = System.Drawing.Point; /// /// 光密度 /// namespace PaintDotNet.Measuring { partial class OpticalDensityDialog : FloatingToolForm { #region 控件 /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code private void InitializeLanguageText() { this.button1.Text = PdnResources.GetString("Menu.measuring.text"); this.button2.Text = PdnResources.GetString("Menu.Imagement.Opticaldensity.Dataoutput.text"); this.button3.Text = PdnResources.GetString("Menu.Imagement.Opticaldensity.imageexport.text"); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.groupBox2.Text = PdnResources.GetString("Menu.display.text"); this.Text = PdnResources.GetString("Menu.MeasureAction.OpticalDensity.Text"); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.panel1 = new PaintDotNet.PanelEx(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(161, 29); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; this.button1.Text = "测量"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // button2 // this.button2.Location = new System.Drawing.Point(243, 29); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 5; this.button2.Text = "数据导出"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Location = new System.Drawing.Point(325, 29); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 6; this.button3.Text = "图片导出"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button3); this.groupBox1.Location = new System.Drawing.Point(27, 13); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(420, 75); this.groupBox1.TabIndex = 4; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // panel1 // this.panel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.panel1.BackColor = System.Drawing.SystemColors.ControlLightLight; this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.HideHScroll = false; this.panel1.HideVScroll = false; this.panel1.IgnoreSetFocus = false; this.panel1.Location = new System.Drawing.Point(3, 17); this.panel1.Name = "panel1"; this.panel1.ScrollPosition = new System.Drawing.Point(0, 0); this.panel1.Size = new System.Drawing.Size(414, 315); this.panel1.TabIndex = 0; this.panel1.TabStop = true; this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint_1); this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown_1); this.panel1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseMove_1); this.panel1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseUp); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.groupBox2.BackColor = System.Drawing.SystemColors.Control; this.groupBox2.Controls.Add(this.panel1); this.groupBox2.Location = new System.Drawing.Point(27, 94); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(420, 335); this.groupBox2.TabIndex = 5; this.groupBox2.TabStop = false; this.groupBox2.Text = "显示"; // // OpticalDensityDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(471, 441); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.MaximumSize = new System.Drawing.Size(487, 480); this.MinimumSize = new System.Drawing.Size(487, 480); this.Name = "OpticalDensityDialog"; this.Text = "光密度"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OpticalDensityDialog_FormClosing); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.GroupBox groupBox1; private PanelEx panel1; private System.Windows.Forms.GroupBox groupBox2; #endregion /// /// 主控件 /// private AppWorkspace appWorkspace; /// /// 关系数据 /// private static List list; /// /// 横坐标比例 /// private float proportion; /// /// 灰度值点数 /// private int pointNumber; private Rectangle sRect; private PointF StartPoint = new Point(70, 10); private Rectangle eRect; private PointF EndPoint = new Point(350, 10); Pen pe = new Pen(Color.YellowGreen, 4); private bool sCanMove; private bool eCanMove; private PointF startPoint; private PointF endPoint; private string unitString; private string unit; /// /// 步长 初始值1,依次增加 /// private string stepLength = "00" + Startup.instance.step_length; public OpticalDensityDialog(AppWorkspace appWorkspace) { if (list == null) { list = InvariantData.GetMeasureRelations(); } this.appWorkspace = appWorkspace; InitializeComponent(); InitializeLanguageText(); } /// /// 刷新光密度画面 /// /// /// public void RefreshOpticalDensity(object sender, EventArgs e) { this.panel1.Refresh(); } /// /// 绘制绿线 /// /// private void drawRect(Graphics graphics) { graphics.DrawLine(pe, EndPoint, new PointF(EndPoint.X, EndPoint.Y + 260)); graphics.DrawLine(pe, StartPoint, new PointF(StartPoint.X, StartPoint.Y + 260)); } private void means(Graphics graphics) { sRect = new Rectangle((int)StartPoint.X, (int)StartPoint.Y, 5, 260); eRect = new Rectangle((int)EndPoint.X, (int)EndPoint.Y, 5, 260); StartPoint = sRect.Location; EndPoint = eRect.Location; //graphics.DrawLine(pe, new Point((int)StartPoint.X, 270), new Point((int)StartPoint.X, 10)); //graphics.DrawLine(pe, new Point((int)EndPoint.X, 270), new Point((int)EndPoint.X, 10)); } /// /// 绘制截线 /// private void DrawInMainScreen() { double kS = (StartPoint.X - 70) / 280; double kE = (350 - EndPoint.X) / 280; if (this.appWorkspace.ActiveDocumentWorkspace != null) this.DrawInMainScreen(kS, kE); } public void DrawInMainScreen(double kS, double kE) { //循环所有测量 if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList != null && this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count > 0) { int count = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count; for (int i = 0; i < count; i++) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].objectType == DrawClass.Other) { ((MeasureDrawObject)(this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i])).kS = kS; ((MeasureDrawObject)(this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i])).kE = kE; } } } this.appWorkspace.ActiveDocumentWorkspace.Refresh(); } /// /// 绘制刻度 /// private void Setscale(Graphics graphics) { Font textfont = new Font(Font, FontStyle.Regular); Brush textbrush = new SolidBrush(Color.Black); graphics.DrawLine(new Pen(Color.Black, 2), new Point(70, 270), new Point(350, 270)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(70, 270), new Point(70, 10)); // 纵坐标刻度 graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 270), new Point(70, 270)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 220), new Point(70, 220)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 170), new Point(350, 170)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 120), new Point(70, 120)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 70), new Point(350, 70)); graphics.DrawLine(new Pen(Color.Black, 2), new Point(63, 20), new Point(70, 20)); graphics.DrawString("0", textfont, textbrush, new Point(42, 263)); graphics.DrawString("100", textfont, textbrush, new Point(42, 163)); graphics.DrawString("200", textfont, textbrush, new Point(42, 63)); graphics.DrawString(PdnResources.GetString("Menu.MeasureAction.MeasureDistanceLine.Text") +"(" + unitString + ")", textfont, textbrush, new Point(180, 300)); graphics.DrawString(PdnResources.GetString("Menu.Imagement.Opticaldensity.Linecontour.text"), textfont, textbrush, new Point(180, 0)); graphics.DrawString(PdnResources.GetString("Menu.strong.Text") + "\r\n" + " " + "\r\n" + PdnResources.GetString("Menu.degree.Text"), textfont, textbrush, new Point(20, 5)); // 横坐标刻度 int n; int growth = 70; int scale = 0; graphics.DrawString(scale.ToString(), textfont, textbrush, new Point(65, 280)); if (this.pointNumber <= 200) { n = this.pointNumber / 10; for (int i = 0; i < n; i++) { scale = scale + 10; growth = growth + 280 / n; if ((i + 1) % 2 == 0) { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 10), new Point(growth, 277)); graphics.DrawString(scale.ToString(), textfont, textbrush, new Point(growth, 277)); } else { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 270), new Point(growth, 277)); } } } else if (this.pointNumber > 200 && this.pointNumber <= 1000) { n = this.pointNumber / 100; for (int i = 0; i < n; i++) { scale = scale + 50; growth = growth + 280 / n; if ((i + 1) % 2 == 0) { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 10), new Point(growth, 277)); graphics.DrawString(scale.ToString(), textfont, textbrush, new Point(growth, 277)); } else { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 270), new Point(growth, 277)); } } } else if (this.pointNumber > 1000) { int length1 = Convert.ToInt32(BasicCalculationHelper.GetDistance(startPoint, endPoint, 2)); int f = 280 / 50; for (int i = 0; i < f; i++) { int scale1 = (int)(1000 * i * 50 / 280); //if ((i + 1) % 2 == 0) { //graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 10), new Point(growth, 277)); graphics.DrawString(scale1.ToString(), textfont, textbrush, new Point(50 * i + 70, 277)); } //else { //graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 270), new Point(growth, 277)); } } /* n = this.pointNumber / 200; for (int i = 0; i < n; i++) { scale = scale + 100; growth = growth + 280 / n; if ((i + 1) % 2 == 0) { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 10), new Point(growth, 277)); graphics.DrawString(scale.ToString(), textfont, textbrush, new Point(growth, 277)); } else { graphics.DrawLine(new Pen(Color.Black, 2), new Point(growth, 270), new Point(growth, 277)); } }*/ } } /// /// 绘制灰度图像 /// private void DrawGrayScale(Graphics graphics) { if (this.appWorkspace.ActiveDocumentWorkspace != null && this.appWorkspace.ActiveDocumentWorkspace.GraphicsList != null && this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count > 0) { int count = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count; for (int i = 0; i < count; i++) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].objectType == DrawClass.Other) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].drawToolType == DrawToolType.OpticalDensityLine) { startPoint = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].startPoint; endPoint = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].endPoint; OpenCvSharp.Mat mat = PaintDotNet.Camera.Tools.ToMat( this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap()); //定义线上的点 List linePoint = new List(); Color color = Color.Blue; Pen pen = new Pen(color, 1); double k = 0; double y = 0; double x = 0; if (startPoint.X != endPoint.X) { // 计算斜率 k = ((double)(startPoint.Y - endPoint.Y)) / (startPoint.X - endPoint.X); // 循环x坐标 double maxPointX; double minPointX; if (startPoint.X > endPoint.X) { maxPointX = startPoint.X; minPointX = endPoint.X; } else { maxPointX = endPoint.X; minPointX = startPoint.X; } if (Math.Abs(startPoint.X - endPoint.X) > Math.Abs(startPoint.Y - endPoint.Y)) { for (int j = (int)(minPointX) + 1; j < maxPointX; j++) { if (k == 0 && startPoint.Y == endPoint.Y) { y = startPoint.Y; } else { // 根据斜率,计算y坐标 y = k * (j - startPoint.X) + startPoint.Y; } linePoint.Add(new Point(j, (int)y)); } } else { if (startPoint.Y > endPoint.Y) { maxPointX = startPoint.Y; minPointX = endPoint.Y; } else { maxPointX = endPoint.Y; minPointX = startPoint.Y; } for (int j = (int)(minPointX) + 1; j < maxPointX; j++) { if (k == 0 && startPoint.Y == endPoint.Y) { y = startPoint.Y; } else { // 根据斜率,计算y坐标 x = -((startPoint.Y - j) / k - startPoint.X); } linePoint.Add(new Point((int)x, j)); } } } else { double maxPointY; double minPointY; if (startPoint.Y > endPoint.Y) { maxPointY = startPoint.Y; minPointY = endPoint.Y; } else { maxPointY = endPoint.Y; minPointY = startPoint.Y; } // 循环y坐标 for (int j = (int)(minPointY) + 1; j < maxPointY; j++) { // 根据斜率,计算y坐标 y = j; linePoint.Add(new Point((int)startPoint.X, (int)y)); } } // 灰度值数据 List list0 = new List(); List list1 = new List(); List list2 = new List(); foreach (var point in linePoint) { if(point.X < mat.Width && point.Y < mat.Height && point.Y >= 0 && point.X >= 0) { Vec3b vec3B = new Vec3b(); byte a; if (mat.Type() == MatType.CV_8UC1) { a = mat.At(point.Y, point.X); list0.Add(a); } else { vec3B = mat.At(point.Y, point.X); list0.Add(vec3B.Item0); list1.Add(vec3B.Item1); list2.Add(vec3B.Item2); } } } // 灰度图绘制坐标点 List pointList = new List(); List pointList1 = new List(); List pointList2 = new List(); this.pointNumber = list0.Count; this.proportion = 280 / (float)list0.Count; float px; if (mat.Type() == MatType.CV_8UC1) { px = 70; foreach (var item in list0) { pointList.Add(new PointF(px, 270 - item)); px = px + this.proportion; } if (pointList.Count > 0) { color = Color.Blue; pen = new Pen(color, 1); graphics.DrawLines(pen, pointList.ToArray()); } } else { px = 70; foreach (var item in list0) { pointList.Add(new PointF(px, 270 - item)); px = px + this.proportion; } if (pointList.Count > 0) { color = Color.Blue; pen = new Pen(color, 1); graphics.DrawLines(pen, pointList.ToArray()); } px = 70; foreach (var item in list1) { pointList1.Add(new PointF(px, 270 - item)); px = px + this.proportion; } if (pointList1.Count > 0) { color = Color.Green; pen = new Pen(color, 1); graphics.DrawLines(pen, pointList1.ToArray()); } px = 70; foreach (var item in list2) { pointList2.Add(new PointF(px, 270 - item)); px = px + this.proportion; } if (pointList2.Count > 0) { color = Color.Red; pen = new Pen(color, 1); graphics.DrawLines(pen, pointList2.ToArray()); } } pen.Dispose(); } } } } } private void ExportEcxel() { string fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.pticaldensitydata.Text"); SaveFileDialog exe = new SaveFileDialog(); exe.Filter = "Execl files (*.xlsx)|*.xlsx"; exe.FilterIndex = 0; exe.RestoreDirectory = true; //exe.CreatePrompt = true; exe.Title = "Export Excel File"; exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); exe.FileName = fileName; DialogResult dr = exe.ShowDialog(); if (dr != DialogResult.OK) { return; } double length = BasicCalculationHelper.GetDistance(this.startPoint, this.endPoint, 2); double length2 =Math.Round(length * (Math.Abs(this.StartPoint.X - this.EndPoint.X) / 280), 2); DataTable dtb = new DataTable(); dtb.Columns.Add(PdnResources.GetString("Menu.Measuringpointdistance.Text")); dtb.Columns.Add(PdnResources.GetString("Menu.Measurinlinedistance.Text")); dtb.Columns.Add(PdnResources.GetString("Menu.unit.text")); DataRow dataRow = dtb.NewRow(); dataRow[PdnResources.GetString("Menu.Measuringpointdistance.Text")] = (length * Convert.ToDouble(unit)).ToString(); dataRow[PdnResources.GetString("Menu.Measurinlinedistance.Text")] = (length2 * Convert.ToDouble(unit)).ToString(); dataRow[PdnResources.GetString("Menu.unit.text")] = unitString; dtb.Rows.Add(dataRow); List list = new List(); list.Add(dtb); this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false,false, true); } /// /// 测量按钮按下 /// /// /// private void button1_Click(object sender, EventArgs e) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count == 0) { if (appWorkspace.ActiveDocumentWorkspace != null) { appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.OpticalDensityLine; } } else { bool other = false; int count = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count; for (int i = 0; i < count; i++) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].objectType == DrawClass.Other && this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].drawToolType == DrawToolType.OpticalDensityLine) { other = true; this.button1.Tag = this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i]; } } if(!other) { if (appWorkspace.ActiveDocumentWorkspace != null) { appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.OpticalDensityLine; } } else { if (this.button1.Tag != null) { var senderGrid = (Button)sender; DrawObject dObject; this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.UnselectAll(); dObject = (DrawObject)senderGrid.Tag; dObject.Selected = true; } } this.appWorkspace.ActiveDocumentWorkspace.Refresh(); } this.panel1.Focus(); } /// /// 数据导出按钮 /// /// /// private void button2_Click(object sender, EventArgs e) { this.ExportEcxel(); } /// /// 绘制事件 /// /// /// private void panel1_Paint_1(object sender, PaintEventArgs e) { unitString = this.appWorkspace.GetPxPerUnit()[1]; unit = this.appWorkspace.GetPxPerUnit()[3]; this.DrawGrayScale(e.Graphics); this.Setscale(e.Graphics); this.DrawGrayScale(e.Graphics); this.means(e.Graphics); this.drawRect(e.Graphics); DrawInMainScreen(); } /// /// 鼠标移动事件 /// /// /// private void panel1_MouseMove_1(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && (sCanMove == true || eCanMove == true)) { if (sCanMove == true && eCanMove == true) eCanMove = false; if (sCanMove == true) sRect.Offset((int)(e.X - StartPoint.X), 0); if (eCanMove == true) eRect.Offset((int)(e.X - EndPoint.X), 0); if (sRect.X < 70) sRect.X = 70; if (sRect.X > 350) sRect.X = 350; if (eRect.X < 70) eRect.X = 70; if (eRect.X > 350) eRect.X = 350; StartPoint = new Point(sRect.X, sRect.Y); EndPoint = new Point(eRect.X, eRect.Y); this.panel1.Refresh(); } } /// /// 鼠标按下事件 /// /// /// private void panel1_MouseDown_1(object sender, MouseEventArgs e) { if (sRect.Contains(e.Location)) { sCanMove = true; } if (eRect.Contains(e.Location)) { eCanMove = true; } } /// /// 鼠标抬起事件 /// /// /// private void panel1_MouseUp(object sender, MouseEventArgs e) { sCanMove = false; eCanMove = false; } private void button3_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(panel1.Width, panel1.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); panel1.DrawToBitmap(bmp, new Rectangle(0, 0, panel1.Width, panel1.Height)); DocumentWorkspace dw = appWorkspace.AddNewDocumentWorkspace(); Document document = Document.FromImageMat(Camera.Tools.ToMat(bmp)); dw.Document = document; dw.xmlSaveModel = Startup.instance.ruleDB; dw.InitRulerInfo(); dw.fileText = this.Text + "-" + stepLength; appWorkspace.ActiveDocumentWorkspace = dw; Startup.instance.step_length += 1; stepLength = "00" + Startup.instance.step_length; } private void OpticalDensityDialog_FormClosing(object sender, FormClosingEventArgs e) { if (this.appWorkspace.ActiveDocumentWorkspace != null) { this.appWorkspace.toolBar.RefreshBtnSelect(false, "OpticalDensity"); this.appWorkspace.toolsPanel.RefreshBtnSelect(false, "OpticalDensity"); for (int i = 0; i < this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.Count; i++) { if (this.appWorkspace.ActiveDocumentWorkspace.GraphicsList[i].drawToolType == DrawToolType.OpticalDensityLine) { this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.RemoveAt(i); this.appWorkspace.Refresh(); } } } } } }