개정판 2184f659
issue #923: fixed miss location of image when pasting
Change-Id: I10c3dc7996496e0f6fab45e966871ad631ae5452
KCOM/Events/PasteCommand.cs | ||
---|---|---|
113 | 113 |
var diff = Point.Subtract(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, final.Centeroid); |
114 | 114 |
final.TranslateItems(diff.X, diff.Y); |
115 | 115 |
|
116 |
//if (final.Members.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null) |
|
117 |
//{ |
|
118 |
// final.TranslateItems(0.001, 0.001); //dummy |
|
119 |
//} |
|
120 |
|
|
121 | 116 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
122 | 117 |
} |
123 | 118 |
/// 외부 이미지 붙여넣기 |
... | ... | |
155 | 150 |
byte[] data = br.ReadBytes((int)numByte); |
156 | 151 |
|
157 | 152 |
filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data); |
158 |
|
|
159 | 153 |
Check_Uri.UriCheck(filename); |
160 | 154 |
|
161 | 155 |
br.Close(); |
... | ... | |
190 | 184 |
{ |
191 | 185 |
img.Source = new BitmapImage(new Uri(filename)); |
192 | 186 |
} |
187 |
|
|
188 |
|
|
189 |
var vecSize = new Vector(clipboardImage.Width, clipboardImage.Height); |
|
190 |
var EndPoint = Point.Add(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, vecSize); |
|
193 | 191 |
var currentControl = new MarkupToPDF.Controls.Etc.ImgControl |
194 | 192 |
{ |
195 | 193 |
PointSet = new List<Point>(), |
196 | 194 |
FilePath = filename, |
197 | 195 |
ImageData = img.Source, |
198 |
StartPoint = new Point(100, 100), |
|
199 |
EndPoint = new Point(200, 200), |
|
200 |
TopRightPoint = new Point(100, 200), |
|
201 |
LeftBottomPoint = new Point(200, 100) |
|
196 |
StartPoint = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, |
|
197 |
EndPoint = Point.Add(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, vecSize), |
|
198 |
TopRightPoint = new Point(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.X + vecSize.X, |
|
199 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.Y), |
|
200 |
LeftBottomPoint = new Point(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.X, |
|
201 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.Y + vecSize.Y) |
|
202 | 202 |
}; |
203 | 203 |
|
204 |
currentControl.TopRightPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y); |
|
205 |
currentControl.LeftBottomPoint = new Point(currentControl.StartPoint.X, currentControl.StartPoint.Y + clipboardImage.Height); |
|
206 |
currentControl.EndPoint = new Point(currentControl.StartPoint.X + clipboardImage.Width, currentControl.StartPoint.Y + clipboardImage.Height); |
|
207 |
|
|
208 | 204 |
currentControl.PointSet = new List<Point> |
209 |
{
|
|
210 |
currentControl.StartPoint,
|
|
211 |
currentControl.LeftBottomPoint,
|
|
212 |
currentControl.EndPoint,
|
|
213 |
currentControl.TopRightPoint,
|
|
214 |
};
|
|
205 |
{ |
|
206 |
currentControl.StartPoint, |
|
207 |
currentControl.LeftBottomPoint, |
|
208 |
currentControl.EndPoint, |
|
209 |
currentControl.TopRightPoint, |
|
210 |
}; |
|
215 | 211 |
|
216 | 212 |
multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo); |
217 | 213 |
UndoData.Markup_List.Add(multi_Undo_Data); |
... | ... | |
226 | 222 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo); |
227 | 223 |
Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo); |
228 | 224 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
229 |
|
|
230 |
double realPointX = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2); |
|
231 |
double realPointY = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2); |
|
232 |
final.TranslateItems(realPointX, realPointY); |
|
233 | 225 |
} |
234 | 226 |
catch (Exception ex) |
235 | 227 |
{ |
KCOM/MainWindow.xaml | ||
---|---|---|
9 | 9 |
mc:Ignorable="d" |
10 | 10 |
WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="CanResizeWithGrip" AllowsTransparency="True" |
11 | 11 |
Background="{DynamicResource KCOMColor_TopMenubackgroundBrush}" |
12 |
Title="MARKUS" |
|
13 |
PreviewKeyDown="WindowKeyDown"> |
|
12 |
Title="MARKUS" > |
|
14 | 13 |
<Window.Resources> |
15 | 14 |
<Style x:Key="NoMarginGrid" TargetType="{x:Type Grid}"> |
16 | 15 |
<Setter Property="Margin" Value="5,5,5,5"/> |
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