프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ 38d69491

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

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Parsing;
5
using MarkupToPDF.Controls.Text;
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 : KCOM.Controls.CustomizedWindow.CustomWindow
22
    {
23
        public double CumulativeWheel = 0;
24
        MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
25
                
26
        public async void KeyEventDownAction(object sender, KeyEventArgs e)
27
        {
28
            //if (e.IsRepeat && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift)
29
            //    return;
30
            await this.Dispatcher.InvokeAsync(() => {
31
            switch (e.Key)
32
            {
33
                    //강인구 추가
34
                #region 단축키 선택
35

    
36
                case Key.I:
37
                    {
38
                        if (ViewerDataModel.Instance.IsPressCtrl && ViewerDataModel.Instance.IsPressShift)
39
                        {
40
                                if (!ViewerDataModel.Instance.IsAdmin)
41
                                {
42
                                    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
                                }
59
                                else
60
                                {
61
                                    ViewerDataModel.Instance.IsAdmin = false;
62
                                }
63
                            }
64
                    }
65
                    break;
66

    
67
                    #region 전체 선택(Ctrl + A)
68
                case Key.A:
69
                    {
70
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
71
                        {
72
                            this.dzMainMenu.ConvertInkControlToPolygon();
73

    
74
                            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
75
                            {
76
                                /// 전체 선택 시 선택된 토글 해제
77
                                var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
78
                                this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
79
                                this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
80

    
81
                                /// 컨트롤을 그리는 도중일 경우 컨트롤 삭제
82
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
83
                                this.dzMainMenu.currentControl = null;
84

    
85
                                foreach (var tog in TogList)
86
                                {
87
                                    tog.IsChecked = false;
88
                                }
89

    
90
                                SelectionSet.Instance.SelectAll();
91
                            }
92
                        }
93
                    }
94
                    break;
95
                #endregion
96

    
97
                #region 복사하기(Ctrl + C)
98
                case Key.C:
99
                    {
100
                        if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute();
101
                    }
102
                    break;
103
                #endregion
104

    
105
                #region 잘라내기(Ctrl + X)
106
                case Key.X:
107
                    {
108
                        if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute();
109
                    }
110
                    break;
111
                #endregion
112

    
113
                #region 붙여넣기(Ctrl + V)
114
                case Key.V:
115
                    {
116
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
117
                        {
118
                            PasteCommand.Instance.Execute();
119
                        }
120
                    }
121
                    break;
122
                #endregion
123

    
124
                #region 저장하기(Ctrl + S)
125
                case Key.S:
126
                    {
127
                        if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
128
                        {
129
                            var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
130
                            if (text_item_ != null)
131
                            {
132
                                (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
133
                                (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
134
                                (text_item_ as TextControl).UnEditingMode();
135

    
136
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
137
                            }
138

    
139
                            var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
140
                            if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
141
                            {
142
                                (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
143
                                (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
144
                                (Arrowtext_item_ as ArrowTextControl).UnEditingMode();
145

    
146
                                SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
147
                            }
148

    
149
                            if (text_item_ == null && Arrowtext_item_ == null)
150
                            {                                 //컨트롤을 그리는 도중일 경우 컨트롤 삭제
151
                                ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
152
                            }
153

    
154
                            this.dzMainMenu.currentControl = null;
155

    
156
                            //this.dzTopMenu.SaveEvent(null, null);
157
                            if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)
158
                            {
159
                                ViewerDataModel.Instance.IsMarkupUpdate = true;
160
                                this.dzTopMenu.SaveEventCallback(new object(), null);
161
                            }
162

    
163
                            //저장완료후 임시파일 삭제
164
                            //TempFile.Remove();
165
                        }
166
                    }
167
                    break;
168
                #endregion
169

    
170
                #region 프린트하기(Ctrl + P)
171
                case Key.P:
172
                    {
173
                        if (ViewerDataModel.Instance.IsPressCtrl)
174
                        {
175
                            this.dzTopMenu.Print_Start("Print");
176
                        }
177
                    }
178
                    break;
179
                #endregion
180

    
181
                #region Undo(Ctrl + Z)
182
                case Key.Z:
183
                    {
184
                        if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute();
185
                    }
186
                    break;
187
                #endregion
188

    
189
                #region Redo(Ctrl + Y)
190
                case Key.Y:
191
                    {
192
                        if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute();
193
                    }
194
                    break;
195
                #endregion
196

    
197
                #region 삭제하기(Delete)
198
                case Key.Delete:
199
                    {
200
                        List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems;
201
                        SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
202
                        this.dzMainMenu.SelectLayer.Children.Clear();
203

    
204
                        DeleteCommand.Instance.Execute(selectItems);
205
                    }
206
                    break;
207
                #endregion
208

    
209
                #region 선택된 컨트롤 모두 해제 하기(ESC)
210
                case Key.Escape:
211
                    {
212
                        //캡쳐모드 일 경우 초기화
213
                        if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture)
214
                        {
215
                            //dzMainMenu.PN_Navi.IsEnabled = true;
216
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
217
                            ViewerDataModel.Instance.Capture_Opacity = 0;
218
                        }
219

    
220
                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
221
                                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
222
                        {
223
                            this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
224
                            this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed;
225
                            this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
226
                            var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>();
227
                            foreach (var tog in TogList)
228
                            {
229
                                tog.IsChecked = false;
230
                            }
231
                        }
232

    
233
                        SelectionSet.Instance.UnSelect(this.dzMainMenu);
234

    
235
                        //코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화
236
                        if (this.dzMainMenu.currentControl != null)
237
                        {
238
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl);
239
                            this.dzMainMenu.currentControl = null;
240
                        }
241

    
242
                        //모든 컨트롤 초기화 하고 Selection모드로 변경
243
                        dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting;
244
                        dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None;
245

    
246
                        var toggleList = this.ChildrenOfType<RadToggleButton>();
247
                        var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>();
248

    
249
                        foreach (var item in toggleList)
250
                        {
251
                            if (item.Name == "btnSelection")
252
                            {
253
                                item.IsChecked = true;
254
                            }
255
                            else
256
                            {
257
                                item.IsChecked = false;
258
                            }
259
                        }
260
                        dzMainMenu.isLeftMouseButtonDownOnWindow = false;
261
                            //foreach (var item in toggleList2)
262
                            //{
263
                            //    item.IsChecked = false;
264
                            //}
265
                            ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
266
                    }
267
                    break;
268
                #endregion
269

    
270
                #region FIND(Ctrl + F)
271
                case Key.F:
272
                    {
273
                        if (ViewerDataModel.Instance.IsPressCtrl)
274
                        {
275
                            if (!this.dzMainMenu.searchPane.IsPinned)
276
                            {
277
                                this.dzMainMenu.searchPane.IsPinned = true;
278
                                if (ViewerDataModel.Instance.searchPDF != null)
279
                                {
280
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
281
                                    {
282
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
283
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
284
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
285
                                    }), System.Windows.Threading.DispatcherPriority.Render);
286
                                }
287
                                else
288
                                {
289
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
290
                                }
291
                            }
292
                            else
293
                            {
294
                                this.dzMainMenu.searchPane.IsPinned = false;
295
                                this.dzMainMenu.searchPane.IsActive = false;
296
                                //this.dzMainMenu.searchPane.IsHidden = true;
297
                            }
298
                        }
299
                    }
300
                    break;
301
                #endregion
302

    
303
                #endregion
304

    
305
                //강인구 추가
306
                #region Control Move
307
                //case Key.NumPad4:
308
                //case Key.NumPad5:
309
                //case Key.NumPad6:
310
                //case Key.NumPad8:
311
                case Key.Right:
312
                case Key.Left:
313
                case Key.Up:
314
                case Key.Down:
315
                    {
316
						if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox)
317
						{
318
							return;
319
						}
320
						
321
                        if(sender is UIElement)
322
                        {
323
                            (sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false);
324
                        }
325

    
326
                        Point? MovePoint = null;
327
                        if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
328
                        {
329
                            MovePoint = new Point(0, 5);
330
                        }
331
                        else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
332
                        {
333
                            MovePoint = new Point(0, -5);
334
                        }
335
                        else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
336
                        {
337
                            MovePoint = new Point(-5, 0);
338
                        }
339
                        else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
340
                        {
341
                            MovePoint = new Point(5, 0);
342
                        }
343

    
344
                        if (MovePoint != null && MovePoint.HasValue)
345
                        {
346
                            if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
347
                            {
348

    
349
                                this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
350
                            }
351
                            else
352
                            {
353
                                //if (ViewerDataModel.Instance.IsPressCtrl)
354
                                //{
355
                                    bool IsMovePossibility = false;
356

    
357
                                    var instance = ViewerDataModel.Instance;
358

    
359
                                    if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
360
                                    {
361
                                        if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
362
                                        {
363
                                            IsMovePossibility = true;
364
                                        }
365
                                    }
366
                                    else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
367
                                    {
368
                                        if (0 < instance.ContentOffsetY)
369
                                        {
370
                                            IsMovePossibility = true;
371
                                        }
372
                                    }
373
                                    else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
374
                                    {
375
                                        if (0 < instance.ContentOffsetX)
376
                                        {
377
                                            IsMovePossibility = true;
378
                                        }
379
                                    }
380
                                    else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
381
                                    {
382
                                        if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth)
383
                                        {
384
                                            IsMovePossibility = true;
385
                                        }
386
                                    }
387

    
388
                                    if (IsMovePossibility)
389
                                    {
390
                                        Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
391

    
392
                                        this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
393

    
394
                                        this.dzMainMenu.MainDocumentPanel.Focus();
395

    
396
                                        System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
397
                                    }
398
                                //}
399
                            }
400
                        }
401
                    }
402
                    break;
403
                #endregion
404
                case Key.PageUp:
405
                    
406
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
407
                    break;
408
                case Key.PageDown:
409
                    this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
410
                    break;
411
            }
412
            });
413
        }
414

    
415

    
416
        /// <summary>
417
        /// translate or rotate items by given pt and angle
418
        /// </summary>
419
        /// <author>humkyung</author>
420
        /// <date>2019.07.03</date>
421
        /// <param name="pt">control point</param>
422
        /// <param name="dAngle">angle in degree</param>
423
        private void TranslateOrRotateItems(Point pt, double dAngle)
424
        {
425
            Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
426
            foreach (var item in this.dzMainMenu.SelectLayer.Children)
427
            {
428
                if (item.GetType().Name == "AdornerFinal")
429
                {
430
                    if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
431
                    {
432
                        (item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
433
                    }
434
                    else
435
                    {
436
                        (item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
437
                    }
438

    
439
                }
440
            }
441
        }
442
    }
443
}
클립보드 이미지 추가 (최대 크기: 500 MB)