markus / KCOM / Controls / Symbol.xaml.cs @ ab7fe8c0
이력 | 보기 | 이력해설 | 다운로드 (47.8 KB)
1 | 53880c83 | ljiyeon | using IKCOM; |
---|---|---|---|
2 | using KCOM.Common; |
||
3 | 787a4489 | KangIngu | using KCOM.Events; |
4 | 5ce56a3a | KangIngu | using KCOMDataModel.Common; |
5 | using KCOMDataModel.DataModel; |
||
6 | 34c8d43a | ljiyeon | using MarkupToPDF.Common; |
7 | 036650a0 | humkyung | using MarkupToPDF.Controls.Parsing; |
8 | 787a4489 | KangIngu | using System; |
9 | using System.Collections.Generic; |
||
10 | 53880c83 | ljiyeon | using System.ComponentModel; |
11 | 787a4489 | KangIngu | using System.Linq; |
12 | using System.Text; |
||
13 | f65e6c02 | taeseongkim | using System.Threading.Tasks; |
14 | 787a4489 | KangIngu | 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 Telerik.Windows.Controls; |
||
24 | 5ce56a3a | KangIngu | using Telerik.Windows.Controls.DragDrop; |
25 | 787a4489 | KangIngu | |
26 | namespace KCOM.Controls |
||
27 | { |
||
28 | public class Symbol_Custom |
||
29 | { |
||
30 | 5ce56a3a | KangIngu | public string ID { get; set; } |
31 | 787a4489 | KangIngu | public string Name { get; set; } |
32 | public string ImageUri { get; set; } |
||
33 | } |
||
34 | |||
35 | /// <summary> |
||
36 | /// Symbol.xaml에 대한 상호 작용 논리 |
||
37 | /// </summary> |
||
38 | public partial class Symbol : UserControl |
||
39 | { |
||
40 | AdornerFinal finalItem; |
||
41 | 5ce56a3a | KangIngu | bool IsMouseDown = false; |
42 | string moveItem_id = ""; |
||
43 | 787a4489 | KangIngu | public string filename { get; set; } |
44 | f65e6c02 | taeseongkim | bool _Initialize = false; |
45 | 787a4489 | KangIngu | |
46 | public Symbol() |
||
47 | { |
||
48 | f65e6c02 | taeseongkim | //App.splashString(ISplashMessage.SYMBOL); |
49 | 787a4489 | KangIngu | InitializeComponent(); |
50 | 53880c83 | ljiyeon | |
51 | //RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo); |
||
52 | //RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery); |
||
53 | //RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true); |
||
54 | f65e6c02 | taeseongkim | this.Loaded += Symbol_Loaded; |
55 | |||
56 | } |
||
57 | |||
58 | |||
59 | 787a4489 | KangIngu | |
60 | f65e6c02 | taeseongkim | private async void Symbol_Loaded(object sender, RoutedEventArgs e) |
61 | { |
||
62 | 8fb54282 | taeseongkim | if (!App.IsDesignMode) |
63 | f65e6c02 | taeseongkim | { |
64 | 8fb54282 | taeseongkim | if (!_Initialize) |
65 | { |
||
66 | _Initialize = true; |
||
67 | await DataBindAsync(); |
||
68 | f65e6c02 | taeseongkim | |
69 | 8fb54282 | taeseongkim | } |
70 | f65e6c02 | taeseongkim | } |
71 | 787a4489 | KangIngu | } |
72 | |||
73 | 5ce56a3a | KangIngu | private void OnDragPrivateInfo(object sender, DragDropEventArgs e) |
74 | { |
||
75 | } |
||
76 | |||
77 | private void OnDragPrivateQuery(object sender, DragDropQueryEventArgs e) |
||
78 | { |
||
79 | if (e.Options.Status == DragStatus.DragQuery) |
||
80 | { |
||
81 | //var draggedListBoxItem = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem; |
||
82 | //BitmapImage im = new BitmapImage(new Uri((draggedListBoxItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate).ImageUri)); |
||
83 | //ImageSource _source = im; |
||
84 | //Image img = new Image(); |
||
85 | //img.Source = _source; |
||
86 | |||
87 | //e.Options.Payload = im; |
||
88 | //var dragCue = new Image(); |
||
89 | //dragCue.Source = img.Source; |
||
90 | //dragCue.Width = 0; |
||
91 | //dragCue.Height = 0; |
||
92 | //e.Options.DragCue = dragCue; |
||
93 | |||
94 | |||
95 | //PayLoadAdorner = new AdornerFinal(); |
||
96 | //DeepView.ServiceDeepView_Symbol.SymbolPrivate tempDragableControl = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate; |
||
97 | //var xamldata = tempDragableControl.Data; |
||
98 | ////this.DeepLayer.markupParse(xamldata, this.DeepLayer._TempLayer, "복사된 데이터_이름으로 수정해야함"); |
||
99 | //PayLoadAdorner = this.DeepLayer.markupParseToAdorner(xamldata, this.DeepLayer._SelectLayer, ""); |
||
100 | //this.DeepLayer._SelectLayer.Children.Add(PayLoadAdorner); |
||
101 | } |
||
102 | |||
103 | e.QueryResult = true; |
||
104 | e.Handled = true; |
||
105 | } |
||
106 | |||
107 | f65e6c02 | taeseongkim | private async Task DataBindAsync() |
108 | 787a4489 | KangIngu | { |
109 | 5ce56a3a | KangIngu | //lstSymbolPrivate.ItemsSource = null; |
110 | //lstSymbolPublic.ItemsSource = null; |
||
111 | 787a4489 | KangIngu | |
112 | Symbol_Custom Custom = new Symbol_Custom(); |
||
113 | ff01c725 | humkyung | List<Symbol_Custom> Custom_List = new List<Symbol_Custom>(); |
114 | |||
115 | try |
||
116 | { |
||
117 | |||
118 | f65e6c02 | taeseongkim | var symbol_Private = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSymbolListAsync(App.ViewInfo.UserID); |
119 | ff01c725 | humkyung | |
120 | foreach (var item in symbol_Private) |
||
121 | { |
||
122 | Custom.Name = item.NAME; |
||
123 | 3b938959 | taeseongkim | Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//","/").Replace(":/", "://"), App.isExternal); |
124 | ff01c725 | humkyung | Custom.ID = item.ID; |
125 | Custom_List.Add(Custom); |
||
126 | Custom = new Symbol_Custom(); |
||
127 | } |
||
128 | lstSymbolPrivate.ItemsSource = Custom_List; |
||
129 | } |
||
130 | catch (Exception ex) |
||
131 | 5ce56a3a | KangIngu | { |
132 | ff01c725 | humkyung | System.Diagnostics.Debug.WriteLine(ex.ToString()); |
133 | 6c781c0c | djkim | } |
134 | 5ce56a3a | KangIngu | |
135 | 6c781c0c | djkim | Custom = new Symbol_Custom(); |
136 | Custom_List = new List<Symbol_Custom>(); |
||
137 | 5ce56a3a | KangIngu | |
138 | f65e6c02 | taeseongkim | deptlist.ItemsSource = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolDeptListAsync(); |
139 | 5ce56a3a | KangIngu | |
140 | 6c781c0c | djkim | List<SYMBOL_PUBLIC> symbol_Public; |
141 | 5ce56a3a | KangIngu | |
142 | 53880c83 | ljiyeon | |
143 | 6c781c0c | djkim | if (deptlist.SelectedValue != null) |
144 | { |
||
145 | f65e6c02 | taeseongkim | symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(deptlist.SelectedValue.ToString()); |
146 | 6c781c0c | djkim | } |
147 | else |
||
148 | { |
||
149 | f65e6c02 | taeseongkim | symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(null); |
150 | 5ce56a3a | KangIngu | } |
151 | e77fc685 | taeseongkim | |
152 | if (symbol_Public != null) |
||
153 | 6c781c0c | djkim | { |
154 | e77fc685 | taeseongkim | foreach (var item in symbol_Public) |
155 | { |
||
156 | Custom.Name = item.NAME; |
||
157 | 3b938959 | taeseongkim | Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//", "/").Replace(":/", "://"), App.isExternal); |
158 | e77fc685 | taeseongkim | Custom.ID = item.ID; |
159 | Custom_List.Add(Custom); |
||
160 | Custom = new Symbol_Custom(); |
||
161 | } |
||
162 | f65e6c02 | taeseongkim | |
163 | e77fc685 | taeseongkim | lstSymbolPublic.ItemsSource = Custom_List; |
164 | } |
||
165 | 5ce56a3a | KangIngu | } |
166 | |||
167 | 3b938959 | taeseongkim | public async Task<PngBitmapEncoder> symImageAsync_old(string data,double PageAngle) |
168 | 5ce56a3a | KangIngu | { |
169 | |||
170 | Canvas _canvas = new Canvas(); |
||
171 | _canvas.Background = Brushes.White; |
||
172 | _canvas.Width = finalItem.BorderSize.Width; |
||
173 | _canvas.Height = finalItem.BorderSize.Height; |
||
174 | d2050059 | taeseongkim | await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken()); |
175 | 5ce56a3a | KangIngu | |
176 | BitmapEncoder encoder = new PngBitmapEncoder(); |
||
177 | |||
178 | |||
179 | RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32); |
||
180 | |||
181 | DrawingVisual dv = new DrawingVisual(); |
||
182 | |||
183 | _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50)); |
||
184 | //_canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 50, Y = -finalItem.BorderSize.Y - 50 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
||
185 | _canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
||
186 | |||
187 | using (DrawingContext ctx = dv.RenderOpen()) |
||
188 | { |
||
189 | VisualBrush vb = new VisualBrush(_canvas); |
||
190 | //ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
||
191 | ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X, Y = -finalItem.BorderSize.Y }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
||
192 | } |
||
193 | |||
194 | try |
||
195 | { |
||
196 | renderBitmap.Render(dv); |
||
197 | |||
198 | GC.Collect(); |
||
199 | GC.WaitForPendingFinalizers(); |
||
200 | GC.Collect(); |
||
201 | //bitmap.Render(controlToConvert); |
||
202 | // encode png data |
||
203 | PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); |
||
204 | // puch rendered bitmap into it |
||
205 | pngEncoder.Interlace = PngInterlaceOption.Off; |
||
206 | pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
||
207 | return pngEncoder; |
||
208 | |||
209 | } |
||
210 | 53880c83 | ljiyeon | catch //(Exception ex) |
211 | 5ce56a3a | KangIngu | { |
212 | return null; |
||
213 | } |
||
214 | 787a4489 | KangIngu | |
215 | } |
||
216 | |||
217 | 3b938959 | taeseongkim | public async Task<PngBitmapEncoder> symImageAsync(string data, double PageAngle) |
218 | { |
||
219 | |||
220 | Canvas _canvas = new Canvas(); |
||
221 | _canvas.Background = Brushes.White; |
||
222 | |||
223 | List<Rect> rects = new List<Rect>(); |
||
224 | |||
225 | finalItem.Members.ForEach(member => |
||
226 | { |
||
227 | if(member?.DrawingData is MarkupToPDF.ICommentRect comment) |
||
228 | { |
||
229 | rects.Add(comment.GetCommentRect()); |
||
230 | } |
||
231 | }); |
||
232 | |||
233 | var rect = MathHelper.CombineRects(rects); |
||
234 | |||
235 | _canvas.Width = rect.Width; |
||
236 | _canvas.Height = rect.Height; |
||
237 | |||
238 | await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken()); |
||
239 | |||
240 | BitmapEncoder encoder = new PngBitmapEncoder(); |
||
241 | RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96d, 96d, PixelFormats.Pbgra32); |
||
242 | |||
243 | DrawingVisual dv = new DrawingVisual(); |
||
244 | //Window window = new Window(); |
||
245 | //window.Content = _canvas; |
||
246 | //var result = window.ShowDialog(); |
||
247 | //if(result.GetValueOrDefault()) |
||
248 | //{ |
||
249 | |||
250 | //} |
||
251 | |||
252 | _canvas.Measure(rect.Size); |
||
253 | _canvas.Arrange(new Rect(new System.Windows.Point { X = -rect.X + 35, Y = -rect.Y + 35 }, new Point(rect.Width + 35, rect.Height + 35))); |
||
254 | |||
255 | using (DrawingContext ctx = dv.RenderOpen()) |
||
256 | { |
||
257 | VisualBrush vb = new VisualBrush(_canvas); |
||
258 | ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -rect.X, Y = -rect.Y }, new Point(rect.Width, rect.Height))); |
||
259 | } |
||
260 | Window window2 = new Window(); |
||
261 | window2.Content = _canvas; |
||
262 | var result2 = window2.ShowDialog(); |
||
263 | if (result2.GetValueOrDefault()) |
||
264 | { |
||
265 | |||
266 | } |
||
267 | try |
||
268 | { |
||
269 | renderBitmap.Render(dv); |
||
270 | |||
271 | GC.Collect(); |
||
272 | GC.WaitForPendingFinalizers(); |
||
273 | GC.Collect(); |
||
274 | //bitmap.Render(controlToConvert); |
||
275 | // encode png data |
||
276 | PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); |
||
277 | // puch rendered bitmap into it |
||
278 | pngEncoder.Interlace = PngInterlaceOption.Off; |
||
279 | pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
||
280 | return pngEncoder; |
||
281 | |||
282 | } |
||
283 | catch //(Exception ex) |
||
284 | { |
||
285 | return null; |
||
286 | } |
||
287 | |||
288 | } |
||
289 | |||
290 | 5ce56a3a | KangIngu | public void DialogMessage_Alert(string content, string header) |
291 | { |
||
292 | 68e3cd94 | taeseongkim | App.splashScreen.Close(); |
293 | |||
294 | 5ce56a3a | KangIngu | DialogParameters parameters = new DialogParameters() |
295 | { |
||
296 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
297 | 0d32593b | ljiyeon | Content = new TextBlock() |
298 | { |
||
299 | MinWidth = 400, |
||
300 | FontSize = 11, |
||
301 | Text = content, |
||
302 | TextWrapping = System.Windows.TextWrapping.Wrap |
||
303 | }, |
||
304 | 5ce56a3a | KangIngu | Header = header, |
305 | Theme = new VisualStudio2013Theme(), |
||
306 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
307 | }; |
||
308 | RadWindow.Alert(parameters); |
||
309 | } |
||
310 | |||
311 | #region Event |
||
312 | |||
313 | 498f0fc9 | ljiyeon | #region Private Symbol Add Event |
314 | 787a4489 | KangIngu | private void Create_Symbol(object sender, RoutedEventArgs e) |
315 | { |
||
316 | 5529d2a2 | humkyung | MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn(); |
317 | 787a4489 | KangIngu | |
318 | if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면 |
||
319 | { |
||
320 | DialogMessage_Alert("Please Select Controls", "Alert"); |
||
321 | } |
||
322 | else //선택된 것이 있으면 |
||
323 | { |
||
324 | string MarkupData = ""; |
||
325 | finalItem = new AdornerFinal(); |
||
326 | |||
327 | foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children) |
||
328 | { |
||
329 | if (item.GetType().Name == "AdornerFinal") |
||
330 | { |
||
331 | finalItem = (item as Controls.AdornerFinal); |
||
332 | 4913851c | humkyung | foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>()) |
333 | 787a4489 | KangIngu | { |
334 | if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData)) |
||
335 | { |
||
336 | 5529d2a2 | humkyung | markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID); |
337 | 787a4489 | KangIngu | MarkupData += markupReturn.ConvertData; |
338 | } |
||
339 | } |
||
340 | } |
||
341 | } |
||
342 | DialogParameters parameters = new DialogParameters() |
||
343 | { |
||
344 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
345 | 53880c83 | ljiyeon | Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args), |
346 | 787a4489 | KangIngu | DefaultPromptResultValue = "Custom State", |
347 | Content = "Name :", |
||
348 | Header = "Insert Custom Symbol Name", |
||
349 | Theme = new VisualStudio2013Theme(), |
||
350 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
351 | }; |
||
352 | RadWindow.Prompt(parameters); |
||
353 | } |
||
354 | |||
355 | } |
||
356 | 5ce56a3a | KangIngu | #endregion |
357 | 787a4489 | KangIngu | |
358 | 5ce56a3a | KangIngu | #region Symbol Add Close Event |
359 | f65e6c02 | taeseongkim | private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args) |
360 | 787a4489 | KangIngu | { |
361 | c73426a9 | ljiyeon | try |
362 | 787a4489 | KangIngu | { |
363 | c73426a9 | ljiyeon | if (args.PromptResult != null) |
364 | 53880c83 | ljiyeon | { |
365 | c73426a9 | ljiyeon | if (args.DialogResult.Value) |
366 | { |
||
367 | 3b938959 | taeseongkim | PngBitmapEncoder _Encoder = null; |
368 | |||
369 | if (finalItem.Members.Any(x=> x.DrawingData is MarkupToPDF.ICommentRect comment)) |
||
370 | { |
||
371 | _Encoder = await symImageAsync(data, ViewerDataModel.Instance.MarkupAngle); |
||
372 | } |
||
373 | else |
||
374 | { |
||
375 | _Encoder = await symImageAsync_old(data, ViewerDataModel.Instance.MarkupAngle); |
||
376 | } |
||
377 | 787a4489 | KangIngu | |
378 | c73426a9 | ljiyeon | System.IO.MemoryStream fs = new System.IO.MemoryStream(); |
379 | _Encoder.Save(fs); |
||
380 | System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs); |
||
381 | 787a4489 | KangIngu | |
382 | c73426a9 | ljiyeon | byte[] Img_byte = fs.ToArray(); |
383 | 787a4489 | KangIngu | |
384 | 76dc223b | taeseongkim | kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader; |
385 | f1f822e9 | taeseongkim | filename = fileUploader.RunSymbol(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte); |
386 | c73426a9 | ljiyeon | Check_Uri.UriCheck(filename); |
387 | if (RadTab.SelectedIndex == 0) |
||
388 | { |
||
389 | SymbolSave(args.PromptResult, filename, data); |
||
390 | } |
||
391 | else |
||
392 | { |
||
393 | SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT); |
||
394 | } |
||
395 | 53880c83 | ljiyeon | |
396 | f65e6c02 | taeseongkim | await DataBindAsync(); |
397 | 53880c83 | ljiyeon | } |
398 | 498f0fc9 | ljiyeon | } |
399 | 53880c83 | ljiyeon | } |
400 | c73426a9 | ljiyeon | catch(Exception ex) |
401 | { |
||
402 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert"); |
||
403 | } |
||
404 | 53880c83 | ljiyeon | } |
405 | #endregion |
||
406 | |||
407 | public void SymbolSave(string Name, string Url, string Data) |
||
408 | { |
||
409 | try |
||
410 | { |
||
411 | SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
||
412 | 498f0fc9 | ljiyeon | { |
413 | 24678e06 | humkyung | ID = Commons.shortGuid(), |
414 | 53880c83 | ljiyeon | MEMBER_USER_ID = App.ViewInfo.UserID, |
415 | NAME = Name, |
||
416 | IMAGE_URL = Url, |
||
417 | DATA = Data |
||
418 | }; |
||
419 | 5ce56a3a | KangIngu | |
420 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted; |
421 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1); |
422 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private); |
423 | } |
||
424 | catch (Exception) |
||
425 | { |
||
426 | throw; |
||
427 | 787a4489 | KangIngu | } |
428 | } |
||
429 | 53880c83 | ljiyeon | |
430 | public void SymbolSave_Public(string Name, string Url, string Data, string Department) |
||
431 | { |
||
432 | try |
||
433 | { |
||
434 | SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC |
||
435 | { |
||
436 | 24678e06 | humkyung | ID = Commons.shortGuid(), |
437 | 53880c83 | ljiyeon | DEPARTMENT = Department, |
438 | NAME = Name, |
||
439 | IMAGE_URL = Url, |
||
440 | DATA = Data |
||
441 | }; |
||
442 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted; |
||
443 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1); |
444 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public); |
445 | } |
||
446 | catch (Exception) |
||
447 | { |
||
448 | throw; |
||
449 | } |
||
450 | } |
||
451 | |||
452 | f65e6c02 | taeseongkim | private async void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e) |
453 | 53880c83 | ljiyeon | { |
454 | 664ea2e1 | taeseongkim | //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
455 | f65e6c02 | taeseongkim | await DataBindAsync(); |
456 | 53880c83 | ljiyeon | } |
457 | |||
458 | f65e6c02 | taeseongkim | private async void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e) |
459 | 53880c83 | ljiyeon | { |
460 | 664ea2e1 | taeseongkim | //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
461 | f65e6c02 | taeseongkim | await DataBindAsync(); |
462 | 53880c83 | ljiyeon | } |
463 | 787a4489 | KangIngu | |
464 | 498f0fc9 | ljiyeon | #region Private Symbol Delete Event |
465 | 5ce56a3a | KangIngu | private void Remove_Symbol(object sender, RoutedEventArgs e) |
466 | 787a4489 | KangIngu | { |
467 | 5ce56a3a | KangIngu | if (lstSymbolPrivate.SelectedItem == null) |
468 | { |
||
469 | DialogMessage_Alert("Please Select Symbol", "Alert"); |
||
470 | return; |
||
471 | } |
||
472 | 6c781c0c | djkim | string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
473 | 0f065e57 | ljiyeon | |
474 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted; |
475 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1); |
476 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex); |
477 | 498f0fc9 | ljiyeon | } |
478 | #endregion |
||
479 | #region Public Symbol Delete Event |
||
480 | private void Remove_Symbol_Public(object sender, RoutedEventArgs e) |
||
481 | { |
||
482 | if (lstSymbolPublic.SelectedItem == null) |
||
483 | { |
||
484 | DialogMessage_Alert("Please Select Symbol", "Alert"); |
||
485 | return; |
||
486 | } |
||
487 | string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
||
488 | |||
489 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted; |
||
490 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1); |
491 | 498f0fc9 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex); |
492 | 6c781c0c | djkim | } |
493 | 787a4489 | KangIngu | |
494 | f65e6c02 | taeseongkim | private async void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e) |
495 | 6c781c0c | djkim | { |
496 | 664ea2e1 | taeseongkim | //Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
497 | f65e6c02 | taeseongkim | await DataBindAsync(); |
498 | 5ce56a3a | KangIngu | } |
499 | #endregion |
||
500 | 787a4489 | KangIngu | |
501 | 34c8d43a | ljiyeon | public Undo_data UndoData { get; set; } |
502 | 702abd98 | humkyung | /// <summary> |
503 | /// place symbol which has given id to original position which is created |
||
504 | /// </summary> |
||
505 | /// <date>2018.06.14</date> |
||
506 | /// <param name="id"></param> |
||
507 | ac4f1e13 | taeseongkim | private async void PlaceSymbol(string id,Point CurrentMousePoint) |
508 | 5ce56a3a | KangIngu | { |
509 | 702abd98 | humkyung | string Data_ = ""; |
510 | 787a4489 | KangIngu | |
511 | c7fde400 | taeseongkim | var systemMain = Common.ViewerDataModel.Instance.SystemMain; |
512 | var mainMenu = systemMain.dzMainMenu; |
||
513 | |||
514 | SelectionSet.Instance.UnSelect(mainMenu); /// unselect alreay selected items |
||
515 | |||
516 | 702abd98 | humkyung | try |
517 | 5ce56a3a | KangIngu | { |
518 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1); |
519 | c7fde400 | taeseongkim | Data_ = mainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex); |
520 | |||
521 | 0f065e57 | ljiyeon | if (Data_ != null || Data_ != "") |
522 | { |
||
523 | 664ea2e1 | taeseongkim | //Logger.sendResLog("GetSymbolData", "TRUE", 1); |
524 | 0f065e57 | ljiyeon | } |
525 | else |
||
526 | { |
||
527 | 664ea2e1 | taeseongkim | //Logger.sendResLog("GetSymbolData", "FALSE", 1); |
528 | 0f065e57 | ljiyeon | } |
529 | 787a4489 | KangIngu | |
530 | 53880c83 | ljiyeon | //MARKUP_DATA_GROUP INSERT |
531 | c0977e97 | djkim | //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP |
532 | //{ |
||
533 | // SYMBOL_ID = id,//InnerItem.Symbol_ID |
||
534 | // STATE = 0, |
||
535 | //}; |
||
536 | //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO); |
||
537 | 664ea2e1 | taeseongkim | ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1); |
538 | 53880c83 | ljiyeon | |
539 | 5ce56a3a | KangIngu | if (Data_.Contains("|DZ|")) |
540 | { |
||
541 | List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
||
542 | |||
543 | string[] delimiterChars = { "|DZ|" }; |
||
544 | string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
||
545 | |||
546 | 34c8d43a | ljiyeon | Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
547 | UndoData = new Undo_data() |
||
548 | { |
||
549 | IsUndo = false, |
||
550 | Event = Event_Type.Create, |
||
551 | EventTime = DateTime.Now, |
||
552 | Markup_List = new List<Multi_Undo_data>() |
||
553 | }; |
||
554 | ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i => |
||
555 | { |
||
556 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
557 | }); |
||
558 | |||
559 | foreach (string parse in data) |
||
560 | 5ce56a3a | KangIngu | { |
561 | if (parse != "") |
||
562 | { |
||
563 | d2050059 | taeseongkim | System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(),App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, string.Empty, string.Empty); |
564 | 24678e06 | humkyung | (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid(); |
565 | c8e9b3e4 | ljiyeon | (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id; |
566 | c0977e97 | djkim | //(item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id; |
567 | c7fde400 | taeseongkim | |
568 | 5ce56a3a | KangIngu | ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
569 | ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo); |
||
570 | 53880c83 | ljiyeon | |
571 | 5ce56a3a | KangIngu | adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo); |
572 | 34c8d43a | ljiyeon | |
573 | multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo); |
||
574 | |||
575 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
576 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
577 | 5ce56a3a | KangIngu | } |
578 | } |
||
579 | c7fde400 | taeseongkim | |
580 | 5ce56a3a | KangIngu | Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
581 | |||
582 | c7fde400 | taeseongkim | // 마우스 클릭된 페이지 위치 |
583 | |||
584 | 315ae55e | taeseongkim | var pageWidth = ViewerDataModel.Instance.ImageViewWidth; |
585 | var pageHeight = ViewerDataModel.Instance.ImageViewHeight; |
||
586 | 4f017ed3 | taeseongkim | var angle = Common.ViewerDataModel.Instance.MarkupAngle; |
587 | c7fde400 | taeseongkim | |
588 | Point pagePoint = new Point(pageWidth/2, pageHeight/2); |
||
589 | |||
590 | var rotatePoint = Rotate(mainMenu.CanvasDrawingMouseDownPoint,pagePoint,angle); |
||
591 | |||
592 | var diff = Point.Subtract(rotatePoint, final.Centeroid); |
||
593 | 6b6e937c | taeseongkim | final.TranslateItems(diff.X, diff.Y); |
594 | c7fde400 | taeseongkim | |
595 | mainMenu.SelectLayer.Children.Add(final); |
||
596 | //var finalPosition = new Point(Canvas.GetLeft(final), Canvas.GetTop(final)); |
||
597 | //Rect rect = new Rect(finalPosition, Point.Add(finalPosition,new Vector(final.Width,final.Height))); |
||
598 | |||
599 | //SelectionSet.Instance.SelectItemByRect(final.getAdornerSize(), mainMenu); |
||
600 | |||
601 | 5ce56a3a | KangIngu | } |
602 | 53880c83 | ljiyeon | else |
603 | { |
||
604 | c0977e97 | djkim | PlaceImageSymbol(id, 0); |
605 | 53880c83 | ljiyeon | } |
606 | } |
||
607 | catch (Exception ex) |
||
608 | { |
||
609 | this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error"); |
||
610 | } |
||
611 | } |
||
612 | |||
613 | c7fde400 | taeseongkim | |
614 | //출처: https://icodebroker.tistory.com/3189 [ICODEBROKER] |
||
615 | public Point Rotate(Point sourcePoint, Point centerPoint, double rotateAngle) |
||
616 | { |
||
617 | Point targetPoint = new Point(); |
||
618 | |||
619 | double radian = rotateAngle / 180 * Math.PI; |
||
620 | |||
621 | targetPoint.X = Math.Cos(radian) * (sourcePoint.X - centerPoint.X) - Math.Sin(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.X; |
||
622 | targetPoint.Y = Math.Sin(radian) * (sourcePoint.X - centerPoint.X) + Math.Cos(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.Y; |
||
623 | |||
624 | return targetPoint; |
||
625 | } |
||
626 | |||
627 | |||
628 | |||
629 | 53880c83 | ljiyeon | private void PlaceImageSymbol(string id, long group_id) |
630 | { |
||
631 | |||
632 | //canvasZoommovingMouseDownPoint |
||
633 | string Data_ = ""; |
||
634 | |||
635 | try |
||
636 | { |
||
637 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1); |
638 | 53880c83 | ljiyeon | Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex); |
639 | if (Data_ != null || Data_ != "") |
||
640 | { |
||
641 | 664ea2e1 | taeseongkim | //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1); |
642 | 53880c83 | ljiyeon | } |
643 | else |
||
644 | { |
||
645 | 664ea2e1 | taeseongkim | //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1); |
646 | 53880c83 | ljiyeon | } |
647 | |||
648 | //MARKUP_DATA_GROUP INSERT |
||
649 | c0977e97 | djkim | //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP |
650 | //{ |
||
651 | // SYMBOL_ID = id,//InnerItem.Symbol_ID |
||
652 | // STATE = 0, |
||
653 | //}; |
||
654 | 53880c83 | ljiyeon | //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO); |
655 | 664ea2e1 | taeseongkim | ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1); |
656 | 53880c83 | ljiyeon | |
657 | if (Data_ != null) |
||
658 | { |
||
659 | Image img = new Image(); |
||
660 | //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_)); |
||
661 | if (Data_.Contains(".svg")) |
||
662 | { |
||
663 | f1f822e9 | taeseongkim | SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_); |
664 | img.Source = (DrawingImage)svgImage.ProvideValue(null); |
||
665 | 53880c83 | ljiyeon | } |
666 | else |
||
667 | { |
||
668 | img.Source = new BitmapImage(new Uri(Data_)); |
||
669 | } |
||
670 | |||
671 | var currentControl = new MarkupToPDF.Controls.Etc.ImgControl |
||
672 | { |
||
673 | PointSet = new List<Point>(), |
||
674 | FilePath = Data_, |
||
675 | ImageData = img.Source, |
||
676 | StartPoint = new Point(0, 0), |
||
677 | EndPoint = new Point(img.Source.Width, img.Source.Height), |
||
678 | TopRightPoint = new Point(img.Source.Width, 0), |
||
679 | LeftBottomPoint = new Point(0, img.Source.Height) |
||
680 | }; |
||
681 | |||
682 | currentControl.PointSet = new List<Point> |
||
683 | { |
||
684 | currentControl.StartPoint, |
||
685 | currentControl.LeftBottomPoint, |
||
686 | currentControl.EndPoint, |
||
687 | currentControl.TopRightPoint, |
||
688 | }; |
||
689 | Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
||
690 | UndoData = new Undo_data() |
||
691 | { |
||
692 | IsUndo = false, |
||
693 | Event = Event_Type.Create, |
||
694 | EventTime = DateTime.Now, |
||
695 | Markup_List = new List<Multi_Undo_data>() |
||
696 | }; |
||
697 | ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i => |
||
698 | { |
||
699 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
700 | }); |
||
701 | |||
702 | //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
703 | multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
704 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
705 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
706 | |||
707 | ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
708 | 24678e06 | humkyung | currentControl.CommentID = Commons.shortGuid(); |
709 | 53880c83 | ljiyeon | currentControl.SymbolID = id; |
710 | currentControl.GroupID = group_id; |
||
711 | currentControl.ApplyTemplate(); |
||
712 | currentControl.SetImage(); |
||
713 | |||
714 | ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
715 | Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo); |
||
716 | this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final); |
||
717 | |||
718 | 7211e0c2 | ljiyeon | /* |
719 | 53880c83 | ljiyeon | // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true; |
720 | // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY)); |
||
721 | double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2); |
||
722 | double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2); |
||
723 | 0d00f9c8 | humkyung | final.TranslateItems(realPointX, realPointY); |
724 | 53880c83 | ljiyeon | // move.control_Select(item, dragRect); |
725 | ApplyDragSelectionRect(); |
||
726 | 7211e0c2 | ljiyeon | //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol; |
727 | e6a9ddaf | humkyung | ///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left; |
728 | 7211e0c2 | ljiyeon | //this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/ |
729 | 53880c83 | ljiyeon | |
730 | } |
||
731 | 5ce56a3a | KangIngu | } |
732 | 702abd98 | humkyung | catch(Exception ex) |
733 | { |
||
734 | 53880c83 | ljiyeon | this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error"); |
735 | } |
||
736 | } |
||
737 | |||
738 | public Multi_Undo_data multi_Undo_Data; |
||
739 | private void ApplyDragSelectionRect() |
||
740 | { |
||
741 | multi_Undo_Data = new Multi_Undo_data(); |
||
742 | |||
743 | UndoData = new Undo_data() |
||
744 | { |
||
745 | IsUndo = false, |
||
746 | Event = Event_Type.Select, |
||
747 | EventTime = DateTime.Now, |
||
748 | Markup_List = new List<Multi_Undo_data>() |
||
749 | }; |
||
750 | |||
751 | this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed; |
||
752 | |||
753 | double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder); |
||
754 | double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder); |
||
755 | double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width; |
||
756 | double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height; |
||
757 | Rect dragRect = new Rect(x, y, width, height); |
||
758 | Boolean Flag = false; |
||
759 | dragRect.Inflate(width / 10, height / 10); |
||
760 | List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
||
761 | var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList(); |
||
762 | |||
763 | dragRect = new Rect(x, y, width, height); |
||
764 | dragRect.Inflate(width / 10, height / 10); |
||
765 | |||
766 | //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting; |
||
767 | //move. |
||
768 | foreach (var item in Items) |
||
769 | { |
||
770 | 91efe37a | humkyung | Flag = SelectionSet.Instance.SelectControl(item, dragRect); |
771 | 53880c83 | ljiyeon | |
772 | if (Flag) |
||
773 | { |
||
774 | adornerSet.Add(item); |
||
775 | ViewerDataModel.Instance.MarkupControls_USER.Remove(item); |
||
776 | |||
777 | this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item); |
||
778 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
779 | multi_Undo_Data = new Multi_Undo_data(); |
||
780 | if (item.GroupID > 0) |
||
781 | { |
||
782 | |||
783 | } |
||
784 | } |
||
785 | } |
||
786 | if (adornerSet.Count > 0) |
||
787 | { |
||
788 | ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
||
789 | { |
||
790 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
791 | }); |
||
792 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
793 | |||
794 | Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
||
795 | this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final); |
||
796 | 702abd98 | humkyung | } |
797 | } |
||
798 | |||
799 | f816dd63 | humkyung | ///private Move move; |
800 | 702abd98 | humkyung | #region Symbol DoubleClick Event |
801 | private void Move_Symbol(object sender, MouseButtonEventArgs e) |
||
802 | { |
||
803 | 16d13764 | djkim | try |
804 | 702abd98 | humkyung | { |
805 | 16d13764 | djkim | Type type = e.OriginalSource.GetType(); |
806 | string id = string.Empty; |
||
807 | 664ea2e1 | taeseongkim | //Logger.sendResLog("Move_Symbol", type.Name, 0); |
808 | 16d13764 | djkim | if (type.Name == "Image") |
809 | { |
||
810 | id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID; |
||
811 | } |
||
812 | else if (type.Name == "Border") |
||
813 | { |
||
814 | id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID; |
||
815 | } |
||
816 | 53880c83 | ljiyeon | else if (type.Name == "TextBox") |
817 | be31927d | djkim | { |
818 | 53880c83 | ljiyeon | id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID; |
819 | be31927d | djkim | } |
820 | 16d13764 | djkim | |
821 | IsMouseDown = true; |
||
822 | 53880c83 | ljiyeon | |
823 | 16d13764 | djkim | if (e.ClickCount > 1) |
824 | { |
||
825 | c7fde400 | taeseongkim | this.PlaceSymbol(id,ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
826 | 16d13764 | djkim | } |
827 | 702abd98 | humkyung | } |
828 | 16d13764 | djkim | catch(Exception ex) |
829 | { |
||
830 | 664ea2e1 | taeseongkim | //Logger.sendResLog("Move_Symbol", ex.Message, 0); |
831 | 53880c83 | ljiyeon | } |
832 | 5ce56a3a | KangIngu | } |
833 | #endregion |
||
834 | |||
835 | 498f0fc9 | ljiyeon | #region Private Symbol Rename Event |
836 | 5ce56a3a | KangIngu | private void Rename_Symbol(object sender, RoutedEventArgs e) |
837 | { |
||
838 | if (lstSymbolPrivate.SelectedItem == null) |
||
839 | 787a4489 | KangIngu | { |
840 | 5ce56a3a | KangIngu | DialogMessage_Alert("Please Select Symbol", "Alert"); |
841 | return; |
||
842 | 787a4489 | KangIngu | } |
843 | |||
844 | 5ce56a3a | KangIngu | DialogParameters parameters = new DialogParameters() |
845 | 787a4489 | KangIngu | { |
846 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
847 | 5ce56a3a | KangIngu | Closed = (obj, args) => this.MarkupReNamePromptClose("", args), |
848 | //DefaultPromptResultValue = "Custom State", |
||
849 | DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name, |
||
850 | Content = "Name :", |
||
851 | Header = "Update Custom Symbol Name", |
||
852 | Theme = new VisualStudio2013Theme(), |
||
853 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
854 | }; |
||
855 | RadWindow.Prompt(parameters); |
||
856 | 787a4489 | KangIngu | |
857 | 5ce56a3a | KangIngu | } |
858 | #endregion |
||
859 | 787a4489 | KangIngu | |
860 | 498f0fc9 | ljiyeon | #region Public Symbol Rename Event |
861 | private void Rename_Symbol_Public(object sender, RoutedEventArgs e) |
||
862 | { |
||
863 | if (lstSymbolPublic.SelectedItem == null) |
||
864 | { |
||
865 | DialogMessage_Alert("Please Select Symbol", "Alert"); |
||
866 | return; |
||
867 | } |
||
868 | |||
869 | DialogParameters parameters = new DialogParameters() |
||
870 | { |
||
871 | b9b01f8e | ljiyeon | Owner = Application.Current.MainWindow, |
872 | 498f0fc9 | ljiyeon | Closed = (obj, args) => this.MarkupReNamePromptClose("", args), |
873 | //DefaultPromptResultValue = "Custom State", |
||
874 | DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name, |
||
875 | Content = "Name :", |
||
876 | Header = "Update Custom Symbol Name", |
||
877 | Theme = new VisualStudio2013Theme(), |
||
878 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
879 | }; |
||
880 | RadWindow.Prompt(parameters); |
||
881 | |||
882 | } |
||
883 | #endregion |
||
884 | 5ce56a3a | KangIngu | #region Symbol Rename Close Event |
885 | private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args) |
||
886 | { |
||
887 | if (args.DialogResult != null && args.DialogResult.Value) |
||
888 | { |
||
889 | 498f0fc9 | ljiyeon | if(RadTab.SelectedIndex == 0) |
890 | { |
||
891 | string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
||
892 | string _name = args.PromptResult; |
||
893 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
||
894 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1); |
895 | 498f0fc9 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex); |
896 | } |
||
897 | else |
||
898 | { |
||
899 | string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
||
900 | string _name = args.PromptResult; |
||
901 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
||
902 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1); |
903 | 498f0fc9 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex); |
904 | 53880c83 | ljiyeon | } |
905 | 787a4489 | KangIngu | } |
906 | 5ce56a3a | KangIngu | } |
907 | 6c781c0c | djkim | |
908 | f65e6c02 | taeseongkim | private async void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e) |
909 | 6c781c0c | djkim | { |
910 | 664ea2e1 | taeseongkim | //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
911 | f65e6c02 | taeseongkim | await DataBindAsync(); |
912 | 6c781c0c | djkim | } |
913 | 5ce56a3a | KangIngu | #endregion |
914 | |||
915 | #region Wheel Event |
||
916 | private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e) |
||
917 | { |
||
918 | ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2)); |
||
919 | } |
||
920 | private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e) |
||
921 | { |
||
922 | ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2)); |
||
923 | } |
||
924 | #endregion |
||
925 | |||
926 | #region Tab Selection Event |
||
927 | private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e) |
||
928 | { |
||
929 | foreach (var item in (e.OriginalSource as RadTabControl).Items) |
||
930 | 787a4489 | KangIngu | { |
931 | 5ce56a3a | KangIngu | (item as RadTabItem).FontWeight = FontWeights.Normal; |
932 | 787a4489 | KangIngu | } |
933 | 5ce56a3a | KangIngu | ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold; |
934 | } |
||
935 | #endregion |
||
936 | 787a4489 | KangIngu | |
937 | 5ce56a3a | KangIngu | #region Department Selection Event |
938 | f65e6c02 | taeseongkim | private async void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e) |
939 | 5ce56a3a | KangIngu | { |
940 | f65e6c02 | taeseongkim | await DataBindAsync(); |
941 | 787a4489 | KangIngu | } |
942 | 5ce56a3a | KangIngu | #endregion |
943 | 787a4489 | KangIngu | |
944 | 5ce56a3a | KangIngu | #endregion |
945 | 29010418 | ljiyeon | |
946 | 5ce56a3a | KangIngu | private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e) |
947 | { |
||
948 | |||
949 | } |
||
950 | |||
951 | private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e) |
||
952 | { |
||
953 | |||
954 | } |
||
955 | |||
956 | private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e) |
||
957 | 787a4489 | KangIngu | { |
958 | |||
959 | } |
||
960 | 29010418 | ljiyeon | |
961 | 5ce56a3a | KangIngu | private void StackPanel_MouseLeave(object sender, MouseEventArgs e) |
962 | 787a4489 | KangIngu | { |
963 | 5ce56a3a | KangIngu | if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed) |
964 | { |
||
965 | ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id; |
||
966 | } |
||
967 | else |
||
968 | { |
||
969 | IsMouseDown = false; |
||
970 | } |
||
971 | } |
||
972 | 787a4489 | KangIngu | |
973 | 5ce56a3a | KangIngu | private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e) |
974 | { |
||
975 | IsMouseDown = false; |
||
976 | 787a4489 | KangIngu | } |
977 | 702abd98 | humkyung | |
978 | /// <summary> |
||
979 | /// place symbol which user select |
||
980 | /// </summary> |
||
981 | /// <author>humkyung</author> |
||
982 | /// <date>2018.06.14</date> |
||
983 | /// <param name="sender"></param> |
||
984 | /// <param name="e"></param> |
||
985 | private void Place_Symbol(object sender, RoutedEventArgs e) |
||
986 | { |
||
987 | if (lstSymbolPrivate.SelectedItem == null) |
||
988 | { |
||
989 | DialogMessage_Alert("Please Select Symbol", "Alert"); |
||
990 | return; |
||
991 | } |
||
992 | |||
993 | string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
||
994 | c7fde400 | taeseongkim | this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
995 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
996 | 702abd98 | humkyung | } |
997 | ffcc8124 | ljiyeon | |
998 | private void Place_Symbol_Public(object sender, RoutedEventArgs e) |
||
999 | { |
||
1000 | if (lstSymbolPublic.SelectedItem == null) |
||
1001 | { |
||
1002 | DialogMessage_Alert("Please Select Symbol", "Alert"); |
||
1003 | return; |
||
1004 | } |
||
1005 | |||
1006 | string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
||
1007 | c7fde400 | taeseongkim | this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
1008 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
1009 | } |
||
1010 | |||
1011 | private void Image_Place_Register(object sender, RoutedEventArgs e) |
||
1012 | { |
||
1013 | SyncInit(); |
||
1014 | ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl; |
||
1015 | //캡쳐 하기 전에 코멘트 저장 |
||
1016 | if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0) |
||
1017 | { |
||
1018 | var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu; |
||
1019 | 077896be | humkyung | SelectionSet.Instance.UnSelect(menu); |
1020 | 53880c83 | ljiyeon | if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true) |
1021 | { |
||
1022 | cb5c7f06 | humkyung | (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null); |
1023 | 53880c83 | ljiyeon | } |
1024 | else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID) |
||
1025 | { |
||
1026 | |||
1027 | } |
||
1028 | else |
||
1029 | { |
||
1030 | cb5c7f06 | humkyung | (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null); |
1031 | 53880c83 | ljiyeon | } |
1032 | } |
||
1033 | Application.Current.MainWindow.Focus(); |
||
1034 | Common.ViewerDataModel.Instance.Capture_Opacity = 0.49; |
||
1035 | (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture; |
||
1036 | } |
||
1037 | |||
1038 | |||
1039 | private void SyncInit() |
||
1040 | { |
||
1041 | try |
||
1042 | { |
||
1043 | if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden) |
||
1044 | { |
||
1045 | ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true; |
||
1046 | ViewerDataModel.Instance.PageBalanceMode = false; |
||
1047 | ViewerDataModel.Instance.PageBalanceNumber = 0; |
||
1048 | 752b18ef | taeseongkim | ViewerDataModel.Instance.SyncPageNumber = 0; |
1049 | 53880c83 | ljiyeon | ViewerDataModel.Instance.MarkupControls_Sync.Clear(); |
1050 | ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed; |
||
1051 | ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false; |
||
1052 | ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false; |
||
1053 | } |
||
1054 | } |
||
1055 | catch (Exception ex) |
||
1056 | { |
||
1057 | 664ea2e1 | taeseongkim | //Logger.sendResLog("SyncInit", ex.Message, 0); |
1058 | 53880c83 | ljiyeon | } |
1059 | } |
||
1060 | |||
1061 | private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
1062 | { |
||
1063 | var block = sender as TextBox; |
||
1064 | block.Focusable = true; |
||
1065 | |||
1066 | } |
||
1067 | |||
1068 | private void TextBlock_MouseEnter(object sender, MouseEventArgs e) |
||
1069 | { |
||
1070 | var block = sender as TextBox; |
||
1071 | if (block != null) |
||
1072 | { |
||
1073 | //block.Text = "Enter"; |
||
1074 | |||
1075 | } |
||
1076 | } |
||
1077 | |||
1078 | private void OnKeyDownHandler(object sender, KeyEventArgs e) |
||
1079 | { |
||
1080 | if (e.Key == Key.Return) |
||
1081 | { |
||
1082 | Type type = e.OriginalSource.GetType(); |
||
1083 | string id = string.Empty; |
||
1084 | 664ea2e1 | taeseongkim | //Logger.sendResLog("Move_Symbol", type.Name, 0); |
1085 | 53880c83 | ljiyeon | if (type.Name == "Image") |
1086 | { |
||
1087 | id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID; |
||
1088 | } |
||
1089 | else if (type.Name == "Border") |
||
1090 | { |
||
1091 | id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID; |
||
1092 | } |
||
1093 | else if (type.Name == "TextBox") |
||
1094 | { |
||
1095 | id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID; |
||
1096 | } |
||
1097 | |||
1098 | //((System.Windows.Controls.TextBox)sender).Text; |
||
1099 | |||
1100 | if (RadTab.SelectedIndex == 0) |
||
1101 | { |
||
1102 | //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
||
1103 | string _name = ((System.Windows.Controls.TextBox)sender).Text; |
||
1104 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
||
1105 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1); |
1106 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex); |
1107 | } |
||
1108 | else |
||
1109 | { |
||
1110 | //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
||
1111 | string _name = ((System.Windows.Controls.TextBox)sender).Text; |
||
1112 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
||
1113 | 664ea2e1 | taeseongkim | //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1); |
1114 | 53880c83 | ljiyeon | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex); |
1115 | } |
||
1116 | |||
1117 | } |
||
1118 | ffcc8124 | ljiyeon | } |
1119 | 8e5a4a6a | taeseongkim | |
1120 | 787a4489 | KangIngu | } |
1121 | } |