프로젝트

일반

사용자정보

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

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

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