12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base.SettingModel;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Globalization;
- using System.Windows.Forms;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Annotation.Measure;
- using System.Linq;
- namespace PaintDotNet.Annotation.Measure
- {
- using PointList = List<PointF>;
- /// <summary>
- /// 测量->点垂线->多点垂线
- /// </summary>
- public class MeasureMulPLine : MeasureDrawObject
- {
- public PointList pointArray;
- /// <summary>
- /// Graphic objects for hit test
- /// </summary>
- private GraphicsPath areaPath = null;
- private Pen areaPen = null;
- private Region areaRegion = null;
- /// <summary>
- /// 总长度
- /// </summary>
- private double Length = 0.0;
- /// <summary>
- /// 测量信息矩形定义
- /// </summary>
- private RectangleF rectangleF1 = new RectangleF();
- private RectangleF rectangleF2 = new RectangleF();
- private RectangleF rectangleF3 = new RectangleF();
- private RectangleF rectangleF4 = new RectangleF();
- private RectangleF rectangleF5 = new RectangleF();
- /// <summary>
- /// 文本上用于拖动的点
- /// </summary>
- private Point pointL = new Point();
- /// <summary>
- /// 绘制限制(第一次绘制时)
- /// </summary>
- public bool pointChange = true;
- /// <summary>
- /// 区分移动文本
- /// </summary>
- private int moveKb;
- /// <summary>
- /// 绘制限制(从配置文件加载)
- /// </summary>
- public bool configurationFile = false;
- /// <summary>
- /// 绘制限制(更改属性时)
- /// </summary>
- private bool SavePointChange;
- /// <summary>
- /// 多点绘制时的文本矩形集合
- /// </summary>
- public List<RectangleF> RectangleFList = new List<RectangleF>();
- /// <summary>
- /// 绘制属性
- /// </summary>
- private string[] drawingPropertiesList;
- /// <summary>
- /// 绘制属性(克隆)
- /// </summary>
- private string[] drawingPropertiesListClone;
- private bool drawing;
- /// <summary>
- /// 旋转角度
- /// </summary>
- private double angle;
- private double angleP;
- private int num = 0;
- /// <summary>
- /// 属性绘制点
- /// </summary>
- private PointF rotationPoint;
- private PointF rotationPoint1;
- /// <summary>
- /// 限制绘制(绘制中)
- /// </summary>
- public bool mouseUpPointChange = false;
- /// <summary>
- /// 测量样式信息model
- /// </summary>
- private MeasureStyleModel.MeasureMulPLine measureStyleModel;
- public MeasureStyleModel.MeasureMulPLine MeasureStyleModel
- {
- set
- {
- this.measureStyleModel = value;
- }
- }
- public MeasureMulPLine(ISurfaceBox surfaceBox, int x1, int y1, bool clone) : base(surfaceBox)
- {
- this.objectType = DrawClass.Measure;
- this.drawToolType = DrawToolType.MeasureMulPLine;
- measureStyleModel = surfaceBox.GetMeasureStyleModel().measureMulPLine;
- pointArray = new PointList();
- startPoint.X = x1;
- startPoint.Y = y1;
- if (clone)
- {
- drawing = true;
- pointArray.Add(new Point(x1, y1));
- }
- this.measurementUnit = (MeasurementUnit)System.Enum.Parse(typeof(MeasurementUnit), surfaceBox.GetPxPerUnit()[0]);
- this.unitString = surfaceBox.GetPxPerUnit()[1];
- this.unit = surfaceBox.GetPxPerUnit()[2];
- surfaceBox.getMeasureInfo().TryGetValue(measurementUnit, out unitLength);
- Initialize();
- }
- /// <summary>
- /// 测量属性
- /// </summary>
- /// <returns></returns>
- public override Dictionary<System.Enum, object> GetData()
- {
- if (data.ContainsKey(MeasureAttributes.MeasureMethod))
- data[MeasureAttributes.MeasureMethod] = PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text");
- else
- data.Add(MeasureAttributes.MeasureMethod, PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"));
- if (data.ContainsKey(MeasureAttributes.MeasureUnitCN))
- data[MeasureAttributes.MeasureUnitCN] = this.unitString;
- else
- data.Add(MeasureAttributes.MeasureUnitCN, this.unitString);
- if (data.ContainsKey(MeasureAttributes.MeasureUnitEN))
- data[MeasureAttributes.MeasureUnitEN] = this.unit;
- else
- data.Add(MeasureAttributes.MeasureUnitEN, this.unit);
- if (data.ContainsKey(MeasureAttributes.PixelStartX))
- data[MeasureAttributes.PixelStartX] = startPoint.X;
- else
- data.Add(MeasureAttributes.PixelStartX, startPoint.X);
- if (data.ContainsKey(MeasureAttributes.PixelStartY))
- data[MeasureAttributes.PixelStartY] = startPoint.Y;
- else
- data.Add(MeasureAttributes.PixelStartY, startPoint.Y);
- if (data.ContainsKey(MeasureAttributes.PhysicalStartX))
- data[MeasureAttributes.PhysicalStartX] = Math.Round(startPoint.X * unitLength, decimalPlaces);
- else
- data.Add(MeasureAttributes.PhysicalStartX, Math.Round(startPoint.X * unitLength, decimalPlaces));
- if (data.ContainsKey(MeasureAttributes.PhysicalStartY))
- data[MeasureAttributes.PhysicalStartY] = Math.Round(startPoint.Y * unitLength, decimalPlaces);
- else
- data.Add(MeasureAttributes.PhysicalStartY, Math.Round(startPoint.Y * unitLength, decimalPlaces));
- if (data.ContainsKey(MeasureAttributes.PixelLength))
- data[MeasureAttributes.PixelLength] = Math.Round(Length, decimalPlaces);
- else
- data.Add(MeasureAttributes.PixelLength, Math.Round(Length, decimalPlaces));
- string s = Math.Round(Length * unitLength, decimalPlaces).ToString();
- if (s.IndexOf(".") == -1)
- {
- for (int i = 0; i < decimalPlaces; i++)
- {
- if (i == 0)
- s += ".";
- s += "0";
- }
- }
- else
- {
- int a = s.Length - s.IndexOf(".") - 1;
- if (a < decimalPlaces)
- {
- for (int i = 0; i < decimalPlaces - a; i++)
- {
- s += "0";
- }
- }
- }
- if (data.ContainsKey(MeasureAttributes.PhysicalLength))
- data[MeasureAttributes.PhysicalLength] = s;
- else
- data.Add(MeasureAttributes.PhysicalLength, s);
- if (data.ContainsKey(MeasureAttributes.PixelAverageIntercept))
- data[MeasureAttributes.PixelAverageIntercept] = Math.Round(Length / (pointArray.Count - 2), decimalPlaces);
- else
- data.Add(MeasureAttributes.PixelAverageIntercept, Math.Round(Length / (pointArray.Count - 2), decimalPlaces));
- s = Math.Round(Length / (pointArray.Count - 2) * unitLength, decimalPlaces).ToString();
- if (s.IndexOf(".") == -1)
- {
- for (int i = 0; i < decimalPlaces; i++)
- {
- if (i == 0)
- s += ".";
- s += "0";
- }
- }
- else
- {
- int a = s.Length - s.IndexOf(".") - 1;
- if (a < decimalPlaces)
- {
- for (int i = 0; i < decimalPlaces - a; i++)
- {
- s += "0";
- }
- }
- }
- if (data.ContainsKey(MeasureAttributes.PhysicalAverage))
- data[MeasureAttributes.PhysicalAverage] = s;
- else
- data.Add(MeasureAttributes.PhysicalAverage, s);
- return data;
- }
- public MeasureMulPLine(ISurfaceBox surfaceBox, List<PointF> points, ParentStyleModel parentStyleModel, Object content) : base()
- {
- this.objectType = DrawClass.Measure;
- this.drawToolType = DrawToolType.MeasureMulPLine;
- this.ISurfaceBox = surfaceBox;
- measureStyleModel = (MeasureStyleModel.MeasureMulPLine)parentStyleModel;
- pointArray = DrawRulerHelper.DeepCopyListByReflect(points);
- startPoint = points[0];
- this.measurementUnit = (MeasurementUnit)System.Enum.Parse(typeof(MeasurementUnit), surfaceBox.GetPxPerUnit()[0]);
- this.unitString = surfaceBox.GetPxPerUnit()[1];
- this.unit = surfaceBox.GetPxPerUnit()[2];
- surfaceBox.getMeasureInfo().TryGetValue(measurementUnit, out unitLength);
- for (int i = 0; i < (points.Count - 1) * 6; i++)
- {
- this.RectangleFList.Add(new RectangleF());
- }
- this.configurationFile = true;
- }
- /// <summary>
- /// Clone this instance
- /// </summary>
- public override DrawObject Clone()
- {
- MeasureMulPLine drawPolygon = new MeasureMulPLine(ISurfaceBox, (int)pointArray[0].X, (int)pointArray[0].Y, false);
- drawPolygon.ISurfaceBox = ISurfaceBox;
- foreach (PointF p in this.pointArray)
- {
- drawPolygon.pointArray.Add(p);
- }
- if (drawingPropertiesList != null)
- drawPolygon.drawingPropertiesListClone = drawingPropertiesList;
- foreach (var rectangleF in RectangleFList)
- {
- drawPolygon.RectangleFList.Add(rectangleF);
- }
- FillDrawObjectFields(drawPolygon);
- return drawPolygon;
- }
- public override DrawObject Clone(ISurfaceBox surfaceBox)
- {
- MeasureMulPLine drawPolygon = new MeasureMulPLine(surfaceBox, this.GetPoints(), this.measureStyleModel, null);
- if (drawingPropertiesList != null)
- drawPolygon.drawingPropertiesListClone = drawingPropertiesList;
- drawPolygon.RectangleFList = DrawRulerHelper.DeepCopyListByReflect(RectangleFList);
- FillDrawObjectFields(drawPolygon);
- return drawPolygon;
- }
- public override void Draw(Graphics g)
- {
- lengthParagraphs = new List<string>();
- drawingProperties.TryGetValue(this.drawToolType, out drawingPropertiesList);
- if (drawingPropertiesList == null)
- {
- drawingPropertiesList = drawingPropertiesListClone;
- if (!this.drawing)
- this.configurationFile = true;
- }
- pointChangeObject.TryGetValue(this.drawToolType, out SavePointChange);
- // 总长度
- double allLengh = 0.0;
- Font textfont1 = new Font(measureStyleModel.font, measureStyleModel.fontSize);
- Brush textbrush1 = new SolidBrush(Color.FromArgb(measureStyleModel.textColor));
- SizeF sizeF = new SizeF();
- int a1 = 0;
- int a2 = 1;
- int a3 = 2;
- int a4 = 3;
- int a5 = 4;
- int a6 = 5;
- RectangleF rectangleF;
- // 连续绘制
- for (int a = 1; a <= HandleCount - 2; a++)
- {
- if (HandleCount - 1 >= 2)
- {
- Font textfont = new Font(measureStyleModel.font, measureStyleModel.fontSize);
- Brush textbrush = new SolidBrush(Color.FromArgb(measureStyleModel.textColor));
- g.SmoothingMode = SmoothingMode.AntiAlias;
- Color color = Color.FromArgb(this.measureStyleModel.lineColor);
- Pen pen = new Pen(color, this.measureStyleModel.lineWidth);
- pen.DashStyle = (DashStyle)this.measureStyleModel.lineStyle;
- double length1 = 0.0;
- Matrix mtxSave = g.Transform;
- Matrix matrix = g.Transform;
- length1 = BasicCalculationHelper.GetDistance(pointArray[1], pointArray[0], 10);
- //if (HandleCount - 1 == 2)
- //{
- // g.DrawLine(pen, pointArray[0], pointArray[1]);
- // g.DrawString(Math.Round(length1 * unitLength, decimalPlaces) + unit, textfont, textbrush, pointArray[1]);
- // g.DrawString(Math.Round(length1 * unitLength, decimalPlaces) + unit, textfont, textbrush, pointArray[0]);
- //}
- // 垂足坐标
- PointF footPoint = new PointF();
- footPoint = BasicCalculationHelper.GetDropFeet(pointArray[1], pointArray[0], pointArray[a]);
- //计算需要旋转的角度
- //double angleRotate = BasicCalculationHelper.Angle(pointArray[0], pointArray[1], new PointF(pointArray[0].X, pointArray[1].Y));
- // 点到直线距离
- double length = BasicCalculationHelper.GetDistance(footPoint, pointArray[a], 2);
- double angle = Math.Round(BasicCalculationHelper.AngleText(pointArray[0],
- pointArray[1], new PointF(pointArray[0].X + 10, pointArray[0].Y)), 2);
- double angle1 = 0.0;
- // 判断第一个点象限
- float x1 = pointArray[0].X - pointArray[1].X;
- if (x1 == 0)
- x1 = 1;
- float y1 = pointArray[0].Y - pointArray[1].Y;
- if (y1 == 0)
- y1 = 1;
- int j1 = 0;
- if (x1 > 0 && y1 > 0) //第4象限
- {
- j1 = 4;
- }
- else if (x1 > 0 && y1 < 0) //第1象限
- {
- j1 = 1;
- }
- else if (x1 < 0 && y1 < 0) //第2象限
- {
- j1 = 2;
- }
- else if (x1 < 0 && y1 > 0) //第3象限
- {
- j1 = 3;
- }
- // 判断第三个点象限
- float x3 = pointArray[a].X - pointArray[1].X;
- if (x3 == 0)
- x3 = 1;
- float y3 = pointArray[a].Y - pointArray[1].Y;
- if (y3 == 0)
- y3 = 1;
- int j3 = 0;
- if (x3 > 0 && y3 > 0) //第4象限
- {
- j3 = 4;
- }
- else if (x3 > 0 && y3 < 0) //第1象限
- {
- j3 = 1;
- }
- else if (x3 < 0 && y3 < 0) //第2象限
- {
- j3 = 2;
- }
- else if (x3 < 0 && y3 > 0) //第3象限
- {
- j3 = 3;
- }
- if (j1 == 3 || j1 == 4)
- {
- angle = 360 - angle;
- }
- double threePointAngle = Math.Round(BasicCalculationHelper.AngleText(pointArray[1],
- pointArray[a], pointArray[0]), 2);
- // 第一个点于X轴的夹角
- double point0ToX = Math.Round(BasicCalculationHelper.AngleText(pointArray[1],
- new PointF(pointArray[1].X + 10, pointArray[1].Y), pointArray[0]), 2);
- // 第三个点于X轴的夹角
- double point2ToX = Math.Round(BasicCalculationHelper.AngleText(pointArray[1],
- pointArray[a], new PointF(pointArray[1].X + 10, pointArray[1].Y)), 2);
- if (point0ToX > 90)
- {
- point0ToX = 180 - point0ToX;
- }
- if (point2ToX > 90)
- {
- point2ToX = 180 - point2ToX;
- }
- if ((j1 == 1 && j3 == 1) || (j1 == 2 && j3 == 4)
- || (j1 == 3 && j3 == 3) || (j1 == 4 && j3 == 2))
- {
- if (point0ToX > point2ToX)
- {
- angle1 = 270;
- }
- else
- {
- angle1 = 90;
- }
- }
- else if ((j1 == 1 && j3 == 2) || (j1 == 2 && j3 == 3)
- || (j1 == 3 && j3 == 4) || (j1 == 4 && j3 == 1))
- {
- angle1 = 90;
- }
- else if (j1 == 1 && j3 == 3 || (j1 == 2 && j3 == 2)
- || (j1 == 3 && j3 == 1) || (j1 == 4 && j3 == 4))
- {
- if (point0ToX > point2ToX)
- {
- angle1 = 90;
- }
- else
- {
- angle1 = 270;
- }
- }
- else if (j1 == 1 && j3 == 4 || (j1 == 2 && j3 == 1)
- || (j1 == 3 && j3 == 2) || (j1 == 4 && j3 == 3))
- {
- angle1 = 270;
- }
- PointF point = BasicCalculationHelper.GetAnglePoint(new PointF(pointArray[0].X + (int)length,
- pointArray[0].Y), pointArray[0], angle);
- PointF point1 = BasicCalculationHelper.GetAnglePoint(point, pointArray[0], angle1);
- double length2 = BasicCalculationHelper.GetDistance(footPoint, pointArray[a], 10);
- double length3 = length2;
- ////长度文本显示
- //g.DrawString(Math.Round(length2 * unitLength, decimalPlaces) + unit, textfont, textbrush, pointArray[a]);
- allLengh = allLengh + length2;
- int offsetValuePoint = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
- int offsetValue1Point = measureStyleModel.lineWidth * 2 / 3;
- int offsetPoint = offsetValue1Point;
- if (drawingPropertiesList != null)
- {
- // 像素长度
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelLength.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 物理长度
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalLength.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 像素起始点X
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartX.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 像素起始点Y
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartY.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 物理起始点X
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartX.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 物理起始点Y
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartY.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- }
- PointF pointF1;
- PointF pointF2;
- PointF pointF3;
- //计算需要旋转的角度
- double angleClass = BasicCalculationHelper.Angle(footPoint, pointArray[a], new PointF(footPoint.X, pointArray[a].Y));
- if (angleClass < 90)
- pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)footPoint.X + offsetPoint + offsetValue1Point, (int)footPoint.Y), footPoint, angleClass - 90);
- else
- pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)footPoint.X + offsetPoint + offsetValue1Point, (int)footPoint.Y), footPoint, angleClass + 90);
- if (angleClass < 90)
- pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[a].X + offsetPoint + offsetValue1Point, (int)pointArray[a].Y), pointArray[a], angleClass - 90);
- else
- pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[a].X + offsetPoint + offsetValue1Point, (int)pointArray[a].Y), pointArray[a], angleClass + 90);
- pointF3 = new PointF((pointF1.X + pointF2.X) / 2, (pointF1.Y + pointF2.Y) / 2);
- if (measureStyleModel.linePositionP == 0)
- this.rotationPoint1 = pointF1;
- else if (measureStyleModel.linePositionP == 1)
- this.rotationPoint1 = pointF3;
- else if (measureStyleModel.linePositionP == 2)
- this.rotationPoint1 = pointF2;
- else if (measureStyleModel.linePositionP == 3)
- this.rotationPoint1 = footPoint;
- else if (measureStyleModel.linePositionP == 4)
- this.rotationPoint1 = new PointF((footPoint.X + pointArray[a].X) / 2, (footPoint.Y + pointArray[a].Y) / 2);
- else if (measureStyleModel.linePositionP == 5)
- this.rotationPoint1 = pointArray[a];
- // 画布旋转
- if (angleClass < 90)
- {
- matrix.RotateAt((float)angleClass, this.rotationPoint1);
- g.Transform = matrix;
- }
- else
- {
- angleClass = BasicCalculationHelper.Angle(pointArray[a], footPoint, new PointF(pointArray[a].X, footPoint.Y));
- matrix.RotateAt((float)angleClass, this.rotationPoint1);
- g.Transform = matrix;
- }
- this.angleP = angleClass;
- int offsetValue = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
- int offsetValue1 = measureStyleModel.lineWidth * 2 / 3;
- int offset = offsetValue1;
- if (drawingPropertiesList != null && a > 1)
- {
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelLength.ToString()))
- {
- rectangleF = this.RectangleFList[a1];
- sizeF = g.MeasureString("" + Math.Round(length3, decimalPlaces) + "px", textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a1] = rectangleF;
- }
- g.DrawString("" + Math.Round(length3, decimalPlaces) + "px", textfont1, textbrush1, this.RectangleFList[a1]);
- a1 += 6;
- }
- else
- {
- this.RectangleFList[a1] = new RectangleF();
- a1 += 6;
- }
- string s = Math.Round(length3 * unitLength, decimalPlaces).ToString();
- if (s.IndexOf(".") == -1)
- {
- for (int i = 0; i < decimalPlaces; i++)
- {
- if (i == 0)
- s += ".";
- s += "0";
- }
- }
- else
- {
- int dic = s.Length - s.IndexOf(".") - 1;
- if (dic < decimalPlaces)
- {
- for (int i = 0; i < decimalPlaces - dic; i++)
- {
- s += "0";
- }
- }
- }
- lengthParagraphs.Add(s);
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalLength.ToString()))
- {
- rectangleF = this.RectangleFList[a2];
- sizeF = g.MeasureString(s + this.unit, textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a2] = rectangleF;
- }
- g.DrawString(s + this.unit, textfont1, textbrush1, this.RectangleFList[a2]);
- a2 += 6;
- }
- else
- {
- this.RectangleFList[a2] = new RectangleF();
- a2 += 6;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartX.ToString()))
- {
- rectangleF = this.RectangleFList[a3];
- sizeF = g.MeasureString("" + pointArray[a].X, textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a3] = rectangleF;
- }
- g.DrawString("" + pointArray[a].X, textfont1, textbrush1, this.RectangleFList[a3]);
- a3 += 6;
- }
- else
- {
- this.RectangleFList[a3] = new RectangleF();
- a3 += 6;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelStartY.ToString()))
- {
- rectangleF = this.RectangleFList[a4];
- sizeF = g.MeasureString("" + pointArray[a].Y, textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a4] = rectangleF;
- }
- g.DrawString("" + pointArray[a].Y, textfont1, textbrush1, this.RectangleFList[a4]);
- a4 += 6;
- }
- else
- {
- this.RectangleFList[a4] = new RectangleF();
- a4 += 6;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartX.ToString()))
- {
- rectangleF = this.RectangleFList[a5];
- sizeF = g.MeasureString("" + Math.Round(pointArray[a].X * unitLength, decimalPlaces), textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a5] = rectangleF;
- }
- g.DrawString("" + Math.Round(pointArray[a].X * unitLength, decimalPlaces), textfont1, textbrush1, this.RectangleFList[a5]);
- a5 += 6;
- }
- else
- {
- this.RectangleFList[a5] = new RectangleF();
- a5 += 6;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalStartY.ToString()))
- {
- rectangleF = this.RectangleFList[a6];
- sizeF = g.MeasureString("" + Math.Round(pointArray[a].Y * unitLength, decimalPlaces), textfont1);
- rectangleF.Width = sizeF.Width;
- rectangleF.Height = sizeF.Height;
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- rectangleF.Location = new PointF((int)this.rotationPoint1.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint1.Y + offset);
- offset += offsetValue;
- this.RectangleFList[a6] = rectangleF;
- }
- g.DrawString("" + Math.Round(pointArray[a].Y * unitLength, decimalPlaces), textfont1, textbrush1, this.RectangleFList[a6]);
- a6 += 6;
- }
- else
- {
- this.RectangleFList[a6] = new RectangleF();
- a6 += 6;
- }
- }
- //还原为原始旋转矩阵
- g.Transform = mtxSave;
- g.DrawLine(pen, pointArray[0], pointArray[1]);
- g.DrawLine(pen, footPoint, pointArray[a]);
- pen.Dispose();
- matrix.Dispose();
- }
- }
- // 总长度
- this.Length = allLengh;
- if (pointArray.Count > 1)
- {
- Matrix mtxSave1 = g.Transform;
- Matrix matrix1 = g.Transform;
- // 旋转角度
- this.angle = BasicCalculationHelper.Angle(pointArray[0], pointArray[1], new PointF(pointArray[0].X, pointArray[1].Y));
- int offsetValuePoint = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
- int offsetValue1Point = measureStyleModel.lineWidth * 2 / 3;
- int offsetPoint = offsetValue1Point;
- if (drawingPropertiesList != null)
- {
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelAverageIntercept.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalAverage.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 测量方式
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 测量单位(中文)
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- // 测量单位(英文)
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
- {
- offsetPoint += offsetValuePoint;
- }
- }
- PointF pointF1;
- PointF pointF2;
- if (angle < 90)
- pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[0].X + offsetPoint + offsetValue1Point, (int)pointArray[0].Y), pointArray[0], angle - 90);
- else
- pointF1 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[0].X + offsetPoint + offsetValue1Point, (int)pointArray[0].Y), pointArray[0], angle + 90);
- if (angle < 90)
- pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[1].X + offsetPoint + offsetValue1Point, (int)pointArray[1].Y), pointArray[1], angle - 90);
- else
- pointF2 = BasicCalculationHelper.GetAnglePoint(new Point((int)pointArray[1].X + offsetPoint + offsetValue1Point, (int)pointArray[1].Y), pointArray[1], angle + 90);
- PointF pointF3 = new PointF((pointF1.X + pointF2.X) / 2, (pointF1.Y + pointF2.Y) / 2);
- if (measureStyleModel.linePositionL == 0)
- this.rotationPoint = pointF1;
- else if (measureStyleModel.linePositionL == 1)
- this.rotationPoint = pointF3;
- else if (measureStyleModel.linePositionL == 2)
- this.rotationPoint = pointF2;
- else if (measureStyleModel.linePositionL == 3)
- this.rotationPoint = pointArray[0];
- else if (measureStyleModel.linePositionL == 4)
- this.rotationPoint = new PointF((pointArray[0].X + pointArray[1].X) / 2, (pointArray[0].Y + pointArray[1].Y) / 2);
- else if (measureStyleModel.linePositionL == 5)
- this.rotationPoint = pointArray[1];
- if (this.angle < 90)
- {
- matrix1.RotateAt((float)this.angle, this.rotationPoint);
- g.Transform = matrix1;
- }
- else
- {
- this.angle = BasicCalculationHelper.Angle(pointArray[1], pointArray[0], new PointF(pointArray[1].X, pointArray[0].Y));
- matrix1.RotateAt((float)this.angle, this.rotationPoint);
- g.Transform = matrix1;
- }
- if (this.pointChange || this.SavePointChange || this.mouseUpPointChange || this.mouseUpAttribute)
- {
- this.pointL = new Point((int)this.rotationPoint.X, (int)this.rotationPoint.Y);
- int offsetValue = measureStyleModel.fontSize + measureStyleModel.fontSize / 2;
- int offsetValue1 = measureStyleModel.lineWidth * 2 / 3;
- int offset = offsetValue1;
- if (drawingPropertiesList != null)
- {
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelAverageIntercept.ToString()))
- {
- double length;
- if (pointArray.Count == 2)
- length = 0;
- else
- length = Length / (pointArray.Count - 2);
- sizeF = g.MeasureString("" + Math.Round(length, decimalPlaces) + "px", textfont1);
- rectangleF4.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset);
- offset += offsetValue;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalAverage.ToString()))
- {
- double length;
- if (pointArray.Count == 2)
- length = 0;
- else
- length = Length / (pointArray.Count - 2);
- string s = Math.Round(length * unitLength, decimalPlaces).ToString();
- if (s.IndexOf(".") == -1)
- {
- for (int i = 0; i < decimalPlaces; i++)
- {
- if (i == 0)
- s += ".";
- s += "0";
- }
- }
- else
- {
- int a = s.Length - s.IndexOf(".") - 1;
- if (a < decimalPlaces)
- {
- for (int i = 0; i < decimalPlaces - a; i++)
- {
- s += "0";
- }
- }
- }
- sizeF = g.MeasureString(s + this.unit, textfont1);
- rectangleF5.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset);
- offset += offsetValue;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
- {
- sizeF = g.MeasureString("" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont1);
- rectangleF1.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset);
- offset += offsetValue;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
- {
- sizeF = g.MeasureString("" + this.unitString, textfont1);
- rectangleF2.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset);
- offset += offsetValue;
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
- {
- sizeF = g.MeasureString("" + this.unit, textfont1);
- rectangleF3.Location = new Point((int)this.rotationPoint.X + offsetValue1 - (int)sizeF.Width / 2, (int)this.rotationPoint.Y + offset);
- offset += offsetValue;
- }
- }
- }
- if (drawingPropertiesList != null)
- {
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureMethod.ToString()))
- {
- sizeF = g.MeasureString("" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont1);
- rectangleF1.Width = sizeF.Width;
- rectangleF1.Height = sizeF.Height;
- g.DrawString("" + PdnResources.GetString("Menu.MeasureAction.PointPerpendicular.Text"), textfont1, textbrush1, rectangleF1);
- }
- else
- {
- rectangleF1 = new RectangleF();
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitCN.ToString()))
- {
- sizeF = g.MeasureString("" + this.unitString, textfont1);
- rectangleF2.Width = sizeF.Width;
- rectangleF2.Height = sizeF.Height;
- g.DrawString("" + this.unitString, textfont1, textbrush1, rectangleF2);
- }
- else
- {
- rectangleF2 = new RectangleF();
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.MeasureUnitEN.ToString()))
- {
- sizeF = g.MeasureString("" + this.unit, textfont1);
- rectangleF3.Width = sizeF.Width;
- rectangleF3.Height = sizeF.Height;
- g.DrawString("" + this.unit, textfont1, textbrush1, rectangleF3);
- }
- else
- {
- rectangleF3 = new RectangleF();
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PixelAverageIntercept.ToString()))
- {
- double length;
- if (pointArray.Count == 2)
- length = 0;
- else
- length = Length / (pointArray.Count - 2);
- sizeF = g.MeasureString("" + Math.Round(length, decimalPlaces) + "px", textfont1);
- rectangleF4.Width = sizeF.Width;
- rectangleF4.Height = sizeF.Height;
- g.DrawString("" + Math.Round(length, decimalPlaces) + "px", textfont1, textbrush1, rectangleF4);
- }
- else
- {
- rectangleF4 = new RectangleF();
- }
- if (drawingPropertiesList.Contains(MeasureAttributes.PhysicalAverage.ToString()))
- {
- double length;
- if (pointArray.Count == 2)
- length = 0;
- else
- length = Length / (pointArray.Count - 2);
- string s = Math.Round(length * unitLength, decimalPlaces).ToString();
- if (s.IndexOf(".") == -1)
- {
- for (int i = 0; i < decimalPlaces; i++)
- {
- if (i == 0)
- s += ".";
- s += "0";
- }
- }
- else
- {
- int a = s.Length - s.IndexOf(".") - 1;
- if (a < decimalPlaces)
- {
- for (int i = 0; i < decimalPlaces - a; i++)
- {
- s += "0";
- }
- }
- }
- sizeF = g.MeasureString(s + this.unit, textfont1);
- rectangleF5.Width = sizeF.Width;
- rectangleF5.Height = sizeF.Height;
- g.DrawString(s + this.unit, textfont1, textbrush1, rectangleF5);
- }
- else
- {
- rectangleF5 = new RectangleF();
- }
- }
- g.Transform = mtxSave1;
- matrix1.Dispose();
- }
- if (this.configurationFile)
- this.pointChange = false;
- this.mouseUpAttribute = false;
- pointChangeObject.Remove(this.drawToolType);
- }
- /// 停止绘制时
- /// </summary>
- /// <param name="up"></param>
- public override void MouseUp(bool up)
- {
- mouseUpPointChange = up;
- }
- public void AddPoint(Point point)
- {
- pointArray.Add(point);
- }
- public override int HandleCount
- {
- get
- {
- return pointArray.Count + 1;
- }
- }
- /// <summary>
- /// Get handle pointscroll by 1-based number
- /// </summary>
- /// <param name="handleNumber"></param>
- /// <returns></returns>
- public override PointF GetHandle(int handleNumber)
- {
- if (handleNumber < 1)
- handleNumber = 1;
- if (handleNumber > pointArray.Count && handleNumber != pointArray.Count + 1)
- handleNumber = pointArray.Count;
- if (handleNumber == pointArray.Count + 1)
- return this.pointL;
- else
- return pointArray[handleNumber - 1];
- }
- public override Cursor GetHandleCursor(int handleNumber)
- {
- return handleCursor;
- }
- public override void MoveHandleTo(Point point, int handleNumber)
- {
- if (handleNumber < 1)
- handleNumber = 1;
- if (handleNumber > pointArray.Count && handleNumber != pointArray.Count + 1)
- handleNumber = pointArray.Count;
- if (handleNumber == pointArray.Count + 1)
- {
- if (this.moveKb == 1 || this.moveKb == 2 || this.moveKb == 3 || this.moveKb == 4 || this.moveKb == 5)
- {
- point = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- if (this.moveKb == 1)
- this.rectangleF1.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- else if (this.moveKb == 2)
- this.rectangleF2.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- else if (this.moveKb == 3)
- this.rectangleF3.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- else if (this.moveKb == 4)
- this.rectangleF4.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- else if (this.moveKb == 5)
- this.rectangleF5.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- }
- else
- {
- for (int i = 0; i < this.RectangleFList.Count; i++)
- {
- num = i / 6;
- if (num + 1 < pointArray.Count)
- {
- RectangleF rectangleF = this.RectangleFList[i];
- if (this.moveKb == -i)
- {
- point = SetOffsetAfterRotation(point, pointArray[num + 1], angleP);
- rectangleF.Offset(point.X - this.pointL.X, point.Y - this.pointL.Y);
- this.RectangleFList[i] = rectangleF;
- break;
- }
- }
- }
- }
- this.pointL = point;
- }
- else
- {
- this.mouseUpPointChange = true;
- if (handleNumber != 1)
- {
- for (int i = 1; i <= this.RectangleFList.Count; i++)
- {
- if (i == handleNumber)
- {
- RectangleF rectangleF = this.RectangleFList[i * 6 - 12];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 12] = rectangleF;
- rectangleF = this.RectangleFList[i * 6 - 11];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 11] = rectangleF;
- rectangleF = this.RectangleFList[i * 6 - 10];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 10] = rectangleF;
- rectangleF = this.RectangleFList[i * 6 - 9];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 9] = rectangleF;
- rectangleF = this.RectangleFList[i * 6 - 8];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 8] = rectangleF;
- rectangleF = this.RectangleFList[i * 6 - 7];
- rectangleF.Offset(point.X - this.pointArray[i - 1].X, point.Y - this.pointArray[i - 1].Y);
- this.RectangleFList[i * 6 - 7] = rectangleF;
- }
- }
- }
- else
- {
- this.rectangleF1.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
- this.rectangleF2.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
- this.rectangleF3.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
- this.rectangleF4.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
- this.rectangleF5.Offset(point.X - this.pointArray[0].X, point.Y - this.pointArray[0].Y);
- }
- pointArray[handleNumber - 1] = point;
- }
- this.startPoint = pointArray[0];
- Invalidate();
- }
- public override void Move(int deltaX, int deltaY)
- {
- int n = pointArray.Count;
- for (int i = 0; i < n; i++)
- {
- PointF point = new PointF(pointArray[i].X + ISurfaceBox.UnscaleScalar(deltaX), pointArray[i].Y + ISurfaceBox.UnscaleScalar(deltaY));
- pointArray[i] = point;
- }
- this.startPoint = pointArray[0];
- int x = ISurfaceBox.UnscaleScalar(deltaX);
- int y = ISurfaceBox.UnscaleScalar(deltaY);
- pointL.X += x;
- pointL.Y += y;
- this.rectangleF1.Offset(x, y);
- this.rectangleF2.Offset(x, y);
- this.rectangleF3.Offset(x, y);
- this.rectangleF4.Offset(x, y);
- this.rectangleF5.Offset(x, y);
- for (int i = 0; i < this.RectangleFList.Count; i++)
- {
- RectangleF rectangleF = this.RectangleFList[i];
- rectangleF.Offset(x, y);
- this.RectangleFList[i] = rectangleF;
- }
- Invalidate();
- }
- /// <summary>
- /// 用于创建一个路径或者是闭合的范围
- /// 用于响应点击选中
- /// 需要咨询用户是仅点击线还是矩形选择
- /// </summary>
- protected virtual void CreateObjects()
- {
- if (AreaPath != null)
- return;
- AreaPath = new GraphicsPath();
- AreaPath.AddRectangle(GetBoundingBox());
- AreaPath.CloseFigure();
- AreaRegion = new Region(AreaPath);
- }
- /// <summary>
- /// Invalidate object.
- /// When object is invalidated, path used for hit test
- /// is released and should be created again.
- /// </summary>
- protected void Invalidate()
- {
- if (AreaPath != null)
- {
- AreaPath.Dispose();
- AreaPath = null;
- }
- if (AreaPen != null)
- {
- AreaPen.Dispose();
- AreaPen = null;
- }
- if (AreaRegion != null)
- {
- AreaRegion.Dispose();
- AreaRegion = null;
- }
- }
- protected GraphicsPath AreaPath
- {
- get
- {
- return areaPath;
- }
- set
- {
- areaPath = value;
- }
- }
- protected Pen AreaPen
- {
- get
- {
- return areaPen;
- }
- set
- {
- areaPen = value;
- }
- }
- protected Region AreaRegion
- {
- get
- {
- return areaRegion;
- }
- set
- {
- areaRegion = value;
- }
- }
- /// <summary>
- /// Draw tracker for selected object
- /// </summary>
- /// <param name="g"></param>
- public override void DrawTracker(Graphics g)
- {
- if (!Selected)
- return;
- SolidBrush brush = new SolidBrush(Color.Black);
- for (int i = 1; i <= HandleCount; i++)
- {
- if (i == HandleCount)
- brush = new SolidBrush(Color.Transparent);
- g.FillRectangle(brush, GetHandleRectangle(i));
- }
- //g.DrawRectangle(new Pen(Color.White), GetBoundingBox());
- brush.Dispose();
- RectangleF r = GetBoundingBox();
- //g.DrawRectangle(new Pen(Color.White), r.X, r.Y, r.Width, r.Height);
- }
- /// <summary>
- /// Hit test.
- /// Return value: -1 - no hit
- /// 0 - hit anywhere
- /// > 1 - handle number
- /// </summary>
- /// <param name="pointscroll"></param>
- /// <returns></returns>
- public override int HitTest(Point point)
- {
- if (Selected)
- {
- for (int i = 1; i <= HandleCount; i++)
- {
- if (GetHandleRectangle(i).Contains(point))
- return i;
- }
- if (GetRectanglePosition(this.rectangleF1, point, this.rotationPoint, angle))
- {
- this.pointL = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- moveKb = 1;
- return this.pointArray.Count + 1;
- }
- else if (GetRectanglePosition(this.rectangleF2, point, this.rotationPoint, angle))
- {
- this.pointL = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- moveKb = 2;
- return this.pointArray.Count + 1;
- }
- else if (GetRectanglePosition(this.rectangleF3, point, this.rotationPoint, angle))
- {
- this.pointL = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- moveKb = 3;
- return this.pointArray.Count + 1;
- }
- else if (GetRectanglePosition(this.rectangleF4, point, this.rotationPoint, angle))
- {
- this.pointL = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- moveKb = 4;
- return this.pointArray.Count + 1;
- }
- else if (GetRectanglePosition(this.rectangleF5, point, this.rotationPoint, angle))
- {
- this.pointL = SetOffsetAfterRotation(point, this.rotationPoint, angle);
- moveKb = 5;
- return this.pointArray.Count + 1;
- }
- for (int i = 0; i < this.RectangleFList.Count; i++)
- {
- num = i / 6;
- if (num + 1 < pointArray.Count)
- {
- RectangleF rectangleF = this.RectangleFList[i];
- if (GetRectanglePosition(rectangleF, point, pointArray[num + 1], angleP))
- {
- this.pointL = SetOffsetAfterRotation(point, pointArray[num + 1], angleP);
- moveKb = -i;
- return this.pointArray.Count + 1;
- }
- }
- }
- }
- if (PointInObject(point))
- return 0;
- return -1;
- }
- protected override bool PointInObject(Point point)
- {
- CreateObjects();
- return AreaRegion.IsVisible(point);
- }
- public override bool IntersectsWith(Rectangle rectangle)
- {
- CreateObjects();
- return AreaRegion.IsVisible(rectangle);
- }
- public override RectangleF GetBoundingBox()
- {
- float minx = 0, maxx = 0, miny = 0, maxy = 0;
- for (int i = 0; i < pointArray.Count; i++)
- {
- if (i == 0)
- {
- minx = maxx = pointArray[i].X;
- miny = maxy = pointArray[i].Y;
- }
- else
- {
- if (pointArray[i].X > maxx) maxx = pointArray[i].X;
- if (pointArray[i].X < minx) minx = pointArray[i].X;
- if (pointArray[i].Y > maxy) maxy = pointArray[i].Y;
- if (pointArray[i].Y < miny) miny = pointArray[i].Y;
- }
- }
- return new RectangleF(minx, miny, maxx - minx, maxy - miny);
- }
- internal void setNextPoint(Point p)
- {
- AddPoint(p);
- //startPoint = endPoint;
- //endPoint = p;
- }
- public override List<PointF> GetPoints()
- {
- return pointArray;
- }
- public override ParentStyleModel GetStyle()
- {
- return measureStyleModel;
- }
- }
- }
|