개정판 26ec6226
issue #00000 copy&Paste 수정
Change-Id: I05c6141221f180d7f53d8f19929ed32d56977085
KCOM/Events/PasteCommand.cs | ||
---|---|---|
48 | 48 |
return _instance; |
49 | 49 |
} |
50 | 50 |
} |
51 |
|
|
52 | 51 |
/// <summary> |
53 | 52 |
/// paste controls |
54 | 53 |
/// </summary> |
... | ... | |
59 | 58 |
{ |
60 | 59 |
if (Clipboard.GetText().Contains("|OR||DZ|")) |
61 | 60 |
{ |
61 |
string[] delimiterChars = { "|OR|" }; |
|
62 |
string[] delimiterChars2 = { "|OR|", "|SymbolID|" }; |
|
63 |
string[] data = Clipboard.GetText().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
|
64 |
|
|
65 |
if (data.Count() > 0) |
|
66 |
{ |
|
67 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
|
68 |
|
|
69 |
Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
|
70 |
|
|
71 |
//강인구 Undo/Redo 보류 |
|
72 |
MarkupToPDF.Common.Undo_data UndoData = new Undo_data() |
|
73 |
{ |
|
74 |
IsUndo = false, |
|
75 |
Event = Event_Type.Create, |
|
76 |
EventTime = DateTime.Now, |
|
77 |
Markup_List = new List<Multi_Undo_data>() |
|
78 |
}; |
|
79 |
|
|
80 |
foreach (string parse in data) |
|
81 |
{ |
|
82 |
if (parse != "") |
|
83 |
{ |
|
84 |
string[] data2 = new string[2]; |
|
85 |
data2 = parse.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
|
86 |
|
|
87 |
System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, data2[0], ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, "#FFFF0000", string.Empty); |
|
88 |
|
|
89 |
var control = (item as MarkupToPDF.Common.CommentUserInfo); |
|
90 |
|
|
91 |
control.CommentID = Commons.shortGuid(); |
|
92 |
control.MarkupInfoID = App.Custom_ViewInfoId; |
|
93 |
control.IsNew = true; |
|
94 |
|
|
95 |
if (data2.Length >= 2) |
|
96 |
{ |
|
97 |
control.SymbolID = data2[1]; |
|
98 |
} |
|
99 |
|
|
100 |
//CreateCommand.Instance.Execute(control); |
|
101 |
adornerSet.Add(control); |
|
102 |
multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(control); |
|
103 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
104 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
105 |
|
|
106 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList(); |
|
107 |
//ViewerDataModel.Instance.MarkupControls_USER.Remove(control); |
|
108 |
|
|
109 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
|
110 |
MarkupParser.MarkupToString(multi_Undo_Data.Markup, App.ViewInfo.UserID), Event_Type.Create, null, null); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
|
115 |
|
|
116 |
/// place controls at current mouse position |
|
117 |
var diff = Point.Subtract(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, final.Centeroid); |
|
118 |
final.TranslateItems(diff.X, diff.Y); |
|
119 |
|
|
120 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
|
121 |
} |
|
122 |
} |
|
123 |
/// 외부 이미지 붙여넣기 |
|
124 |
else if (Clipboard.GetImage() != null) |
|
125 |
{ |
|
126 |
try |
|
127 |
{ |
|
128 |
Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
|
129 |
|
|
130 |
MarkupToPDF.Common.Undo_data UndoData = new Undo_data() |
|
131 |
{ |
|
132 |
IsUndo = false, |
|
133 |
Event = Event_Type.Create, |
|
134 |
EventTime = DateTime.Now, |
|
135 |
Markup_List = new List<Multi_Undo_data>() |
|
136 |
}; |
|
137 |
|
|
138 |
string temppath = System.IO.Path.GetTempPath(); |
|
139 |
string filename = Commons.shortFileKey(); |
|
140 |
|
|
141 |
System.Drawing.Image clipboardImage = System.Windows.Forms.Clipboard.GetImage(); |
|
142 |
clipboardImage.Save(Path.Combine(temppath, filename)); |
|
143 |
|
|
144 |
/// upload image file to server |
|
145 |
System.IO.FileInfo fileInfo = new System.IO.FileInfo(Path.Combine(temppath, filename)); |
|
146 |
String strFile = System.IO.Path.GetFileName(fileInfo.FullName); |
|
147 |
long numByte = fileInfo.Length; |
|
148 |
double dLen = Convert.ToDouble(fileInfo.Length / 1000000); |
|
149 |
kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader; |
|
150 |
if (dLen < 4) |
|
151 |
{ |
|
152 |
System.IO.FileStream fStream = new System.IO.FileStream(fileInfo.FullName, |
|
153 |
System.IO.FileMode.Open, System.IO.FileAccess.Read, FileShare.Read); |
|
154 |
System.IO.BinaryReader br = new System.IO.BinaryReader(fStream); |
|
155 |
byte[] data = br.ReadBytes((int)numByte); |
|
156 |
|
|
157 |
filename = fileUploader.Run(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, strFile + ".png", data); |
|
158 |
Check_Uri.UriCheck(filename); |
|
159 |
|
|
160 |
br.Close(); |
|
161 |
fStream.Close(); |
|
162 |
fStream.Dispose(); |
|
163 |
} |
|
164 |
else |
|
165 |
{ |
|
166 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("Available Memory less than 4 mega byte", "Alert"); |
|
167 |
return; |
|
168 |
} |
|
169 |
|
|
170 |
fileInfo.Delete(); |
|
171 |
|
|
172 |
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(clipboardImage); |
|
173 |
IntPtr hBitmap = bmp.GetHbitmap(); |
|
174 |
System.Windows.Media.ImageSource WpfBitmap = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); |
|
175 |
System.Windows.Controls.Image img = new System.Windows.Controls.Image(); |
|
176 |
if (filename.Contains(".svg")) |
|
177 |
{ |
|
178 |
SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(filename); |
|
179 |
img.Source = (DrawingImage)svgImage.ProvideValue(null); |
|
180 |
} |
|
181 |
else |
|
182 |
{ |
|
183 |
img.Source = new BitmapImage(new Uri(filename)); |
|
184 |
} |
|
185 |
|
|
186 |
|
|
187 |
var vecSize = new Vector(clipboardImage.Width, clipboardImage.Height); |
|
188 |
var EndPoint = Point.Add(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, vecSize); |
|
189 |
var currentControl = new MarkupToPDF.Controls.Etc.ImgControl |
|
190 |
{ |
|
191 |
PointSet = new List<Point>(), |
|
192 |
FilePath = filename, |
|
193 |
ImageData = img.Source, |
|
194 |
StartPoint = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, |
|
195 |
EndPoint = Point.Add(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint, vecSize), |
|
196 |
TopRightPoint = new Point(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.X + vecSize.X, |
|
197 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.Y), |
|
198 |
LeftBottomPoint = new Point(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.X, |
|
199 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.getCurrentPoint.Y + vecSize.Y) |
|
200 |
}; |
|
201 |
|
|
202 |
currentControl.PointSet = new List<Point> |
|
203 |
{ |
|
204 |
currentControl.StartPoint, |
|
205 |
currentControl.LeftBottomPoint, |
|
206 |
currentControl.EndPoint, |
|
207 |
currentControl.TopRightPoint, |
|
208 |
}; |
|
209 |
|
|
210 |
multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo); |
|
211 |
UndoData.Markup_List.Add(multi_Undo_Data); |
|
212 |
ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
|
213 |
|
|
214 |
ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo); |
|
215 |
currentControl.CommentID = Commons.shortGuid(); |
|
216 |
|
|
217 |
currentControl.ApplyTemplate(); |
|
218 |
currentControl.SetImage(); |
|
219 |
|
|
220 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo); |
|
221 |
Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo); |
|
222 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final); |
|
223 |
|
|
224 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
|
225 |
MarkupParser.MarkupToString(multi_Undo_Data.Markup, App.ViewInfo.UserID), Event_Type.Create, null, null); |
|
226 |
} |
|
227 |
catch (Exception ex) |
|
228 |
{ |
|
229 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert"); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
/// <summary> |
|
234 |
/// paste controls |
|
235 |
/// </summary> |
|
236 |
/// <author>humkyung</author> |
|
237 |
/// <date>2019.06.18</date> |
|
238 |
/// <param name="comments"></param> |
|
239 |
public async void Execute2() |
|
240 |
{ |
|
241 |
if (Clipboard.GetText().Contains("|OR||DZ|")) |
|
242 |
{ |
|
62 | 243 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
63 | 244 |
|
64 | 245 |
SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu); |
... | ... | |
95 | 276 |
{ |
96 | 277 |
(item as MarkupToPDF.Common.CommentUserInfo).SymbolID = data2[1]; |
97 | 278 |
} |
279 |
|
|
98 | 280 |
ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
99 | 281 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
100 | 282 |
|
... | ... | |
107 | 289 |
|
108 | 290 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate( |
109 | 291 |
MarkupParser.MarkupToString(multi_Undo_Data.Markup, App.ViewInfo.UserID), Event_Type.Create, null, null); |
292 |
|
|
293 |
(item as MarkupToPDF.Common.CommentUserInfo).ApplyOverViewData(); |
|
110 | 294 |
} |
111 | 295 |
} |
112 | 296 |
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
내보내기 Unified diff