123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
- 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.DedicatedAnalysis
- {
- public class InclusionDrawObject : DedicatedAnalysisDrawObject
- {
- public Inclusion inclusion;
- public bool is_showRectangle;
- public bool is_showOval;
- public int is_full;
- public bool is_edit;
- public bool showStr;
- public InclusionDrawObject(ISurfaceBox surfaceBox, Inclusion inclusion) : base(surfaceBox)
- {
- this.drawToolType = DrawToolType.InclusionSelect;
- this.inclusion = inclusion;
- this.is_showRectangle = true;
- }
- public InclusionDrawObject(ISurfaceBox surfaceBox, Inclusion inclusion, int is_full) : base(surfaceBox)
- {
- this.drawToolType = DrawToolType.InclusionSelect;
- this.inclusion = inclusion;
- this.is_full = is_full;
- this.is_showRectangle = true;
- }
- public InclusionDrawObject(ISurfaceBox surfaceBox, Inclusion inclusion, bool is_showRectangle, int is_full) : base(surfaceBox)
- {
- this.drawToolType = DrawToolType.InclusionSelect;
- this.inclusion = inclusion;
- this.is_full = is_full;
- this.is_showRectangle = is_showRectangle;
- }
- public InclusionDrawObject(ISurfaceBox surfaceBox, Inclusion inclusion, bool is_showRectangle, bool is_showOval,int is_full,bool showStr) :base(surfaceBox)
- {
- this.drawToolType = DrawToolType.InclusionSelect;
- this.inclusion = inclusion;
- this.is_showRectangle = is_showRectangle;
- this.is_showOval = is_showOval;
- this.is_full = is_full;
- this.showStr = showStr;
- }
- public override void Draw(Graphics g)
- {
- Drawing(g);
- }
- public override DrawObject Clone()
- {
- return new InclusionDrawObject(this.ISurfaceBox,this.inclusion);
- }
- public override RectangleF GetBoundingBox()
- {
- throw new NotImplementedException();
- }
- public override void DrawTracker(Graphics g)
- {
- Drawing(g);
- }
- private void Drawing(Graphics g)
- {
- g.SmoothingMode = SmoothingMode.AntiAlias;
- foreach (Particle particle in this.inclusion.particles)
- {
- if (is_showRectangle)
- {
- g.DrawRectangle(new Pen(Color.Red,0.1f), particle.rectProfile.X, particle.rectProfile.Y, particle.rectProfile.Width, particle.rectProfile.Height);
- }
- if (particle.points2.Count() > 2)
- {
- // 填充夹杂物
- if (is_full == 1)
- {
- g.FillPolygon(new SolidBrush(Color.FromArgb(this.inclusion.type.showColor)), particle.points2);
- }
- else
- {
- g.DrawPolygon(new Pen(Color.FromArgb(this.inclusion.type.showColor), 0.1f), particle.points2);
- }
- }
- }
- if (is_showRectangle) {
- g.DrawRectangle(new Pen(Color.Blue, Selected ? 3 : 0.1f), this.inclusion.rectProfile.X, this.inclusion.rectProfile.Y, this.inclusion.rectProfile.Width, this.inclusion.rectProfile.Height);
- }
- if (is_showOval) {
- g.DrawEllipse(new Pen(Color.Green), this.inclusion.rectProfile.X, this.inclusion.rectProfile.Y, this.inclusion.rectProfile.Width, this.inclusion.rectProfile.Height);
- }
- if (this.inclusion.pixelLength > 0)
- {
- if (this.showStr)
- {
- Font type = new Font(System.Drawing.SystemFonts.DefaultFont.FontFamily, (float)(this.inclusion.pixelLength / 10), System.Drawing.SystemFonts.DefaultFont.Style);
- Font chemicalCharacteristics = new Font(type.FontFamily, type.Size / 2);
- g.DrawString(this.inclusion.type.type, type, new SolidBrush(Color.Blue), this.inclusion.rectProfile.Right, this.inclusion.rectProfile.Bottom - type.Size);
- g.DrawString(this.inclusion.chemicalCharacteristics, chemicalCharacteristics, new SolidBrush(Color.Blue), this.inclusion.rectProfile.Right + (this.inclusion.type.type.Length * type.Size), this.inclusion.rectProfile.Bottom - chemicalCharacteristics.Size);
- }
- }
- }
- }
- }
|