프로젝트

일반

사용자정보

개정판 10df01b4

ID10df01b4e37896e1d50a21758423b919e8447185
상위 d5ec83f5
하위 9e29ba79

백흠경이(가) 5년 이상 전에 추가함

issue #937: Final시 텍스트가 잘리는 현상 수정

Change-Id: I51be12df2188d7ec9a2df0854a3123c294bd06bc

차이점 보기:

FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_DrawString.cs
20 20
            contentByte.SaveState();
21 21

  
22 22
            Rect rect = new Rect(sp, ep);
23
            List<Point> point = new List<Point>();
24
            point.Add(rect.TopLeft);
25
            point.Add(rect.BottomLeft);
26
            point.Add(rect.BottomRight);
27
            point.Add(rect.TopRight);
23
            List<Point> points = new List<Point>();
24
            points.Add(rect.TopLeft);
25
            points.Add(rect.BottomLeft);
26
            points.Add(rect.BottomRight);
27
            points.Add(rect.TopRight);
28 28

  
29
            var calRect = MathSet.GetPointsToRectX(point);
30
            lineSize = lineSize * 72 / 96*0.5;
29
            lineSize = lineSize * 72 / 96 * 0.5;
31 30
            contentByte.SetLineWidth((float)lineSize);
32 31

  
33 32
            if ((PaintStyle & PaintSet.Hatch) == PaintSet.Hatch)
34 33
            {
35 34
                double ArcLength = 10;  /// default arc length
36 35

  
37
                DrawSet_Cloud.DrawCloud(point, lineSize, ArcLength, contentByte, new DoubleCollection(99999), color, (PaintStyle & ~PaintSet.Hatch), opac);
36
                DrawSet_Cloud.DrawCloud(points, lineSize, ArcLength, contentByte, new DoubleCollection(99999), color, (PaintStyle & ~PaintSet.Hatch), opac);
38 37

  
39 38
                contentByte.RestoreState();
40 39
                contentByte.SaveState();
41 40
            }
42 41
            else if (((PaintStyle & PaintSet.Highlight) == PaintSet.Highlight) || ((PaintStyle & PaintSet.Fill) == PaintSet.Fill))
43 42
            {
44
                PdfGState gs1 = new PdfGState();
45
                gs1.FillOpacity = 0.7f;
46
                gs1.StrokeOpacity = (float)opac;
47
                if ((PaintStyle & PaintSet.Highlight) == PaintSet.Highlight)
48
                {
49
                    contentByte.SetColorFill(BaseColor.YELLOW);
50
                }
51
                else
43
                if (PaintStyle == PaintSet.Fill)
52 44
                {
53
                    contentByte.SetColorFill(BaseColor.WHITE);
45
                    PaintStyle = PaintSet.None;
54 46
                }
55
                contentByte.SetColorStroke(bs);
56
                contentByte.SetGState(gs1);
57 47

  
58 48
                contentByte.NewPath();
59
                contentByte.Rectangle((float)calRect.Left, (float)calRect.Bottom, (float)calRect.Width, (float)calRect.Height);
60
                System.Drawing.Drawing2D.Matrix mat2 = new System.Drawing.Drawing2D.Matrix();
61
                mat2.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y));
62
                contentByte.Transform(mat2);
63

  
64
                contentByte.Fill();
65
                contentByte.RestoreState();
66
                contentByte.SaveState();
49
                contentByte.MoveTo(points[0].X, points[0].Y);
50
                for (int i = 1; i <= points.Count; ++i) contentByte.LineTo(points[i%points.Count].X, points[i%points.Count].Y);
51
                HoneyPDFLib_DrawSet_Shape.PaintFill(contentByte, PaintStyle, bs);
67 52
            }
68 53

  
69
            //string ARIALUNI_TFF = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial Unicode MS.TTF");
70
            //string ARIALUNI_TFF = @"‪C:\Windows\Fonts\ARIALUNI.TTF";
71
            //string ARIALUNI_TFF = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), fontFamilly + ".ttf");
72

  
73 54
            string ARIALUNI_TFF = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial Unicode MS.TTF");
74 55

  
75 56
            //BaseFont bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
......
99 80
                itextFont.SetStyle(itextFont.Style | Font.UNDERLINE);
100 81
            }
101 82

  
102
            //Font itextFont = FontFactory.GetFont("Arial", (float)FontSize / (float)3.0, BaseColor.GRAY);
103
            //BaseFont bf = BaseFont.CreateFont("HYGoThic-Medium", "UniKS-UCS2-H", false); 
104
            //BaseFont bf = BaseFont.CreateFont("HYGoThic-Medium", "UniKS-UCS2-H", BaseFont.NOT_EMBEDDED);
105
            //itextFont.SetStyle(Font.UNDERLINE | Font.BOLDITALIC);
106 83
            contentByte.SetColorStroke(bs);
107
            //contentByte.SetWordSpacing((float)0);
108 84
            contentByte.SetColorFill(bs);
109
            //contentByte.SetCharacterSpacing((float)-0.05);
110
            //contentByte.SetCharacterSpacing((float)0.05);
111
            //contentByte.SetFontAndSize(bf, (float)FontSize / (float)3.0);
112

  
113
            //contentByte.BeginText();
114

  
115
            //Point rx = new Point(0, 0);
116
            //Point ry = new Point(0, 0);
117
            //if (PaintStyle == MarkupEditToolKit.Common.PaintSet.Hatch)
118
            //{
119
            //    contentByte.MoveText((float)sp.X + (float)1.5, (float)sp.Y - (float)font.Height / (float)2.5 - (float)font.Height / (float)2.5);
120
            //}
121
            //else
122
            //{
123
            //    contentByte.MoveText((float)sp.X, (float)sp.Y - (float)font.Height / (float)2.25 - (float)font.Height / (float)2.25);
124
            //}
125

  
126
            //contentByte.SetTextMatrix(300, 300);
127
            //contentByte.ShowText(text);
128

  
129
            //contentByte.EndText();
130

  
85
            
131 86
            ColumnText ct = new ColumnText(contentByte);
132 87
            PdfGState gs3 = new PdfGState();
133 88
            gs3.StrokeOpacity = (float)opac;
134 89
            gs3.FillOpacity = (float)opac;
135 90

  
136
            //ct.Canvas.Transform(new System.Drawing.Drawing2D.Matrix(0,1,-1,0,100,200));
137

  
138
            //Matrix mat = new Matrix();
139
            //mat.RotateAt(90,
140
            //ct.Canvas.Transform(mat);
141

  
142 91
            System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
143 92
            mat.RotateAt((float)Angle * -1, new System.Drawing.PointF((float)sp.X, (float)sp.Y));
144 93

  
......
147 96
                text = text.Remove(0, 1);
148 97
            }
149 98

  
150
            //text = text.Replace("\r", "\r ");
151

  
152 99
            ct.Canvas.Transform(mat);
153 100
            ct.Canvas.SetGState(gs3);
154 101
            itextFont.Size -= 0.3f;
......
156 103
            ct.Alignment = Element.ALIGN_CENTER | Element.ALIGN_TOP;
157 104
            ct.SetLeading(itextFont.CalculatedSize + 1, ct.MultipliedLeading);
158 105

  
159
            //var ts = new Rectangle(calRect.Left + (float)1.5, calRect.Bottom , calRect.Right, calRect.Top+ (float)1.5);
160
            var ts = new Rectangle(calRect.Left + (float)1.5, calRect.Bottom, calRect.Right, calRect.Top + (float)1.5);
161
            ct.SetSimpleColumn(ts);
106
            var calRect = MathSet.GetPointsToRectX(points);
107
            calRect.Left += (float)lineSize;
108
            calRect.Top += (float)lineSize;
109
            calRect.Right += (float)lineSize;
110
            calRect.Bottom -= (float)lineSize;
111
            ct.SetSimpleColumn(calRect);
162 112
            ct.Go();
163 113

  
164 114
            contentByte.RestoreState();
......
178 128
            points.Add(rect.BottomRight);
179 129
            points.Add(rect.TopRight);
180 130

  
181
            //lineSize = 1;
182
            var calRect = MathSet.GetPointsToRectX(points);
183 131
            lineSize = lineSize * 72 / 96*0.5;
184 132
            contentByte.SetLineWidth((float)lineSize);
185 133

  
......
235 183
                itextFont.SetStyle(itextFont.Style | Font.UNDERLINE);
236 184
            }
237 185

  
238
            //Font itextFont = FontFactory.GetFont("Arial", (float)FontSize / (float)3.0, BaseColor.GRAY);
239
            //BaseFont bf = BaseFont.CreateFont("HYGoThic-Medium", "UniKS-UCS2-H", false); 
240
            //BaseFont bf = BaseFont.CreateFont("HYGoThic-Medium", "UniKS-UCS2-H", BaseFont.NOT_EMBEDDED);
241
            //itextFont.SetStyle(Font.UNDERLINE | Font.BOLDITALIC);
242 186
            contentByte.SetColorStroke(bs);
243
            //contentByte.SetWordSpacing((float)0);
244 187
            contentByte.SetColorFill(bs);
245
            //contentByte.SetCharacterSpacing((float)-0.05);
246
            //contentByte.SetCharacterSpacing((float)0.05);
247
            //contentByte.SetFontAndSize(bf, (float)FontSize / (float)3.0);
248

  
249
            //contentByte.BeginText();
250

  
251
            //Point rx = new Point(0, 0);
252
            //Point ry = new Point(0, 0);
253
            //if (PaintStyle == MarkupEditToolKit.Common.PaintSet.Hatch)
254
            //{
255
            //    contentByte.MoveText((float)sp.X + (float)1.5, (float)sp.Y - (float)font.Height / (float)2.5 - (float)font.Height / (float)2.5);
256
            //}
257
            //else
258
            //{
259
            //    contentByte.MoveText((float)sp.X, (float)sp.Y - (float)font.Height / (float)2.25 - (float)font.Height / (float)2.25);
260
            //}
261

  
262
            //contentByte.SetTextMatrix(300, 300);
263
            //contentByte.ShowText(text);
264

  
265
            //contentByte.EndText();
266 188

  
267 189
            ColumnText ct = new ColumnText(contentByte);
268 190
            PdfGState gs3 = new PdfGState();
......
277 199
                text = text.Remove(0, 1);
278 200
            }
279 201

  
280
            //text = text.Replace("\r", "\r ");
281

  
282 202
            ct.Canvas.Transform(mat);
283 203
            ct.Canvas.SetGState(gs3);
284 204
            itextFont.Size -= 0.3f;
......
286 206
            ct.Alignment = Element.ALIGN_CENTER | Element.ALIGN_TOP;
287 207
            ct.SetLeading(itextFont.CalculatedSize + 1, ct.MultipliedLeading);
288 208

  
209
            var calRect = MathSet.GetPointsToRectX(points);
210
            calRect.Left += (float)lineSize;
211
            calRect.Top += (float)lineSize;
212
            calRect.Right -= (float)lineSize;
213
            calRect.Bottom -= (float)lineSize;
289 214
            if (PaintStyle == PaintSet.None)
290 215
            {
291
                var ts = new Rectangle(calRect.Left + (float)1.5, calRect.Bottom, calRect.Right, calRect.Top + (float)1.5);
292
                ct.SetSimpleColumn(ts);
216
                ct.SetSimpleColumn(calRect);
293 217
            }
294 218
            else if (((PaintStyle & PaintSet.Fill) == PaintSet.Fill) || ((PaintStyle & PaintSet.Highlight) == PaintSet.Highlight))
295 219
            {
296
                var ts = new Rectangle(calRect.Left + (float)1.5, calRect.Bottom, calRect.Right, calRect.Top + (float)1.5);
297
                ct.SetSimpleColumn(ts);
220
                ct.SetSimpleColumn(calRect);
298 221
            }
299 222
            else if ((PaintStyle & PaintSet.Fill) == PaintSet.Hatch)
300 223
            {
301
                var ts = new Rectangle(calRect.Left + (float)1.5, calRect.Bottom, calRect.Right, calRect.Top + (float)1.5);
302
                ct.SetSimpleColumn(ts);
224
                ct.SetSimpleColumn(calRect);
303 225
            }
304 226

  
305 227
            ct.Go();
FinalService/KCOM_FinalService/MarkupToPDF/Controls_PDF/HoneyPDFLib_DrawSet_Shape.cs
192 192

  
193 193
            if(PaintStyle == PaintSet.None)
194 194
            {
195
                contentByte.SetColorStroke(bs);
195 196
                contentByte.ClosePathStroke();
196 197
            }
197 198
        }
FinalService/KCOM_FinalService/MarkupToPDF/MarkupToPDF.cs
114 114
            return angle;
115 115
        }
116 116

  
117
        public string replaceXY(string text)
118
        {
119
            return text.Replace(@"_x", @"X").Replace(@"_y", @"Y");
120

  
121
        }
122

  
123

  
124

  
125 117
        #endregion
126 118

  
127 119
        #region 생성자 & 소멸자
......
788 780
                                            using (S_TextControl control = JsonSerializerHelper.JsonDeserialize<S_TextControl>(item))
789 781
                                            {
790 782
                                                string[] data2 = control.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
791
                                                string Text = " " + replaceXY(control.Text);
783
                                                string Text = control.Text;
792 784

  
793 785
                                                bool isUnderline = false;
794 786
                                                control.BoxW -= scaleWidth;
......
915 907

  
916 908
                                                if (Paint == PaintSet.Hatch)
917 909
                                                {
918
                                                    Text = replaceXY(control.ArrowText);
910
                                                    Text = control.ArrowText;
919 911
                                                }
920 912
                                                else
921 913
                                                {
922
                                                    Text = " " + replaceXY(control.ArrowText);
914
                                                    Text = control.ArrowText;
923 915
                                                }
924 916

  
925 917
                                                try
MarkupToPDF/Controls/Text/TextControl.cs
297 297
        {
298 298
            this.ApplyTemplate();
299 299

  
300
            //pathGeometry = new PathGeometry();
301

  
302 300
            List<Point> pCloud = new List<Point>
303 301
            {
304
                //new Point(0, 0),
305
                //new Point(0, 0 + BoxHeight + 2),
306
                //new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2),
307
                //new Point(0 + BoxWidth + 4 ,0),
308
                //new Point(0, 0)
309

  
310 302
                new Point(0, 0),
311 303
                new Point(0, 0 + BoxHeight + 0),
312 304
                new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0),
313 305
                new Point(0 + BoxWidth + 2 ,0),
314
                new Point(0, 0)
315 306
            };
316 307

  
317 308
            if (Base_TextPath != null)
......
327 318
                    case 1:
328 319
                        {
329 320
                            PathData = (Generate_Rect(pCloud));
330

  
331 321
                            List<Point> pCloud2 = new List<Point>
332 322
                            {
333
                                //new Point(0, 0),
334
                                //new Point(0, 0 + BoxHeight + 2),
335
                                //new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2),
336
                                //new Point(0 + BoxWidth + 4 ,0),
337
                                //new Point(0, 0)
338

  
339 323
                                new Point(0, 0),
340 324
                                new Point(0, 0 + BoxHeight + 0),
341 325
                                new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0),
342 326
                                new Point(0 + BoxWidth + 10 ,0),
343
                                new Point(0, 0)
344 327
                            };
345

  
346 328
                            PathDataInner = (GenerateInner(pCloud));
347 329
                        }
348 330
                        break;
......
373 355
        #region Drawing Cloud Method
374 356
        public static PathGeometry Generate_Rect(List<Point> pData)
375 357
        {
376
            //this.StartPoint;
377

  
378 358
            PathFigure pathFigure = new PathFigure();
379 359
            pathFigure.StartPoint = pData[0];
380 360

  
381
            LineSegment lineSegment0 = new LineSegment();
382
            lineSegment0.Point = pData[0];
383
            pathFigure.Segments.Add(lineSegment0);
384

  
385
            LineSegment lineSegment1 = new LineSegment();
386
            lineSegment1.Point = pData[1];
387
            pathFigure.Segments.Add(lineSegment1);
388

  
389
            LineSegment lineSegment2 = new LineSegment();
390
            lineSegment2.Point = pData[2];
391
            pathFigure.Segments.Add(lineSegment2);
392

  
393
            LineSegment lineSegment3 = new LineSegment();
394
            lineSegment3.Point = pData[3];
395
            pathFigure.Segments.Add(lineSegment3);
361
            PolyLineSegment polyline = new PolyLineSegment(pData, true);
362
            pathFigure.Segments.Add(polyline);
396 363

  
397 364
            PathGeometry rectPathGeometry = new PathGeometry();
398 365
            rectPathGeometry.Figures = new PathFigureCollection();
......
410 377
            double area = MathSet.AreaOf(pData);
411 378
            bool reverse = (area > 0);
412 379
            int count = pData.Count;
413
            for (int i = 0; i < (count - 1); i++)
380
            for (int i = 0; i < count; i++)
414 381
            {
415
                PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
382
                PathFigure pathFigure = GenerateLineWithCloud(pData[i%count], pData[(i + 1)%count], 20, reverse);
416 383
                pathFigure.IsClosed = false;
417 384
                pathFigure.IsFilled = true;
418 385
                _pathGeometry.Figures.Add(pathFigure);
419 386
            }
420 387

  
421
            //    PathFigure pathFigur2= new PathFigure();
422
            //pathFigur2.StartPoint = pData[0];
423

  
424
            //    LineSegment lineSegment0 = new LineSegment();
425
            //    lineSegment0.Point = pData[0];
426
            //pathFigur2.Segments.Add(lineSegment0);
427

  
428
            //    LineSegment lineSegment1 = new LineSegment();
429
            //    lineSegment1.Point = pData[1];
430
            //pathFigur2.Segments.Add(lineSegment1);
431

  
432
            //    LineSegment lineSegment2 = new LineSegment();
433
            //    lineSegment2.Point = pData[2];
434
            //pathFigur2.Segments.Add(lineSegment2);
435

  
436
            //    LineSegment lineSegment3 = new LineSegment();
437
            //    lineSegment3.Point = pData[3];
438
            //pathFigur2.Segments.Add(lineSegment3);
439

  
440

  
441
            //pathFigur2.IsClosed = true;
442
            //pathFigur2.IsFilled = true;
443
            //_pathGeometry.Figures.Add(pathFigur2);
444

  
445 388
            return _pathGeometry;
446 389
        }
447 390

  
......
456 399
            PathFigure pathFigur2 = new PathFigure();
457 400
            pathFigur2.StartPoint = pData[0];
458 401

  
459
            LineSegment lineSegment0 = new LineSegment();
460
            lineSegment0.Point = pData[0];
461
            pathFigur2.Segments.Add(lineSegment0);
462

  
463
            LineSegment lineSegment1 = new LineSegment();
464
            lineSegment1.Point = pData[1];
465
            pathFigur2.Segments.Add(lineSegment1);
466

  
467
            LineSegment lineSegment2 = new LineSegment();
468
            lineSegment2.Point = pData[2];
469
            pathFigur2.Segments.Add(lineSegment2);
470

  
471
            LineSegment lineSegment3 = new LineSegment();
472
            lineSegment3.Point = pData[3];
473
            pathFigur2.Segments.Add(lineSegment3);
474

  
402
            PolyLineSegment polyline = new PolyLineSegment(pData, true);
403
            pathFigur2.Segments.Add(polyline);
475 404

  
476 405
            pathFigur2.IsClosed = true;
477 406
            pathFigur2.IsFilled = true;
......
480 409
            return _pathGeometry;
481 410
        }
482 411

  
483

  
484

  
485 412
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse)
486 413
        {
487 414
            PathFigure pathFigure = new PathFigure();
MarkupToPDF_Old/Adorner/AdornerControl.xaml
1
<UserControl x:Class="MarkupToPDF.Adorner.AdornerControl"
2
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
             mc:Ignorable="d" 
7
             d:DesignHeight="300" d:DesignWidth="300">
8
    <Grid>
9
            
10
    </Grid>
11
</UserControl>
MarkupToPDF_Old/Adorner/AdornerControl.xaml.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Controls;
8
using System.Windows.Data;
9
using System.Windows.Documents;
10
using System.Windows.Input;
11
using System.Windows.Media;
12
using System.Windows.Media.Imaging;
13
using System.Windows.Navigation;
14
using System.Windows.Shapes;
15

  
16
namespace MarkupToPDF.Adorner
17
{
18
    /// <summary>
19
    /// Interaction logic for AdornerControl.xaml
20
    /// </summary>
21
    public partial class AdornerControl : UserControl
22
    {
23
        public AdornerControl()
24
        {
25
            InitializeComponent();
26
        }
27
    }
28
}
MarkupToPDF_Old/Adorner/Classes/AdornerMember.cs
1
using MarkupToPDF.Controls.Common;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5
using System.Text;
6
using System.Threading.Tasks;
7
using System.Windows;
8
using System.Windows.Controls.Primitives;
9

  
10
namespace MarkupToPDF.Adorner.Classes
11
{
12
    public class AdornerMember
13
    {
14
        public UIElement DrawingData { get; set; }
15
        public double DrawingAngle { get; set; }
16
        public List<Thumb> Thumbs { get; set; }
17
        public ControlType DrawingType { get; set; }
18
    }
19
}
MarkupToPDF_Old/App.Config
1
<?xml version="1.0" encoding="utf-8"?>
2
<configuration>
3
  <configSections>
4
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
6
  </configSections>
7
  <connectionStrings>
8
    <add name="Entity" connectionString="metadata=res://*/Database.Entity.csdl|res://*/Database.Entity.ssdl|res://*/Database.Entity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=honeyhead.net,7777;initial catalog=DeepView;user id=honeyhead;password=dof1073#;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
9
    <add name="Kcom_entity" connectionString="metadata=res://*/Database.Kcom_Entity.csdl|res://*/Database.Kcom_Entity.ssdl|res://*/Database.Kcom_Entity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=honeyhead.net,7777;initial catalog=DeepView;user id=honeyhead;password=dof1073#;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
10
    <add name="Kcom_Entity" connectionString="metadata=res://*/Database.Kcom_Entity.csdl|res://*/Database.Kcom_Entity.ssdl|res://*/Database.Kcom_Entity.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=honeyhead.net,7777;initial catalog=DeepView;user id=honeyhead;password=dof1073#;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
11
  </connectionStrings>
12
  <entityFramework>
13
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
14
  </entityFramework>
15
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
MarkupToPDF_Old/Controls/Common/BaseShape.cs
1
//using System;
2
//using System.Collections.Generic;
3
//using System.ComponentModel;
4
//using System.Linq;
5
//using System.Text;
6
//using System.Threading.Tasks;
7
//using System.Windows;
8
//using System.Windows.Controls;
9
//using System.Windows.Shapes;
10
//using System.Windows.Media;
11

  
12
//namespace MarkupToPDF.Controls.Common
13
//{
14
//    public class BaseShape : Control, IDisposable, INotifyPropertyChanged, IMarkupCommonData
15
//    {
16
//        public Path Base_BasePath { get; set; }
17

  
18

  
19
//        #region Property
20

  
21
//        public Point StartPoint
22
//        {
23
//            get
24
//            {
25
//                return (Point)GetValue(StartPointProperty);
26
//            }
27
//            set
28
//            {
29
//                SetValue(StartPointProperty, value);
30
//                OnPropertyChanged("StartPoint");
31
//            }
32
//        }
33

  
34
//        public Point EndPoint
35
//        {
36
//            get
37
//            {
38
//                return (Point)GetValue(EndPointProperty);
39
//            }
40
//            set
41
//            {
42
//                SetValue(EndPointProperty, value);
43
//                OnPropertyChanged("EndPoint");
44
//            }
45
//        }
46

  
47
//        public bool IsSelected
48
//        {
49
//            get
50
//            {
51
//                return (bool)GetValue(IsSelectedProperty);
52
//            }
53
//            set
54
//            {
55
//                SetValue(IsSelectedProperty, value);
56
//                OnPropertyChanged("IsSelected");
57
//            }
58
//        }
59

  
60
//        public double CanvasX
61
//        {
62
//            get { return (double)GetValue(CanvasXProperty); }
63
//            set
64
//            {
65
//                if (this.CanvasX != value)
66
//                {
67
//                    SetValue(CanvasXProperty, value);
68
//                    OnPropertyChanged("CanvasX");
69
//                }
70
//            }
71
//        }
72

  
73
//        public double CanvasY
74
//        {
75
//            get { return (double)GetValue(CanvasYProperty); }
76
//            set
77
//            {
78
//                if (this.CanvasY != value)
79
//                {
80
//                    SetValue(CanvasYProperty, value);
81
//                    OnPropertyChanged("CanvasY");
82
//                }
83
//            }
84
//        }
85

  
86
//        public ControlType ControlType
87
//        {
88
//            set
89
//            {
90
//                SetValue(ControlTypeProperty, value);
91
//                OnPropertyChanged("ControlType");
92
//            }
93
//            get
94
//            {
95
//                return (ControlType)GetValue(ControlTypeProperty);
96
//            }
97
//        }
98

  
99
//        #endregion Property
100

  
101
//        #region Dependency Property
102

  
103
//        public static readonly DependencyProperty IsSelectedProperty =
104
//              DependencyProperty.Register("IsSelected", typeof(bool), typeof(BaseShape), new FrameworkPropertyMetadata(false, IsSelectedChanged));
105

  
106
//        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
107
//                     "CanvasX", typeof(double), typeof(BaseShape), new PropertyMetadata((double)0, OnSetCansvasChanged));
108

  
109
//        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
110
//                "CanvasY", typeof(double), typeof(BaseShape), new PropertyMetadata((double)0, OnSetCansvasChanged));
111

  
112
//        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
113
//            "StartPoint", typeof(Point), typeof(BaseShape), new PropertyMetadata(new Point(0, 0), PointValueChanged));
114

  
115
//        public static readonly DependencyProperty SetPointProperty = DependencyProperty.Register(
116
//        "SetPoint", typeof(Point), typeof(BaseShape), new PropertyMetadata(new Point(0, 0), PointValueChanged));
117

  
118
//        public static readonly DependencyProperty OriginPointProperty = DependencyProperty.Register(
119
//        "OriginPoint", typeof(Point), typeof(BaseShape), new PropertyMetadata(new Point(0, 0), PointValueChanged));
120

  
121
//        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
122
//              "EndPoint", typeof(Point), typeof(BaseShape), new PropertyMetadata(new Point(0, 0), PointValueChanged));
123

  
124
//        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
125
//            "PointSet", typeof(List<Point>), typeof(BaseShape), new PropertyMetadata(new List<Point>(), PointValueChanged));
126

  
127
//        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
128
//        "StrokeColor", typeof(SolidColorBrush), typeof(BaseShape), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
129

  
130
//        public static readonly DependencyProperty ControlTypeProperty =
131
//                DependencyProperty.Register("ControlType", typeof(ControlType), typeof(BaseShape), new FrameworkPropertyMetadata(ControlType.Rectangle));
132

  
133
//        #endregion  Dependency Property
134

  
135
//        #region Dependency PropertyChanged
136

  
137
//        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
138
//        {
139
//            var instance = (BaseShape)sender;
140

  
141
//            if (e.OldValue != e.NewValue && instance != null)
142
//            {
143
//                instance.SetValue(e.Property, e.NewValue);
144
//            }
145
//        }
146

  
147
//        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
148
//        {
149
//            var instance = (BaseShape)sender;
150

  
151
//            if (e.OldValue != e.NewValue && instance.Base_BasePath != null)
152
//            {
153
//                instance.SetValue(e.Property, e.NewValue);
154

  
155
//                if (instance.IsSelected)
156
//                {
157
//                    instance.Base_BasePath.Stroke = new SolidColorBrush(Colors.Blue);
158
//                }
159
//                else
160
//                {
161
//                    instance.Base_BasePath.Stroke = new SolidColorBrush(Colors.Red);
162
//                }
163
//            }
164
//        }
165

  
166
//        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
167
//        {
168
//            var instance = (BaseShape)sender;
169

  
170
//            if (e.OldValue != e.NewValue && instance.Base_BasePath != null)
171
//            {
172
//                instance.SetValue(e.Property, e.NewValue);
173
//                //instance.SetRectPath(instance);
174
//            }
175
//        }
176

  
177
//        #endregion Dependency PropertyChanged
178

  
179

  
180
//        #region Internal Method
181
//        private void OnPropertyChanged(string name)
182
//        {
183
//            if (PropertyChanged != null)
184
//            {
185
//                PropertyChanged(this, new PropertyChangedEventArgs(name));
186
//            }
187
//        }
188

  
189
//        public event PropertyChangedEventHandler PropertyChanged;
190

  
191
//        public void Dispose()
192
//        {
193
//            GC.Collect();
194
//            GC.SuppressFinalize(this);
195
//        }
196

  
197
//        #endregion Internal Method
198
//    }
199
//}
MarkupToPDF_Old/Controls/Common/ControlType.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace MarkupToPDF.Controls.Common
8
{
9
    public enum ControlType
10
    {
11
        None,
12

  
13
        #region Line
14

  
15
        SingleLine,
16

  
17
        ArrowLine,
18

  
19
        CancelLine,
20

  
21
        TwinLine,
22

  
23
        DimLine,
24

  
25
        ChainLine,
26

  
27
        ArcLine,
28

  
29
        ArcArrow,
30

  
31
        ArrowMultiLine,
32

  
33
        #endregion
34

  
35
        #region Shape
36

  
37
        Rectangle, 
38

  
39
        RectCloud,
40

  
41
        Circle,
42

  
43
        Triangle,
44

  
45
        #endregion
46

  
47
        #region Text
48

  
49
        TextControl,
50

  
51
        TextBorder,
52

  
53
        TextCloud,
54

  
55
        #endregion
56

  
57
        #region ArrowText
58

  
59
        ArrowTextControl,
60

  
61
        ArrowTransTextControl,
62

  
63
        ArrowTextBorderControl,
64

  
65
        ArrowTransTextBorderControl,
66

  
67
        ArrowTextCloudControl,
68

  
69
        ArrowTransTextCloudControl,
70

  
71
        #endregion
72

  
73
        #region Polygone
74

  
75
        PolygonControl,
76

  
77
        PolygonCloud,
78

  
79
        #endregion
80

  
81
        #region Pen
82

  
83
        PenControl,
84

  
85
        #endregion
86

  
87
        #region Etc
88
        ImgControl,
89
        Date
90
        #endregion
91
    }
92
}
MarkupToPDF_Old/Controls/Common/HatchMake.cs
1
using System;
2
using System.Net;
3
using System.Windows;
4
using System.Windows.Controls;
5
using System.Windows.Documents;
6
using System.Windows.Ink;
7
using System.Windows.Input;
8
using System.Windows.Media;
9
using System.Windows.Media.Animation;
10
using System.Windows.Shapes;
11

  
12

  
13
namespace MarkupToPDF.Controls.Common
14
{
15
    public static class HatchMake
16
    {
17
        public static Brush CreateHatchBrush(SolidColorBrush color)
18
        {
19
            Color c = (color as SolidColorBrush).Color;
20
            LinearGradientBrush brush = new LinearGradientBrush();
21
            brush.MappingMode = BrushMappingMode.Absolute;
22
            brush.SpreadMethod = GradientSpreadMethod.Repeat;
23
            brush.StartPoint = new Point(0, 0);
24
            brush.EndPoint = new Point(8.0, 8.0);
25
            GradientStop gs = new GradientStop();
26
            gs.Color = c;
27
            brush.GradientStops.Add(gs);
28
            gs = new GradientStop();
29
            gs.Color = c;
30
            gs.Offset = 0.3;
31
            brush.GradientStops.Add(gs);
32
            gs = new GradientStop();
33
            gs.Color = Colors.Transparent;
34
            gs.Offset = 0.3;
35
            brush.GradientStops.Add(gs);
36
            gs = new GradientStop();
37
            gs.Color = Colors.Transparent;
38
            gs.Offset = 1;
39
            brush.GradientStops.Add(gs);
40
            return brush;
41
        }
42
    }
43
}
MarkupToPDF_Old/Controls/Common/IMarkupCommonData.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Media;
8

  
9

  
10
namespace MarkupToPDF.Controls.Common
11
{
12
    public interface IMarkupCommonData
13
    {
14
        bool IsSelected { get; set; }
15

  
16
        Point StartPoint { get; set; }
17

  
18
        Point EndPoint { get; set; }
19

  
20
        ControlType ControlType { get; set; }
21

  
22
        //MarkupWindow MarkupWindow { get; set; }
23
    }
24

  
25

  
26
    public interface IMarkupControlData : IMarkupCommonData
27
    {
28
        double CanvasX { get; set; }
29

  
30
        double CanvasY { get; set; }
31
    }
32

  
33
    public interface ITextControl : IPath
34
    {
35
        FontFamily TextFamily { get; set; }
36
        bool IsEditingMode { get; set; }
37
    }
38

  
39
    public interface IShapeControl : IPath
40
    {
41
        double Angle { get; set; }
42
        PaintSet Paint { get; set; }
43
        //void ChangePaint(PaintSet state);
44
    }
45

  
46
    public enum MarkupWindow
47
    {
48
        Main,
49

  
50
        OverView
51
    }
52
}
MarkupToPDF_Old/Controls/Common/IPath.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Media;
8

  
9
namespace MarkupToPDF.Controls.Common
10
{
11
    public interface IPath : IMarkupCommonData
12
    {
13
        List<Point> PointSet { get; set; }
14

  
15
        Double LineSize { get; set; }
16

  
17
        Geometry PathData { get; set; }
18

  
19
        double Width { get; set; }
20

  
21
        double Height { get; set; }
22

  
23
        string UserID { get; set; }
24

  
25
        void updateControl();
26
    }
27
}
MarkupToPDF_Old/Controls/Common/InkToPath.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Ink;
8
using System.Windows.Input;
9
using System.Windows.Media;
10
using System.Windows.Shapes;
11

  
12
namespace MarkupToPDF.Controls.Common
13
{
14
    public class InkToPath
15
    {
16
        public double[,] StrokeGetPoints(Stroke oStroke)
17
        {
18
            int iRow = -1;
19
            System.Windows.Input.StylusPointCollection colStylusPoints =
20
                                                  oStroke.StylusPoints;
21
            double[,] AllPoints = new double[colStylusPoints.Count, 2];
22
            foreach (StylusPoint oPoint in colStylusPoints)
23
            {
24
                iRow += 1;
25
                AllPoints[iRow, 0] = oPoint.X;
26
                AllPoints[iRow, 1] = oPoint.Y;
27
            }
28
            return AllPoints;
29
        }
30

  
31
        public List<Point> StrokeGetPointsPlus(Stroke oStroke)
32
        {
33
            System.Windows.Input.StylusPointCollection colStylusPoints =
34
                                      oStroke.StylusPoints;
35

  
36
            List<Point> instance = new List<Point>();
37
            foreach (StylusPoint oPoint in colStylusPoints)
38
            {
39
                instance.Add(new Point(oPoint.X, oPoint.Y));
40
            }
41
            return instance;
42
        }
43

  
44
        public StrokeCollection PointGetStroke(List<Point> lstPoint, double lineSize)
45
        {
46
            //foreach (var T in _InkBoard.Strokes[i].StylusPoints) 참고
47
            StrokeCollection strokeSet = new StrokeCollection();
48
#if SILVERLIGHT
49
                Stroke instance = new Stroke(); 
50
#endif
51
#if !SILVERLIGHT
52
            Stroke instance = new Stroke(null);
53
#endif
54
            instance.DrawingAttributes.Color = Colors.Red;
55
            instance.DrawingAttributes.Width = lineSize;
56
            instance.DrawingAttributes.Height = lineSize;
57

  
58
            foreach (var data in lstPoint)
59
            {
60
                instance.StylusPoints.Add(new StylusPoint { X = data.X, Y = data.Y, PressureFactor = 0.5F });
61
               
62

  
63
                strokeSet.Add(instance);
64
            }
65

  
66
            return strokeSet;
67
        }
68

  
69
        public Path StrokeToPath(Stroke oStroke)
70
        {
71
            PathFigure myPathFigure = null;
72
            LineSegment myLineSegment = null;
73
            PathFigureCollection myPathFigureCollection =
74
                new PathFigureCollection();
75
            PathSegmentCollection myPathSegmentCollection =
76
                new PathSegmentCollection();
77

  
78
            if (oStroke == null) return null;
79

  
80
            // Number of points.
81
            int n = oStroke.StylusPoints.Count;
82
            if (n == 0) return null;
83

  
84
            // Start point is first point from sytluspoints collection (M, item 0).
85
            myPathFigure = new PathFigure();
86
            myPathFigure.StartPoint =
87
                new Point(oStroke.StylusPoints[0].X, oStroke.StylusPoints[0].Y);
88
            myPathFigureCollection.Add(myPathFigure);
89

  
90
            // Make small line segment L if there is only one point in the Stroke.
91
            // Data with only M is not shown (workaround).
92
            if (n == 1)
93
            {
94
                myLineSegment = new LineSegment();
95
                myLineSegment.Point =
96
                    new Point(oStroke.StylusPoints[0].X + 1,
97
                              oStroke.StylusPoints[0].Y + 1);
98
                myPathSegmentCollection.Add(myLineSegment);
99
            }
100

  
101
            // The other points are line segments (L, items 1..n-1).
102
            for (int i = 1; i < n; i++)
103
            {
104
                myLineSegment = new LineSegment();
105
                myLineSegment.Point =
106
                    new Point(oStroke.StylusPoints[i].X,
107
                              oStroke.StylusPoints[i].Y);
108
                myPathSegmentCollection.Add(myLineSegment);
109
            }
110

  
111
            myPathFigure.Segments = myPathSegmentCollection;
112

  
113
            PathGeometry myPathGeometry = new PathGeometry();
114
            myPathGeometry.Figures = myPathFigureCollection;
115

  
116
            System.Windows.Shapes.Path oPath = new System.Windows.Shapes.Path();
117

  
118
            // Add the data to the Path.
119
            oPath.Data = myPathGeometry;
120

  
121
            return oPath;
122
        }
123

  
124
    }
125
}
MarkupToPDF_Old/Controls/Common/Interfaces.cs
1
using System;
2
using System.Net;
3
using System.Windows;
4
using System.Windows.Controls;
5
using System.Windows.Documents;
6
using System.Windows.Ink;
7
using System.Windows.Input;
8
using System.Windows.Media;
9
using System.Windows.Media.Animation;
10
using System.Windows.Shapes;
11
using System.Collections.Generic;
12

  
13
namespace MarkupToPDF.Controls.Common
14
{
15

  
16
    public interface INormal
17
    {
18
        List<Point> PointSet { get; set; }
19
        double Width { get; set; }
20
        double Height { get; set; }
21
        Point StartPoint { get; set; }
22
        Point EndPoint { get; set; }
23
        void updateControl();
24
    }
25

  
26
    public interface ICloudControl : IPath
27
    {
28
        double Toler { get; set; }
29
        double ArcLength { get; set; }
30
        void DrawingCloud();
31
    }
32
    
33
    public interface IDashControl : IPath
34
    {
35
        DoubleCollection DashSize { get; set; }
36
    }
37

  
38
    public interface IViewBox : IPath
39
    {
40
        double Angle { get; set; }
41
    }
42
    public interface ICircleControl : IShapeControl
43
    {
44
        void SetCenterXY();
45
    }
46
}
MarkupToPDF_Old/Controls/Common/MarkupToPDF.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace MarkupToPDF.Controls.Common
8
{
9
    class MarkupToPDF
10
    {
11
    }
12
}
MarkupToPDF_Old/Controls/Common/MathSet.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7

  
8
namespace MarkupToPDF.Controls.Common
9
{
10
    public class MathSet
11
    {
12
        const double Rad2Deg = 180.0 / Math.PI;
13
        const double Deg2Rad = Math.PI / 180.0;
14
        const double UnitAngle = 15;
15

  
16
        public static List<double> angleSet = new List<double>();
17

  
18
        public static double getMultipleAngle(double increase, double YourAngle)
19
        {
20
            angleSet.Clear();
21

  
22
            for (double i = 0; i <= 360; i += increase)
23
            {
24
                angleSet.Add(i);
25
            }
26

  
27
            if (YourAngle < 0)
28
            {
29
                YourAngle += 360;
30
            }
31
            double TargetData = YourAngle;
32
            double NearAngle = 0;
33
            double k = 0;
34

  
35

  
36
            foreach (var item in angleSet)
37
            {
38
                double j = 0;
39
                j = TargetData - item;
40
                j = j < 0 ? -j : j;
41
                if (j < k)
42
                {
43
                    NearAngle = item;
44
                }
45
                k = j;
46

  
47
            }
48
            return NearAngle;
49
        }
50

  
51
        public static Point getNearPoint(List<Point> pointList, Point setPoint)
52
        {
53
            Point nearPoint = pointList.Select
54
            (n => new
55
                {
56
                    n, 
57
                    distance = Math.Sqrt
58
                    (
59
                        Math.Pow(
60
                                    (n.X - setPoint.X),2
61
                                )
62

  
63
                        + System.Math.Pow
64
                        (
65
                            (n.Y - setPoint.Y), 2
66
                        )
67
                    )
68

  
69
                }
70
            ).OrderBy(p => p.distance).First().n;
71

  
72
            return nearPoint;
73
        }
74

  
75
        public class ClipLine
76
        {
77
            public static int DONT_INTERSECT = -0x01;
78
            public static int COLLINEAR = 0x00;
79
            public static int INTERSECT = 0x01;
80
            public static double TOLER = 0.0;
81

  
82
            public Point _start;
83
            public Point _end;
84

  
85
            public ClipLine(Point start, Point end)
86
            {
87
                _start = start;
88
                _end = end;
89
            }
90

  
91
            public bool IsLeftSide(Point pt)
92
            {
93
                double dx1 = _end.X - _start.X;
94
                double dy1 = _end.Y - _start.Y;
95
                double dx2 = pt.X - _start.X;
96
                double dy2 = pt.Y - _start.Y;
97

  
98
                return ((dx1 * dy2 - dy1 * dx2) > 0.0);
99
            }
100

  
101
            public bool IsRightSide(Point pt)
102
            {
103
                double dx1 = _end.X - _start.X;
104
                double dy1 = _end.Y - _start.Y;
105
                double dx2 = pt.X - _start.X;
106
                double dy2 = pt.Y - _start.Y;
107

  
108
                return ((dx1 * dy2 - dy1 * dx2) < 0.0);
109
            }
110

  
111
            /// <summary>
112
            /// get intersection point betwwen this and line2d
113
            /// </summary>
114
            /// <author>humkyung</author>
115
            /// <date>2012.08.30</date>
116
            /// <param name="intsec"></param>
117
            /// <param name="line2d"></param>
118
            /// <returns></returns>
119
            public int IntersectWith(ref Point intsec, ClipLine line2d)
120
            {
121
                double Ax = 0.0, Bx = 0.0, Cx = 0.0, Ay = 0.0, By = 0.0, Cy = 0.0, d = 0.0, e = 0.0, f = 0.0;
122
                double x1lo = 0.0, x1hi = 0.0, y1lo = 0.0, y1hi = 0.0;
123

  
124
                Ax = _end.X - _start.X;
125
                Bx = line2d._start.X - line2d._end.X;
126
                // X bound box test
127
                if (Ax < 0.0)
128
                {
129
                    x1lo = _end.X;
130
                    x1hi = _start.X;
131
                }
132
                else
133
                {
134
                    x1hi = _end.X;
135
                    x1lo = _start.X;
136
                }
137

  
138
                if (Bx > 0.0)
139
                {
140
                    if ((x1hi < line2d._end.X) || (line2d._start.X < x1lo)) return ClipLine.DONT_INTERSECT;
141
                }
142
                else
143
                {
144
                    if ((x1hi < line2d._start.X) || (line2d._end.X < x1lo)) return ClipLine.DONT_INTERSECT;
145
                }
146

  
147
                Ay = _end.Y - _start.Y;
148
                By = line2d._start.Y - line2d._end.Y;
149
                /* Y bound box test*/
150
                if (Ay < 0)
151
                {
152
                    y1lo = _end.Y;
153
                    y1hi = _start.Y;
154
                }
155
                else
156
                {
157
                    y1hi = _end.Y;
158
                    y1lo = _start.Y;
159
                }
160

  
161
                if (By > 0)
162
                {
163
                    if ((y1hi < line2d._end.Y) || (line2d._start.Y < y1lo)) return ClipLine.DONT_INTERSECT;
164
                }
165
                else
166
                {
167
                    if ((y1hi < line2d._start.Y) || (line2d._end.Y < y1lo)) return ClipLine.DONT_INTERSECT;
168
                }
169

  
170
                Cx = _start.X - line2d._start.X;
171
                Cy = _start.Y - line2d._start.Y;
172
                f = Ay * Bx - Ax * By;	/* both denominator*/
173
                /// lines are collinear.
174
                if (0.0 == f) return ClipLine.COLLINEAR;
175

  
176
                d = By * Cx - Bx * Cy;	/* alpha numerator*/
177
                if (f > 0.0)
178
                {		/* alpha tests*/
179
                    if ((d < (0 + ClipLine.TOLER)) || (d > (f - ClipLine.TOLER))) return ClipLine.DONT_INTERSECT;
180
                }
181
                else
182
                {
183
                    if ((d > (0 - ClipLine.TOLER)) || (d < (f + ClipLine.TOLER))) return ClipLine.DONT_INTERSECT;
184
                }
185

  
186
                e = Ax * Cy - Ay * Cx;	/* beta numerator*/
187
                if (f > 0.0)
188
                {		/* beta tests*/
189
                    if ((e < (0 + ClipLine.TOLER)) || (e > (f - ClipLine.TOLER))) return ClipLine.DONT_INTERSECT;
190
                }
191
                else
192
                {
193
                    if ((e > (0 - ClipLine.TOLER)) || (e < (f + ClipLine.TOLER))) return ClipLine.DONT_INTERSECT;
194
                }
195

  
196
                /*compute intersection coordinates*/
197
                double alpha = d / f;
198

  
199
                if (_start.X == _end.X)
200
                    intsec.X = _start.X;
201
                else intsec.X = _start.X + alpha * Ax;
202
                if (_start.Y == _end.Y)
203
                    intsec.Y = _start.Y;
204
                else intsec.Y = _start.Y + alpha * Ay;
205

  
206
                return ClipLine.INTERSECT;
207
            }
208
        }
209

  
210
        public class ClipRect
211
        {
212
            public Point center;
213
            public double width, height, angle;	/// angle is degree
214

  
215
            public int IntersectWith(ref Point intsec, ClipLine line2d)
216
            {
217
                double radians = Math.PI * angle / 180.0;
218
                double cs = Math.Cos(radians), sn = Math.Sin(radians);
219
                Point[] corner = new Point[4];
220
                corner[0].X = center.X - width * 0.5;
221
                corner[0].Y = center.Y - height * 0.5;
222
                corner[1] = corner[0];
223
                corner[1].X += width;
224
                corner[2] = corner[1];
225
                corner[2].Y += height;
226
                corner[3] = corner[2];
227
                corner[3].X -= width;
228
                /// rotate 4 corners about angle
229
                for (int i = 0; i < corner.Length; ++i)
230
                {
231
                    double ptx = corner[i].X - center.X;
232
                    double pty = corner[i].Y - center.Y;
233
                    corner[i].X = center.X + ((cs * ptx) - (sn * pty));
234
                    corner[i].Y = center.Y + ((sn * ptx) + (cs * pty));
235
                }
236

  
237
                for (int i = 0; i < corner.Length; ++i)
238
                {
239
                    int si = i % corner.Length, ei = (i + 1) % corner.Length;
240
                    if (ClipLine.INTERSECT == line2d.IntersectWith(ref intsec, new ClipLine(corner[si], corner[ei])))
241
                    {
242
                        return ClipLine.INTERSECT;
243
                    }
244
                }
245

  
246
                return ClipLine.DONT_INTERSECT;
247
            }
248
        }
249

  
250
        public static double AngleMethod(Point StartPoint, Point EndPoint)
251
        {
252
            return Math.Abs(Math.Atan2(EndPoint.X - StartPoint.X, StartPoint.Y - EndPoint.Y) * Rad2Deg);
253
        }
254
        public static double DegreesToRadians(double angle)
255
        {
256
            return ((angle * Math.PI) / 180f);
257
        }
258
        //public static double AngleMethod(double px1, double py1, double px2, double py2)
259
        //{
260
        //    return Math.Abs(Math.Atan2(px2 - px1, py1 - py2) * Rad2Deg);
261
        //}
262
        public static double DistanceTo(Point p1, Point p2)
263
        {
264
            double dx = p2.X - p1.X;
265
            double dy = p2.Y - p1.Y;
266
            return Math.Sqrt(dx * dx + dy * dy);
267
        }
268

  
269
        public static Point getMiddlePoint(Point p1, Point p2)
270
        {
271
            return new Point { X = (p1.X + p2.X) / 2, Y = (p1.Y + p2.Y) / 2 };
272
        }
273

  
274
        /// <summary>
275
        /// return area of polygon
276
        /// </summary>
277
        /// <author>humkyung</author>
278
        /// <date>2012.07.04</date>
279
        /// <param name="points"></param>
280
        /// <returns></returns>
281
        public static double AreaOf(List<Point> points)
282
        {
283
            double res = 0;
284
            int p = 0, q = 0;
285

  
286
            for (p = points.Count - 1, q = 0; q < points.Count; p = q++)
287
            {
288
                res += points[p].X * points[q].Y - points[p].Y * points[q].X;
289
            }
290

  
291
            return res;
292
        }
293
        /// <summary>
294
        /// return normal vector from p1 to p2
295
        /// </summary>
296
        /// <author>humkyung</author>
297
        /// <date>2012.07.19</date>
298
        /// <param name="p1"></param>
299
        /// <param name="p2"></param>
300
        /// <returns></returns>
301
        public static Point GetNormVectorBetween(Point p1, Point p2)
302
        {
303
            Point res = new Point();
304

  
305
            double d = MathSet.DistanceTo(p1, p2);
306

  
307
            if (d > 0)
308
            {
309
                res.X = (p2.X - p1.X) / d;
310
                res.Y = (p2.Y - p1.Y) / d;
311
            }
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)