markus / KCOM / Events / Event_KeyEvent.cs @ d04e8ee9
이력 | 보기 | 이력해설 | 다운로드 (16.3 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 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 |
#region 전체 선택(Ctrl + A) |
37 |
case Key.A: |
38 |
{ |
39 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
40 |
{ |
41 |
this.dzMainMenu.ConvertInkControlToPolygon(); |
42 |
|
43 |
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0) |
44 |
{ |
45 |
/// 전체 선택 시 선택된 토글 해제 |
46 |
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 |
/// 컨트롤을 그리는 도중일 경우 컨트롤 삭제 |
51 |
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 |
|
59 |
SelectionSet.Instance.SelectAll(); |
60 |
} |
61 |
} |
62 |
} |
63 |
break; |
64 |
#endregion |
65 |
|
66 |
#region 복사하기(Ctrl + C) |
67 |
case Key.C: |
68 |
{ |
69 |
if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute(); |
70 |
} |
71 |
break; |
72 |
#endregion |
73 |
|
74 |
#region 잘라내기(Ctrl + X) |
75 |
case Key.X: |
76 |
{ |
77 |
if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute(); |
78 |
} |
79 |
break; |
80 |
#endregion |
81 |
|
82 |
#region 붙여넣기(Ctrl + V) |
83 |
case Key.V: |
84 |
{ |
85 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
86 |
{ |
87 |
PasteCommand.Instance.Execute(); |
88 |
} |
89 |
} |
90 |
break; |
91 |
#endregion |
92 |
|
93 |
#region 저장하기(Ctrl + S) |
94 |
case Key.S: |
95 |
{ |
96 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
97 |
{ |
98 |
//컨트롤을 그리는 도중일 경우 컨트롤 삭제 |
99 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
100 |
this.dzMainMenu.currentControl = null; |
101 |
|
102 |
//this.dzTopMenu.SaveEvent(null, null); |
103 |
if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission) |
104 |
{ |
105 |
this.dzTopMenu.SaveEventCallback(new object(), null); |
106 |
} |
107 |
|
108 |
//저장완료후 임시파일 삭제 |
109 |
TempFile.Remove(); |
110 |
} |
111 |
} |
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 |
if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute(); |
130 |
} |
131 |
break; |
132 |
#endregion |
133 |
|
134 |
#region Redo(Ctrl + Y) |
135 |
case Key.Y: |
136 |
{ |
137 |
if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute(); |
138 |
} |
139 |
break; |
140 |
#endregion |
141 |
|
142 |
#region 삭제하기(Delete) |
143 |
case Key.Delete: |
144 |
{ |
145 |
DeleteCommand.Instance.Execute(SelectionSet.Instance.SelectedItems); |
146 |
this.dzMainMenu.SelectLayer.Children.Clear(); |
147 |
} |
148 |
break; |
149 |
#endregion |
150 |
|
151 |
#region 선택된 컨트롤 모두 해제 하기(ESC) |
152 |
case Key.Escape: |
153 |
{ |
154 |
//캡쳐모드 일 경우 초기화 |
155 |
if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture) |
156 |
{ |
157 |
//dzMainMenu.PN_Navi.IsEnabled = true; |
158 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
159 |
ViewerDataModel.Instance.Capture_Opacity = 0; |
160 |
} |
161 |
|
162 |
if (Common.ViewerDataModel.Instance.SelectedControl == "Batch") |
163 |
{ |
164 |
this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
165 |
this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed; |
166 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
167 |
var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>(); |
168 |
foreach (var tog in TogList) |
169 |
{ |
170 |
tog.IsChecked = false; |
171 |
} |
172 |
} |
173 |
|
174 |
SelectionSet.Instance.UnSelect(this.dzMainMenu); |
175 |
|
176 |
//코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화 |
177 |
if (this.dzMainMenu.currentControl != null) |
178 |
{ |
179 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
180 |
this.dzMainMenu.currentControl = null; |
181 |
} |
182 |
|
183 |
//모든 컨트롤 초기화 하고 Selection모드로 변경 |
184 |
dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting; |
185 |
dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
186 |
|
187 |
var toggleList = this.ChildrenOfType<RadToggleButton>(); |
188 |
var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>(); |
189 |
|
190 |
foreach (var item in toggleList) |
191 |
{ |
192 |
if (item.Name == "btnSelection") |
193 |
{ |
194 |
item.IsChecked = true; |
195 |
} |
196 |
else |
197 |
{ |
198 |
item.IsChecked = false; |
199 |
} |
200 |
} |
201 |
dzMainMenu.isLeftMouseButtonDownOnWindow = false; |
202 |
//foreach (var item in toggleList2) |
203 |
//{ |
204 |
// item.IsChecked = false; |
205 |
//} |
206 |
} |
207 |
break; |
208 |
#endregion |
209 |
|
210 |
#region FIND(Ctrl + F) |
211 |
case Key.F: |
212 |
{ |
213 |
if (ViewerDataModel.Instance.IsPressCtrl) |
214 |
{ |
215 |
if (!this.dzMainMenu.searchPane.IsPinned) |
216 |
{ |
217 |
this.dzMainMenu.searchPane.IsPinned = true; |
218 |
if (ViewerDataModel.Instance.searchPDF != null) |
219 |
{ |
220 |
Application.Current.Dispatcher.BeginInvoke(new Action(() => |
221 |
{ |
222 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true; |
223 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focus(); |
224 |
Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch); |
225 |
}), System.Windows.Threading.DispatcherPriority.Render); |
226 |
} |
227 |
else |
228 |
{ |
229 |
this.dzMainMenu.searchPanel_Instance.btnSearch.Focus(); |
230 |
} |
231 |
} |
232 |
else |
233 |
{ |
234 |
this.dzMainMenu.searchPane.IsPinned = false; |
235 |
this.dzMainMenu.searchPane.IsActive = false; |
236 |
//this.dzMainMenu.searchPane.IsHidden = true; |
237 |
} |
238 |
} |
239 |
} |
240 |
break; |
241 |
#endregion |
242 |
|
243 |
#endregion |
244 |
|
245 |
//강인구 추가 |
246 |
#region Control Move |
247 |
case Key.NumPad4: |
248 |
case Key.NumPad5: |
249 |
case Key.NumPad6: |
250 |
case Key.NumPad8: |
251 |
case Key.Right: |
252 |
case Key.Left: |
253 |
case Key.Up: |
254 |
case Key.Down: |
255 |
{ |
256 |
if(sender is UIElement) |
257 |
{ |
258 |
(sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false); |
259 |
} |
260 |
|
261 |
Point? MovePoint = null; |
262 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
263 |
{ |
264 |
MovePoint = new Point(0, 5); |
265 |
} |
266 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
267 |
{ |
268 |
MovePoint = new Point(0, -5); |
269 |
} |
270 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
271 |
{ |
272 |
MovePoint = new Point(-5, 0); |
273 |
} |
274 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
275 |
{ |
276 |
MovePoint = new Point(5, 0); |
277 |
} |
278 |
|
279 |
if (MovePoint != null && MovePoint.HasValue) |
280 |
{ |
281 |
if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift) |
282 |
{ |
283 |
|
284 |
this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle); |
285 |
} |
286 |
else |
287 |
{ |
288 |
//if (ViewerDataModel.Instance.IsPressCtrl) |
289 |
//{ |
290 |
bool IsMovePossibility = false; |
291 |
|
292 |
var instance = ViewerDataModel.Instance; |
293 |
|
294 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
295 |
{ |
296 |
if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight) |
297 |
{ |
298 |
IsMovePossibility = true; |
299 |
} |
300 |
} |
301 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
302 |
{ |
303 |
if (0 < instance.ContentOffsetY) |
304 |
{ |
305 |
IsMovePossibility = true; |
306 |
} |
307 |
} |
308 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
309 |
{ |
310 |
if (0 < instance.ContentOffsetX) |
311 |
{ |
312 |
IsMovePossibility = true; |
313 |
} |
314 |
} |
315 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
316 |
{ |
317 |
if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth) |
318 |
{ |
319 |
IsMovePossibility = true; |
320 |
} |
321 |
} |
322 |
|
323 |
if (IsMovePossibility) |
324 |
{ |
325 |
Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10); |
326 |
|
327 |
this.dzMainMenu.MoveZoomAndPanControl(dragOffset); |
328 |
|
329 |
this.dzMainMenu.MainDocumentPanel.Focus(); |
330 |
|
331 |
System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX); |
332 |
} |
333 |
//} |
334 |
} |
335 |
} |
336 |
} |
337 |
break; |
338 |
#endregion |
339 |
case Key.PageUp: |
340 |
|
341 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1); |
342 |
break; |
343 |
case Key.PageDown: |
344 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1); |
345 |
break; |
346 |
} |
347 |
}); |
348 |
} |
349 |
|
350 |
|
351 |
/// <summary> |
352 |
/// translate or rotate items by given pt and angle |
353 |
/// </summary> |
354 |
/// <author>humkyung</author> |
355 |
/// <date>2019.07.03</date> |
356 |
/// <param name="pt">control point</param> |
357 |
/// <param name="dAngle">angle in degree</param> |
358 |
private void TranslateOrRotateItems(Point pt, double dAngle) |
359 |
{ |
360 |
Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle); |
361 |
foreach (var item in this.dzMainMenu.SelectLayer.Children) |
362 |
{ |
363 |
if (item.GetType().Name == "AdornerFinal") |
364 |
{ |
365 |
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) |
366 |
{ |
367 |
(item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2)); |
368 |
} |
369 |
else |
370 |
{ |
371 |
(item as Controls.AdornerFinal).TranslateItems(control.X, control.Y); |
372 |
} |
373 |
|
374 |
} |
375 |
} |
376 |
} |
377 |
} |
378 |
} |