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