프로젝트

일반

사용자정보

개정판 b84c78a8

IDb84c78a8cb57f88fb68efada7af8dd121ef01423
상위 1c1abe3b
하위 3d702fcc

백흠경이(가) 4달 전에 추가함

Fix: ArrowTextControl의 꺽인선 위치 오류 수정

Change-Id: I8f1cdc8e7de8a1980eb5ba232d3709593566f1a2

차이점 보기:

MarkupToPDF/Controls/Text/ArrowTextControl.cs
33 33
        public Border BaseTextbox_Caret = null;
34 34
        public event EventHandler<EventArgs> EditEnded;
35 35

  
36

  
37 36
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
37
        private const int _BendingLineLength = 50;
38 38

  
39 39
        #region Object & Variable
40
        GeometryGroup instanceGroup = new GeometryGroup();
41
        
42
        Path Cemy = new Path();
43
        LineGeometry connectorSMGeometry = new LineGeometry();
44
        LineGeometry connectorMEGeometry = new LineGeometry();
40
        GeometryGroup instanceGroup { get; } = new GeometryGroup();
41
        LineGeometry connectorSMGeometry { get; } = new LineGeometry();
42
        LineGeometry connectorMEGeometry { get; } = new LineGeometry();
45 43

  
46 44
        public enum ArrowTextStyleSet { Normal, Cloud, Rect };
47 45

  
......
50 48
        static ArrowTextControl()
51 49
        {
52 50
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl)));
53
            //ResourceDictionary dictionary = new ResourceDictionary();
54
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
55
            //if(!Application.Current.Resources.MergedDictionaries.Any(x=>x.Source == dictionary.Source))
56
            //    Application.Current.Resources.MergedDictionaries.Add(dictionary);
57 51
        }
58 52

  
59
        public ArrowTextControl() :base()
53
        public ArrowTextControl() : base()
60 54
        {
61
            //this.DefaultStyleKey = typeof(ArrowTextControl);
62 55
        }
63 56

  
64 57
        public override void Copy(CommentUserInfo lhs)
......
72 65
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
73 66
                this.StrokeColor = item.StrokeColor;
74 67
                this.ArcLength = item.ArcLength;
75
                //this.DashSize = s.DashSize; 
76 68
                this.ArrowTextStyle = item.ArrowTextStyle;
77 69
                this.isHighLight = item.isHighLight;
78 70
                this.ArrowText = item.ArrowText;
......
81 73
                this.BoxWidth = item.BoxWidth;
82 74
                this.BoxHeight = item.BoxHeight;
83 75
                this.isFixed = item.isFixed;
84
                //this.VisualPageAngle = s.Angle;
76
                this.ControlType = item.ControlType;
85 77
                this.UserID = item.UserID;
86 78
                this.isTrans = item.isTrans;
87 79
                this.MidPoint = item.MidPoint;
......
287 279
            {
288 280
                EditEnded(this, new EventArgs());
289 281
            }
290

  
291 282
        }
292 283

  
293 284
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
......
980 971
        }
981 972

  
982 973

  
983

  
984 974
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
985 975
        {
986 976
            var instance = (ArrowTextControl)sender;
......
1075 1065
        {
1076 1066
            instanceGroup.Children.Clear();
1077 1067

  
1078
            //VisualPageAngle = 0;
1079

  
1080 1068
            if (Math.Abs(PageAngle).ToString() == "90")
1081 1069
            {
1082 1070
                VisualPageAngle = 270;
......
1097 1085
            /// 텍스트박스의 좌표 설정
1098 1086
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1099 1087
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1100
            //System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
1101
            
1102 1088

  
1103 1089
            List<Point> ps = new List<Point>();
1104 1090
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
......
1146 1132
                        break;
1147 1133
                }
1148 1134
                
1149
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1135
                var ConnectionPoint = MathSet.getNearPoint(ps, this.StartPoint);
1150 1136

  
1151 1137
                //20180911 LJY 꺾이는 부분 수정
1152
                Point testP = endP;                
1138
                Point BendingPoint = ConnectionPoint;                
1153 1139
                switch (Math.Abs(this.PageAngle).ToString())
1154 1140
                {
1155 1141
                    case "90":
1156
                        testP = new Point(endP.X + 50, endP.Y);
1142
                        BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1157 1143
                        break;
1158 1144
                    case "270":
1159
                        testP = new Point(endP.X - 50, endP.Y);
1145
                        BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1160 1146
                        break;
1161 1147
                }                
1162 1148

  
......
1166 1152
                    case "90":
1167 1153
                        if (isFixed)
1168 1154
                        {
1169
                            if (ps[0] == endP) //상단
1155
                            if (ps[0] == ConnectionPoint) //상단
1170 1156
                            {
1171
                                testP = new Point(endP.X , endP.Y + 50);
1172
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1157
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y + _BendingLineLength);
1173 1158
                            }
1174
                            else if (ps[1] == endP) //하단
1159
                            else if (ps[1] == ConnectionPoint) //하단
1175 1160
                            {
1176
                                testP = new Point(endP.X , endP.Y - 50);
1177
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1161
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y - _BendingLineLength);
1178 1162
                            }
1179
                            else if (ps[2] == endP) //좌단
1163
                            else if (ps[2] == ConnectionPoint) //좌단
1180 1164
                            {
1181
                                testP = new Point(endP.X - 50, endP.Y);
1182
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1165
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1183 1166
                            }
1184
                            else if (ps[3] == endP) //우단
1167
                            else if (ps[3] == ConnectionPoint) //우단
1185 1168
                            {
1186
                                testP = new Point(endP.X + 50, endP.Y);
1187
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1169
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1188 1170
                            }
1189 1171
                        }
1190 1172
                        break;
1191 1173
                    case "270":
1192 1174
                        if (isFixed)
1193 1175
                        {
1194
                            if (ps[0] == endP) //상단
1176
                            if (ps[0] == ConnectionPoint) //상단
1195 1177
                            {
1196
                                testP = new Point(endP.X , endP.Y - 50);
1197
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1178
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y - _BendingLineLength);
1198 1179
                            }
1199
                            else if (ps[1] == endP) //하단
1180
                            else if (ps[1] == ConnectionPoint) //하단
1200 1181
                            {
1201
                                testP = new Point(endP.X, endP.Y + 50);
1202
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1182
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y + _BendingLineLength);
1203 1183
                            }
1204
                            else if (ps[2] == endP) //좌단
1184
                            else if (ps[2] == ConnectionPoint) //좌단
1205 1185
                            {
1206
                                testP = new Point(endP.X + 50, endP.Y);
1207
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1186
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1208 1187
                            }
1209
                            else if (ps[3] == endP) //우단
1188
                            else if (ps[3] == ConnectionPoint) //우단
1210 1189
                            {
1211
                                testP = new Point(endP.X - 50, endP.Y);
1212
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1190
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1213 1191
                            }
1214 1192
                        }
1215 1193
                        break;
1216 1194
                    default:
1217 1195
                        if (isFixed)
1218 1196
                        {
1219
                            if (ps[0] == endP) //상단
1197
                            if (ps[0] == ConnectionPoint) //상단
1220 1198
                            {
1221
                                testP = new Point(endP.X, endP.Y - 50);
1222
                                //System.Diagnostics.Debug.WriteLine("상단");
1199
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y - _BendingLineLength);
1223 1200
                            }
1224
                            else if (ps[1] == endP) //하단
1201
                            else if (ps[1] == ConnectionPoint) //하단
1225 1202
                            {
1226
                                testP = new Point(endP.X, endP.Y + 50);
1227
                                //System.Diagnostics.Debug.WriteLine("하단");
1203
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y + _BendingLineLength);
1228 1204
                            }
1229
                            else if (ps[2] == endP) //좌단
1205
                            else if (ps[2] == ConnectionPoint) //좌단
1230 1206
                            {
1231
                                testP = new Point(endP.X - 50, endP.Y);
1232
                                //System.Diagnostics.Debug.WriteLine("좌단");
1207
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1233 1208
                            }
1234
                            else if (ps[3] == endP) //우단
1209
                            else if (ps[3] == ConnectionPoint) //우단
1235 1210
                            {
1236
                                testP = new Point(endP.X + 50, endP.Y);
1237
                                //System.Diagnostics.Debug.WriteLine("우단");
1211
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1238 1212
                            }
1239 1213
                        }
1240 1214
                        break;
1241 1215
                }
1242
                connectorMEGeometry.EndPoint = endP;
1243
                connectorSMGeometry.EndPoint = testP;
1244
                connectorMEGeometry.StartPoint = testP;
1216

  
1217
                connectorSMGeometry.EndPoint = BendingPoint;
1218
                connectorMEGeometry.StartPoint = BendingPoint;
1219
                connectorMEGeometry.EndPoint = ConnectionPoint;
1245 1220
                
1246 1221
                //20180910 LJY 각도에 따라.
1247
                this.MidPoint = testP;
1248
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1222
                this.MidPoint = BendingPoint;
1223
                instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint, this.StartPoint, this.LineSize));
1249 1224
                instanceGroup.FillRule = FillRule.Nonzero;
1250 1225
                this.Base_ArrowPath.Fill = this.StrokeColor;
1251 1226
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
......
1309 1284
                }
1310 1285

  
1311 1286

  
1312
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1313
                connectorMEGeometry.EndPoint = endP; //최상단
1314
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1315
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1287
                var ConnectionPoint = MathSet.getNearPoint(ps, this.StartPoint);
1316 1288
                #region 보정치
1317
                Point testP = endP;
1289
                Point BendingPoint = ConnectionPoint;
1318 1290

  
1319 1291
                //20180910 LJY 각도에 따라.
1320 1292
                switch (Math.Abs(this.PageAngle).ToString())
......
1322 1294
                    case "90":
1323 1295
                        if (isFixed)
1324 1296
                        {
1325
                            if (ps[0] == endP) //상단
1297
                            if (ps[0] == ConnectionPoint) //상단
1326 1298
                            {
1327
                                testP = new Point(endP.X - 50, endP.Y);
1328
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1299
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1329 1300
                            }
1330
                            else if (ps[1] == endP) //하단
1301
                            else if (ps[1] == ConnectionPoint) //하단
1331 1302
                            {
1332
                                testP = new Point(endP.X + 50, endP.Y);
1333
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1303
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1334 1304
                            }
1335
                            else if (ps[2] == endP) //좌단
1305
                            else if (ps[2] == ConnectionPoint) //좌단
1336 1306
                            {
1337
                                testP = new Point(endP.X - 50, endP.Y);
1338
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1307
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1339 1308
                            }
1340
                            else if (ps[3] == endP) //우단
1309
                            else if (ps[3] == ConnectionPoint) //우단
1341 1310
                            {
1342
                                testP = new Point(endP.X + 50 , endP.Y);
1343
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1311
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength , ConnectionPoint.Y);
1344 1312
                            }
1345 1313
                        }
1346 1314
                        break;
1347 1315
                    case "270":
1348 1316
                        if (isFixed)
1349 1317
                        {
1350
                            if (ps[0] == endP) //상단
1318
                            if (ps[0] == ConnectionPoint) //상단
1351 1319
                            {
1352
                                testP = new Point(endP.X + 50, endP.Y);
1353
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1320
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1354 1321
                            }
1355
                            else if (ps[1] == endP) //하단
1322
                            else if (ps[1] == ConnectionPoint) //하단
1356 1323
                            {
1357
                                testP = new Point(endP.X - 50, endP.Y);
1358
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1324
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1359 1325
                            }
1360
                            else if (ps[2] == endP) //좌단
1326
                            else if (ps[2] == ConnectionPoint) //좌단
1361 1327
                            {
1362
                                testP = new Point(endP.X + 50, endP.Y);
1363
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1328
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1364 1329
                            }
1365
                            else if (ps[3] == endP) //우단
1330
                            else if (ps[3] == ConnectionPoint) //우단
1366 1331
                            {
1367
                                testP = new Point(endP.X + 50, endP.Y );
1368
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1332
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y );
1369 1333
                            }
1370 1334
                        }
1371 1335
                        break;
1372 1336
                    default:
1373 1337
                        if (isFixed)
1374 1338
                        {
1375
                            if (ps[0] == endP) //상단
1339
                            if (ps[0] == ConnectionPoint) //상단
1376 1340
                            {
1377
                                testP = new Point(endP.X, endP.Y - 50);
1378
                                //System.Diagnostics.Debug.WriteLine("상단");
1341
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y - _BendingLineLength);
1379 1342
                            }
1380
                            else if (ps[1] == endP) //하단
1343
                            else if (ps[1] == ConnectionPoint) //하단
1381 1344
                            {
1382
                                testP = new Point(endP.X, endP.Y + 50);
1383
                                //System.Diagnostics.Debug.WriteLine("하단");
1345
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y + _BendingLineLength);
1384 1346
                            }
1385
                            else if (ps[2] == endP) //좌단
1347
                            else if (ps[2] == ConnectionPoint) //좌단
1386 1348
                            {
1387
                                testP = new Point(endP.X - 50, endP.Y);
1388
                                //System.Diagnostics.Debug.WriteLine("좌단");
1349
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1389 1350
                            }
1390
                            else if (ps[3] == endP) //우단
1351
                            else if (ps[3] == ConnectionPoint) //우단
1391 1352
                            {
1392
                                testP = new Point(endP.X + 50, endP.Y);
1393
                                //System.Diagnostics.Debug.WriteLine("우단");
1353
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1394 1354
                            }
1395 1355
                        }
1396 1356
                        break;
1397 1357
                }
1398
                  
1399 1358

  
1400
                connectorSMGeometry.EndPoint = testP;
1401
                connectorMEGeometry.StartPoint = testP;
1402
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1359
                connectorSMGeometry.EndPoint = BendingPoint;
1360
                connectorMEGeometry.StartPoint = BendingPoint;
1361
                connectorMEGeometry.EndPoint = ConnectionPoint;
1362
                instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint, this.StartPoint, this.LineSize));
1403 1363
                instanceGroup.FillRule = FillRule.Nonzero;
1404 1364
                this.Base_ArrowPath.Fill = this.StrokeColor;
1405 1365
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
......
1497 1457
            {
1498 1458
                List<Point> pCloud = new List<Point>()
1499 1459
                {
1500
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1460
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1501 1461
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1502 1462
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1503 1463
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
......
1796 1756
            }
1797 1757

  
1798 1758
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1799
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1759
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) ||
1800 1760
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1801 1761

  
1802 1762
            this.PointSet = new List<Point>
......
1831 1791
                double _dx = dx * cos - dy * sin;
1832 1792
                double _dy = dx * sin + dy * cos;
1833 1793

  
1834
                //var transform = new RotateTransform() { Angle = CommentAngle, CenterX = dx, CenterY = dy };
1835
                //var transformedPoint = transform.Transform(pt);
1836
                //selected = transformedPoint;
1837

  
1838 1794
                selected.X += _dx;
1839 1795
                selected.Y += _dy;
1840 1796
            }
......
1865 1821
            if (path.PointSet.Count > i) {
1866 1822
                path.PointSet[i] = selected;
1867 1823
            }
1868
            //System.Diagnostics.Debug.WriteLine($"OnMoveCtrlPoint end : {path.PointSet[1].X},{path.PointSet[1].Y}");
1824

  
1869 1825
            this.UpdateControl();
1870 1826
        }
1871 1827

  
......
1902 1858
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
1903 1859
                ctrl.StartPoint = this.StartPoint;
1904 1860
                ctrl.ArrowStyle = this.ArrowTextStyle;
1905
                //ctrl.StrokeColor = "#FF00FF00";
1906 1861
                ctrl.UserID = this.UserID;
1907 1862
                ctrl.ArrowText = this.Base_TextBox.Text;
1908 1863
                ctrl.BorderSize = this.BorderSize;
......
1912 1867
                ctrl.Opac = this.Opacity;
1913 1868
                ctrl.EndPoint = this.EndPoint;
1914 1869
                ctrl.isFixed = this.isFixed;
1915
                //ctrl.DashSize = this.DashSize;
1870
                ctrl.ControlType = this.ControlType;
1916 1871
                ctrl.Name = this.GetType().Name.ToString();
1917 1872
                ctrl.isTrans = this.isTrans;
1918 1873
                ctrl.MidPoint = this.MidPoint;
1919 1874
                ctrl.Angle = this.PageAngle;
1920 1875
                ctrl.fontConfig = new List<string>()
1921
                            {
1922
                                this.TextFamily.FontName(),
1923
                                this.TextStyle.ToString(),
1924
                                this.TextWeight.ToString(),
1925
                                this.TextSize.ToString(),
1926
                            };
1876
                {
1877
                    this.TextFamily.FontName(),
1878
                    this.TextStyle.ToString(),
1879
                    this.TextWeight.ToString(),
1880
                    this.TextSize.ToString(),
1881
                };
1927 1882

  
1928 1883
                if (this.UnderLine != null)
1929 1884
                {
......
1960 1915
                instance.StartPoint = s.StartPoint;
1961 1916
                instance.EndPoint = s.EndPoint;
1962 1917
                instance.StrokeColor = brush;
1963
                //instance.DashSize = s.DashSize; 
1964 1918
                instance.ArrowTextStyle = s.ArrowStyle;
1965 1919
                instance.isHighLight = s.isHighLight;
1966 1920
                instance.ArrowText = s.ArrowText;
......
1969 1923
                instance.BoxWidth = s.BoxWidth;
1970 1924
                instance.BoxHeight = s.BoxHeight;
1971 1925
                instance.isFixed = s.isFixed;
1972
                //instance.VisualPageAngle = s.Angle;
1926
                instance.ControlType = s.ControlType;
1973 1927
                instance.UserID = s.UserID;
1974 1928
                instance.isTrans = s.isTrans;
1975 1929
                instance.MidPoint = s.MidPoint;
......
1991 1945
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1992 1946
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1993 1947
                instance.ArcLength = s.ArcLength;
1994
                if (s.fontConfig.Count() == 5)
1948
                if (s.fontConfig.Count == 5)
1995 1949
                {
1996 1950
                    instance.UnderLine = TextDecorations.Underline;
1997 1951
                }

내보내기 Unified diff