개정판 2184f659
issue #923: fixed miss location of image when pasting
Change-Id: I10c3dc7996496e0f6fab45e966871ad631ae5452
KCOM/MainWindow.xaml.cs | ||
---|---|---|
491 | 491 |
internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi); |
492 | 492 |
[DllImport("User32")] |
493 | 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 | 494 |
} |
690 | 495 |
} |
내보내기 Unified diff