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