프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Events / Event_KeyEvent.cs @ 2d584f1a

이력 | 보기 | 이력해설 | 다운로드 (13.1 KB)

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Parsing;
5
using Svg2Xaml;
6
using System;
7
using System.Collections.Generic;
8
using System.ComponentModel;
9
using System.Linq;
10
using System.Text;
11
using System.Windows;
12
using System.Windows.Controls;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using Telerik.Windows.Controls;
17
//using static KCOM.Views.MainMenu;
18

    
19
namespace KCOM
20
{
21
    public partial class MainWindow : Window
22
    {
23
        public double CumulativeWheel = 0;
24
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25
                
26
        public void KeyEventDownAction(object sender, KeyEventArgs e)
27
        {
28
            if (e.IsRepeat)
29
                return;
30
            switch (e.Key)
31
            {
32
                //강인구 추가
33
                #region 단축키 선택
34

    
35
                #region 전체 선택(Ctrl + A)
36
                case Key.A:
37
                    {
38
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
39
                        {
40
                            this.dzMainMenu.ConvertInkControlToPolygon();
41

    
42
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
43
                            {
44
                                /// 전체 선택 시 선택된 토글 해제
45
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
46
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
47
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
48

    
49
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
50
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
51
                                this.dzMainMenu.currentControl = null;
52

    
53
                                foreach (var tog in TogList)
54
                                {
55
                                    tog.IsChecked = false;
56
                                }
57

    
58
                                SelectionSet.Instance.SelectAll();
59
                            }
60
                        }
61
                    }
62
                    break;
63
                #endregion
64

    
65
                #region 복사하기(Ctrl + C)
66
                case Key.C:
67
                    {
68
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
69
                    }
70
                    break;
71
                #endregion
72

    
73
                #region 잘라내기(Ctrl + X)
74
                case Key.X:
75
                    {
76
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
77
                    }
78
                    break;
79
                #endregion
80

    
81
                #region 붙여넣기(Ctrl + V)
82
                case Key.V:
83
                    {
84
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
85
                        {
86
                            PasteCommand.Instance.Execute();
87
                        }
88
                    }
89
                    break;
90
                #endregion
91

    
92
                #region 저장하기(Ctrl + S)
93
                case Key.S:
94
                    {
95
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
96
                        {
97
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
98
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
99
                            this.dzMainMenu.currentControl = null;
100

    
101
                            //this.dzTopMenu.SaveEvent(null, null);
102
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
103
                            {
104
                                this.dzTopMenu.SaveEventCallback(new object(), null);
105
                            }
106

    
107
                            //저장완료후 임시파일 삭제
108
                            TempFile.Remove();
109
                        }
110
                    }
111
                    break;
112
                #endregion
113

    
114
                #region 프린트하기(Ctrl + P)
115
                case Key.P:
116
                    {
117
                        if (ViewerDataModel.Instance.IsPressCtrl)
118
                        {
119
                            this.dzTopMenu.Print_Start("Print");
120
                        }
121
                    }
122
                    break;
123
                #endregion
124

    
125
                #region Undo(Ctrl + Z)
126
                case Key.Z:
127
                    {
128
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
129
                    }
130
                    break;
131
                #endregion
132

    
133
                #region Redo(Ctrl + Y)
134
                case Key.Y:
135
                    {
136
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
137
                    }
138
                    break;
139
                #endregion
140

    
141
                #region 삭제하기(Delete)
142
                case Key.Delete:
143
                    {
144
                        DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems);
145
                        this.dzMainMenu.SelectLayer.Children.Clear();
146
                    }
147
                    break;
148
                #endregion
149

    
150
                #region 선택된 컨트롤 모두 해제 하기(ESC)
151
                case Key.Escape:
152
                    {
153
                        //캡쳐모드 일 경우 초기화
154
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
155
                        {
156
                            //dzMainMenu.PN_Navi.IsEnabled = true;
157
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
158
                            ViewerDataModel.Instance.Capture_Opacity = 0;
159
                        }
160

    
161
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
162
                        {
163
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
164
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
165
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
166
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
167
                            foreach (var tog in TogList)
168
                            {
169
                                tog.IsChecked = false;
170
                            }
171
                        }
172

    
173
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
174

    
175
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
176
                        if (this.dzMainMenu.currentControl != null)
177
                        {
178
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
179
                            this.dzMainMenu.currentControl = null;
180
                        }
181

    
182
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
183
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
184
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
185

    
186
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
187
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
188

    
189
                        foreach (var item in toggleList)
190
                        {
191
                            if (item.Name == "btnSelection")
192
                            {
193
                                item.IsChecked = true;
194
                            }
195
                            else
196
                            {
197
                                item.IsChecked = false;
198
                            }
199
                        }
200
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
201
                        //foreach (var item in toggleList2)
202
                        //{
203
                        //    item.IsChecked = false;
204
                        //}
205
                    }
206
                    break;
207
                #endregion
208

    
209
                #region FIND(Ctrl + F)
210
                case Key.F:
211
                    {
212
                        if (ViewerDataModel.Instance.IsPressCtrl)
213
                        {
214
                            if (!this.dzMainMenu.searchPane.IsPinned)
215
                            {
216
                                this.dzMainMenu.searchPane.IsPinned = true;
217
                                if (ViewerDataModel.Instance.searchPDF != null)
218
                                {
219
                                    this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
220
                                }
221
                                else
222
                                {
223
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
224
                                }
225
                            }
226
                            else
227
                            {
228
                                this.dzMainMenu.searchPane.IsPinned = false;
229
                                this.dzMainMenu.searchPane.IsActive = false;
230
                                //this.dzMainMenu.searchPane.IsHidden = true;
231
                            }
232
                        }
233
                    }
234
                    break;
235
                #endregion
236

    
237
                #endregion
238

    
239
                //강인구 추가
240
                #region Control Move
241
                case Key.NumPad4:
242
                case Key.NumPad5:
243
                case Key.NumPad6:
244
                case Key.NumPad8:
245
                case Key.Right:
246
                case Key.Left:
247
                case Key.Up:
248
                case Key.Down:
249
                    {
250
                        if (this.dzMainMenu.SelectLayer.Children.Count > 0)
251
                        {
252
                            Point? control = null;
253
                            if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad5)) || (e.Key == Key.Down))
254
                            {
255
                                control = new Point(0, 5);
256
                            }
257
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad8)) || (e.Key == Key.Up))
258
                            {
259
                                control = new Point(0, -5);
260
                            }
261
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad4)) || (e.Key == Key.Left))
262
                            {
263
                                control = new Point(-5, 0);
264
                            }
265
                            else if ((ViewerDataModel.Instance.IsPressShift && (e.Key == Key.NumPad6)) || (e.Key == Key.Right))
266
                            {
267
                                control = new Point(5, 0);
268
                            }
269
                            if(control != null && control.HasValue) this.TranslateOrRotateItems(control.Value, this.dzMainMenu.rotate.Angle);
270
                        }
271
                    }
272
                    break;
273
                #endregion
274
                case Key.PageUp:
275
                    
276
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
277
                    break;
278
                case Key.PageDown:
279
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
280
                    break;
281
            }
282
        }
283

    
284
        /// <summary>
285
        /// translate or rotate items by given pt and angle
286
        /// </summary>
287
        /// <author>humkyung</author>
288
        /// <date>2019.07.03</date>
289
        /// <param name="pt">control point</param>
290
        /// <param name="dAngle">angle in degree</param>
291
        private void TranslateOrRotateItems(Point pt, double dAngle)
292
        {
293
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
294
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
295
            {
296
                if (item.GetType().Name == "AdornerFinal")
297
                {
298
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
299
                    {
300
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
301
                    }
302
                    else
303
                    {
304
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
305
                    }
306

    
307
                }
308
            }
309
        }
310
    }
311
}
클립보드 이미지 추가 (최대 크기: 500 MB)