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