3 #include "Annotation.h"
5 using namespace System;
6 using namespace System::Text;
7 using namespace System::Drawing;
8 using namespace System::Drawing::Drawing2D;
9 using namespace MST::Imaging::Annotations;
10 using namespace System::Collections::Generic;
30 m_AnnList =
gcnew List<MSTAnnotation^>();
36 property int AnnotationCount
38 int get(){
return m_AnnList->Count;}
44 property List<MSTAnnotation^>^ AllAnnotation
46 List<MSTAnnotation^>^
get(){
return m_AnnList;}
56 if(value <= m_AnnList->Count)
57 return m_AnnList[value];
66 virtual System::Collections::IEnumerator^ GetEnumerator();
83 void RemoveAllAnnotation();
85 List<MSTAnnotation^>^ m_AnnList;
89 public delegate
void ZoomChangeEvent(
float fScale);
111 m_OrientationPath =
gcnew System::Drawing::Drawing2D::GraphicsPath();
112 m_OrientationPath->AddRectangle(System::Drawing::Rectangle(0,0,100,100));
113 m_ImgPath =
gcnew System::Drawing::Drawing2D::GraphicsPath();
118 Object^
get(){
return m_Tag;}
119 void set(Object^ value){m_Tag=value;}
132 property System::Windows::Forms::ScrollableControl^ Parent
134 System::Windows::Forms::ScrollableControl^
get()
138 void set(System::Windows::Forms::ScrollableControl^ parent)
147 property float Rotate
149 float get(){
return m_iRotateAngle;}
150 void set(
float Value)
152 while(Value >= 360)Value-=360;
153 while(Value <= -360)Value+=360;
154 if(Value < 0)Value = 360 + Value;
155 if(Value==m_iRotateAngle)
return;
156 System::Drawing::Drawing2D::Matrix^ matrix =
gcnew System::Drawing::Drawing2D::Matrix();
157 System::Drawing::Rectangle ClientRect = m_Parent->ClientRectangle;
158 matrix->RotateAt(Value-m_iRotateAngle,PointF(ClientRect.Width/2,ClientRect.Height/2),System::Drawing::Drawing2D::MatrixOrder::Append);
161 m_iRotateAngle = (int)Value;
167 property bool FlipHorizontal
169 bool get(){
return m_bHorzFlip;}
172 if(m_bHorzFlip!=Value)
174 System::Drawing::Drawing2D::Matrix^ matrix =
gcnew System::Drawing::Drawing2D::Matrix(-1, 0, 0, 1, 0, 0);
175 matrix->Translate(-m_Parent->ClientRectangle.Width,0);
186 property bool FlipVertical
188 bool get(){
return m_bVertFlip;}
191 if(m_bVertFlip!=Value)
193 System::Drawing::Drawing2D::Matrix^ matrix =
gcnew System::Drawing::Drawing2D::Matrix(1, 0, 0, -1, 0, 0);
194 matrix->Translate(0,-m_Parent->ClientRectangle.Height);
207 float get(){
return m_iZoom;}
208 void set(
float Value)
210 if(Value<10)Value=10;
211 if(Value>9999)Value=9999;
212 if(Value==m_iZoom)
return;
213 float fZoom = Value/m_iZoom;
214 System::Drawing::Drawing2D::Matrix^ matrix =
gcnew System::Drawing::Drawing2D::Matrix();
215 System::Drawing::Rectangle rect = m_Parent->ClientRectangle;
216 float cx = rect.Width / 2;
217 float cy = rect.Height / 2;
218 matrix->Translate(cx,cy, System::Drawing::Drawing2D::MatrixOrder::Append);
219 matrix->Scale(fZoom,fZoom,System::Drawing::Drawing2D::MatrixOrder::Append);
220 matrix->Translate(-cx*(2*fZoom-1),-cy*(2*fZoom-1), System::Drawing::Drawing2D::MatrixOrder::Append);
224 ZoomChangeEventHandler(m_iZoom);
232 PointF pt1 = m_OrientationPath->PathPoints[0];
233 PointF pt2 = m_OrientationPath->PathPoints[1];
234 return GetSlope(pt1 ,pt2);
237 property PointF ReferencePoint
241 array<PointF>^ ptArr = m_OrientationPath->PathPoints;
242 float minX=ptArr[0].X,minY=ptArr[0].Y,maxX=ptArr[0].X,maxY=ptArr[0].Y;
243 for(
int i=1; i<ptArr->Length; i++)
245 minX = Math::Min(minX,ptArr[i].X);
246 minY = Math::Min(minY,ptArr[i].Y);
247 maxX = Math::Max(maxX,ptArr[i].X);
248 maxY = Math::Max(maxY,ptArr[i].Y);
250 return PointF(((
float)(maxX+minX))/2,((
float)(maxY+minY))/2);
253 property array<PointF>^ ImagePoints
257 return m_ImgPath->PathPoints;
268 MSTAnnotation^ CreateAnnotation(Annotations::Type type,Pen^ pen);
275 void Draw(Graphics^ g,System::Drawing::Image^ image,
bool bAnnotationVisible);
276 void DrawImage(Graphics^ g,System::Drawing::Image^ image,array<PointF>^ pts);
277 void DrawString(Graphics^ g,Font^ font,Color TextColor,StringFormat^ fmt,String^ Text,array<PointF>^ pts);
278 void DrawString(Graphics^ g,Font^ font,Color TextColor,String^ Text,array<PointF>^ pts);
279 array<Byte>^ BurnAnnotation(System::Drawing::Image^ image);
285 void ApplyMatrix(System::Drawing::Drawing2D::Matrix^ matrix);
287 void Translate(
float cx,
float cy)
289 if(cx==0&&cy==0)
return;
290 System::Drawing::Drawing2D::Matrix^ matrix =
gcnew System::Drawing::Drawing2D::Matrix();
291 matrix->Translate(cx,cy,System::Drawing::Drawing2D::MatrixOrder::Append);
298 void BringImageToCenter();
299 void ScaleImageToFitWindow();
300 void ScaleImageToFitWindowWidth();
301 void ScaleImageToFitWindowHeight();
302 void SetImageDimension(
float cx,
float cy)
305 FlipHorizontal =
false;
306 FlipVertical =
false;
309 array<PointF> ^arr =
gcnew array<PointF>(4);
310 PointF pt = ReferencePoint;
311 arr[0]=PointF(pt.X-cx/2,pt.Y-cy/2);
312 arr[1]=PointF(pt.X+cx/2,pt.Y-cy/2);
313 arr[2]=PointF(pt.X-cx/2,pt.Y+cy/2);
314 arr[3]=PointF(pt.X+cx/2,pt.Y+cy/2);
315 m_ImgPath->AddPolygon(arr);
318 void TransformPoints(array<PointF>^,
bool bFromCenter);
319 void TransformPoints(array<PointF>^);
320 void DeTransformPoints(array<PointF>^,
bool bFromCenter);
321 void DeTransformPoints(array<PointF>^);
322 static float GetSlope(PointF pt1 , PointF pt2);
324 event ZoomChangeEvent^ ZoomChangeEventHandler;
333 System::Windows::Forms::ScrollableControl^ m_Parent;
334 System::Drawing::Drawing2D::GraphicsPath ^m_OrientationPath;
335 System::Drawing::Drawing2D::GraphicsPath ^m_ImgPath;
AnnotationCollection()
Constructor of a class.
Definition: AnnotationPage.h:28
Definition: AnnotationPage.h:95
Definition: AnnotationPage.h:22
MSTAnnotationPage(System::Windows::Forms::ScrollableControl^ parent)
Constructor of a class.
Definition: AnnotationPage.h:102
Definition: Annotation.h:45