프로젝트

일반

사용자정보

개정판 d251456f

IDd251456ff29093c83c7ce74cce90aab1cfa01f58
상위 59e0aa5f
하위 6d1a8228

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

issue #214: adjust arrow size

Change-Id: I8aa507c61ea8a6dd72eb180f30d8493feed515ac

차이점 보기:

MarkupToPDF/Controls/Common/DrawSet.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
    class DrawSet
12
    {
13
        /// <summary>
14
        /// draw a arrow with given two points
15
        /// </summary>
16
        /// <param name="p2"></param>
17
        /// <param name="p1"></param>
18
        /// <param name="lineSize"></param>
19
        /// <returns></returns>
20
        public static PathGeometry DrawArrow(Point p2, Point p1, double lineSize)
21
        {
22
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
23
            PathGeometry pathGeometry = new PathGeometry();
24
            PathFigure pathFigure = new PathFigure();
25
            pathFigure.StartPoint = p1;
26

  
27
            Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 6);
28
            Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 6);
29

  
30
            List<Point> points = new List<Point>() { lpoint, rpoint, p1 };
31
            PolyLineSegment polyline = new PolyLineSegment(points, true);
32
            pathFigure.Segments.Add(polyline);
33

  
34
            pathFigure.IsClosed = true;
35
            pathFigure.IsFilled = true;
36

  
37
            pathGeometry.Figures.Add(pathFigure);
38
            pathGeometry.FillRule = FillRule.Nonzero;
39
            RotateTransform transform = new RotateTransform();
40
            transform.Angle = theta - 90;
41
            transform.CenterX = p1.X;
42
            transform.CenterY = p1.Y;
43
            pathGeometry.Transform = transform;
44
            return pathGeometry;
45
        }
46
    }
47
}
MarkupToPDF/Controls/Line/ArcControl.cs
464 464
            if (isTransOn)
465 465
            {
466 466
                //isTransOn = true;
467
                instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize));
468
                instanceGroup.Children.Add(ConverseAllow(this.EndPoint, this.MidPoint, this.LineSize));
467
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.MidPoint, this.StartPoint, this.LineSize));
468
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.MidPoint, this.LineSize));
469 469
                this.Base_ArcPath.Fill = this.StrokeColor;
470 470
            }
471 471
            //Base_ArcPath.StrokeThickness = 3;
......
476 476

  
477 477
        }
478 478

  
479

  
480
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
481
        {
482
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
483
            PathGeometry pathGeometry = new PathGeometry();
484
            PathFigure pathFigure = new PathFigure();
485
            pathFigure.StartPoint = p1;
486

  
487
            Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 4);
488
            Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 4);
489

  
490
            LineSegment seg1 = new LineSegment();
491
            seg1.Point = lpoint;
492
            pathFigure.Segments.Add(seg1);
493

  
494
            LineSegment seg2 = new LineSegment();
495
            seg2.Point = rpoint;
496
            pathFigure.Segments.Add(seg2);
497

  
498
            LineSegment seg3 = new LineSegment();
499
            seg3.Point = p1;
500
            pathFigure.Segments.Add(seg3);
501

  
502
            pathFigure.IsClosed = true;
503
            pathFigure.IsFilled = true;
504

  
505
            pathGeometry.Figures.Add(pathFigure);
506
            pathGeometry.FillRule = FillRule.Nonzero;
507
            RotateTransform transform = new RotateTransform();
508
            transform.Angle = theta - 90;
509
            transform.CenterX = p1.X;
510
            transform.CenterY = p1.Y;
511
            pathGeometry.Transform = transform;
512
            return pathGeometry;
513
        }
514

  
515 479
        public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize)
516 480
        {
517 481
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
MarkupToPDF/Controls/Line/ArrowArcControl.cs
449 449
            pathFigure.IsClosed = false;
450 450
            instanceGroup.Children.Add(pathGeometry);
451 451

  
452
            //화살표하나
453
            instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize));
454
            //화살표 두개 
455
            instanceGroup.Children.Add(ConverseAllow(this.EndPoint, this.MidPoint, this.LineSize));
452
            instanceGroup.Children.Add(DrawSet.DrawArrow(this.MidPoint, this.StartPoint, this.LineSize));
453
            instanceGroup.Children.Add(DrawSet.DrawArrow(this.MidPoint, this.EndPoint, this.LineSize));
456 454
            this.Base_ArcPath.Fill = this.StrokeColor;
457
            //Base_ArcPath.StrokeThickness = 3;
458 455

  
459 456
            instanceGroup.FillRule = FillRule.Nonzero;
460 457
            this.PathData = instanceGroup;
461 458
            this.OverViewPathData = PathData;
462 459

  
463 460
        }
464

  
465

  
466
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
467
        {
468
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
469
            PathGeometry pathGeometry = new PathGeometry();
470
            PathFigure pathFigure = new PathFigure();
471
            pathFigure.StartPoint = p1;
472

  
473
            Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 4);
474
            Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 4);
475

  
476
            LineSegment seg1 = new LineSegment();
477
            seg1.Point = lpoint;
478
            pathFigure.Segments.Add(seg1);
479

  
480
            LineSegment seg2 = new LineSegment();
481
            seg2.Point = rpoint;
482
            pathFigure.Segments.Add(seg2);
483

  
484
            LineSegment seg3 = new LineSegment();
485
            seg3.Point = p1;
486
            pathFigure.Segments.Add(seg3);
487

  
488
            pathFigure.IsClosed = true;
489
            pathFigure.IsFilled = true;
490

  
491
            pathGeometry.Figures.Add(pathFigure);
492
            pathGeometry.FillRule = FillRule.Nonzero;
493
            RotateTransform transform = new RotateTransform();
494
            transform.Angle = theta - 90;
495
            transform.CenterX = p1.X;
496
            transform.CenterY = p1.Y;
497
            pathGeometry.Transform = transform;
498
            return pathGeometry;
499
        }
500

  
501
        public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize)
502
        {
503
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
504
            PathGeometry pathGeometry2 = new PathGeometry();
505
            PathFigure pathFigure2 = new PathFigure();
506
            pathFigure2.StartPoint = p2;
507

  
508
            Point lpoint2 = new Point(p2.X + lineSize * 2, p2.Y + lineSize * 4);
509
            Point rpoint2 = new Point(p2.X - lineSize * 2, p2.Y + lineSize * 4);
510
            LineSegment seg1_1 = new LineSegment();
511
            seg1_1.Point = lpoint2;
512
            pathFigure2.Segments.Add(seg1_1);
513

  
514
            LineSegment seg2_1 = new LineSegment();
515
            seg2_1.Point = rpoint2;
516
            pathFigure2.Segments.Add(seg2_1);
517

  
518
            LineSegment seg3_1 = new LineSegment();
519
            seg3_1.Point = p2;
520
            pathFigure2.Segments.Add(seg3_1);
521

  
522
            LineSegment seg4_1 = new LineSegment();
523

  
524
            seg4_1.Point = new Point(lpoint2.X, lpoint2.Y);
525
            pathFigure2.Segments.Add(seg4_1);
526

  
527
            //pathFigure2.IsFilled = true;
528
            //pathFigure2.IsClosed = true;
529

  
530
            RotateTransform transform2 = new RotateTransform();
531
            transform2.Angle = theta + 90;
532
            transform2.CenterX = p2.X;
533
            transform2.CenterY = p2.Y;
534
            pathGeometry2.Figures.Add(pathFigure2);
535
            pathGeometry2.Transform = transform2;
536
            return pathGeometry2;
537
        }
538

  
461
        
539 462
        public void ApplyOverViewData()
540 463
        {
541 464
            this.OverViewPathData = this.PathData;
MarkupToPDF/Controls/Line/ArrowControl_Multi.cs
262 262
            if (this.MiddlePoint == new Point(0,0))
263 263
            {
264 264
                //instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.MiddlePoint, this.LineSize));
265
                instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize));
265
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
266 266
            }
267 267
            else
268 268
            {
269
                instanceGroup.Children.Add(SingleAllow(this.MiddlePoint, this.EndPoint, this.LineSize));
269
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.MiddlePoint, this.EndPoint, this.LineSize));
270 270
                LineSegment lineSegment1 = new LineSegment();
271 271
                lineSegment1.Point = this.MiddlePoint;
272 272
                pathFigure.Segments.Add(lineSegment1);
......
335 335
        //    return pathGeometry;
336 336
        //}
337 337

  
338
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
339
        {
340
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
341
            PathGeometry pathGeometry = new PathGeometry();
342
            PathFigure pathFigure = new PathFigure();
343
            pathFigure.StartPoint = p1;
344
            //lineSize = 2;
345
            Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6);
346
            Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6);
347

  
348
            LineSegment seg1 = new LineSegment();
349
            seg1.Point = lpoint;
350
            pathFigure.Segments.Add(seg1);
351

  
352
            LineSegment seg2 = new LineSegment();
353
            seg2.Point = rpoint;
354
            pathFigure.Segments.Add(seg2);
355

  
356
            LineSegment seg3 = new LineSegment();
357
            seg3.Point = p1;
358
            pathFigure.Segments.Add(seg3);
359

  
360
            pathFigure.IsClosed = true;
361
            pathFigure.IsFilled = true;
362

  
363
            pathGeometry.Figures.Add(pathFigure);
364
            pathGeometry.FillRule = FillRule.Nonzero;
365
            RotateTransform transform = new RotateTransform();
366
            transform.Angle = theta - 90;
367
            transform.CenterX = p1.X;
368
            transform.CenterY = p1.Y;
369
            pathGeometry.Transform = transform;
370
            return pathGeometry;
371
        }
372 338
        protected void OnPropertyChanged(string propName)
373 339
        {
374 340
            if (PropertyChanged != null)
MarkupToPDF/Controls/Line/LineControl.cs
358 358
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
359 359
            this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
360 360
        }
361
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
362
        {
363
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
364
            PathGeometry pathGeometry = new PathGeometry();
365
            PathFigure pathFigure = new PathFigure();
366
            pathFigure.StartPoint = new Point(p1.X, p1.Y);
367
            //lineSize = 2;
368
            Point lpoint = new Point(p1.X + lineSize * 3, p1.Y + lineSize * 6);
369
            Point rpoint = new Point(p1.X - lineSize * 3, p1.Y + lineSize * 6);
370
            LineSegment seg1 = new LineSegment();
371
            seg1.Point = lpoint;
372
            pathFigure.Segments.Add(seg1);
373
            LineSegment seg2 = new LineSegment();
374
            seg2.Point = rpoint;
375
            pathFigure.Segments.Add(seg2);
376

  
377
            LineSegment seg3 = new LineSegment();
378
            seg3.Point = p1;
379
            pathFigure.Segments.Add(seg3);
380

  
381
            pathFigure.IsClosed = true;
382
            pathFigure.IsFilled = true;
383
            pathGeometry.Figures.Add(pathFigure);
384
            pathGeometry.FillRule = FillRule.Nonzero;
385
            RotateTransform transform = new RotateTransform();
386
            transform.Angle = theta - 90;
387
            transform.CenterX = p1.X;
388
            transform.CenterY = p1.Y;
389
            pathGeometry.Transform = transform;
390
            return pathGeometry;
391
        }
392 361

  
393

  
394
        public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize)
395
        {
396
            //lineSize = 2;
397
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
398
            PathGeometry pathGeometry2 = new PathGeometry();
399
            PathFigure pathFigure2 = new PathFigure();
400
            pathFigure2.StartPoint = p2;
401

  
402
            Point lpoint2 = new Point(p2.X + lineSize * 3, p2.Y + lineSize * 6);
403
            Point rpoint2 = new Point(p2.X - lineSize * 3, p2.Y + lineSize * 6);
404
            LineSegment seg1_1 = new LineSegment();
405
            seg1_1.Point = lpoint2;
406
            pathFigure2.Segments.Add(seg1_1);
407

  
408
            LineSegment seg2_1 = new LineSegment();
409
            seg2_1.Point = rpoint2;
410
            pathFigure2.Segments.Add(seg2_1);
411

  
412
            LineSegment seg3_1 = new LineSegment();
413
            seg3_1.Point = p2;
414
            pathFigure2.Segments.Add(seg3_1);
415

  
416
            LineSegment seg4_1 = new LineSegment();
417

  
418
            seg4_1.Point = new Point(lpoint2.X, lpoint2.Y);
419
            pathFigure2.Segments.Add(seg4_1);
420
            RotateTransform transform2 = new RotateTransform();
421
            transform2.Angle = theta + 90;
422
            transform2.CenterX = p2.X;
423
            transform2.CenterY = p2.Y;
424
            pathGeometry2.Figures.Add(pathFigure2);
425
            pathGeometry2.Transform = transform2;
426
            return pathGeometry2;
427
        }
428 362
        public static List<LineGeometry> DimAllow(Point p1, Point p2, Double lineSize, double DimSize)
429 363
        {
430 364
            //lineSize = 2;
......
494 428
            switch (LineStyleSet)
495 429
            {
496 430
                case LineStyleSet.ArrowLine:
497
                    instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize));
431
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
498 432
                    break;
499 433
                case LineStyleSet.TwinLine:
500
                    instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize));
501
                    instanceGroup.Children.Add(ConverseAllow(this.StartPoint, this.EndPoint, this.LineSize));
434
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
435
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
502 436
                    break;
503 437
                case LineStyleSet.DimLine:
504 438
                    List<LineGeometry> metrySet = DimAllow(this.StartPoint, this.EndPoint, this.LineSize, this.DimSize);
505 439
                    instanceGroup.Children.Add(metrySet[0]);
506 440
                    instanceGroup.Children.Add(metrySet[1]);
507
                    instanceGroup.Children.Add(SingleAllow(this.StartPoint, this.EndPoint, this.LineSize));
508
                    instanceGroup.Children.Add(ConverseAllow(this.StartPoint, this.EndPoint, this.LineSize));
441
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
442
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
509 443
                    break;
510 444
                case LineStyleSet.CancelLine:
511 445
                    PathFigure pathFigure_Multi = new PathFigure();
......
527 461
                    pathFigure_Multi.Segments.Add(lineSegment1);
528 462
                    pathGeometry.Figures.Add(pathFigure_Multi);
529 463

  
530
                    
531

  
532 464
                    this.PathData = pathGeometry;
533 465
                    this.OverViewPathData = PathData;
534 466

  
MarkupToPDF/Controls/Text/ArrowTextControl.cs
1314 1314
                //20180910 LJY 각도에 따라.
1315 1315
                this.MidPoint = testP;
1316 1316
                //instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize));
1317
                instanceGroup.Children.Add(SingleAllow(testP, this.StartPoint, this.LineSize));
1317
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1318 1318
            }
1319 1319
            else
1320 1320
            {
......
1484 1484
                connectorMEGeometry.StartPoint = testP;
1485 1485
                //connectorSMGeometry.EndPoint = endP;
1486 1486
                //connectorMEGeometry.StartPoint = endP;
1487
                instanceGroup.Children.Add(SingleAllow(testP, this.StartPoint, this.LineSize));
1487
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1488 1488
                #endregion
1489 1489
            }
1490 1490

  
......
1844 1844

  
1845 1845
            return _pathGeometry;
1846 1846
        }
1847
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
1848
        {
1849
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
1850
            PathGeometry pathGeometry = new PathGeometry();
1851
            PathFigure pathFigure = new PathFigure();
1852
            pathFigure.StartPoint = p1;
1853

  
1854
            Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 4);
1855
            Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 4);
1856

  
1857
            LineSegment seg1 = new LineSegment();
1858
            seg1.Point = lpoint;
1859
            pathFigure.Segments.Add(seg1);
1860

  
1861
            LineSegment seg2 = new LineSegment();
1862
            seg2.Point = rpoint;
1863
            pathFigure.Segments.Add(seg2);
1864

  
1865
            LineSegment seg3 = new LineSegment();
1866
            seg3.Point = p1;
1867
            pathFigure.Segments.Add(seg3);
1868

  
1869
            pathFigure.IsClosed = true;
1870
            pathFigure.IsFilled = true;
1871

  
1872
            pathGeometry.Figures.Add(pathFigure);
1873
            pathGeometry.FillRule = FillRule.Nonzero;
1874
            RotateTransform transform = new RotateTransform();
1875
            transform.Angle = theta - 90;
1876
            transform.CenterX = p1.X;
1877
            transform.CenterY = p1.Y;
1878
            pathGeometry.Transform = transform;
1879
            return pathGeometry;
1880
        }
1881 1847

  
1882 1848
        #region Dispose
1883 1849
        public void Dispose()
MarkupToPDF/MarkupToPDF.csproj
129 129
    <Compile Include="Controls\Cad\OverlapWhiteControlcs.cs" />
130 130
    <Compile Include="Controls\Common\BaseShape.cs" />
131 131
    <Compile Include="Controls\Common\ControlType.cs" />
132
    <Compile Include="Controls\Common\DrawSet.cs" />
132 133
    <Compile Include="Controls\Common\HatchMake.cs" />
133 134
    <Compile Include="Controls\Common\IMarkupCommonData.cs" />
134 135
    <Compile Include="Controls\Common\InkToPath.cs" />

내보내기 Unified diff

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