프로젝트

일반

사용자정보

개정판 d2114d3b

IDd2114d3b43eba86003919f41890e541e9e88a4ba
상위 6b518442
하위 018e77ac

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

issue #923: add OnMoveCtrlPoint method to interface

Change-Id: If3b10f5b54eaecd8bd8fa299d702e70e05d4b97e

차이점 보기:

KCOM/Controls/AdornerFinal.xaml.cs
33 33
        }
34 34

  
35 35
        /// <summary>
36
        /// translate thumb with given delta and angle
37
        /// </summary>
38
        /// <param name="e"></param>
39
        /// <param name="angle"></param>
40
        public void Translate(DragDeltaEventArgs e, double angle)
41
        {
42
            double radian = angle * Math.PI / 180;
43
            double cos = Math.Cos(radian);
44
            double sin = Math.Sin(radian);
45

  
46
            double dx = e.HorizontalChange*cos -e.VerticalChange * sin;
47
            double dy = e.HorizontalChange*sin +e.VerticalChange * cos;
48
            Canvas.SetLeft(this, Canvas.GetLeft(this) + dx);
49
            Canvas.SetTop(this, Canvas.GetTop(this) + dy);
50
        }
51

  
52
        /// <summary>
36 53
        /// </summary>
37 54
        /// <param name="sender"></param>
38 55
        /// <param name="e"></param>
......
908 925

  
909 926
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
910 927
        {
911
            if (this.Members.Count > 1)
912
                return;
928
            if (this.Members.Count > 1) return;
913 929
            if (reSizePoint != new Point(0, 0))
914 930
            {
915
                Thumb thumb = sender as Thumb;
916

  
917
                if (AngleValue == -90)
918
                {
919
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
920
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
921
                }
922
                else if (AngleValue == -180)
923
                {
924
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
925
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
926
                }
927
                else if (AngleValue == -270)
928
                {
929
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
930
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
931
                }
932
                else //(AngleValue == 0)
933
                {
934
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
935
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
936
                }
937

  
938

  
931
                MyThumb thumb = sender as MyThumb;
939 932
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
933
                thumb.Translate(e, this.AngleValue);
940 934
                
941 935
                AdornerMember control = (from userThumb in this.Members
942 936
                                         where userThumb.ThumbList.Contains(thumb)
943 937
                                         select userThumb).FirstOrDefault();
944
                Point nearPoint = new Point(0, 0);
945
                IPath AllControl = control.DrawingData as IPath;
946
                if (ControlType.TextControl != control.Drawingtype)
947
                {
948

  
949
                    var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
950
                    List<Point> ps = new List<Point>();
951

  
952
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
953
                    
954

  
955
                }
956
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
957
                {
958
                    switch (control.Drawingtype)
959
                    {
960
                        #region Arc + Line
961
                        case ControlType.ArrowMultiLine:
962
                        case ControlType.ArcLine:
963
                        case ControlType.ArcArrow:
964
                        case ControlType.SingleLine:
965
                        case ControlType.Triangle:
966
                            if (nearPoint.Equals(AllControl.PointSet[i]))
967
                            {
968
                                AllControl.PointSet[i] = setPoint;
969
                                AllControl.updateControl();
970
                                DynamicThumbUpdate(control);
971
                                BorderUpdate();
972
                                
973
                            }
974
                            break;
975
                        #endregion
976
                        #region Shape                        
977
                        case ControlType.RectCloud:
978
                        case ControlType.Rectangle:
979
                            if (nearPoint.Equals(AllControl.PointSet[i]))
980
                            {
981
                                AllControl.PointSet[i] = setPoint;
982
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
983
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
984
                                var NextP = (i + 1) % AllControl.PointSet.Count();
985

  
986
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
987

  
988
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
989
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
990
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
991
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
992
                                    [ReverseP].Y
993
                                    + PreviousV.Y * l);
994

  
995
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
996
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
997
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
998
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
999
                                    NextV.Y * l);
1000
                                AllControl.updateControl();
1001
                                DynamicThumbUpdate(control);
1002
                                BorderUpdate();
1003
                            }
1004
                            break;
1005
                        #endregion
1006
                        #region Polygon
1007
                        case ControlType.PolygonControl:
1008
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1009
                            {
1010
                                AllControl.PointSet[i] = setPoint;
1011
                                AllControl.updateControl();
1012
                                BorderUpdate();
1013
                            }
1014
                            break;
1015
                        #endregion
1016
                        #region Cicle
1017
                        case ControlType.Circle:
1018
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1019
                            {
1020
                                AllControl.PointSet[i] = setPoint;
1021
                                List<Point> newPointSet = new List<Point> { };
1022
                                Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
1023
                                    AllControl.PathData.Bounds.Y +
1024
                                    AllControl.PathData.Bounds.Height * 0.5);
1025
                                foreach (Point pt in AllControl.PointSet)
1026
                                {
1027
                                    newPointSet.Add(pt);
1028
                                }
1029
                                var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
1030
                                var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
1031
                                var NextP = (i + 1) % newPointSet.Count();
1032
                                var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
1033
                                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
1034
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
1035
                                    newPointSet[i].Y - newPointSet[ReverseP].Y);
1036
                                newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
1037
                                    + PreviousV.Y * l);
1038

  
1039
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
1040
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
1041
                                    - newPointSet[ReverseP].Y);
1042
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
1043

  
1044
                                AllControl.PointSet = newPointSet;
1045
                                DynamicThumbUpdate(control);
1046
                                AllControl.updateControl();
1047
                                BorderUpdate();
1048
                            }
1049
                            break;
1050
                        #endregion
1051
                        #region ArrowText
1052
                        case ControlType.ArrowTextControl:
1053
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1054
                            {
1055 938

  
1056
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
1057

  
1058
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
1059
                                {
1060
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
1061
                                }
1062
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
1063
                                {
1064
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
1065
                                }
1066
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
1067

  
1068

  
1069
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
1070
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
1071
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1072

  
1073
                                AllControl.PointSet[i] = setPoint;
1074
                                //System.Diagnostics.Debug.WriteLine("PointSet : " + AllControl.PointSet[i]);
1075

  
1076
                                AllControl.updateControl();
1077

  
1078
                                DynamicThumbUpdate(control);
1079
                                BorderUpdate();
1080
                                                                
1081
                            }
1082
                            break;
1083
                        #endregion
1084
                        #region Text
1085
                        case ControlType.TextControl:
1086
                            break;
1087
                        #endregion
1088
                        #region Image
1089
                        case ControlType.ImgControl:
1090
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1091
                            {
1092
                                AllControl.PointSet[i] = setPoint;
1093
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1094
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1095
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1096

  
1097
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1098

  
1099
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1100
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1101
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1102
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1103
                                    [ReverseP].Y
1104
                                    + PreviousV.Y * l);
1105

  
1106
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1107
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1108
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1109
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1110
                                    NextV.Y * l);
1111
                                AllControl.updateControl();
1112
                                DynamicThumbUpdate(control);
1113
                                BorderUpdate();
1114
                            }
1115
                            break;
1116
                        #endregion
1117
                        #region Sign
1118
                        case ControlType.Sign:
1119
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1120
                            {
1121
                                AllControl.PointSet[i] = setPoint;
1122
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1123
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1124
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1125

  
1126
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1127

  
1128
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1129
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1130
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1131
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1132
                                    [ReverseP].Y
1133
                                    + PreviousV.Y * l);
1134

  
1135
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1136
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1137
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1138
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1139
                                    NextV.Y * l);
1140
                                AllControl.updateControl();
1141
                                DynamicThumbUpdate(control);
1142
                                BorderUpdate();
1143
                            }
1144
                            break;
1145
                        #endregion
1146
                        #region Cloud
1147
                        case ControlType.PolygonCloud:
1148
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1149
                            {
1150
                                AllControl.PointSet[i] = setPoint;
1151
                                AllControl.updateControl();
1152
                                ((ICloudControl)AllControl).DrawingCloud();
1153
                                BorderUpdate();
1154
                            }
1155
                            break;
1156
                        #endregion
1157
                        #region SymBol
1158
                        case ControlType.Symbol:
1159
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1160
                            {
1161
                                AllControl.PointSet[i] = setPoint;
1162
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1163
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1164
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1165

  
1166
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1167

  
1168
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1169
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1170
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1171
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1172
                                    [ReverseP].Y
1173
                                    + PreviousV.Y * l);
1174

  
1175
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1176
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1177
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1178
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1179
                                    NextV.Y * l);
1180
                                AllControl.updateControl();
1181
                                DynamicThumbUpdate(control);
1182
                                BorderUpdate();
1183
                            }
1184
                            break;
1185
                        case ControlType.Stamp:
1186
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1187
                            {
1188
                                AllControl.PointSet[i] = setPoint;
1189
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1190
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1191
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1192

  
1193
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1194

  
1195
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1196
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1197
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1198
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1199
                                    [ReverseP].Y
1200
                                    + PreviousV.Y * l);
1201

  
1202
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1203
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1204
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1205
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1206
                                    NextV.Y * l);
1207
                                AllControl.updateControl();
1208
                                DynamicThumbUpdate(control);
1209
                                BorderUpdate();
1210
                            }
1211
                            break;
1212
                        case ControlType.Date:
1213
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1214
                            {
1215
                                AllControl.PointSet[i] = setPoint;
1216
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1217
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1218
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1219

  
1220
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1221

  
1222
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1223
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1224
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1225
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1226
                                    [ReverseP].Y
1227
                                    + PreviousV.Y * l);
1228

  
1229
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1230
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1231
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1232
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1233
                                    NextV.Y * l);
1234
                                AllControl.updateControl();
1235
                                DynamicThumbUpdate(control);
1236
                                BorderUpdate();
1237
                            }
1238
                            break;
1239
                        #endregion
1240
                        #region Ink
1241
                        case ControlType.Ink:
1242
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1243
                            {
1244
                                AllControl.PointSet[i] = setPoint;
1245
                                AllControl.updateControl();
1246
                                BorderUpdate();
1247
                            }
1248
                            break;
1249
                        #endregion
1250
                        default:
1251
                            break;
1252
                    }
1253
                }
939
                IPath AllControl = control.DrawingData as IPath;
940
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
941
                DynamicThumbUpdate(control);
942
                BorderUpdate();
1254 943
            }
1255
            //}
1256 944
        }
1257 945

  
1258

  
1259

  
1260 946
        #endregion
1261 947
        #region 이벤트
1262 948

  

내보내기 Unified diff

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