using PaintDotNet.Base.SettingModel; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass { /// /// 需要根据当前操作图片备份和读取的辅助线数据 /// class GrainSizeGuideModel { public string oldSelectItem; /// /// 辅助线位置 /// public PointF loctation; /// /// 辅助线区域 /// public RectangleF rectangleFLine = new RectangleF(); //辅助线缩放控制 public float originWidth = 1; public float originHeight = 1; //辅助线缩放控制(物理长度) public float rectangleFLineWidth = 1; public float rectangleFLineHeight = 1; /// /// 矩形宽 /// public double lineRectangleWidth; public double originLineRectangleWidth; /// /// 矩形高 /// public double lineRectangleHeight; public double originLineRectangleHeight; /// /// 直径 /// public double lineDiameter; public double originLineDiameter; /// /// 长度(物理长度) /// public int lineLength; public float mat_lineLength; public double originLineLength; /// /// 间距 /// public float mat_lineSpacing; public double originMat_lineSpacing; private double originLineSpacing; /// /// 线条数 /// public int lineDec; /// /// 直径(物理长度) /// public double diameter; public float mat_diameter; public double originDiameter; /// /// 边距(物理长度) /// public double margin; public float mat_margin; public double originMargin; /// /// 长度(垂线)(物理长度) /// private double originVLineLength; public int vLineLength; public float mat_vLineLength; /// /// 长度(水平线)(物理长度) /// private double originHLineLength; public int hLineLength; public float mat_hLineLength; /// /// 左上到右下斜线长度(物理长度) /// private double originTopleftLineLength; public int TopleftLineLength; public float mat_TopleftLineLength; /// /// 左下到右上斜线长度(物理长度) /// private double originToprightLineLength; public int ToprightLineLength; public float mat_ToprightLineLength; /// /// 垂线到圆距离 /// private float VLineToCDistance; public float mat_VLineToCDistance; public double originVLineToCDistance; /// /// 水平线到圆距离(物理长度) /// private float HLineToCDistance; public float mat_HLineToCDistance; public double originHLineToCDistance; /// /// 线颜色 /// public int lineColor; /// /// 线宽 /// public int lineWidth; /// /// 找到当前的参数数据 /// /// /// public GrainSizeGuideModel cloneListParamModel() { GrainSizeGuideModel newMod = new GrainSizeGuideModel(); newMod.oldSelectItem = this.oldSelectItem;//###################################### ////newMod.ListParam = new List(); ////foreach (var item in this.ListParam) //// if (item.menuId == menuId) //// newMod.ListParam.Add(item.cloneModel()); return newMod; } public GrainSizeGuideModel cloneModel() { GrainSizeGuideModel newMod = new GrainSizeGuideModel(); newMod.oldSelectItem = this.oldSelectItem; newMod.loctation = new PointF(loctation.X, loctation.Y); newMod.rectangleFLine = new RectangleF(rectangleFLine.X, rectangleFLine.Y, rectangleFLine.Width, rectangleFLine.Height); newMod.originWidth = this.originWidth; newMod.originHeight = this.originHeight; newMod.rectangleFLineWidth = this.rectangleFLineWidth; newMod.rectangleFLineHeight = this.rectangleFLineHeight; newMod.lineRectangleWidth = this.lineRectangleWidth; newMod.originLineRectangleWidth = this.originLineRectangleWidth; newMod.lineRectangleHeight = this.lineRectangleHeight; newMod.originLineRectangleHeight = this.originLineRectangleHeight; newMod.lineDiameter = this.lineDiameter; newMod.originLineDiameter = this.originLineDiameter; newMod.lineLength = this.lineLength; newMod.mat_lineLength = this.mat_lineLength; newMod.originLineLength = this.originLineLength; newMod.mat_lineSpacing = this.mat_lineSpacing; newMod.originMat_lineSpacing = this.originMat_lineSpacing; newMod.originLineSpacing = this.originLineSpacing; newMod.lineDec = this.lineDec; newMod.diameter = this.diameter; newMod.mat_diameter = this.mat_diameter; newMod.originDiameter = this.originDiameter; newMod.margin = this.margin; newMod.mat_margin = this.mat_margin; newMod.originMargin = this.originMargin; newMod.vLineLength = this.vLineLength; newMod.mat_vLineLength = this.mat_vLineLength; newMod.hLineLength = this.hLineLength; newMod.mat_hLineLength = this.mat_hLineLength; newMod.TopleftLineLength = this.TopleftLineLength; newMod.mat_TopleftLineLength = this.mat_TopleftLineLength; newMod.ToprightLineLength = this.ToprightLineLength; newMod.mat_ToprightLineLength = this.mat_ToprightLineLength; newMod.VLineToCDistance = this.VLineToCDistance; newMod.mat_VLineToCDistance = this.mat_VLineToCDistance; newMod.originVLineToCDistance = this.originVLineToCDistance; newMod.HLineToCDistance = this.HLineToCDistance; newMod.mat_HLineToCDistance = this.mat_HLineToCDistance; newMod.originHLineToCDistance = this.originHLineToCDistance; newMod.lineColor = this.lineColor; newMod.lineWidth = this.lineWidth; return newMod; } public RectangleF RectangleFLine { get { return this.rectangleFLine; } set { this.rectangleFLine = value; } } /// /// 绘制辅助线(垂直辅助线) /// public void DrawGuideLines1(Graphics graphics) { Matrix mtxSave = graphics.Transform; Matrix matrix = graphics.Transform; // 以下为绘制样式 Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth); if (this.lineDec % 2 == 0) { float Spacing = (float)this.mat_lineSpacing / 2; for (int i = 0; i < (float)this.lineDec / 2; i++) { graphics.DrawLine(linePen, new PointF((float)this.rectangleFLine.X + this.lineWidth / 2 + (this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Top) , new PointF((float)this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Bottom)); graphics.DrawLine(linePen, new PointF((float)this.rectangleFLine.X + this.lineWidth / 2 + (this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Top) , new PointF((float)this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Bottom)); Spacing += this.mat_lineSpacing; } } else { if (this.lineDec == 1) { graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Top) , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Bottom)); } else { float Spacing = this.mat_lineSpacing; for (int i = 0; i < (this.lineDec - 1) / 2; i++) { if (i == 0) graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Top) , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Bottom)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Top) , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Bottom)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Top) , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Bottom)); Spacing += this.mat_lineSpacing; } } } Pen pen = new Pen(Color.FromArgb(this.lineColor), 1); pen.DashStyle = DashStyle.DashDotDot; //使用自定义线型 float[] dashArray = { 2.0f, //线长2个像素 5.0f, //间断5个像素 2.0f, //线长2个像素 5.0f //间断5个像素 }; pen.DashPattern = dashArray; graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height)); pen.Dispose(); //显示辅助线像素长度 SizeF sizeF = graphics.MeasureString("" + this.lineLength, new System.Drawing.Font("宋体", 20)); matrix.RotateAt((float)270, new PointF(this.rectangleFLine.Left - sizeF.Height, this.rectangleFLine.Top + sizeF.Width)); graphics.Transform = matrix; graphics.DrawString("" + this.lineLength, new System.Drawing.Font("宋体", 20), new SolidBrush(Color.Black), new PointF(this.rectangleFLine.Left - sizeF.Height, this.rectangleFLine.Top + sizeF.Width)); graphics.Transform = mtxSave; } /// /// 绘制辅助线(水平辅助线) /// public void DrawGuideLines2(Graphics graphics) { // 以下为绘制样式 Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth); if (this.lineDec % 2 == 0) { float Spacing = (float)this.mat_lineSpacing / 2; for (int i = 0; i < (float)this.lineDec / 2; i++) { graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing)); Spacing += this.mat_lineSpacing; } } else { if (this.lineDec == 1) { graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2)); } else { float Spacing = this.mat_lineSpacing; for (int i = 0; i < (this.lineDec - 1) / 2; i++) { if (i == 0) graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing) , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing)); Spacing += this.mat_lineSpacing; } } } Pen pen = new Pen(Color.FromArgb(this.lineColor), 1); pen.DashStyle = DashStyle.DashDotDot; //使用自定义线型 float[] dashArray = { 2.0f, //线长2个像素 5.0f, //间断5个像素 2.0f, //线长2个像素 5.0f //间断5个像素 }; pen.DashPattern = dashArray; graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height)); pen.Dispose(); //显示辅助线像素长度 SizeF sizeF = graphics.MeasureString("" + this.lineLength, new System.Drawing.Font("宋体", 20)); graphics.DrawString("" + this.lineLength, new System.Drawing.Font("宋体", 20), new SolidBrush(Color.Black), new PointF(this.rectangleFLine.Right - sizeF.Width, this.rectangleFLine.Top - sizeF.Height)); } /// /// 绘制辅助线(单圆辅助线) /// public void DrawGuideLines3(Graphics graphics) { // 以下为绘制样式 Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth); graphics.DrawEllipse(linePen, this.rectangleFLine.X, this.rectangleFLine.Y, this.rectangleFLine.Width, this.rectangleFLine.Height); Pen pen = new Pen(Color.FromArgb(this.lineColor), 1); pen.DashStyle = DashStyle.DashDotDot; //使用自定义线型 float[] dashArray = { 2.0f, //线长2个像素 5.0f, //间断5个像素 2.0f, //线长2个像素 5.0f //间断5个像素 }; pen.DashPattern = dashArray; graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height)); pen.Dispose(); } /// /// 绘制辅助线(三圆辅助线) /// public void DrawGuideLines4(Graphics graphics) { // 以下为绘制样式 Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth); graphics.DrawEllipse(linePen, this.rectangleFLine.X, this.rectangleFLine.Y, this.rectangleFLine.Width, this.rectangleFLine.Height); graphics.DrawEllipse(linePen, this.rectangleFLine.X + this.mat_margin, this.rectangleFLine.Y + this.mat_margin, this.rectangleFLine.Width - 2 * this.mat_margin, this.rectangleFLine.Height - 2 * this.mat_margin); graphics.DrawEllipse(linePen, this.rectangleFLine.X + 2 * this.mat_margin, this.rectangleFLine.Y + 2 * this.mat_margin, this.rectangleFLine.Width - 4 * this.mat_margin, this.rectangleFLine.Height - 4 * this.mat_margin); Pen pen = new Pen(Color.FromArgb(this.lineColor), 1); pen.DashStyle = DashStyle.DashDotDot; //使用自定义线型 float[] dashArray = { 2.0f, //线长2个像素 5.0f, //间断5个像素 2.0f, //线长2个像素 5.0f //间断5个像素 }; pen.DashPattern = dashArray; graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height)); pen.Dispose(); } /// /// 绘制辅助线(复合辅助线) /// public void DrawGuideLines5(Graphics graphics) { // 以下为绘制样式 Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X, this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2 - this.mat_vLineLength / 2) , new PointF(this.rectangleFLine.X, this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2 + this.mat_vLineLength / 2)); graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2 - this.mat_hLineLength / 2, this.rectangleFLine.Bottom) , new PointF(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2 + this.mat_hLineLength / 2, this.rectangleFLine.Bottom)); // 圆心 Point center = new Point((int)(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2), (int)(this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2)); double len = System.Math.Sqrt(((this.mat_ToprightLineLength / 2) * (this.mat_ToprightLineLength / 2)) / 2); // 左下到右上斜线 Point a = new Point((int)center.X - (int)len, (int)center.Y + (int)len); Point b = new Point((int)center.X + (int)len, (int)center.Y - (int)len); graphics.DrawLine(linePen, a, b); len = System.Math.Sqrt(((this.mat_TopleftLineLength / 2) * (this.mat_TopleftLineLength / 2)) / 2); // 左上到右下斜线 a = new Point((int)center.X - (int)len, (int)center.Y - (int)len); b = new Point((int)center.X + (int)len, (int)center.Y + (int)len); graphics.DrawLine(linePen, a, b); graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2, center.Y - this.mat_diameter / 2, this.mat_diameter, this.mat_diameter); graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2 - this.mat_margin, center.Y - this.mat_diameter / 2 - this.mat_margin, this.mat_diameter + 2 * this.mat_margin, this.mat_diameter + 2 * this.mat_margin); graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2 - 2 * this.mat_margin, center.Y - this.mat_diameter / 2 - 2 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin); Pen pen = new Pen(Color.FromArgb(this.lineColor), 1); pen.DashStyle = DashStyle.DashDotDot; //使用自定义线型 float[] dashArray = { 2.0f, //线长2个像素 5.0f, //间断5个像素 2.0f, //线长2个像素 5.0f //间断5个像素 }; pen.DashPattern = dashArray; graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height)); pen.Dispose(); } /// /// 切换辅助线时控制缩放比例避免超出当前图片(垂直辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void updateWithGuideModel1(double multiple, double physical_Micron, float recWidth) { if (recWidth == -1) {//### this.mat_lineLength = this.rectangleFLine.Height; this.lineLength = (int)(this.mat_lineLength * physical_Micron); this.mat_lineSpacing = (int)(this.rectangleFLine.Width / System.Math.Max(1, this.lineDec - 1)); return; } this.lineLength = (int)(multiple * this.lineLength); this.mat_lineLength = (float)(this.lineLength / physical_Micron); this.originMat_lineSpacing = this.originLineSpacing / physical_Micron; this.mat_lineSpacing = (int)(multiple * recWidth / System.Math.Max(1, this.lineDec - 1)); } /// /// 切换辅助线时控制缩放比例避免超出当前图片(水平辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void updateWithGuideModel2(double multiple, double physical_Micron, float recHeight) { if (recHeight == -1) {//### this.mat_lineLength = this.rectangleFLine.Width; this.lineLength = (int)(this.mat_lineLength * physical_Micron); this.mat_lineSpacing = (int)(this.rectangleFLine.Height / System.Math.Max(1, this.lineDec - 1)); return; } this.lineLength = (int)(multiple * this.lineLength); this.mat_lineLength = (float)(this.lineLength / physical_Micron); this.originMat_lineSpacing = this.originLineSpacing / physical_Micron; this.mat_lineSpacing = (int)(multiple * recHeight / System.Math.Max(1, this.lineDec - 1)); } /// /// 切换辅助线时控制缩放比例避免超出当前图片(单圆辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void updateWithGuideModel3(double multiple, double physical_Micron, bool moving = false) { if (moving) { this.diameter = multiple * this.originDiameter; this.mat_diameter = (int)(this.diameter / physical_Micron); return; } this.diameter = (double)(multiple * this.diameter); this.mat_diameter = (float)(this.diameter / physical_Micron); ////### //this.diameter = multiple * this.originDiameter; //this.mat_diameter = (int)(this.diameter / physical_Micron); } /// /// 切换辅助线时控制缩放比例避免超出当前图片(三圆辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void updateWithGuideModel4(double multiple, double physical_Micron, bool moving = false) { if (moving) { this.diameter = multiple * this.originDiameter; this.mat_diameter = (int)(this.diameter / physical_Micron); this.margin = multiple * this.originMargin; this.mat_margin = (int)(this.margin / physical_Micron); return; } this.diameter = (double)(multiple * this.diameter); this.mat_diameter = (float)(this.diameter / physical_Micron); this.margin = (double)(multiple * this.margin); this.mat_margin = (float)(this.margin / physical_Micron); ////### //this.diameter = multiple * this.originDiameter; //this.mat_diameter = (int)(this.diameter / physical_Micron); //this.margin = multiple * this.originMargin; //this.mat_margin = (int)(this.margin / physical_Micron); } /// /// 切换辅助线时控制缩放比例避免超出当前图片(复合辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void updateWithGuideModel5(double multiple, double physical_Micron, bool moving = false) { if (moving) { this.vLineLength = (int)(multiple * this.originVLineLength); this.mat_vLineLength = (int)(this.vLineLength / physical_Micron); this.hLineLength = (int)(multiple * this.originHLineLength); this.mat_hLineLength = (int)(this.hLineLength / physical_Micron); this.diameter = multiple * this.originDiameter; this.mat_diameter = (int)(this.diameter / physical_Micron); this.margin = multiple * this.originMargin; this.mat_margin = (int)(this.margin / physical_Micron); this.TopleftLineLength = (int)(multiple * this.originTopleftLineLength); this.mat_TopleftLineLength = (int)(this.TopleftLineLength / physical_Micron); this.ToprightLineLength = (int)(multiple * this.originToprightLineLength); this.mat_ToprightLineLength = (int)(this.ToprightLineLength / physical_Micron); this.VLineToCDistance = (int)(multiple * this.originVLineToCDistance); this.mat_VLineToCDistance = (int)(this.VLineToCDistance / physical_Micron); this.HLineToCDistance = (int)(multiple * this.originHLineToCDistance); this.mat_HLineToCDistance = (int)(this.HLineToCDistance / physical_Micron); return; } this.vLineLength = (int)(multiple * this.vLineLength); this.mat_vLineLength = (float)(this.vLineLength / physical_Micron); this.hLineLength = (int)(multiple * this.hLineLength); this.mat_hLineLength = (float)(this.hLineLength / physical_Micron); this.diameter = (double)(multiple * this.diameter); this.mat_diameter = (float)(this.diameter / physical_Micron); this.margin = (double)(multiple * this.margin); this.mat_margin = (float)(this.margin / physical_Micron); this.TopleftLineLength = (int)(multiple * this.TopleftLineLength); this.mat_TopleftLineLength = (float)(this.TopleftLineLength / physical_Micron); this.ToprightLineLength = (int)(multiple * this.ToprightLineLength); this.mat_ToprightLineLength = (float)(this.ToprightLineLength / physical_Micron); this.VLineToCDistance = (float)(multiple * this.VLineToCDistance); this.HLineToCDistance = (float)(multiple * this.HLineToCDistance); this.mat_VLineToCDistance = (float)(this.VLineToCDistance / physical_Micron); this.mat_HLineToCDistance = (float)(this.HLineToCDistance / physical_Micron); ////### //this.vLineLength = (int)(multiple * this.originVLineLength); //this.mat_vLineLength = (int)(this.vLineLength / physical_Micron); //this.hLineLength = (int)(multiple * this.originHLineLength); //this.mat_hLineLength = (int)(this.hLineLength / physical_Micron); //this.diameter = multiple * this.originDiameter; //this.mat_diameter = (int)(this.diameter / physical_Micron); //this.margin = multiple * this.originMargin; //this.mat_margin = (int)(this.margin / physical_Micron); //this.TopleftLineLength = (int)(multiple * this.originTopleftLineLength); //this.mat_TopleftLineLength = (int)(this.TopleftLineLength / physical_Micron); //this.ToprightLineLength = (int)(multiple * this.originToprightLineLength); //this.mat_ToprightLineLength = (int)(this.ToprightLineLength / physical_Micron); //this.VLineToCDistance = (int)(multiple * this.originVLineToCDistance); //this.mat_VLineToCDistance = (int)(this.VLineToCDistance / physical_Micron); //this.HLineToCDistance = (int)(multiple * this.originHLineToCDistance); //this.mat_HLineToCDistance = (int)(this.HLineToCDistance / physical_Micron); } /// /// 通过配置文件rGuideStyle给model赋值(垂直辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void initWithGrainRGuideStyle1(double multiple, double physical_Micron, GrainSizeGuideStyleModel.VGuideStyle vGuideStyle) { this.originLineLength = 1/*multiple*/ * vGuideStyle.lineLength; this.lineLength = (int)(multiple * vGuideStyle.lineLength); this.mat_lineLength = (int)(multiple * vGuideStyle.lineLength / physical_Micron); this.originLineSpacing = 1/*multiple*/ * vGuideStyle.lineSpacing; this.originMat_lineSpacing = 1/*multiple*/ * vGuideStyle.lineSpacing / physical_Micron; this.mat_lineSpacing = (int)(multiple * vGuideStyle.lineSpacing / physical_Micron); this.lineDec = vGuideStyle.lineDec; this.lineColor = vGuideStyle.lineColor; this.lineWidth = vGuideStyle.lineWidth; } /// /// 通过配置文件rGuideStyle给model赋值(水平辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void initWithGrainRGuideStyle2(double multiple, double physical_Micron, GrainSizeGuideStyleModel.HGuideStyle hGuideStyle) { this.originLineLength = 1/*multiple*/ * hGuideStyle.lineLength; this.lineLength = (int)(multiple * hGuideStyle.lineLength); this.mat_lineLength = (int)(multiple * hGuideStyle.lineLength / physical_Micron); this.originLineSpacing = 1/*multiple*/ * hGuideStyle.lineSpacing; this.originMat_lineSpacing = 1/*multiple*/ * hGuideStyle.lineSpacing / physical_Micron; this.mat_lineSpacing = (int)(multiple * hGuideStyle.lineSpacing / physical_Micron); this.lineDec = hGuideStyle.lineDec; this.lineColor = hGuideStyle.lineColor; this.lineWidth = hGuideStyle.lineWidth; } /// /// 通过配置文件rGuideStyle给model赋值(单圆辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void initWithGrainRGuideStyle3(double multiple, double physical_Micron, GrainSizeGuideStyleModel.CGuideStyle cGuideStyle) { this.originDiameter = 1/*multiple*/ * cGuideStyle.diameter; this.diameter = multiple * cGuideStyle.diameter; this.mat_diameter = (int)(multiple * cGuideStyle.diameter / physical_Micron); this.lineColor = cGuideStyle.lineColor; this.lineWidth = cGuideStyle.lineWidth; } /// /// 通过配置文件rGuideStyle给model赋值(三圆辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void initWithGrainRGuideStyle4(double multiple, double physical_Micron, GrainSizeGuideStyleModel.TCGuideStyle tCGuideStyle) { this.originDiameter = 1/*multiple*/ * tCGuideStyle.diameter; this.diameter = multiple * tCGuideStyle.diameter; this.mat_diameter = (int)(multiple * tCGuideStyle.diameter / physical_Micron); this.originMargin = 1/*multiple*/ * tCGuideStyle.margin; this.margin = multiple * tCGuideStyle.margin; this.mat_margin = (int)(multiple * tCGuideStyle.margin / physical_Micron); this.lineColor = tCGuideStyle.lineColor; this.lineWidth = tCGuideStyle.lineWidth; } /// /// 通过配置文件rGuideStyle给model赋值(复合辅助线) /// /// 放大倍数 /// 标尺 /// 配置文件rGuideStyle public void initWithGrainRGuideStyle5(double multiple, double physical_Micron, GrainSizeGuideStyleModel.RGuideStyle rGuideStyle) { this.originVLineLength = 1/*multiple*/ * rGuideStyle.vLineLength; this.vLineLength = (int)(multiple * rGuideStyle.vLineLength); this.mat_vLineLength = (int)(multiple * rGuideStyle.vLineLength / physical_Micron); this.originHLineLength = 1/*multiple*/ * rGuideStyle.hLineLength; this.hLineLength = (int)(multiple * rGuideStyle.hLineLength); this.mat_hLineLength = (int)(multiple * rGuideStyle.hLineLength / physical_Micron); this.originDiameter = 1/*multiple*/ * rGuideStyle.diameter; this.diameter = multiple * rGuideStyle.diameter; this.mat_diameter = (int)(multiple * rGuideStyle.diameter / physical_Micron); this.originMargin = 1/*multiple*/ * rGuideStyle.margin; this.margin = multiple * rGuideStyle.margin; this.mat_margin = (int)(multiple * rGuideStyle.margin / physical_Micron); this.originTopleftLineLength = 1/*multiple*/ * rGuideStyle.TopleftLineLength; this.TopleftLineLength = (int)(multiple * rGuideStyle.TopleftLineLength); this.mat_TopleftLineLength = (int)(multiple * rGuideStyle.TopleftLineLength / physical_Micron); this.originToprightLineLength = 1/*multiple*/ * rGuideStyle.ToprightLineLength; this.ToprightLineLength = (int)(multiple * rGuideStyle.ToprightLineLength); this.mat_ToprightLineLength = (int)(multiple * rGuideStyle.ToprightLineLength / physical_Micron); this.originVLineToCDistance = 1/*multiple*/ * rGuideStyle.VLineToCDistance; this.VLineToCDistance = (int)(multiple * rGuideStyle.VLineToCDistance); this.mat_VLineToCDistance = (int)(multiple * rGuideStyle.VLineToCDistance / physical_Micron); this.originHLineToCDistance = 1/*multiple*/ * rGuideStyle.HLineToCDistance; this.HLineToCDistance = (int)(multiple * rGuideStyle.HLineToCDistance); this.mat_HLineToCDistance = (int)(multiple * rGuideStyle.HLineToCDistance / physical_Micron); this.lineColor = rGuideStyle.lineColor; this.lineWidth = rGuideStyle.lineWidth; } } }