1
|
using KCOM.Common;
|
2
|
using KCOMDataModel;
|
3
|
using KCOMDataModel.DataModel;
|
4
|
using MarkupToPDF.Common;
|
5
|
using MarkupToPDF.Controls.Parsing;
|
6
|
using MarkupToPDF.Serialize.Core;
|
7
|
using MarkupToPDF.Serialize.S_Control;
|
8
|
using System;
|
9
|
using System.Collections.Generic;
|
10
|
using System.IO;
|
11
|
using System.Linq;
|
12
|
using System.Runtime.InteropServices;
|
13
|
using System.Text;
|
14
|
using System.Windows;
|
15
|
using System.Windows.Controls;
|
16
|
using System.Windows.Data;
|
17
|
using System.Windows.Documents;
|
18
|
using System.Windows.Input;
|
19
|
using System.Windows.Media;
|
20
|
using System.Windows.Media.Imaging;
|
21
|
using System.Windows.Navigation;
|
22
|
using System.Windows.Shapes;
|
23
|
using System.Xml;
|
24
|
using Telerik.Windows.Controls;
|
25
|
using WinInterop = System.Windows.Interop;
|
26
|
|
27
|
namespace KCOM
|
28
|
{
|
29
|
/// <summary>
|
30
|
/// MainWindow.xaml에 대한 상호 작용 논리
|
31
|
/// </summary>
|
32
|
public partial class MainWindow : Window
|
33
|
{
|
34
|
public MainWindow()
|
35
|
{
|
36
|
this.Loaded += MainWindow_Loaded;
|
37
|
this.KeyDown += new KeyEventHandler(KeyEventDownAction);
|
38
|
this.KeyUp += new KeyEventHandler(KeyEventUpAction);
|
39
|
this.SourceInitialized += new EventHandler(win_SourceInitialized);
|
40
|
|
41
|
}
|
42
|
|
43
|
public static BitmapImage CursorChange()
|
44
|
{
|
45
|
BitmapImage bmp = new BitmapImage();
|
46
|
bmp.BeginInit();
|
47
|
bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
|
48
|
return bmp;
|
49
|
}
|
50
|
|
51
|
public void DialogMessage_Alert(string content, string header)
|
52
|
{
|
53
|
var box = new TextBlock();
|
54
|
box.MinWidth = 400;
|
55
|
box.FontSize = 12;
|
56
|
box.Text = content;
|
57
|
box.TextWrapping = System.Windows.TextWrapping.Wrap;
|
58
|
|
59
|
Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
|
60
|
{
|
61
|
Owner = Application.Current.MainWindow,
|
62
|
Content = box,
|
63
|
Header = header,
|
64
|
Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
|
65
|
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
|
66
|
};
|
67
|
Telerik.Windows.Controls.RadWindow.Alert(parameters);
|
68
|
}
|
69
|
|
70
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
71
|
{
|
72
|
InitializeComponent();
|
73
|
|
74
|
//cursor change
|
75
|
this.Cursor = new Cursor(CursorChange().StreamSource);
|
76
|
|
77
|
double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
|
78
|
double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
|
79
|
//this.Width += 40;
|
80
|
double windowWidth = this.Width;
|
81
|
double windowHeight = this.Height;
|
82
|
this.Left = (screenWidth / 2) - (windowWidth / 2);
|
83
|
this.Top = (screenHeight / 2) - (windowHeight / 2);
|
84
|
|
85
|
ViewerDataModel.Instance.SystemMain = this;
|
86
|
|
87
|
if (!App.ParameterMode)
|
88
|
{
|
89
|
//App.ViewInfo = new IKCOM.ViewInfo
|
90
|
//{
|
91
|
// DocumentItemID = "11111112",
|
92
|
// //DocumentItemID = "10001",
|
93
|
// bPartner = false,
|
94
|
// CreateFinalPDFPermission = true,
|
95
|
// NewCommentPermission = true,
|
96
|
// ProjectNO = "000000",
|
97
|
// UserID = "H2011357",
|
98
|
// //UserID = "H2009115",
|
99
|
// //Mode = 0 , 1 , 2
|
100
|
//};
|
101
|
//DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
|
102
|
|
103
|
//#if DEBUG
|
104
|
// App.ViewInfo = new IKCOM.ViewInfo
|
105
|
// {
|
106
|
// DocumentItemID = "11111112",
|
107
|
// //DocumentItemID = "10001",
|
108
|
// bPartner = false,
|
109
|
// CreateFinalPDFPermission = true,
|
110
|
// NewCommentPermission = true,
|
111
|
// ProjectNO = "000000",
|
112
|
// UserID = "H2011357",
|
113
|
// //UserID = "H2009115",
|
114
|
// //Mode = 0 , 1 , 2
|
115
|
// };
|
116
|
// App.ParameterMode = true;
|
117
|
// this.dzMainMenu.ServiceOn();
|
118
|
// this.dzMainMenu.SetView(App.ViewInfo);
|
119
|
//#else
|
120
|
|
121
|
DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
|
122
|
this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
|
123
|
this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
|
124
|
this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
|
125
|
this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
|
126
|
this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
|
127
|
//#endif
|
128
|
}
|
129
|
else
|
130
|
{
|
131
|
this.dzMainMenu.ServiceOn();
|
132
|
|
133
|
if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
|
134
|
{
|
135
|
this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
|
136
|
var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
|
137
|
list.ForEach(item => item.Visibility = Visibility.Collapsed);
|
138
|
this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
|
139
|
this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
|
140
|
//this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
|
141
|
//this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
|
142
|
//this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
|
143
|
}
|
144
|
this.dzMainMenu.SetView(App.ViewInfo);
|
145
|
this.dzMainMenu.HubSet();
|
146
|
}
|
147
|
|
148
|
//App.ViewInfo = new IKCOM.ViewInfo
|
149
|
//{
|
150
|
// DocumentItemID = "11111112",
|
151
|
// //DocumentItemID = "10001",
|
152
|
// bPartner = false,
|
153
|
// CreateFinalPDFPermission = true,
|
154
|
// NewCommentPermission = true,
|
155
|
// ProjectNO = "000000",
|
156
|
// UserID = "H2011357",
|
157
|
// //UserID = "H2009115",
|
158
|
// //Mode = 0 , 1 , 2
|
159
|
//};
|
160
|
|
161
|
//this.dzMainMenu.ServiceOn();
|
162
|
//this.dzMainMenu.SetView(App.ViewInfo);
|
163
|
}
|
164
|
|
165
|
|
166
|
bool restoreIfMove = false;
|
167
|
|
168
|
private void WindowDragEvent(object sender, MouseButtonEventArgs e)
|
169
|
{
|
170
|
if (e.ClickCount == 2)
|
171
|
{
|
172
|
if ((ResizeMode == ResizeMode.CanResize) ||
|
173
|
(ResizeMode == ResizeMode.CanResizeWithGrip))
|
174
|
{
|
175
|
SwitchState();
|
176
|
}
|
177
|
}
|
178
|
else
|
179
|
{
|
180
|
if (WindowState == WindowState.Maximized)
|
181
|
{
|
182
|
restoreIfMove = true;
|
183
|
}
|
184
|
|
185
|
this.DragMove();
|
186
|
}
|
187
|
}
|
188
|
|
189
|
private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
|
190
|
{
|
191
|
restoreIfMove = false;
|
192
|
}
|
193
|
|
194
|
private void WindowDragEventMove(object sender, MouseEventArgs e)
|
195
|
{
|
196
|
if (restoreIfMove)
|
197
|
{
|
198
|
if (Mouse.LeftButton == MouseButtonState.Pressed)
|
199
|
{
|
200
|
//this.WindowState = WindowState.Normal;
|
201
|
|
202
|
restoreIfMove = false;
|
203
|
|
204
|
double percentHorizontal = e.GetPosition(this).X / ActualWidth;
|
205
|
double targetHorizontal = RestoreBounds.Width * percentHorizontal;
|
206
|
|
207
|
double percentVertical = e.GetPosition(this).Y / ActualHeight;
|
208
|
double targetVertical = RestoreBounds.Height * percentVertical;
|
209
|
|
210
|
POINT lMousePosition;
|
211
|
GetCursorPos(out lMousePosition);
|
212
|
|
213
|
Left = lMousePosition.X - targetHorizontal;
|
214
|
double top = lMousePosition.Y - targetVertical;
|
215
|
if(top < 10)
|
216
|
{
|
217
|
top = 10;
|
218
|
}
|
219
|
Top = lMousePosition.Y;
|
220
|
|
221
|
|
222
|
WindowState = WindowState.Normal;
|
223
|
|
224
|
this.DragMove();
|
225
|
}
|
226
|
}
|
227
|
}
|
228
|
|
229
|
[DllImport("user32.dll")]
|
230
|
[return: MarshalAs(UnmanagedType.Bool)]
|
231
|
static extern bool GetCursorPos(out POINT lpPoint);
|
232
|
|
233
|
[StructLayout(LayoutKind.Sequential)]
|
234
|
public struct POINT
|
235
|
{
|
236
|
public int X;
|
237
|
public int Y;
|
238
|
|
239
|
public POINT(int x, int y)
|
240
|
{
|
241
|
this.X = x;
|
242
|
this.Y = y;
|
243
|
}
|
244
|
}
|
245
|
|
246
|
private void SwitchState()
|
247
|
{
|
248
|
switch (WindowState)
|
249
|
{
|
250
|
case WindowState.Normal:
|
251
|
{
|
252
|
WindowState = WindowState.Maximized;
|
253
|
break;
|
254
|
}
|
255
|
case WindowState.Maximized:
|
256
|
{
|
257
|
WindowState = WindowState.Normal;
|
258
|
break;
|
259
|
}
|
260
|
}
|
261
|
}
|
262
|
|
263
|
private void RadButton_Click(object sender, RoutedEventArgs e)
|
264
|
{
|
265
|
Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
|
266
|
|
267
|
switch (button.CommandParameter.ToString())
|
268
|
{
|
269
|
case ("Min"):
|
270
|
{
|
271
|
WindowState = WindowState.Minimized;
|
272
|
}
|
273
|
break;
|
274
|
case ("Max"):
|
275
|
{
|
276
|
WindowState = WindowState.Maximized;
|
277
|
}
|
278
|
break;
|
279
|
case ("Exit"):
|
280
|
{
|
281
|
|
282
|
}
|
283
|
break;
|
284
|
}
|
285
|
}
|
286
|
|
287
|
private void WinState(object sender, MouseButtonEventArgs e)
|
288
|
{
|
289
|
switch ((e.Source as Image).Name)
|
290
|
{
|
291
|
case ("Win_min"):
|
292
|
{
|
293
|
WindowState = WindowState.Minimized;
|
294
|
}
|
295
|
break;
|
296
|
case ("Win_max"):
|
297
|
{
|
298
|
if (WindowState == WindowState.Maximized)
|
299
|
{
|
300
|
WindowState = WindowState.Normal;
|
301
|
}
|
302
|
else
|
303
|
{
|
304
|
WindowState = WindowState.Maximized;
|
305
|
}
|
306
|
}
|
307
|
break;
|
308
|
case ("Win_Close"):
|
309
|
{
|
310
|
if (ViewerDataModel.Instance.UndoDataList.Count > 0)
|
311
|
{
|
312
|
DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
|
313
|
DateTime updatetime = DateTime.Now.AddDays(-1);
|
314
|
if (ViewerDataModel.Instance._markupInfoList.Count > 0)
|
315
|
{
|
316
|
updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
|
317
|
}
|
318
|
|
319
|
if (undoTime > updatetime)
|
320
|
{
|
321
|
var box = new TextBlock();
|
322
|
box.MinWidth = 400;
|
323
|
box.FontSize = 11;
|
324
|
box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
|
325
|
box.TextWrapping = System.Windows.TextWrapping.Wrap;
|
326
|
|
327
|
DialogParameters parameters = new DialogParameters()
|
328
|
{
|
329
|
Owner = Application.Current.MainWindow,
|
330
|
Content = box,
|
331
|
Header = "Confirm",
|
332
|
Theme = new VisualStudio2013Theme(),
|
333
|
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
|
334
|
Closed = Onclose,
|
335
|
};
|
336
|
RadWindow.Confirm(parameters);
|
337
|
}
|
338
|
}
|
339
|
this.Close();
|
340
|
}
|
341
|
break;
|
342
|
}
|
343
|
}
|
344
|
|
345
|
private void Onclose(object sender, WindowClosedEventArgs e)
|
346
|
{
|
347
|
if (e.DialogResult == true)
|
348
|
{
|
349
|
dzTopMenu.SaveEvent(null, null);
|
350
|
}
|
351
|
}
|
352
|
|
353
|
void win_SourceInitialized(object sender, EventArgs e)
|
354
|
{
|
355
|
System.IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle;
|
356
|
WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(WindowProc));
|
357
|
}
|
358
|
|
359
|
private static System.IntPtr WindowProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled)
|
360
|
{
|
361
|
switch (msg)
|
362
|
{
|
363
|
case 0x0024:
|
364
|
WmGetMinMaxInfo(hwnd, lParam);
|
365
|
handled = true;
|
366
|
break;
|
367
|
}
|
368
|
return (System.IntPtr)0;
|
369
|
}
|
370
|
|
371
|
private static void WmGetMinMaxInfo(System.IntPtr hwnd, System.IntPtr lParam)
|
372
|
{
|
373
|
MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
|
374
|
int MONITOR_DEFAULTTONEAREST = 0x00000002;
|
375
|
System.IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
376
|
|
377
|
if (monitor != System.IntPtr.Zero)
|
378
|
{
|
379
|
MONITORINFO monitorInfo = new MONITORINFO();
|
380
|
GetMonitorInfo(monitor, monitorInfo);
|
381
|
RECT rcWorkArea = monitorInfo.rcWork;
|
382
|
RECT rcMonitorArea = monitorInfo.rcMonitor;
|
383
|
mmi.ptMaxPosition.x = Math.Abs(rcWorkArea.left - rcMonitorArea.left);
|
384
|
mmi.ptMaxPosition.y = Math.Abs(rcWorkArea.top - rcMonitorArea.top);
|
385
|
mmi.ptMaxSize.x = Math.Abs(rcWorkArea.right - rcWorkArea.left);
|
386
|
mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom - rcWorkArea.top);
|
387
|
}
|
388
|
Marshal.StructureToPtr(mmi, lParam, true);
|
389
|
}
|
390
|
|
391
|
[StructLayout(LayoutKind.Sequential)]
|
392
|
public struct POINT2
|
393
|
{
|
394
|
public int x;
|
395
|
public int y;
|
396
|
public POINT2(int x, int y)
|
397
|
{
|
398
|
this.x = x;
|
399
|
this.y = y;
|
400
|
}
|
401
|
}
|
402
|
|
403
|
[StructLayout(LayoutKind.Sequential)]
|
404
|
public struct MINMAXINFO
|
405
|
{
|
406
|
public POINT2 ptReserved;
|
407
|
public POINT2 ptMaxSize;
|
408
|
public POINT2 ptMaxPosition;
|
409
|
public POINT2 ptMinTrackSize;
|
410
|
public POINT2 ptMaxTrackSize;
|
411
|
};
|
412
|
|
413
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
414
|
public class MONITORINFO
|
415
|
{
|
416
|
public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));
|
417
|
public RECT rcMonitor = new RECT();
|
418
|
public RECT rcWork = new RECT();
|
419
|
public int dwFlags = 0;
|
420
|
}
|
421
|
|
422
|
[StructLayout(LayoutKind.Sequential, Pack = 0)]
|
423
|
public struct RECT
|
424
|
{
|
425
|
public int left;
|
426
|
public int top;
|
427
|
public int right;
|
428
|
public int bottom;
|
429
|
|
430
|
public static readonly RECT Empty = new RECT();
|
431
|
|
432
|
public int Width
|
433
|
{
|
434
|
get { return Math.Abs(right - left); } // Abs needed for BIDI OS
|
435
|
}
|
436
|
|
437
|
public int Height
|
438
|
{
|
439
|
get { return bottom - top; }
|
440
|
}
|
441
|
|
442
|
public RECT(int left, int top, int right, int bottom)
|
443
|
{
|
444
|
this.left = left;
|
445
|
this.top = top;
|
446
|
this.right = right;
|
447
|
this.bottom = bottom;
|
448
|
}
|
449
|
|
450
|
public RECT(RECT rcSrc)
|
451
|
{
|
452
|
this.left = rcSrc.left;
|
453
|
this.top = rcSrc.top;
|
454
|
this.right = rcSrc.right;
|
455
|
this.bottom = rcSrc.bottom;
|
456
|
}
|
457
|
|
458
|
public bool IsEmpty
|
459
|
{
|
460
|
get
|
461
|
{
|
462
|
// BUGBUG : On Bidi OS (hebrew arabic) left > right
|
463
|
return left >= right || top >= bottom;
|
464
|
}
|
465
|
}
|
466
|
|
467
|
public override bool Equals(object obj)
|
468
|
{
|
469
|
if (!(obj is Rect)) { return false; }
|
470
|
return (this == (RECT)obj);
|
471
|
}
|
472
|
|
473
|
public override int GetHashCode()
|
474
|
{
|
475
|
return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode();
|
476
|
}
|
477
|
|
478
|
public static bool operator ==(RECT rect1, RECT rect2)
|
479
|
{
|
480
|
return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right && rect1.bottom == rect2.bottom);
|
481
|
}
|
482
|
|
483
|
public static bool operator !=(RECT rect1, RECT rect2)
|
484
|
{
|
485
|
return !(rect1 == rect2);
|
486
|
}
|
487
|
}
|
488
|
|
489
|
[DllImport("user32")]
|
490
|
internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);
|
491
|
[DllImport("User32")]
|
492
|
internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
|
493
|
|
494
|
private void WindowKeyDown(object sender, KeyEventArgs e)
|
495
|
{
|
496
|
if (e.Key == Key.V && Keyboard.Modifiers == ModifierKeys.Control) //Ctrl + V
|
497
|
{
|
498
|
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
|
499
|
{
|
500
|
if (Clipboard.GetText().Contains("|OR||DZ|"))
|
501
|
{
|
502
|
TextBox_Paste_Start();
|
503
|
}
|
504
|
|
505
|
}
|
506
|
}
|
507
|
}
|
508
|
|
509
|
public void TextBox_Paste_Start()
|
510
|
{
|
511
|
if (ViewerDataModel.Instance.IsPressCtrl && (App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
|
512
|
{
|
513
|
if (Clipboard.GetText().Contains("|OR||DZ|"))
|
514
|
{
|
515
|
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
|
516
|
|
517
|
string[] delimiterChars = { "|OR|" };
|
518
|
string[] delimiterChars2 = { "|OR|", "|SymbolID|" };
|
519
|
string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
|
520
|
|
521
|
SelectionSet.Instance.UnSelect(this.dzMainMenu);
|
522
|
|
523
|
Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
|
524
|
|
525
|
Undo_data UndoData = new Undo_data()
|
526
|
{
|
527
|
IsUndo = false,
|
528
|
Event = Event_Type.Create,
|
529
|
EventTime = DateTime.Now,
|
530
|
Markup_List = new List<Multi_Undo_data>()
|
531
|
};
|
532
|
|
533
|
ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
|
534
|
{
|
535
|
ViewerDataModel.Instance.UndoDataList.Remove(i);
|
536
|
});
|
537
|
|
538
|
foreach (string parse in data)
|
539
|
{
|
540
|
if (parse != "")
|
541
|
{
|
542
|
string[] data2 = new string[2];
|
543
|
data2 = parse.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
|
544
|
|
545
|
System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, data2[0], ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
|
546
|
|
547
|
var controldata = JsonSerializerHelper.UnCompressString(data2[0]);
|
548
|
var unkownControl = JsonSerializerHelper.JsonDeserialize<S_BaseControl>(controldata); //복호화작업
|
549
|
ViewerDataModel.Instance.IsPressCtrl = false;
|
550
|
|
551
|
(item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
|
552
|
if (data2.Length >= 2)
|
553
|
{
|
554
|
(item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1];
|
555
|
}
|
556
|
|
557
|
ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
|
558
|
ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
|
559
|
|
560
|
adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
|
561
|
|
562
|
multi_Undo_Data = dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
|
563
|
|
564
|
UndoData.Markup_List.Add(multi_Undo_Data);
|
565
|
ViewerDataModel.Instance.UndoDataList.Add(UndoData);
|
566
|
}
|
567
|
}
|
568
|
|
569
|
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
|
570
|
|
571
|
double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
|
572
|
double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
|
573
|
final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
|
574
|
|
575
|
if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
|
576
|
{
|
577
|
final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001));
|
578
|
}
|
579
|
|
580
|
this.dzMainMenu.SelectLayer.Children.Add(final);
|
581
|
|
582
|
}
|
583
|
else if (Clipboard.GetImage() != null) //외부 이미지 붙여넣기
|
584
|
{
|
585
|
try
|
586
|
{
|
587
|
Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
|
588
|
|
589
|
//Undo/Redo 보류
|
590
|
Undo_data UndoData = new Undo_data()
|
591
|
{
|
592
|
IsUndo = false,
|
593
|
Event = Event_Type.Create,
|
594
|
EventTime = DateTime.Now,
|
595
|
Markup_List = new List<Multi_Undo_data>()
|
596
|
};
|
597
|
|
598
|
string temppath = System.IO.Path.GetTempPath();
|
599
|
//string filename = KCOM.Events.Save.shortCommentKey();
|
600
|
string filename = Commons.shortFileKey();
|
601
|
|
602
|
System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
|
603
|
clipboardImage.Save(temppath + "\\" + filename);
|
604
|
|
605
|
System.IO.FileInfo fileInfo = new System.IO.FileInfo(temppath + "\\" + filename);
|
606
|
String strFile = System.IO.Path.GetFileName(fileInfo.FullName);
|
607
|
long numByte = fileInfo.Length;
|
608
|
double dLen = Convert.ToDouble(fileInfo.Length / 1000000);
|
609
|
kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
|
610
|
|
611
|
if (dLen < 4)
|
612
|
{
|
613
|
System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName,
|
614
|
System.IO.FileMode.Open, System.IO.FileAccess.Read);
|
615
|
System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
|
616
|
byte[] data = br.ReadBytes((int)numByte);
|
617
|
|
618
|
filename = fileUploader.Run(App.ViewInfo.ProjectNO, this.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data);
|
619
|
Check_Uri.UriCheck(filename);
|
620
|
|
621
|
br.Close();
|
622
|
fStream.Close();
|
623
|
fStream.Dispose();
|
624
|
}
|
625
|
else
|
626
|
{
|
627
|
dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert");
|
628
|
return;
|
629
|
}
|
630
|
|
631
|
fileInfo.Delete();
|
632
|
|
633
|
//System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage();
|
634
|
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage);
|
635
|
IntPtr hBitmap = bmp.GetHbitmap();
|
636
|
System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
|
637
|
Image img = new Image();
|
638
|
img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(filename));
|
639
|
|
640
|
var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
|
641
|
{
|
642
|
PointSet = new List<Point>(),
|
643
|
FilePath = img.Source.ToString(),
|
644
|
ImageData = img.Source,
|
645
|
StartPoint = new Point(100, 100),
|
646
|
EndPoint = new Point(200, 200),
|
647
|
TopRightPoint = new Point(100, 200),
|
648
|
LeftBottomPoint = new Point(200, 100)
|
649
|
};
|
650
|
|
651
|
currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y);
|
652
|
currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height);
|
653
|
currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height);
|
654
|
|
655
|
currentControl.PointSet = new List<Point>
|
656
|
{
|
657
|
currentControl.StartPoint,
|
658
|
currentControl.LeftBottomPoint,
|
659
|
currentControl.EndPoint,
|
660
|
currentControl.TopRightPoint,
|
661
|
};
|
662
|
|
663
|
multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
|
664
|
UndoData.Markup_List.Add(multi_Undo_Data);
|
665
|
ViewerDataModel.Instance.UndoDataList.Add(UndoData);
|
666
|
|
667
|
ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
|
668
|
currentControl.CommentID = Commons.shortGuid();
|
669
|
|
670
|
currentControl.ApplyTemplate();
|
671
|
currentControl.SetImage();
|
672
|
|
673
|
ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
|
674
|
Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
|
675
|
this.dzMainMenu.SelectLayer.Children.Add(final);
|
676
|
|
677
|
double realPointX = this.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
|
678
|
double realPointY = this.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
|
679
|
final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
|
680
|
}
|
681
|
catch(Exception ex)
|
682
|
{
|
683
|
DialogMessage_Alert("" + ex, "Alert");
|
684
|
}
|
685
|
}
|
686
|
}
|
687
|
}
|
688
|
}
|
689
|
}
|