프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ f882e166

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

1 787a4489 KangIngu
using KCOM.Common;
2 f816dd63 humkyung
using KCOM.Events;
3 787a4489 KangIngu
using MarkupToPDF.Common;
4 036650a0 humkyung
using MarkupToPDF.Controls.Parsing;
5 53880c83 ljiyeon
using Svg2Xaml;
6 787a4489 KangIngu
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 53880c83 ljiyeon
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16 787a4489 KangIngu
using Telerik.Windows.Controls;
17 0c997b99 ljiyeon
//using static KCOM.Views.MainMenu;
18 787a4489 KangIngu
19
namespace KCOM
20
{
21 68302e9d taeseongkim
    public partial class MainWindow : KCOM.Controls.CustomizedWindow.CustomWindow
22 787a4489 KangIngu
    {
23
        public double CumulativeWheel = 0;
24 036650a0 humkyung
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25 da92cfb7 ljiyeon
                
26 91e84544 taeseongkim
        public async void KeyEventDownAction(object sender, KeyEventArgs e)
27 787a4489 KangIngu
        {
28 91e84544 taeseongkim
            //if (e.IsRepeat && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift)
29
            //    return;
30
            await this.Dispatcher.InvokeAsync(() => {
31 787a4489 KangIngu
            switch (e.Key)
32
            {
33
                //강인구 추가
34
                #region 단축키 선택
35
36
                #region 전체 선택(Ctrl + A)
37
                case Key.A:
38
                    {
39 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
40 787a4489 KangIngu
                        {
41 f959ea6f humkyung
                            this.dzMainMenu.ConvertInkControlToPolygon();
42 787a4489 KangIngu
43
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
44
                            {
45 b37ef4b3 humkyung
                                /// 전체 선택 시 선택된 토글 해제
46 787a4489 KangIngu
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
47
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
48
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
49
50 b37ef4b3 humkyung
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
51 787a4489 KangIngu
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
52
                                this.dzMainMenu.currentControl = null;
53
54
                                foreach (var tog in TogList)
55
                                {
56
                                    tog.IsChecked = false;
57
                                }
58 077896be humkyung
59 b37ef4b3 humkyung
                                SelectionSet.Instance.SelectAll();
60 787a4489 KangIngu
                            }
61
                        }
62
                    }
63
                    break;
64
                #endregion
65
66
                #region 복사하기(Ctrl + C)
67
                case Key.C:
68
                    {
69 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
70 787a4489 KangIngu
                    }
71
                    break;
72
                #endregion
73
74
                #region 잘라내기(Ctrl + X)
75
                case Key.X:
76
                    {
77 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
78 787a4489 KangIngu
                    }
79
                    break;
80
                #endregion
81
82
                #region 붙여넣기(Ctrl + V)
83
                case Key.V:
84
                    {
85 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
86 787a4489 KangIngu
                        {
87 b37ef4b3 humkyung
                            PasteCommand.Instance.Execute();
88 37b65344 humkyung
                        }
89 787a4489 KangIngu
                    }
90
                    break;
91
                #endregion
92
93
                #region 저장하기(Ctrl + S)
94
                case Key.S:
95
                    {
96 37b65344 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
97 787a4489 KangIngu
                        {
98
                            //컨트롤을 그리는 도중일 경우 컨트롤 삭제
99
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
100
                            this.dzMainMenu.currentControl = null;
101
102 316d0f5c KangIngu
                            //this.dzTopMenu.SaveEvent(null, null);
103 65eb8dd6 ljiyeon
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
104
                            {
105 cb5c7f06 humkyung
                                this.dzTopMenu.SaveEventCallback(new object(), null);
106 65eb8dd6 ljiyeon
                            }
107 6707a5c7 ljiyeon
108
                            //저장완료후 임시파일 삭제
109 a20d338f ljiyeon
                            TempFile.Remove();
110 37b65344 humkyung
                        }
111 787a4489 KangIngu
                    }
112
                    break;
113
                #endregion
114
115
                #region 프린트하기(Ctrl + P)
116
                case Key.P:
117
                    {
118
                        if (ViewerDataModel.Instance.IsPressCtrl)
119
                        {
120
                            this.dzTopMenu.Print_Start("Print");
121
                        }
122
                    }
123
                    break;
124
                #endregion
125
126
                #region Undo(Ctrl + Z)
127
                case Key.Z:
128
                    {
129 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
130 787a4489 KangIngu
                    }
131
                    break;
132
                #endregion
133
134
                #region Redo(Ctrl + Y)
135
                case Key.Y:
136
                    {
137 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
138 787a4489 KangIngu
                    }
139
                    break;
140
                #endregion
141
142
                #region 삭제하기(Delete)
143
                case Key.Delete:
144
                    {
145 8e6884a5 taeseongkim
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
146
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
147 f816dd63 humkyung
                        this.dzMainMenu.SelectLayer.Children.Clear();
148 8e6884a5 taeseongkim
149
                        DeleteCommand.Instance.Execute(selectItems);
150 787a4489 KangIngu
                    }
151
                    break;
152
                #endregion
153
154
                #region 선택된 컨트롤 모두 해제 하기(ESC)
155
                case Key.Escape:
156
                    {
157
                        //캡쳐모드 일 경우 초기화
158 37b65344 humkyung
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
159 787a4489 KangIngu
                        {
160
                            //dzMainMenu.PN_Navi.IsEnabled = true;
161
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
162
                            ViewerDataModel.Instance.Capture_Opacity = 0;
163
                        }
164
165 37b65344 humkyung
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
166 787a4489 KangIngu
                        {
167
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
168
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
169
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
170
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
171
                            foreach (var tog in TogList)
172
                            {
173
                                tog.IsChecked = false;
174
                            }
175
                        }
176
177 077896be humkyung
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
178 787a4489 KangIngu
179
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
180 49b217ad humkyung
                        if (this.dzMainMenu.currentControl != null)
181
                        {
182
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
183
                            this.dzMainMenu.currentControl = null;
184
                        }
185 787a4489 KangIngu
186 2eac4f76 KangIngu
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
187
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
188
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
189
190
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
191
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
192
193 17a22987 KangIngu
                        foreach (var item in toggleList)
194
                        {
195
                            if (item.Name == "btnSelection")
196 2eac4f76 KangIngu
                            {
197
                                item.IsChecked = true;
198
                            }
199 17a22987 KangIngu
                            else
200 2eac4f76 KangIngu
                            {
201
                                item.IsChecked = false;
202
                            }
203 17a22987 KangIngu
                        }
204 9f473fb7 KangIngu
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
205 b643fcca taeseongkim
                            //foreach (var item in toggleList2)
206
                            //{
207
                            //    item.IsChecked = false;
208
                            //}
209
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
210 787a4489 KangIngu
                    }
211
                    break;
212 992a98b4 KangIngu
                #endregion
213
214
                #region FIND(Ctrl + F)
215
                case Key.F:
216
                    {
217 469b2bbf KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl)
218 992a98b4 KangIngu
                        {
219 469b2bbf KangIngu
                            if (!this.dzMainMenu.searchPane.IsPinned)
220 992a98b4 KangIngu
                            {
221 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = true;
222
                                if (ViewerDataModel.Instance.searchPDF != null)
223
                                {
224 8bd25583 taeseongkim
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
225
                                    {
226
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
227
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
228
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
229
                                    }), System.Windows.Threading.DispatcherPriority.Render);
230 469b2bbf KangIngu
                                }
231
                                else
232
                                {
233
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
234
                                }
235 992a98b4 KangIngu
                            }
236
                            else
237
                            {
238 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = false;
239
                                this.dzMainMenu.searchPane.IsActive = false;
240
                                //this.dzMainMenu.searchPane.IsHidden = true;
241 992a98b4 KangIngu
                            }
242
                        }
243
                    }
244
                    break;
245
                #endregion
246 787a4489 KangIngu
247
                #endregion
248
249
                //강인구 추가
250
                #region Control Move
251 5cbd5c21 djkim
                case Key.NumPad4:
252
                case Key.NumPad5:
253
                case Key.NumPad6:
254 37b65344 humkyung
                case Key.NumPad8:
255 d543f923 ljiyeon
                case Key.Right:
256
                case Key.Left:
257
                case Key.Up:
258
                case Key.Down:
259
                    {
260 91e84544 taeseongkim
                        if(sender is UIElement)
261
                        {
262
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
263
                        }
264
265 f87dfb18 taeseongkim
                        Point? MovePoint = null;
266
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
267 d543f923 ljiyeon
                        {
268 f87dfb18 taeseongkim
                            MovePoint = new Point(0, 5);
269
                        }
270
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
271
                        {
272
                            MovePoint = new Point(0, -5);
273
                        }
274
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
275
                        {
276
                            MovePoint = new Point(-5, 0);
277
                        }
278
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
279
                        {
280
                            MovePoint = new Point(5, 0);
281
                        }
282
283
                        if (MovePoint != null && MovePoint.HasValue)
284
                        {
285
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
286 37b65344 humkyung
                            {
287 f87dfb18 taeseongkim
288
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
289 37b65344 humkyung
                            }
290 f87dfb18 taeseongkim
                            else
291 37b65344 humkyung
                            {
292 91e84544 taeseongkim
                                //if (ViewerDataModel.Instance.IsPressCtrl)
293
                                //{
294 f87dfb18 taeseongkim
                                    bool IsMovePossibility = false;
295
296
                                    var instance = ViewerDataModel.Instance;
297
298
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
299
                                    {
300 f06cce07 taeseongkim
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
301 f87dfb18 taeseongkim
                                        {
302
                                            IsMovePossibility = true;
303
                                        }
304
                                    }
305
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
306
                                    {
307
                                        if (0 < instance.ContentOffsetY)
308
                                        {
309
                                            IsMovePossibility = true;
310
                                        }
311
                                    }
312
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
313
                                    {
314
                                        if (0 < instance.ContentOffsetX)
315
                                        {
316
                                            IsMovePossibility = true;
317
                                        }
318
                                    }
319
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
320
                                    {
321 f06cce07 taeseongkim
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
322 f87dfb18 taeseongkim
                                        {
323
                                            IsMovePossibility = true;
324
                                        }
325
                                    }
326
327
                                    if (IsMovePossibility)
328
                                    {
329
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
330
331
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
332
333
                                        this.dzMainMenu.MainDocumentPanel.Focus();
334
335
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
336
                                    }
337 91e84544 taeseongkim
                                //}
338 37b65344 humkyung
                            }
339 d543f923 ljiyeon
                        }
340
                    }
341
                    break;
342 da92cfb7 ljiyeon
                #endregion
343
                case Key.PageUp:
344 2d584f1a djkim
                    
345 da92cfb7 ljiyeon
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
346
                    break;
347
                case Key.PageDown:
348
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
349
                    break;
350 787a4489 KangIngu
            }
351 91e84544 taeseongkim
            });
352 787a4489 KangIngu
        }
353
354 f87dfb18 taeseongkim
355 37b65344 humkyung
        /// <summary>
356
        /// translate or rotate items by given pt and angle
357
        /// </summary>
358
        /// <author>humkyung</author>
359
        /// <date>2019.07.03</date>
360
        /// <param name="pt">control point</param>
361
        /// <param name="dAngle">angle in degree</param>
362
        private void TranslateOrRotateItems(Point pt, double dAngle)
363
        {
364
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
365
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
366
            {
367
                if (item.GetType().Name == "AdornerFinal")
368
                {
369
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
370
                    {
371
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
372
                    }
373
                    else
374
                    {
375 6b6e937c taeseongkim
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
376 37b65344 humkyung
                    }
377
378
                }
379
            }
380
        }
381 787a4489 KangIngu
    }
382
}
클립보드 이미지 추가 (최대 크기: 500 MB)