프로젝트

일반

사용자정보

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

markus / KCOM / Events / Event_KeyEvent.cs @ 6b6e937c

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
209
                #region FIND(Ctrl + F)
210
                case Key.F:
211
                    {
212
                        if (ViewerDataModel.Instance.IsPressCtrl)
213
                        {
214
                            if (!this.dzMainMenu.searchPane.IsPinned)
215
                            {
216
                                this.dzMainMenu.searchPane.IsPinned = true;
217
                                if (ViewerDataModel.Instance.searchPDF != null)
218
                                {
219
                                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
220
                                    {
221
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true;
222
                                        this.dzMainMenu.searchPanel_Instance.tbSearch.Focus();
223
                                        Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch);
224
                                    }), System.Windows.Threading.DispatcherPriority.Render);
225
                                }
226
                                else
227
                                {
228
                                    this.dzMainMenu.searchPanel_Instance.btnSearch.Focus();
229
                                }
230
                            }
231
                            else
232
                            {
233
                                this.dzMainMenu.searchPane.IsPinned = false;
234
                                this.dzMainMenu.searchPane.IsActive = false;
235
                                //this.dzMainMenu.searchPane.IsHidden = true;
236
                            }
237
                        }
238
                    }
239
                    break;
240
                #endregion
241

    
242
                #endregion
243

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

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

    
312
                }
313
            }
314
        }
315
    }
316
}
클립보드 이미지 추가 (최대 크기: 500 MB)