프로젝트

일반

사용자정보

개정판 fb827eb4

IDfb827eb461e2c91d4fcda492dea939fbfebec252
상위 51c6ce90
하위 24da769b

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

Fix: ArrowTextControl에서 중간점을 이동시켜 꺽인선의 길이를 조정 가능하도록 수정

Change-Id: Ic1a3cc1c60055b78c4e131c711091716ac2dd5c6

차이점 보기:

MarkupToPDF/Controls/Text/ArrowTextControl.cs
923 923
                {
924 924
                    var connections = instance.GetConnectionPointList();
925 925
                    var near = MathSet.getNearPoint(connections, instance.StartPoint);
926
                    var BendingPoint = instance.GetBendingPoint(connections, near);
927
                    if (BendingPoint.HasValue) instance.MidPoint = BendingPoint.Value;
926
                    if (!near.Equals(instance.connectorMEGeometry.EndPoint))
927
                    {
928
                        var BendingPoint = instance.GetBendingPoint(connections, instance.StartPoint, null);
929
                        if (BendingPoint.HasValue) instance.MidPoint = BendingPoint.Value;
930
                    }
931

  
932
                    instance.SetArrowTextPath();
933
                }
934
                else if(e.Property.Name == "MidPoint")
935
                {
936
                    instance.SetArrowTextPath();
928 937
                }
929
                instance.SetArrowTextPath();
930 938
            }
931 939
        }
932 940

  
......
1124 1132
        /// connection을 이용하여 꺽인점의 위치를 구한다.
1125 1133
        /// </summary>
1126 1134
        /// <returns></returns>
1127
        private Point? GetBendingPoint(List<Point> ConnectionPointList, Point connection)
1135
        private Point? GetBendingPoint(List<Point> ConnectionPointList, Point pt, Point? MidPoint)
1128 1136
        {
1129 1137
            Point? BendingPoint = null;
1130 1138

  
1139
            var connection = MathSet.getNearPoint(ConnectionPointList, pt);
1131 1140
            if (isTrans)
1132 1141
            {
1142
                ///if (!pt.Equals(this.MidPoint) && Point.Subtract(this.connectorMEGeometry.EndPoint, connection).Length == 0) return MidPoint; 
1143

  
1133 1144
                //20180910 LJY 각도에 따라.
1145
                Vector offset = MidPoint.HasValue ? Point.Subtract(MidPoint.Value, connection) : new Vector(0, 0);
1134 1146
                switch (Math.Abs(this.PageAngle).ToString())
1135 1147
                {
1136 1148
                    case "90":
......
1138 1150
                        {
1139 1151
                            if (ConnectionPointList[0] == connection) //상단
1140 1152
                            {
1141
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1153
                                Vector dir = new Vector(0, 1);
1154
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1155
                                BendingPoint = connection + dir * BendingLength;
1142 1156
                            }
1143 1157
                            else if (ConnectionPointList[1] == connection) //하단
1144 1158
                            {
1145
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1159
                                Vector dir = new Vector(0, -1);
1160
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1161
                                BendingPoint = connection + dir * BendingLength;
1146 1162
                            }
1147 1163
                            else if (ConnectionPointList[2] == connection) //좌단
1148 1164
                            {
1149
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1165
                                Vector dir = new Vector(-1, 0);
1166
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1167
                                BendingPoint = connection + dir * BendingLength;
1150 1168
                            }
1151 1169
                            else if (ConnectionPointList[3] == connection) //우단
1152 1170
                            {
1153
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1171
                                Vector dir = new Vector(1, 0);
1172
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1173
                                BendingPoint = connection + dir * BendingLength;
1154 1174
                            }
1155 1175
                        }
1156 1176
                        else
......
1163 1183
                        {
1164 1184
                            if (ConnectionPointList[0] == connection) //상단
1165 1185
                            {
1166
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1186
                                Vector dir = new Vector(0, -1);
1187
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1188
                                BendingPoint = connection + dir * BendingLength;
1167 1189
                            }
1168 1190
                            else if (ConnectionPointList[1] == connection) //하단
1169 1191
                            {
1170
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1192
                                Vector dir = new Vector(0, 1);
1193
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1194
                                BendingPoint = connection + dir * BendingLength;
1171 1195
                            }
1172 1196
                            else if (ConnectionPointList[2] == connection) //좌단
1173 1197
                            {
1174
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1198
                                Vector dir = new Vector(1, 0);
1199
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1200
                                BendingPoint = connection + dir * BendingLength;
1175 1201
                            }
1176 1202
                            else if (ConnectionPointList[3] == connection) //우단
1177 1203
                            {
1178
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1204
                                Vector dir = new Vector(-1, 0);
1205
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1206
                                BendingPoint = connection + dir * BendingLength;
1179 1207
                            }
1180 1208
                        }
1181 1209
                        else
......
1188 1216
                        {
1189 1217
                            if (ConnectionPointList[0] == connection) //상단
1190 1218
                            {
1191
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1219
                                Vector dir = new Vector(0, -1);
1220
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1221
                                BendingPoint = connection + dir * BendingLength;
1192 1222
                            }
1193 1223
                            else if (ConnectionPointList[1] == connection) //하단
1194 1224
                            {
1195
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1225
                                Vector dir = new Vector(0, 1);
1226
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1227
                                BendingPoint = connection + dir * BendingLength;
1196 1228
                            }
1197 1229
                            else if (ConnectionPointList[2] == connection) //좌단
1198 1230
                            {
1199
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1231
                                Vector dir = new Vector(-1, 0);
1232
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1233
                                BendingPoint = connection + dir * BendingLength;
1200 1234
                            }
1201 1235
                            else if (ConnectionPointList[3] == connection) //우단
1202 1236
                            {
1203
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1237
                                Vector dir = new Vector(1, 0);
1238
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1239
                                BendingPoint = connection + dir * BendingLength;
1204 1240
                            }
1205 1241
                        }
1206 1242
                        else
......
1213 1249
            else
1214 1250
            {
1215 1251
                //20180910 LJY 각도에 따라.
1252
                Vector offset = MidPoint.HasValue ? Point.Subtract(MidPoint.Value, connection) : new Vector(0, 0);
1216 1253
                switch (Math.Abs(this.PageAngle).ToString())
1217 1254
                {
1218 1255
                    case "90":
......
1220 1257
                        {
1221 1258
                            if (ConnectionPointList[0] == connection) //상단
1222 1259
                            {
1223
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1260
                                Vector dir = new Vector(-1, 0);
1261
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1262
                                BendingPoint = connection + dir * BendingLength;
1224 1263
                            }
1225 1264
                            else if (ConnectionPointList[1] == connection) //하단
1226 1265
                            {
1227
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1266
                                Vector dir = new Vector(1, 0);
1267
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1268
                                BendingPoint = connection + dir * BendingLength;
1228 1269
                            }
1229 1270
                            else if (ConnectionPointList[2] == connection) //좌단
1230 1271
                            {
1231
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1272
                                Vector dir = new Vector(-1, 0);
1273
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1274
                                BendingPoint = connection + dir * BendingLength;
1232 1275
                            }
1233 1276
                            else if (ConnectionPointList[3] == connection) //우단
1234 1277
                            {
1235
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1278
                                Vector dir = new Vector(1, 0);
1279
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1280
                                BendingPoint = connection + dir * BendingLength;
1236 1281
                            }
1237 1282
                        }
1238 1283
                        else
......
1245 1290
                        {
1246 1291
                            if (ConnectionPointList[0] == connection) //상단
1247 1292
                            {
1248
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1293
                                Vector dir = new Vector(1, 0);
1294
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1295
                                BendingPoint = connection + dir * BendingLength;
1249 1296
                            }
1250 1297
                            else if (ConnectionPointList[1] == connection) //하단
1251 1298
                            {
1252
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1299
                                Vector dir = new Vector(-1, 0);
1300
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1301
                                BendingPoint = connection + dir * BendingLength;
1253 1302
                            }
1254 1303
                            else if (ConnectionPointList[2] == connection) //좌단
1255 1304
                            {
1256
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1305
                                Vector dir = new Vector(1, 0);
1306
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1307
                                BendingPoint = connection + dir * BendingLength;
1257 1308
                            }
1258 1309
                            else if (ConnectionPointList[3] == connection) //우단
1259 1310
                            {
1260
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1311
                                Vector dir = new Vector(1, 0);
1312
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1313
                                BendingPoint = connection + dir * BendingLength;
1261 1314
                            }
1262 1315
                        }
1263 1316
                        else
......
1270 1323
                        {
1271 1324
                            if (ConnectionPointList[0] == connection) //상단
1272 1325
                            {
1273
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1326
                                Vector dir = new Vector(0, -1);
1327
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1328
                                BendingPoint = connection + dir * BendingLength;
1274 1329
                            }
1275 1330
                            else if (ConnectionPointList[1] == connection) //하단
1276 1331
                            {
1277
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1332
                                Vector dir = new Vector(0, 1);
1333
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1334
                                BendingPoint = connection + dir * BendingLength;
1278 1335
                            }
1279 1336
                            else if (ConnectionPointList[2] == connection) //좌단
1280 1337
                            {
1281
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1338
                                Vector dir = new Vector(-1, 0);
1339
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1340
                                BendingPoint = connection + dir * BendingLength;
1282 1341
                            }
1283 1342
                            else if (ConnectionPointList[3] == connection) //우단
1284 1343
                            {
1285
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1344
                                Vector dir = new Vector(1, 0);
1345
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1346
                                BendingPoint = connection + dir * BendingLength;
1286 1347
                            }
1287 1348
                        }
1288 1349
                        else
......
1293 1354
                }
1294 1355
            }
1295 1356

  
1296

  
1297 1357
            return BendingPoint;
1298 1358
        }
1299

  
1359
        
1360
        /// <summary>
1361
        /// 형상을 생성한다.
1362
        /// </summary>
1363
        /// <param name="IsInit"></param>
1300 1364
        private void SetArrowTextPath(bool IsInit = false)
1301 1365
        {
1302 1366
            instanceGroup.Children.Clear();
......
1326 1390
            if (isTrans)
1327 1391
            {
1328 1392
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1329
                Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint);
1393
                Point? BendingPoint = GetBendingPoint(ps, this.MidPoint, this.MidPoint);
1330 1394
                if (BendingPoint.HasValue)
1331 1395
                {
1332 1396
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
......
1335 1399

  
1336 1400
                    //20180910 LJY 각도에 따라.
1337 1401
                    this.MidPoint = BendingPoint.Value;
1338
                    instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1339
                    instanceGroup.FillRule = FillRule.Nonzero;
1340
                    this.Base_ArrowPath.Fill = this.StrokeColor;
1341
                    this.Base_ArrowSubPath.Fill = this.StrokeColor;
1342 1402
                }
1403
                instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1404
                instanceGroup.FillRule = FillRule.Nonzero;
1405
                this.Base_ArrowPath.Fill = this.StrokeColor;
1406
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1343 1407
            }
1344 1408
            else
1345 1409
            {
1346 1410
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1347 1411
                #region 보정치
1348
                Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint);
1412
                Point? BendingPoint = GetBendingPoint(ps, this.MidPoint, this.MidPoint);
1349 1413
                if (BendingPoint.HasValue)
1350 1414
                {
1351 1415
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
......
1562 1626

  
1563 1627
        public override void UpdateControl()
1564 1628
        {
1565
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1566
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1567
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1629
            if(!this.StartPoint.Equals(this.PointSet[0])) 
1630
                this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1631
            if (!this.MidPoint.Equals(this.PointSet[1]))
1632
                this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1633
            if (!this.EndPoint.Equals(this.PointSet[2]))
1634
                this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1568 1635
        }
1569 1636

  
1570 1637
        public override void ApplyOverViewData()
......
1783 1850
                if (pt.Equals((this as IPath).PointSet[i])) break;
1784 1851
            }
1785 1852

  
1786
            List<Point> pts = path.PointSet;
1787 1853
            #region 끝점을 이동할때
1788 1854
            if (i == 0)
1789 1855
            {
1856
                #region 끝점을 기준으로 중간점을 계산한다.
1790 1857
                var connections = GetConnectionPointList();
1791
                var near = MathSet.getNearPoint(connections, selected);
1792
                var bending = GetBendingPoint(connections, near);
1793
                if(bending.HasValue) path.PointSet[1] = bending.Value;
1858
                var connection = MathSet.getNearPoint(connections, selected);
1859
                #region 연결점이 바뀌지 않으면 중간점을 그대로 그렇지 않으면 중간점을 재계산한다.
1860
                Point? bending = null;
1861
                if (connectorMEGeometry.EndPoint.Equals(connection))
1862
                {
1863
                    bending = GetBendingPoint(connections, selected, this.MidPoint);
1864
                }
1865
                else
1866
                {
1867
                    bending = GetBendingPoint(connections, selected, null);
1868
                }
1869
                #endregion
1870
                if (bending.HasValue) path.PointSet[1] = bending.Value;
1871
                #endregion
1794 1872
            }
1795 1873
            #endregion
1796 1874
            #region 중간점을 이동할때
......
1799 1877
                path.PointSet[1] = selected;
1800 1878
            }
1801 1879
            #endregion
1880
            #region 텍스트 박스를 이동할때
1881
            else
1882
            {
1883
                var connections = GetConnectionPointList();
1884
                var connection = MathSet.getNearPoint(connections, this.StartPoint);
1885
                if (!connectorMEGeometry.EndPoint.Equals(connection))
1886
                {
1887
                    var bending = GetBendingPoint(connections, this.StartPoint, null);
1888
                    if (bending.HasValue) path.PointSet[1] = bending.Value;
1889
                }
1890
                else
1891
                {
1892
                    var bending = GetBendingPoint(connections, this.StartPoint, this.MidPoint);
1893
                    if (bending.HasValue) path.PointSet[1] = bending.Value;
1894
                }
1895
            }
1896
            #endregion
1802 1897

  
1803 1898
            if (path.PointSet.Count > i) {
1804 1899
                path.PointSet[i] = selected;
......
1983 2078
        public event PropertyChangedEventHandler PropertyChanged; 
1984 2079
        #endregion
1985 2080
    }
2081

  
2082
    public static class Extension
2083
    {
2084
        public static double Dot(this Vector lhs,  Vector rhs)
2085
        {
2086
            return lhs.X * rhs.X + lhs.Y * rhs.Y;
2087
        }
2088
    }
1986 2089
}

내보내기 Unified diff

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