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 && !ViewerDataModel.Instance.IsPressCtrl && !ViewerDataModel.Instance.IsPressShift)
|
29
|
return;
|
30
|
|
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
|
Point? MovePoint = null;
|
257
|
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
|
258
|
{
|
259
|
MovePoint = new Point(0, 5);
|
260
|
}
|
261
|
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
|
262
|
{
|
263
|
MovePoint = new Point(0, -5);
|
264
|
}
|
265
|
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
|
266
|
{
|
267
|
MovePoint = new Point(-5, 0);
|
268
|
}
|
269
|
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
|
270
|
{
|
271
|
MovePoint = new Point(5, 0);
|
272
|
}
|
273
|
|
274
|
if (MovePoint != null && MovePoint.HasValue)
|
275
|
{
|
276
|
if (this.dzMainMenu.SelectLayer.Children.Count > 0 && ViewerDataModel.Instance.IsPressShift)
|
277
|
{
|
278
|
|
279
|
this.TranslateOrRotateItems(MovePoint.Value, this.dzMainMenu.rotate.Angle);
|
280
|
}
|
281
|
else
|
282
|
{
|
283
|
if (ViewerDataModel.Instance.IsPressCtrl)
|
284
|
{
|
285
|
bool IsMovePossibility = false;
|
286
|
|
287
|
var instance = ViewerDataModel.Instance;
|
288
|
|
289
|
if ((e.Key == Key.NumPad5) || (e.Key == Key.Down))
|
290
|
{
|
291
|
if (instance.ContentHeight > instance.ContentOffsetY)
|
292
|
{
|
293
|
IsMovePossibility = true;
|
294
|
}
|
295
|
}
|
296
|
else if ((e.Key == Key.NumPad8) || (e.Key == Key.Up))
|
297
|
{
|
298
|
if (0 < instance.ContentOffsetY)
|
299
|
{
|
300
|
IsMovePossibility = true;
|
301
|
}
|
302
|
}
|
303
|
else if ((e.Key == Key.NumPad4) || (e.Key == Key.Left))
|
304
|
{
|
305
|
if (0 < instance.ContentOffsetX)
|
306
|
{
|
307
|
IsMovePossibility = true;
|
308
|
}
|
309
|
}
|
310
|
else if ((e.Key == Key.NumPad6) || (e.Key == Key.Right))
|
311
|
{
|
312
|
if (instance.ContentWidth > instance.ContentOffsetX)
|
313
|
{
|
314
|
IsMovePossibility = true;
|
315
|
}
|
316
|
}
|
317
|
|
318
|
if (IsMovePossibility)
|
319
|
{
|
320
|
Vector dragOffset = new Vector(MovePoint.Value.X * -10, MovePoint.Value.Y * -10);
|
321
|
|
322
|
this.dzMainMenu.MoveZoomAndPanControl(dragOffset);
|
323
|
|
324
|
this.dzMainMenu.MainDocumentPanel.Focus();
|
325
|
|
326
|
System.Diagnostics.Debug.WriteLine(this.dzMainMenu.zoomAndPanControl.ContentOffsetX);
|
327
|
}
|
328
|
}
|
329
|
}
|
330
|
}
|
331
|
}
|
332
|
break;
|
333
|
#endregion
|
334
|
case Key.PageUp:
|
335
|
|
336
|
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) - 1);
|
337
|
break;
|
338
|
case Key.PageDown:
|
339
|
this.dzMainMenu.pageNavigator.GotoPage(Convert.ToInt32(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + 1);
|
340
|
break;
|
341
|
}
|
342
|
}
|
343
|
|
344
|
|
345
|
/// <summary>
|
346
|
/// translate or rotate items by given pt and angle
|
347
|
/// </summary>
|
348
|
/// <author>humkyung</author>
|
349
|
/// <date>2019.07.03</date>
|
350
|
/// <param name="pt">control point</param>
|
351
|
/// <param name="dAngle">angle in degree</param>
|
352
|
private void TranslateOrRotateItems(Point pt, double dAngle)
|
353
|
{
|
354
|
Point control = MarkupToPDF.Controls.Common.MathSet.RotateAbout(new Point(0, 0), pt, dAngle);
|
355
|
foreach (var item in this.dzMainMenu.SelectLayer.Children)
|
356
|
{
|
357
|
if (item.GetType().Name == "AdornerFinal")
|
358
|
{
|
359
|
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
|
360
|
{
|
361
|
(item as Controls.AdornerFinal).MoveRotate(new System.Windows.Controls.Primitives.DragDeltaEventArgs(control.X * 2, control.Y * 2));
|
362
|
}
|
363
|
else
|
364
|
{
|
365
|
(item as Controls.AdornerFinal).TranslateItems(control.X, control.Y);
|
366
|
}
|
367
|
|
368
|
}
|
369
|
}
|
370
|
}
|
371
|
}
|
372
|
}
|