1 #include "Annotation.h"
2 #include "AnnotationPage.h"
3 using namespace System;
4 using namespace System::Collections::Generic;
5 using namespace System::Text;
6 using namespace System::Drawing;
7 using namespace System::Drawing::Drawing2D;
20 m_ptArr =
gcnew array<PointF>(2);
21 m_ptArr[0] = PointF(0,0);
22 m_ptArr[1] = PointF(0,0);
30 property Type AnnotationType
32 virtual Type
get()
override
34 return Annotations::Type::Line;
39 return IsLineIntersectsRect(m_ptArr,rect);
41 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override
43 gp->AddLine(ptArr[0],ptArr[1]);
52 m_clrFill = Color::Transparent;
54 [CategoryAttribute(
"General"), DescriptionAttribute(
"Color to fill in annotation. [Format: RGB/ARGB]")]
55 property Color FillColor
61 virtual void set(Color clr)
67 property Type AnnotationType
69 virtual Type
get()
override
71 return Annotations::Type::Rectangle;
75 property PointF Points[Int16]
77 virtual PointF
get(Int16 iIndex)
override
79 if(iIndex < 0 || iIndex >= 4)
throw gcnew System::ArgumentException(
"index out of bound");
80 return m_ptArr[iIndex];
82 virtual void set(Int16 iIndex,PointF Value)
override
84 if(m_ptArr->Length < 4 && iIndex==0)
89 if(m_ptArr->Length<4)Array::Resize(m_ptArr,4);
90 m_ptArr[iIndex] = Value;
91 Matrix^ mat =
gcnew Matrix();
92 mat->Rotate(-m_pPage->Slope);
93 mat->TransformPoints(m_ptArr);
94 if(iIndex==0||iIndex==1)
96 m_ptArr[2].X = m_ptArr[1].X;
97 m_ptArr[2].Y = m_ptArr[0].Y;
98 m_ptArr[3].X = m_ptArr[0].X;
99 m_ptArr[3].Y = m_ptArr[1].Y;
103 m_ptArr[0].X = m_ptArr[3].X;
104 m_ptArr[0].Y = m_ptArr[2].Y;
105 m_ptArr[1].X = m_ptArr[2].X;
106 m_ptArr[1].Y = m_ptArr[3].Y;
109 mat->Rotate(m_pPage->Slope);
110 mat->TransformPoints(m_ptArr);
114 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override
118 gp->AddRectangle(System::Drawing::Rectangle(Math::Min(ptArr[0].X,ptArr[1].X),
119 Math::Min(ptArr[0].Y,ptArr[1].Y),
120 Math::Abs(ptArr[0].X-ptArr[1].X),
121 Math::Abs(ptArr[0].Y-ptArr[1].Y)));
125 gp->AddLine(ptArr[0],ptArr[2]);
126 gp->AddLine(ptArr[2],ptArr[1]);
127 gp->AddLine(ptArr[1],ptArr[3]);
133 virtual void Draw(Graphics^ g,array<PointF>^ ptArr,
bool bShowSelection)
override;
135 virtual void Load(System::Xml::XmlElement^ element)
override;
136 virtual void Save(XmlDocument^ writer,XmlElement^ element)
override;
147 FillColor = Color::Gray;
149 [BrowsableAttribute(
false)]
150 property Color FillColor
152 virtual Color
get()
override
154 return Color::FromArgb(128,__super::FillColor.R,__super::FillColor.G,__super::FillColor.B);
156 virtual void set(Color clr)
override
158 __super::FillColor = clr;
161 [CategoryAttribute(
"General"), DescriptionAttribute(
"Hilite Color")]
162 property Color HiliteColor
168 virtual void set(Color clr)
173 [BrowsableAttribute(
false)]
174 property Int32 BorderWidth
181 [BrowsableAttribute(
false)]
182 property Color BorderColor
189 property Type AnnotationType
191 virtual Type
get()
override
193 return Annotations::Type::Hilite;
203 m_pen->CustomStartCap =
gcnew System::Drawing::Drawing2D::AdjustableArrowCap(5,8,
true);
206 property Type AnnotationType
208 virtual Type
get()
override
210 return Annotations::Type::Arrow;
221 m_bShowRulerMeasurement =
true;
224 property Type AnnotationType
226 virtual Type
get()
override
228 return Annotations::Type::Ruler;
232 property bool TickMarks
234 bool get(){
return m_bShowTick;}
235 void set(
bool value){m_bShowTick=value;}
238 property bool RulerMeasurement
240 bool get(){
return m_bShowRulerMeasurement;}
241 void set(
bool value){m_bShowRulerMeasurement=value;}
244 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override
246 gp->AddLine(ptArr[0],ptArr[1]);
250 Graphics^ g = Graphics::FromHwnd(IntPtr(0));
251 float cx = 2.54/g->DpiX;
252 float cy = 2.54/g->DpiY;
254 array<PointF>^ normalPts = GetNormalPoints();
255 DrawScale(gp,ptArr[0],ptArr[1],getdistance(normalPts[0],normalPts[1],cx,cy));
256 double dx = System::Convert::ToDouble( ptArr[0].X- ptArr[1].X);
257 double dy = System::Convert::ToDouble( ptArr[0].Y- ptArr[1].Y);
258 dx /= System::Math::Sqrt(System::Math::Pow(ptArr[0].X- ptArr[1].X, 2) + System::Math::Pow(ptArr[0].Y-ptArr[1].Y, 2));
259 dy /= System::Math::Sqrt(System::Math::Pow(ptArr[0].X- ptArr[1].X, 2) + System::Math::Pow(ptArr[0].Y-ptArr[1].Y, 2));
260 gp->AddLine((
float)(ptArr[1].X + 12*dy),(
float)(ptArr[1].Y - 12*dx),(
float)(ptArr[1].X - 12*dy),(
float)(ptArr[1].Y + 12*dx));
263 virtual void Draw(Graphics^ g,array<PointF>^ ptArr,
bool bShowSelection)
override;
268 virtual void Load(XmlElement^ element)
override;
275 virtual void Save(XmlDocument^ writer,XmlElement^ element)
override;
278 bool m_bShowRulerMeasurement;
287 m_bShowRulerMeasurement =
true;
289 property Type AnnotationType
291 virtual Type
get()
override
293 return Annotations::Type::CrossProduct;
296 property Int16 PointsCount
298 virtual Int16
get()
override{
return 4;}
301 property array<PointF>^ Points
303 virtual array<PointF>^
get()
override
305 if(m_ptArr->Length==4)
309 array<PointF>^ newArr = (array<PointF>^)m_ptArr->Clone();
310 Array::Resize(newArr,4);
311 double dx = System::Convert::ToDouble( newArr[0].X- newArr[1].X);
312 double dy = System::Convert::ToDouble( newArr[0].Y- newArr[1].Y);
314 dx /= System::Math::Sqrt(System::Math::Pow(newArr[0].X- newArr[1].X, 2) + System::Math::Pow(newArr[0].Y-newArr[1].Y, 2));
315 dy /= System::Math::Sqrt(System::Math::Pow(newArr[0].X- newArr[1].X, 2) + System::Math::Pow(newArr[0].Y-newArr[1].Y, 2));
316 double distance = getdistance(newArr[0],newArr[1],1,1)/2;
317 PointF pt((newArr[0].X+newArr[1].X)/2,(newArr[0].Y+newArr[1].Y)/2);
318 newArr[2]=PointF((
float)(pt.X + distance*dy),(
float)(pt.Y - distance*dx));
319 newArr[3]=PointF((
float)(pt.X - distance*dy),(
float)(pt.Y + distance*dx));
324 property PointF Points[Int16]
326 virtual PointF
get(Int16 iIndex)
override
328 if(iIndex < 0 || iIndex >= 4)
throw gcnew System::ArgumentException(
"Index out of range.");
329 if(iIndex < 2 || m_ptArr->Length >3)
330 return m_ptArr[iIndex];
333 array<PointF>^ ptArr = Points;
334 return ptArr[iIndex];
337 virtual void set(Int16 iIndex,PointF Value)
override
339 if(iIndex < 0 || iIndex >= 4)
throw gcnew System::ArgumentException(
"Index out of range.");
340 if(m_ptArr->Length < 4)
342 if(m_ptArr->Length>=iIndex)
343 Array::Resize(m_ptArr,iIndex+1);
344 m_ptArr[iIndex] = Value;
350 if(iIndex == 0 || iIndex ==1)
352 float Numerator = m_ptArr[1].Y-m_ptArr[0].Y;
353 float Denominator = m_ptArr[1].X-m_ptArr[0].X;
355 Denominator=(float)0.001;
356 m = Numerator/Denominator;
357 c = m_ptArr[1].Y-m*m_ptArr[1].X;
361 float Numerator = m_ptArr[3].Y-m_ptArr[2].Y;
362 float Denominator = m_ptArr[3].X-m_ptArr[2].X;
364 Denominator=(float)0.001;
365 m = Numerator/Denominator;
366 c = m_ptArr[3].Y-m*m_ptArr[3].X;
368 pt.X = (m*Value.Y + Value.X - m*c)/(m*m+1);
369 pt.Y = (m*m*Value.Y + m*Value.X + c)/(m*m+1);
370 m_ptArr[iIndex] = pt;
377 return __super::GetPointIndex(pt);
380 property bool TickMarks
382 bool get(){
return m_bShowTick;}
383 void set(
bool value){m_bShowTick=value;}
386 property bool RulerMeasurement
388 bool get(){
return m_bShowRulerMeasurement;}
389 void set(
bool value){m_bShowRulerMeasurement=value;}
398 array<PointF> ^ptArr =
gcnew array<PointF>(2);
399 ptArr[0] = m_ptArr[2];
400 ptArr[1] = m_ptArr[3];
401 return IsLineIntersectsRect(m_ptArr,rect)||IsLineIntersectsRect(ptArr,rect);
403 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override
405 Graphics^ g = Graphics::FromHwnd(IntPtr(0));
406 float cx = 2.54/g->DpiX;
407 float cy = 2.54/g->DpiY;
409 array<PointF>^ normalPts = GetNormalPoints();
411 gp->AddLine(ptArr[0],ptArr[1]);
414 DrawScale(gp,ptArr[0],ptArr[1],getdistance(normalPts[0],normalPts[1],cx,cy));
415 gp->AddLine(ptArr[2],ptArr[3]);
418 DrawScale(gp,ptArr[2],ptArr[3],getdistance(normalPts[2],normalPts[3],cx,cy));
420 virtual void Draw(Graphics^ g,array<PointF>^ ptArr,
bool bShowSelection)
override;
425 virtual void Load(XmlElement^ element)
override;
432 virtual void Save(XmlDocument^ writer,XmlElement^ element)
override;
435 bool m_bShowRulerMeasurement;
444 property Type AnnotationType
446 virtual Type
get()
override
448 return Annotations::Type::Ellipse;
451 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptfArr)
override
453 array<PointF>^ ptArr = (array<PointF>^)ptfArr->Clone();
454 Matrix^ mat =
gcnew Matrix();
455 float Slope = (ptArr->Length>2)?m_pPage->Slope:0;
457 mat->TransformPoints(ptArr);
458 System::Drawing::Rectangle rect(Math::Min(ptArr[0].X,ptArr[1].X),
459 Math::Min(ptArr[0].Y,ptArr[1].Y),
460 Math::Abs(ptArr[0].X-ptArr[1].X+1),
461 Math::Abs(ptArr[0].Y-ptArr[1].Y+1));
462 gp->AddEllipse(rect);
477 property Type AnnotationType
479 virtual Type
get()
override
481 return Annotations::Type::Cloud;
484 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override;
485 virtual void Draw(Graphics^ gp,array<PointF>^ ptArr,
bool bShowSelection)
override;
494 [BrowsableAttribute(
false)]
495 property Color FillColor
497 virtual Color
get()
override
499 return Color::Transparent;
502 property Type AnnotationType
504 virtual Type
get()
override
506 return Annotations::Type::ScratchOut;
509 virtual void Draw(GraphicsPath^ gp,array<PointF>^ ptArr)
override;
517 m_TextBox =
gcnew System::Windows::Forms::TextBox();
518 m_sText =
gcnew String(
"Write Text Here.");
519 FillColor = Color::Yellow;
520 m_font =
gcnew Font(
"Calibri",20);
521 m_TextColor = Color::Green;
525 [BrowsableAttribute(
false)]
539 property Type AnnotationType
541 virtual Type
get()
override
543 return Annotations::Type::TextNote;
547 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text font.")]
548 property System::Drawing::Font^ font
550 System::Drawing::Font^
get(){
return m_font;}
551 void set(System::Drawing::Font^ Value){m_font = Value;}
553 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text.")]
554 property String^ Text
556 String^
get(){
return m_sText;}
557 void set(String^ Value)
559 if(Value !=
nullptr && Value->Length>0)
563 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text color. [Format: RGB/ARGB]")]
564 property System::Drawing::Color TextColor
566 Color
get(){
return m_TextColor;}
567 void set(Color Value){m_TextColor=Value;}
569 void EditText(
bool value);
570 virtual void Draw(Graphics^ g,array<PointF>^ ptArr,
bool bShowSelection)
override;
571 virtual void Load(System::Xml::XmlElement^ element)
override;
572 virtual void Save(XmlDocument^ writer,XmlElement^ element)
override;
578 static System::Windows::Forms::TextBox^ m_TextBox;
588 m_font =
gcnew Font(
"Calibri",20);
589 m_TextColor = Color::Green;
590 FillColor = Color::FromArgb(128,0,255,0);
593 property Type AnnotationType
595 virtual Type
get()
override
597 return Annotations::Type::Stamp;
600 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text.")]
601 property String^ Text
603 String^
get(){
return m_sText;}
604 void set(String^ Value)
610 [CategoryAttribute(
"General"), DescriptionAttribute(
"Image.")]
611 property Image^ StampImage
613 Image^
get(){
return m_Image;}
614 void set(
Image^ Value)
620 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text color. [Format: RGB/ARGB]")]
621 property System::Drawing::Color TextColor
623 Color
get(){
return m_TextColor;}
624 void set(Color Value){m_TextColor=Value;}
626 [CategoryAttribute(
"General"), DescriptionAttribute(
"Text font.")]
627 property System::Drawing::Font^ font
629 System::Drawing::Font^
get(){
return m_font;}
630 void set(System::Drawing::Font^ Value){m_font = Value;}
633 virtual void Draw(Graphics^ g,array<PointF>^ ptArr,
bool bShowSelection)
override;
634 virtual void Load(System::Xml::XmlElement^ element)
override;
635 virtual void Save(XmlDocument^ writer,XmlElement^ element)
override;
Definition: TwoPointAnnotation.h:281
Definition: TwoPointAnnotation.h:438
Definition: TwoPointAnnotation.h:512
Definition: TwoPointAnnotation.h:26
Definition: TwoPointAnnotation.h:47
Definition: AnnotationPage.h:95
Definition: TwoPointAnnotation.h:15
virtual bool IntersectsRect(System::Drawing::Rectangle rect) override
use to check annotation lies in rectangle or not.
Definition: TwoPointAnnotation.h:396
Definition: TwoPointAnnotation.h:471
Definition: TwoPointAnnotation.h:215
Definition: TwoPointAnnotation.h:488
Definition: TwoPointAnnotation.h:142
virtual bool IntersectsRect(System::Drawing::Rectangle rect) override
use to check annotation lies in rectangle or not.
Definition: TwoPointAnnotation.h:37
Definition: TwoPointAnnotation.h:582
Definition: TwoPointAnnotation.h:198
virtual Int16 GetPointIndex(PointF pt) override
use to get index of point.
Definition: TwoPointAnnotation.h:374
Definition: Annotation.h:45