Documentation
 All Classes Functions Variables Properties
Annotation.h
1 #pragma once
2 
3 using namespace System;
4 using namespace System::Xml;
5 using namespace System::Text;
6 using namespace System::Drawing;
7 using namespace System::Drawing::Drawing2D;
8 using namespace System::Collections::Generic;
9 using namespace System::ComponentModel;
10 
11 
12 namespace MST
13 {
14 namespace Imaging
15 {
16 namespace Annotations
17 {
18  public enum class Type
19  {
20  Line,
21  Rectangle,
22  Hilite,
23  Arrow,
24  Ruler,
25  CrossProduct,
26  Ellipse,
27  Pencil,
28  Polyline,
29  PolyRuler,
30  Curve,
31  Cloud,
32  ScratchOut,
33  Angle,
34  Point,
35  TextNote,
36  Stamp
37  };
38 
39  ref class MSTAnnotationPage;
44  [DefaultPropertyAttribute("Name")]
45  public ref class MSTAnnotation abstract
46  {
47  public:
53  MSTAnnotation(Pen^ pen,MSTAnnotationPage^ page);
54 
58  [CategoryAttribute("General"), DescriptionAttribute("Type of annotation.")]
59  property Type AnnotationType
60  {
61  virtual Type get()=0;
62  }
66  [CategoryAttribute("General"), DescriptionAttribute("Border color of annotation. [Format: RGB/ARGB]")]
67  property Color BorderColor
68  {
69  Color get()
70  {
71  return m_pen->Color;
72  }
73  void set(Color clr)
74  {
75  m_pen->Color = clr;
76  }
77  }
78 
82  [CategoryAttribute("General"), DescriptionAttribute("Border width of annotation. [Range: 1-10]")]
83  property Int32 BorderWidth
84  {
85  Int32 get()
86  {
87  return (Int32)m_pen->Width;
88  }
89  void set(Int32 Value)
90  {
91  if(Value<1)Value=1;
92  if(Value>10)Value=10;
93  m_pen->Width=Value;
94  }
95  }
96 
100  [BrowsableAttribute(false)]
101  property bool Selected
102  {
103  bool get(){return m_bSelected;}
104  void set(bool value){m_bSelected=value;}
105  }
106 
110  [BrowsableAttribute(false)]
111  property array<PointF>^ Points
112  {
113  virtual array<PointF>^ get(){return m_ptArr;}
114  }
115 
119  [BrowsableAttribute(false)]
120  property PointF Points[Int16]
121  {
122  virtual PointF get(Int16 iIndex)
123  {
124  if(iIndex < 0 || iIndex >= m_ptArr->Length) throw gcnew System::ArgumentException("Index out of range.");
125  return m_ptArr[iIndex];
126  }
127  virtual void set(Int16 iIndex,PointF Value)
128  {
129  if(iIndex < 0 || iIndex >= m_ptArr->Length) throw gcnew System::ArgumentException("Index out of range.");
130  m_ptArr[iIndex] = Value;
131  }
132  }
133 
137  [BrowsableAttribute(false)]
138  property System::Drawing::Drawing2D::GraphicsPath^ graphicsPath
139  {
140  GraphicsPath^ get()
141  {
142  GraphicsPath^ path = gcnew GraphicsPath();
143  Draw(path,m_ptArr);
144  return path;
145  }
146  }
147 
151  [BrowsableAttribute(false)]
152  property array<RectangleF>^ PointRect
153  {
154  virtual array<RectangleF>^ get()
155  {
156  array<PointF>^ pts = Points;
157  array<RectangleF>^ rectArr = gcnew array<RectangleF>(pts->Length);
158  for(int i=0;i<pts->Length;i++)
159  {
160  rectArr[i] = RectangleF(pts[i].X-4,pts[i].Y-4,8,8);
161  }
162  return rectArr;
163  }
164  }
165 
169  [BrowsableAttribute(false)]
170  property Int16 PointsCount
171  {
172  virtual Int16 get(){return m_ptArr->Length;}
173  }
174 
179  void DrawPoints(Graphics ^g);
180 
185  array<PointF>^ GetNormalPoints();
191  virtual void Save(XmlDocument^ writer,XmlElement^ element);
196  virtual void Load(XmlElement^ element);
197 
206  void FlipGraphicsPath(GraphicsPath^ gp,float Width,float Height,bool bHorz,bool bVert);
207 
214  void DrawString(Graphics^ g, String^ text ,Point location)
215  {
216  System::Drawing::SolidBrush^ brush = gcnew System::Drawing::SolidBrush(Color::FromArgb(150,0,0,0));
217  StringFormat ^ Centre = gcnew StringFormat();
218  Centre->Alignment = StringAlignment::Center;
219  Font^ font = gcnew Font("Calibri",12);
220  System::Drawing::Rectangle rect = System::Drawing::Rectangle(location.X,location.Y,g->MeasureString(text,font).Width+5 ,g->MeasureString(text,font).Height);
221  g->FillRectangle(brush,rect);
222  g->DrawString(text, font,Brushes::Wheat,rect,Centre);
223  delete brush;
224  delete Centre;
225  delete font;
226  }
227  void DrawScale(GraphicsPath^ g,PointF pt1,PointF pt2,float distance);
228 
234  virtual void Move(int cx,int cy);
235 
241  virtual bool HitTest(PointF pt);
242 
248  virtual bool IntersectsRect(System::Drawing::Rectangle rect);
249 
254  virtual void ApplyMatrix(Matrix^ matrix);
255 
260  virtual Int16 GetPointIndex(PointF pt);
261 
266  virtual void Draw(Graphics^ g,array<PointF>^ ptArr,bool bShowSelection);
267  virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr);
268  void Burn(Graphics^ g);
269  protected:
276  static bool IsLineIntersectsRect(array<PointF>^ pts,System::Drawing::Rectangle rect);
277  static double getdistance(PointF start, PointF end,float fPixelWidth,float fPixelHeight);
278  protected:
279  Pen^ m_pen;
280  array<PointF>^ m_ptArr;
281  MSTAnnotationPage^ m_pPage;
282  bool m_bSelected;
283  };
284 }
285 }
286 }
Definition: AnnotationPage.h:95
void DrawString(Graphics^ g, String^ text, Point location)
Draw String.
Definition: Annotation.h:214
Definition: SinglePointAnnotation.h:37
Definition: Annotation.h:45