1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using PaintDotNet.Annotation.Enum;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PaintDotNet.Annotation.PhysicalPhaseAction
- {
- /// <summary>
- /// 物相提取->定义物体->轮廓->椭圆
- /// </summary>
- public class DrawPPhaseRectangle : DrawObject
- {
- private Pen pen = new Pen(Color.Blue, 2);
- public DrawPPhaseRectangle(ISurfaceBox surfaceBox, int x, int y, int width, int height) : base()
- {
- this.objectType = DrawClass.Label;
- this.drawToolType = DrawToolType.PPhaseRectangle;
- this.rectangle.X = x;
- this.rectangle.Y = y;
- this.rectangle.Width = width;
- this.rectangle.Height = height;
- }
- public override void Draw(Graphics g)
- {
- g.DrawRectangle(pen, GetNormalizedRectangle(Rectangle));
- }
- public override void MoveHandleTo(Point point, int handleNumber)
- {
- float left = Rectangle.Left;
- float top = Rectangle.Top;
- float right = Rectangle.Right;
- float bottom = Rectangle.Bottom;
- switch (handleNumber)
- {
- case 1:
- left = point.X;
- top = point.Y;
- break;
- case 2:
- top = point.Y;
- break;
- case 3:
- right = point.X;
- top = point.Y;
- break;
- case 4:
- right = point.X;
- break;
- case 5:
- right = point.X;
- bottom = point.Y;
- break;
- case 6:
- bottom = point.Y;
- break;
- case 7:
- left = point.X;
- bottom = point.Y;
- break;
- case 8:
- left = point.X;
- break;
- }
- SetRectangle(left, top, right - left, bottom - top);
- }
- protected void SetRectangle(float x, float y, float width, float height)
- {
- this.rectangle.X = x;
- this.rectangle.Y = y;
- this.rectangle.Width = width;
- this.rectangle.Height = height;
- }
- public override DrawObject Clone()
- {
- return null;
- }
- public override RectangleF GetBoundingBox()
- {
- return this.rectangle;
- }
- }
- }
|