markus / KCOM / Events / Event_KeyEvent.cs @ 3abe8d4e
이력 | 보기 | 이력해설 | 다운로드 (18.4 KB)
1 |
using KCOM.Common; |
---|---|
2 |
using KCOM.Events; |
3 |
using MarkupToPDF.Common; |
4 |
using MarkupToPDF.Controls.Parsing; |
5 |
using System; |
6 |
using System.Collections.Generic; |
7 |
using System.ComponentModel; |
8 |
using System.Linq; |
9 |
using System.Text; |
10 |
using System.Windows; |
11 |
using System.Windows.Controls; |
12 |
using System.Windows.Input; |
13 |
using System.Windows.Media; |
14 |
using System.Windows.Media.Imaging; |
15 |
using Telerik.Windows.Controls; |
16 |
//using static KCOM.Views.MainMenu; |
17 |
|
18 |
namespace KCOM |
19 |
{ |
20 |
public partial class MainWindow : KCOM.Controls.CustomizedWindow.CustomWindow |
21 |
{ |
22 |
public double CumulativeWheel = 0; |
23 |
MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn(); |
24 |
|
25 |
public async void KeyEventDownAction(object sender, KeyEventArgs e) |
26 |
{ |
27 |
//if (e.IsRepeat && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift) |
28 |
// return; |
29 |
await this.Dispatcher.InvokeAsync(() => { |
30 |
switch (e.Key) |
31 |
{ |
32 |
//강인구 추가 |
33 |
#region 단축키 선택 |
34 |
|
35 |
case Key.I: |
36 |
{ |
37 |
if (ViewerDataModel.Instance.IsPressCtrl && ViewerDataModel.Instance.IsPressShift) |
38 |
{ |
39 |
if (!ViewerDataModel.Instance.IsAdmin) |
40 |
{ |
41 |
EventHandler<WindowClosedEventArgs> closeEventHandler = (snd, evt) => |
42 |
{ |
43 |
if (evt.PromptResult == "markus01#") |
44 |
{ |
45 |
ViewerDataModel.Instance.IsAdmin = true; |
46 |
} |
47 |
}; |
48 |
|
49 |
var parameters = new DialogParameters() |
50 |
{ |
51 |
ContentStyle = (Style)this.FindResource("RadPasswordPromptStyle"), |
52 |
Content = "Enter password: ", |
53 |
Closed = closeEventHandler |
54 |
}; |
55 |
|
56 |
RadWindow.Prompt(parameters); |
57 |
} |
58 |
else |
59 |
{ |
60 |
ViewerDataModel.Instance.IsAdmin = false; |
61 |
} |
62 |
} |
63 |
} |
64 |
break; |
65 |
|
66 |
#region 전체 선택(Ctrl + A) |
67 |
case Key.A: |
68 |
{ |
69 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
70 |
{ |
71 |
this.dzMainMenu.ConvertInkControlToPolygon(); |
72 |
|
73 |
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0) |
74 |
{ |
75 |
/// 전체 선택 시 선택된 토글 해제 |
76 |
var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>(); |
77 |
this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
78 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
79 |
|
80 |
/// 컨트롤을 그리는 도중일 경우 컨트롤 삭제 |
81 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
82 |
this.dzMainMenu.currentControl = null; |
83 |
|
84 |
foreach (var tog in TogList) |
85 |
{ |
86 |
tog.IsChecked = false; |
87 |
} |
88 |
|
89 |
SelectionSet.Instance.SelectAll(); |
90 |
} |
91 |
} |
92 |
} |
93 |
break; |
94 |
#endregion |
95 |
|
96 |
#region 복사하기(Ctrl + C) |
97 |
case Key.C: |
98 |
{ |
99 |
if (ViewerDataModel.Instance.IsPressCtrl) CopyCommand.Instance.Execute(); |
100 |
} |
101 |
break; |
102 |
#endregion |
103 |
|
104 |
#region 잘라내기(Ctrl + X) |
105 |
case Key.X: |
106 |
{ |
107 |
if (ViewerDataModel.Instance.IsPressCtrl) CutCommand.Instance.Execute(); |
108 |
} |
109 |
break; |
110 |
#endregion |
111 |
|
112 |
#region 붙여넣기(Ctrl + V) |
113 |
case Key.V: |
114 |
{ |
115 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
116 |
{ |
117 |
PasteCommand.Instance.Execute(); |
118 |
} |
119 |
} |
120 |
break; |
121 |
#endregion |
122 |
|
123 |
#region 저장하기(Ctrl + S) |
124 |
case Key.S: |
125 |
{ |
126 |
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission)) |
127 |
{ |
128 |
//컨트롤을 그리는 도중일 경우 컨트롤 삭제 |
129 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
130 |
this.dzMainMenu.currentControl = null; |
131 |
|
132 |
//this.dzTopMenu.SaveEvent(null, null); |
133 |
if (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission) |
134 |
{ |
135 |
ViewerDataModel.Instance.IsMarkupUpdate = true; |
136 |
this.dzTopMenu.SaveEventCallback(new object(), null); |
137 |
} |
138 |
|
139 |
//저장완료후 임시파일 삭제 |
140 |
//TempFile.Remove(); |
141 |
} |
142 |
} |
143 |
break; |
144 |
#endregion |
145 |
|
146 |
#region 프린트하기(Ctrl + P) |
147 |
case Key.P: |
148 |
{ |
149 |
if (ViewerDataModel.Instance.IsPressCtrl) |
150 |
{ |
151 |
this.dzTopMenu.Print_Start("Print"); |
152 |
} |
153 |
} |
154 |
break; |
155 |
#endregion |
156 |
|
157 |
#region Undo(Ctrl + Z) |
158 |
case Key.Z: |
159 |
{ |
160 |
if (ViewerDataModel.Instance.IsPressCtrl) UndoCommand.Instance.Execute(); |
161 |
} |
162 |
break; |
163 |
#endregion |
164 |
|
165 |
#region Redo(Ctrl + Y) |
166 |
case Key.Y: |
167 |
{ |
168 |
if (ViewerDataModel.Instance.IsPressCtrl) RedoCommand.Instance.Execute(); |
169 |
} |
170 |
break; |
171 |
#endregion |
172 |
|
173 |
#region 삭제하기(Delete) |
174 |
case Key.Delete: |
175 |
{ |
176 |
List<CommentUserInfo> selectItems = SelectionSet.Instance.SelectedItems; |
177 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
178 |
this.dzMainMenu.SelectLayer.Children.Clear(); |
179 |
|
180 |
DeleteCommand.Instance.Execute(selectItems); |
181 |
} |
182 |
break; |
183 |
#endregion |
184 |
|
185 |
#region 선택된 컨트롤 모두 해제 하기(ESC) |
186 |
case Key.Escape: |
187 |
{ |
188 |
//캡쳐모드 일 경우 초기화 |
189 |
if (this.dzMainMenu.mouseHandlingMode == IKCOM.MouseHandlingMode.Capture) |
190 |
{ |
191 |
//dzMainMenu.PN_Navi.IsEnabled = true; |
192 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
193 |
ViewerDataModel.Instance.Capture_Opacity = 0; |
194 |
} |
195 |
|
196 |
if (Common.ViewerDataModel.Instance.SelectedControl == "Batch" |
197 |
|| Common.ViewerDataModel.Instance.SelectedControl == "MACRO") |
198 |
{ |
199 |
this.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
200 |
this.dzMainMenu.txtBatch.Visibility = Visibility.Collapsed; |
201 |
this.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
202 |
var TogList = this.dzTopMenu.Parent.ChildrenOfType<RadToggleButton>(); |
203 |
foreach (var tog in TogList) |
204 |
{ |
205 |
tog.IsChecked = false; |
206 |
} |
207 |
} |
208 |
|
209 |
SelectionSet.Instance.UnSelect(this.dzMainMenu); |
210 |
|
211 |
//코멘트 그리는 도중일 경우 코멘트 삭제 및 초기화 |
212 |
if (this.dzMainMenu.currentControl != null) |
213 |
{ |
214 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(this.dzMainMenu.currentControl); |
215 |
this.dzMainMenu.currentControl = null; |
216 |
} |
217 |
|
218 |
//모든 컨트롤 초기화 하고 Selection모드로 변경 |
219 |
dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Selecting; |
220 |
dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.None; |
221 |
|
222 |
var toggleList = this.ChildrenOfType<RadToggleButton>(); |
223 |
var toggleList2 = this.ChildrenOfType<RadRibbonToggleButton>(); |
224 |
|
225 |
foreach (var item in toggleList) |
226 |
{ |
227 |
if (item.Name == "btnSelection") |
228 |
{ |
229 |
item.IsChecked = true; |
230 |
} |
231 |
else |
232 |
{ |
233 |
item.IsChecked = false; |
234 |
} |
235 |
} |
236 |
dzMainMenu.isLeftMouseButtonDownOnWindow = false; |
237 |
//foreach (var item in toggleList2) |
238 |
//{ |
239 |
// item.IsChecked = false; |
240 |
//} |
241 |
ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed); |
242 |
} |
243 |
break; |
244 |
#endregion |
245 |
|
246 |
#region FIND(Ctrl + F) |
247 |
case Key.F: |
248 |
{ |
249 |
if (ViewerDataModel.Instance.IsPressCtrl) |
250 |
{ |
251 |
if (!this.dzMainMenu.searchPane.IsPinned) |
252 |
{ |
253 |
this.dzMainMenu.searchPane.IsPinned = true; |
254 |
if (ViewerDataModel.Instance.searchPDF != null) |
255 |
{ |
256 |
Application.Current.Dispatcher.BeginInvoke(new Action(() => |
257 |
{ |
258 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focusable = true; |
259 |
this.dzMainMenu.searchPanel_Instance.tbSearch.Focus(); |
260 |
Keyboard.Focus(this.dzMainMenu.searchPanel_Instance.tbSearch); |
261 |
}), System.Windows.Threading.DispatcherPriority.Render); |
262 |
} |
263 |
else |
264 |
{ |
265 |
this.dzMainMenu.searchPanel_Instance.btnSearch.Focus(); |
266 |
} |
267 |
} |
268 |
else |
269 |
{ |
270 |
this.dzMainMenu.searchPane.IsPinned = false; |
271 |
this.dzMainMenu.searchPane.IsActive = false; |
272 |
//this.dzMainMenu.searchPane.IsHidden = true; |
273 |
} |
274 |
} |
275 |
} |
276 |
break; |
277 |
#endregion |
278 |
|
279 |
#endregion |
280 |
|
281 |
//강인구 추가 |
282 |
#region Control Move |
283 |
//case Key.NumPad4: |
284 |
//case Key.NumPad5: |
285 |
//case Key.NumPad6: |
286 |
//case Key.NumPad8: |
287 |
case Key.Right: |
288 |
case Key.Left: |
289 |
case Key.Up: |
290 |
case Key.Down: |
291 |
{ |
292 |
if(System.Windows.Input.Keyboard.FocusedElement is System.Windows.Controls.TextBox) |
293 |
{ |
294 |
return; |
295 |
} |
296 |
|
297 |
if(sender is UIElement) |
298 |
{ |
299 |
(sender as UIElement).SetValue(TabNavigationExtensions.IsTabStopProperty, false); |
300 |
} |
301 |
|
302 |
Point? MovePoint = null; |
303 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
304 |
{ |
305 |
MovePoint = new Point(0, 5); |
306 |
} |
307 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
308 |
{ |
309 |
MovePoint = new Point(0, -5); |
310 |
} |
311 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
312 |
{ |
313 |
MovePoint = new Point(-5, 0); |
314 |
} |
315 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
316 |
{ |
317 |
MovePoint = new Point(5, 0); |
318 |
} |
319 |
|
320 |
if (MovePoint != null && MovePoint.HasValue) |
321 |
{ |
322 |
if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift) |
323 |
{ |
324 |
|
325 |
this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle); |
326 |
} |
327 |
else |
328 |
{ |
329 |
//if (ViewerDataModel.Instance.IsPressCtrl) |
330 |
//{ |
331 |
bool IsMovePossibility = false; |
332 |
|
333 |
var instance = ViewerDataModel.Instance; |
334 |
|
335 |
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down)) |
336 |
{ |
337 |
if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight) |
338 |
{ |
339 |
IsMovePossibility = true; |
340 |
} |
341 |
} |
342 |
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up)) |
343 |
{ |
344 |
if (0 < instance.ContentOffsetY) |
345 |
{ |
346 |
IsMovePossibility = true; |
347 |
} |
348 |
} |
349 |
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left)) |
350 |
{ |
351 |
if (0 < instance.ContentOffsetX) |
352 |
{ |
353 |
IsMovePossibility = true; |
354 |
} |
355 |
} |
356 |
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right)) |
357 |
{ |
358 |
if (instance.ContentWidth > instance.ContentOffsetX + instance.ContentViewportWidth) |
359 |
{ |
360 |
IsMovePossibility = true; |
361 |
} |
362 |
} |
363 |
|
364 |
if (IsMovePossibility) |
365 |
{ |
366 |
Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10); |
367 |
|
368 |
this.dzMainMenu.MoveZoomAndPanControl(dragOffset); |
369 |
|
370 |
this.dzMainMenu.MainDocumentPanel.Focus(); |
371 |
|
372 |
System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX); |
373 |
} |
374 |
//} |
375 |
} |
376 |
} |
377 |
} |
378 |
break; |
379 |
#endregion |
380 |
case Key.PageUp: |
381 |
|
382 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1); |
383 |
break; |
384 |
case Key.PageDown: |
385 |
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1); |
386 |
break; |
387 |
} |
388 |
}); |
389 |
} |
390 |
|
391 |
|
392 |
/// <summary> |
393 |
/// translate or rotate items by given pt and angle |
394 |
/// </summary> |
395 |
/// <author>humkyung</author> |
396 |
/// <date>2019.07.03</date> |
397 |
/// <param name="pt">control point</param> |
398 |
/// <param name="dAngle">angle in degree</param> |
399 |
private void TranslateOrRotateItems(Point pt, double dAngle) |
400 |
{ |
401 |
Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle); |
402 |
foreach (var item in this.dzMainMenu.SelectLayer.Children) |
403 |
{ |
404 |
if (item.GetType().Name == "AdornerFinal") |
405 |
{ |
406 |
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) |
407 |
{ |
408 |
(item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2)); |
409 |
} |
410 |
else |
411 |
{ |
412 |
(item as Controls.AdornerFinal).TranslateItems(control.X, control.Y); |
413 |
} |
414 |
|
415 |
} |
416 |
} |
417 |
} |
418 |
} |
419 |
} |