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