프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ e2d3d2dc

이력 | 보기 | 이력해설 | 다운로드 (21.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 38d69491 taeseongkim
using MarkupToPDF.Controls.Text;
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 5a65e058 taeseongkim
                    //강인구 추가
34 787a4489 KangIngu
                #region 단축키 선택
35
36 872b94b9 taeseongkim
                case Key.I:
37 5a65e058 taeseongkim
                    {
38
                        if (ViewerDataModel.Instance.IsPressCtrl && ViewerDataModel.Instance.IsPressShift)
39
                        {
40 c206d293 taeseongkim
                                if (!ViewerDataModel.Instance.IsAdmin)
41 872b94b9 taeseongkim
                                {
42 c206d293 taeseongkim
                                    EventHandler<WindowClosedEventArgs> closeEventHandler = (snd, evt) =>
43
                                    {
44
                                        if (evt.PromptResult == "markus01#")
45
                                        {
46
                                            ViewerDataModel.Instance.IsAdmin = true;
47
                                        }
48
                                    };
49
50
                                    var parameters = new DialogParameters()
51
                                    {
52
                                        ContentStyle = (Style)this.FindResource("RadPasswordPromptStyle"),
53
                                        Content = "Enter password: ",
54
                                        Closed = closeEventHandler
55
                                    };
56
57
                                    RadWindow.Prompt(parameters);
58 872b94b9 taeseongkim
                                }
59
                                else
60
                                {
61
                                    ViewerDataModel.Instance.IsAdmin = false;
62
                                }
63
                            }
64 5a65e058 taeseongkim
                    }
65
                    break;
66
67
                    #region 전체 선택(Ctrl + A)
68 787a4489 KangIngu
                case Key.A:
69
                    {
70 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
71 787a4489 KangIngu
                        {
72 f959ea6f humkyung
                            this.dzMainMenu.ConvertInkControlToPolygon();
73 787a4489 KangIngu
74
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
75
                            {
76 92c9cab8 taeseongkim
                                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
77
                                if (text_item_ != null)
78
                                {
79
                                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
80
                                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
81
                                    (text_item_ as TextControl).UnEditingMode();
82
83
                                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
84
                                }
85
86
                                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
87
                                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
88
                                {
89
                                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
90
                                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
91
                                    (Arrowtext_item_ as ArrowTextControl).UnEditingMode();
92
93
                                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
94
                                }
95
96
                                    /// 전체 선택 시 선택된 토글 해제
97 787a4489 KangIngu
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
98
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
99
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
100
101 92c9cab8 taeseongkim
                                if (text_item_ == null && Arrowtext_item_ == null)
102
                                {
103
                                    /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
104
                                    ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
105
                                }
106
107 787a4489 KangIngu
                                this.dzMainMenu.currentControl = null;
108
109
                                foreach (var tog in TogList)
110
                                {
111
                                    tog.IsChecked = false;
112
                                }
113 077896be humkyung
114 b37ef4b3 humkyung
                                SelectionSet.Instance.SelectAll();
115 787a4489 KangIngu
                            }
116
                        }
117
                    }
118
                    break;
119
                #endregion
120
121
                #region 복사하기(Ctrl + C)
122
                case Key.C:
123
                    {
124 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
125 787a4489 KangIngu
                    }
126
                    break;
127
                #endregion
128
129
                #region 잘라내기(Ctrl + X)
130
                case Key.X:
131
                    {
132 b37ef4b3 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
133 787a4489 KangIngu
                    }
134
                    break;
135
                #endregion
136
137
                #region 붙여넣기(Ctrl + V)
138
                case Key.V:
139
                    {
140 53393bae KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
141 787a4489 KangIngu
                        {
142 b37ef4b3 humkyung
                            PasteCommand.Instance.Execute();
143 37b65344 humkyung
                        }
144 787a4489 KangIngu
                    }
145
                    break;
146
                #endregion
147
148
                #region 저장하기(Ctrl + S)
149
                case Key.S:
150
                    {
151 37b65344 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
152 787a4489 KangIngu
                        {
153 38d69491 taeseongkim
                            var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
154
                            if (text_item_ != null)
155
                            {
156
                                (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
157
                                (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
158
                                (text_item_ as TextControl).UnEditingMode();
159
160
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
161
                            }
162
163
                            var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
164
                            if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
165
                            {
166
                                (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
167
                                (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
168
                                (Arrowtext_item_ as ArrowTextControl).UnEditingMode();
169
170
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
171
                            }
172
173
                            if (text_item_ == null && Arrowtext_item_ == null)
174
                            {                                 //컨트롤을 그리는 도중일 경우 컨트롤 삭제
175
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
176
                            }
177
178 787a4489 KangIngu
                            this.dzMainMenu.currentControl = null;
179
180 316d0f5c KangIngu
                            //this.dzTopMenu.SaveEvent(null, null);
181 65eb8dd6 ljiyeon
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
182
                            {
183 5ba8f2d5 taeseongkim
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
184 cb5c7f06 humkyung
                                this.dzTopMenu.SaveEventCallback(new object(), null);
185 65eb8dd6 ljiyeon
                            }
186 6707a5c7 ljiyeon
187
                            //저장완료후 임시파일 삭제
188 2b1f30fe taeseongkim
                            //TempFile.Remove();
189 37b65344 humkyung
                        }
190 787a4489 KangIngu
                    }
191
                    break;
192
                #endregion
193
194
                #region 프린트하기(Ctrl + P)
195
                case Key.P:
196
                    {
197
                        if (ViewerDataModel.Instance.IsPressCtrl)
198
                        {
199
                            this.dzTopMenu.Print_Start("Print");
200
                        }
201
                    }
202
                    break;
203
                #endregion
204
205
                #region Undo(Ctrl + Z)
206
                case Key.Z:
207
                    {
208 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
209 787a4489 KangIngu
                    }
210
                    break;
211
                #endregion
212
213
                #region Redo(Ctrl + Y)
214
                case Key.Y:
215
                    {
216 f816dd63 humkyung
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
217 787a4489 KangIngu
                    }
218
                    break;
219
                #endregion
220
221
                #region 삭제하기(Delete)
222
                case Key.Delete:
223
                    {
224 8e6884a5 taeseongkim
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
225
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
226 f816dd63 humkyung
                        this.dzMainMenu.SelectLayer.Children.Clear();
227 8e6884a5 taeseongkim
228
                        DeleteCommand.Instance.Execute(selectItems);
229 787a4489 KangIngu
                    }
230
                    break;
231
                #endregion
232
233
                #region 선택된 컨트롤 모두 해제 하기(ESC)
234
                case Key.Escape:
235
                    {
236
                        //캡쳐모드 일 경우 초기화
237 37b65344 humkyung
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
238 787a4489 KangIngu
                        {
239
                            //dzMainMenu.PN_Navi.IsEnabled = true;
240
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
241
                            ViewerDataModel.Instance.Capture_Opacity = 0;
242
                        }
243
244 b74a9c91 taeseongkim
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
245
                                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
246 787a4489 KangIngu
                        {
247
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
248
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
249
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
250
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
251
                            foreach (var tog in TogList)
252
                            {
253
                                tog.IsChecked = false;
254
                            }
255
                        }
256
257 077896be humkyung
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
258 787a4489 KangIngu
259
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
260 49b217ad humkyung
                        if (this.dzMainMenu.currentControl != null)
261
                        {
262
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
263
                            this.dzMainMenu.currentControl = null;
264
                        }
265 787a4489 KangIngu
266 2eac4f76 KangIngu
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
267
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
268
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
269
270
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
271
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
272
273 17a22987 KangIngu
                        foreach (var item in toggleList)
274
                        {
275
                            if (item.Name == "btnSelection")
276 2eac4f76 KangIngu
                            {
277
                                item.IsChecked = true;
278
                            }
279 17a22987 KangIngu
                            else
280 2eac4f76 KangIngu
                            {
281
                                item.IsChecked = false;
282
                            }
283 17a22987 KangIngu
                        }
284 9f473fb7 KangIngu
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
285 b643fcca taeseongkim
                            //foreach (var item in toggleList2)
286
                            //{
287
                            //    item.IsChecked = false;
288
                            //}
289
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
290 787a4489 KangIngu
                    }
291
                    break;
292 992a98b4 KangIngu
                #endregion
293
294
                #region FIND(Ctrl + F)
295
                case Key.F:
296
                    {
297 469b2bbf KangIngu
                        if (ViewerDataModel.Instance.IsPressCtrl)
298 992a98b4 KangIngu
                        {
299 469b2bbf KangIngu
                            if (!this.dzMainMenu.searchPane.IsPinned)
300 992a98b4 KangIngu
                            {
301 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = true;
302
                                if (ViewerDataModel.Instance.searchPDF != null)
303
                                {
304 8bd25583 taeseongkim
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
305
                                    {
306
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
307
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
308
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
309
                                    }), System.Windows.Threading.DispatcherPriority.Render);
310 469b2bbf KangIngu
                                }
311
                                else
312
                                {
313
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
314
                                }
315 992a98b4 KangIngu
                            }
316
                            else
317
                            {
318 469b2bbf KangIngu
                                this.dzMainMenu.searchPane.IsPinned = false;
319
                                this.dzMainMenu.searchPane.IsActive = false;
320
                                //this.dzMainMenu.searchPane.IsHidden = true;
321 992a98b4 KangIngu
                            }
322
                        }
323
                    }
324
                    break;
325
                #endregion
326 787a4489 KangIngu
327
                #endregion
328
329
                //강인구 추가
330
                #region Control Move
331 1edefbdf taeseongkim
                //case Key.NumPad4:
332
                //case Key.NumPad5:
333
                //case Key.NumPad6:
334
                //case Key.NumPad8:
335 d543f923 ljiyeon
                case Key.Right:
336
                case Key.Left:
337
                case Key.Up:
338
                case Key.Down:
339
                    {
340 d60f94ee taeseongkim
						if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox)
341
						{
342
							return;
343
						}
344
						
345 91e84544 taeseongkim
                        if(sender is UIElement)
346
                        {
347
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
348
                        }
349
350 f87dfb18 taeseongkim
                        Point? MovePoint = null;
351
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
352 d543f923 ljiyeon
                        {
353 f87dfb18 taeseongkim
                            MovePoint = new Point(0, 5);
354
                        }
355
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
356
                        {
357
                            MovePoint = new Point(0, -5);
358
                        }
359
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
360
                        {
361
                            MovePoint = new Point(-5, 0);
362
                        }
363
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
364
                        {
365
                            MovePoint = new Point(5, 0);
366
                        }
367
368
                        if (MovePoint != null && MovePoint.HasValue)
369
                        {
370
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
371 37b65344 humkyung
                            {
372 f87dfb18 taeseongkim
373
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
374 37b65344 humkyung
                            }
375 f87dfb18 taeseongkim
                            else
376 37b65344 humkyung
                            {
377 91e84544 taeseongkim
                                //if (ViewerDataModel.Instance.IsPressCtrl)
378
                                //{
379 f87dfb18 taeseongkim
                                    bool IsMovePossibility = false;
380
381
                                    var instance = ViewerDataModel.Instance;
382
383
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
384
                                    {
385 f06cce07 taeseongkim
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
386 f87dfb18 taeseongkim
                                        {
387
                                            IsMovePossibility = true;
388
                                        }
389
                                    }
390
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
391
                                    {
392
                                        if (0 < instance.ContentOffsetY)
393
                                        {
394
                                            IsMovePossibility = true;
395
                                        }
396
                                    }
397
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
398
                                    {
399
                                        if (0 < instance.ContentOffsetX)
400
                                        {
401
                                            IsMovePossibility = true;
402
                                        }
403
                                    }
404
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
405
                                    {
406 f06cce07 taeseongkim
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
407 f87dfb18 taeseongkim
                                        {
408
                                            IsMovePossibility = true;
409
                                        }
410
                                    }
411
412
                                    if (IsMovePossibility)
413
                                    {
414
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
415
416
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
417
418
                                        this.dzMainMenu.MainDocumentPanel.Focus();
419
420
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
421
                                    }
422 91e84544 taeseongkim
                                //}
423 37b65344 humkyung
                            }
424 d543f923 ljiyeon
                        }
425
                    }
426
                    break;
427 da92cfb7 ljiyeon
                #endregion
428
                case Key.PageUp:
429 2d584f1a djkim
                    
430 da92cfb7 ljiyeon
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
431
                    break;
432
                case Key.PageDown:
433
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
434
                    break;
435 787a4489 KangIngu
            }
436 91e84544 taeseongkim
            });
437 787a4489 KangIngu
        }
438
439 f87dfb18 taeseongkim
440 37b65344 humkyung
        /// <summary>
441
        /// translate or rotate items by given pt and angle
442
        /// </summary>
443
        /// <author>humkyung</author>
444
        /// <date>2019.07.03</date>
445
        /// <param name="pt">control point</param>
446
        /// <param name="dAngle">angle in degree</param>
447
        private void TranslateOrRotateItems(Point pt, double dAngle)
448
        {
449
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
450
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
451
            {
452
                if (item.GetType().Name == "AdornerFinal")
453
                {
454
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
455
                    {
456
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
457
                    }
458
                    else
459
                    {
460 6b6e937c taeseongkim
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
461 37b65344 humkyung
                    }
462
463
                }
464
            }
465
        }
466 787a4489 KangIngu
    }
467
}
클립보드 이미지 추가 (최대 크기: 500 MB)