프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Controls / Symbol.xaml.cs @ 58dd9e89

이력 | 보기 | 이력해설 | 다운로드 (48 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 f1f822e9 taeseongkim
                        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 24678e06 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 664ea2e1 taeseongkim
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
424 53880c83 ljiyeon
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
425
            }
426
            catch (Exception)
427
            {
428
                throw;
429 787a4489 KangIngu
            }
430
        }
431 53880c83 ljiyeon
432
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
433
        {
434
            try
435
            {
436
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
437
                {
438 24678e06 humkyung
                    ID = Commons.shortGuid(),
439 53880c83 ljiyeon
                    DEPARTMENT = Department,
440
                    NAME = Name,
441
                    IMAGE_URL = Url,
442
                    DATA = Data
443
                };
444
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
445 664ea2e1 taeseongkim
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
446 53880c83 ljiyeon
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
447
            }
448
            catch (Exception)
449
            {
450
                throw;
451
            }
452
        }
453
454 f65e6c02 taeseongkim
        private async void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
455 53880c83 ljiyeon
        {
456 664ea2e1 taeseongkim
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
457 f65e6c02 taeseongkim
            await DataBindAsync();
458 53880c83 ljiyeon
        }
459
460 f65e6c02 taeseongkim
        private async void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
461 53880c83 ljiyeon
        {
462 664ea2e1 taeseongkim
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
463 f65e6c02 taeseongkim
            await DataBindAsync();
464 53880c83 ljiyeon
        }
465 787a4489 KangIngu
466 498f0fc9 ljiyeon
        #region Private Symbol Delete Event
467 5ce56a3a KangIngu
        private void Remove_Symbol(object sender, RoutedEventArgs e)
468 787a4489 KangIngu
        {
469 5ce56a3a KangIngu
            if (lstSymbolPrivate.SelectedItem == null)
470
            {
471
                DialogMessage_Alert("Please Select Symbol", "Alert");
472
                return;
473
            }
474 6c781c0c djkim
            string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
475 0f065e57 ljiyeon
476 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
477 664ea2e1 taeseongkim
            //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
478 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
479 498f0fc9 ljiyeon
        }
480
        #endregion
481
        #region Public Symbol Delete Event
482
        private void Remove_Symbol_Public(object sender, RoutedEventArgs e)
483
        {
484
            if (lstSymbolPublic.SelectedItem == null)
485
            {
486
                DialogMessage_Alert("Please Select Symbol", "Alert");
487
                return;
488
            }
489
            string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
490
491
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
492 664ea2e1 taeseongkim
            //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
493 498f0fc9 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
494 6c781c0c djkim
        }
495 787a4489 KangIngu
496 f65e6c02 taeseongkim
        private async void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e)
497 6c781c0c djkim
        {
498 664ea2e1 taeseongkim
            //Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
499 f65e6c02 taeseongkim
             await DataBindAsync();
500 5ce56a3a KangIngu
        }
501
        #endregion
502 787a4489 KangIngu
503 b79d6e7f humkyung
        public UndoDataGroup UndoDataGroup { get; set; }
504 702abd98 humkyung
        /// <summary>
505
        /// place symbol which has given id to original position which is created
506
        /// </summary>
507
        /// <date>2018.06.14</date>
508
        /// <param name="id"></param>
509 ac4f1e13 taeseongkim
        private async void PlaceSymbol(string id,Point CurrentMousePoint)
510 5ce56a3a KangIngu
        {
511 702abd98 humkyung
            string Data_ = "";
512 787a4489 KangIngu
513 c7fde400 taeseongkim
            var systemMain = Common.ViewerDataModel.Instance.SystemMain;
514
            var mainMenu = systemMain.dzMainMenu;
515
            
516
            SelectionSet.Instance.UnSelect(mainMenu);  /// unselect alreay selected items
517
518 702abd98 humkyung
            try
519 5ce56a3a KangIngu
            {
520 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1);
521 c7fde400 taeseongkim
                Data_ = mainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex);
522
523 0f065e57 ljiyeon
                if (Data_ != null || Data_ != "")
524
                {
525 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolData", "TRUE", 1);
526 0f065e57 ljiyeon
                }
527
                else
528
                {
529 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolData", "FALSE", 1);
530 0f065e57 ljiyeon
                }
531 787a4489 KangIngu
532 53880c83 ljiyeon
                //MARKUP_DATA_GROUP INSERT
533 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
534
                //{
535
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
536
                //    STATE = 0,
537
                //};
538
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
539 664ea2e1 taeseongkim
                ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
540 53880c83 ljiyeon
541 5ce56a3a KangIngu
                if (Data_.Contains("|DZ|"))
542
                {
543
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
544
545
                    string[] delimiterChars = { "|DZ|" };
546
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
547
548 b79d6e7f humkyung
                    UndoData multi_UndoData = new UndoData();
549
                    UndoDataGroup = new UndoDataGroup()
550 34c8d43a ljiyeon
                    {
551
                        IsUndo = false,
552 873011c4 humkyung
                        Event = EventType.Create,
553 34c8d43a ljiyeon
                        EventTime = DateTime.Now,
554 b79d6e7f humkyung
                        MarkupDataColl = new List<UndoData>()
555 34c8d43a ljiyeon
                    };
556
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
557
                    {
558
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
559
                    });
560
561
                    foreach (string parse in data)
562 5ce56a3a KangIngu
                    {
563
                        if (parse != "")
564
                        {
565 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,
566
                                STAMP_Contents: App.SystemInfo.STAMP_CONTENTS);
567 24678e06 humkyung
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
568 c8e9b3e4 ljiyeon
                            (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id;
569 c0977e97 djkim
                            //(item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id;
570 c7fde400 taeseongkim
571 5ce56a3a KangIngu
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
572
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
573 53880c83 ljiyeon
574 5ce56a3a KangIngu
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
575 34c8d43a ljiyeon
576 873011c4 humkyung
                            multi_UndoData = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
577 34c8d43a ljiyeon
578 b79d6e7f humkyung
                            UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
579
                            ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
580 5ce56a3a KangIngu
                        }
581
                    }
582 c7fde400 taeseongkim
583 5ce56a3a KangIngu
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
584
585 c7fde400 taeseongkim
                    // 마우스 클릭된 페이지 위치
586
587 315ae55e taeseongkim
                    var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
588
                    var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
589 4f017ed3 taeseongkim
                    var angle = Common.ViewerDataModel.Instance.MarkupAngle;
590 c7fde400 taeseongkim
591
                    Point pagePoint = new Point(pageWidth/2, pageHeight/2);
592
593
                    var rotatePoint = Rotate(mainMenu.CanvasDrawingMouseDownPoint,pagePoint,angle);
594
595
                    var diff = Point.Subtract(rotatePoint, final.Centeroid);
596 6b6e937c taeseongkim
                    final.TranslateItems(diff.X, diff.Y);
597 c7fde400 taeseongkim
598
                    mainMenu.SelectLayer.Children.Add(final);
599
                    //var finalPosition = new Point(Canvas.GetLeft(final), Canvas.GetTop(final));
600
                    //Rect rect = new Rect(finalPosition, Point.Add(finalPosition,new Vector(final.Width,final.Height)));
601
602
                    //SelectionSet.Instance.SelectItemByRect(final.getAdornerSize(), mainMenu);
603
604 5ce56a3a KangIngu
                }
605 53880c83 ljiyeon
                else
606
                {
607 c0977e97 djkim
                    PlaceImageSymbol(id, 0);
608 53880c83 ljiyeon
                }
609
            }
610
            catch (Exception ex)
611
            {
612
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
613
            }
614
        }
615
616 c7fde400 taeseongkim
617
        //출처: https://icodebroker.tistory.com/3189 [ICODEBROKER]
618
        public Point Rotate(Point sourcePoint, Point centerPoint, double rotateAngle)
619
        {
620
            Point targetPoint = new Point();
621
622
            double radian = rotateAngle / 180 * Math.PI;
623
624
            targetPoint.X = Math.Cos(radian) * (sourcePoint.X - centerPoint.X) - Math.Sin(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.X;
625
            targetPoint.Y = Math.Sin(radian) * (sourcePoint.X - centerPoint.X) + Math.Cos(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.Y;
626
627
            return targetPoint;
628
        }
629
630
631
632 53880c83 ljiyeon
        private void PlaceImageSymbol(string id, long group_id)
633
        {
634
           
635
            //canvasZoommovingMouseDownPoint
636
            string Data_ = "";
637
638
            try
639
            {
640 664ea2e1 taeseongkim
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1);
641 53880c83 ljiyeon
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex);
642
                if (Data_ != null || Data_ != "")
643
                {
644 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
645 53880c83 ljiyeon
                }
646
                else
647
                {
648 664ea2e1 taeseongkim
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
649 53880c83 ljiyeon
                }
650
651
                //MARKUP_DATA_GROUP INSERT
652 c0977e97 djkim
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
653
                //{
654
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
655
                //    STATE = 0,
656
                //};
657 53880c83 ljiyeon
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
658 664ea2e1 taeseongkim
                ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
659 53880c83 ljiyeon
660
                if (Data_ != null)
661
                {
662
                    Image img = new Image();
663
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
664
                    if (Data_.Contains(".svg"))
665
                    {
666 f1f822e9 taeseongkim
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
667
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
668 53880c83 ljiyeon
                    }
669
                    else
670
                    {
671
                        img.Source = new BitmapImage(new Uri(Data_));
672
                    }
673
674
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
675
                    {
676
                        PointSet = new List<Point>(),
677
                        FilePath = Data_,
678
                        ImageData = img.Source,
679
                        StartPoint = new Point(0, 0),
680
                        EndPoint = new Point(img.Source.Width, img.Source.Height),
681
                        TopRightPoint = new Point(img.Source.Width, 0),
682
                        LeftBottomPoint = new Point(0, img.Source.Height)
683
                    };
684
685
                    currentControl.PointSet = new List<Point>
686
                                        {
687
                                            currentControl.StartPoint,
688
                                            currentControl.LeftBottomPoint,
689
                                            currentControl.EndPoint,
690
                                            currentControl.TopRightPoint,
691
                                        };
692 b79d6e7f humkyung
                    UndoData multi_UndoData = new UndoData();
693
                    UndoDataGroup = new UndoDataGroup()
694 53880c83 ljiyeon
                    {
695
                        IsUndo = false,
696 873011c4 humkyung
                        Event = EventType.Create,
697 53880c83 ljiyeon
                        EventTime = DateTime.Now,
698 b79d6e7f humkyung
                        MarkupDataColl = new List<UndoData>()
699 53880c83 ljiyeon
                    };
700
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
701
                    {
702
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
703
                    });
704
705 873011c4 humkyung
                    //multi_UndoData = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
706
                    multi_UndoData = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
707 b79d6e7f humkyung
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
708
                    ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
709 53880c83 ljiyeon
710
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
711 24678e06 humkyung
                    currentControl.CommentID = Commons.shortGuid();
712 53880c83 ljiyeon
                    currentControl.SymbolID = id;
713
                    currentControl.GroupID = group_id;
714
                    currentControl.ApplyTemplate();
715
                    currentControl.SetImage();
716
717
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
718
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
719
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
720
721 7211e0c2 ljiyeon
                    /*
722 53880c83 ljiyeon
                    // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true;
723
                    // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
724
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
725
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
726 0d00f9c8 humkyung
                      final.TranslateItems(realPointX, realPointY);
727 53880c83 ljiyeon
                    // move.control_Select(item, dragRect);
728
                    ApplyDragSelectionRect();
729 7211e0c2 ljiyeon
                    //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol;
730 e6a9ddaf humkyung
                    ///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left;
731 7211e0c2 ljiyeon
                    //this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/
732 53880c83 ljiyeon
                    
733
                }
734 5ce56a3a KangIngu
            }
735 702abd98 humkyung
            catch(Exception ex)
736
            {
737 53880c83 ljiyeon
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
738
            }
739
        }
740
741 b79d6e7f humkyung
        public UndoData multi_UndoData;
742 53880c83 ljiyeon
        private void ApplyDragSelectionRect()
743
        {
744 b79d6e7f humkyung
            multi_UndoData = new UndoData();
745 53880c83 ljiyeon
746 b79d6e7f humkyung
            UndoDataGroup = new UndoDataGroup()
747 53880c83 ljiyeon
            {
748
                IsUndo = false,
749 873011c4 humkyung
                Event = EventType.Operation,
750 53880c83 ljiyeon
                EventTime = DateTime.Now,
751 b79d6e7f humkyung
                MarkupDataColl = new List<UndoData>()
752 53880c83 ljiyeon
            };
753
754
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
755
756
            double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
757
            double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
758
            double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width;
759
            double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height;
760
            Rect dragRect = new Rect(x, y, width, height);
761
            Boolean Flag = false;
762
            dragRect.Inflate(width / 10, height / 10);
763
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
764
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
765
766
            dragRect = new Rect(x, y, width, height);
767
            dragRect.Inflate(width / 10, height / 10);
768
769
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
770
            //move.
771
            foreach (var item in Items)
772
            {
773 91efe37a humkyung
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
774 53880c83 ljiyeon
775
                if (Flag)
776
                {
777
                    adornerSet.Add(item);
778
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
779
780
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
781 b79d6e7f humkyung
                    UndoDataGroup.MarkupDataColl.Add(multi_UndoData);
782
                    multi_UndoData = new UndoData();
783 53880c83 ljiyeon
                    if (item.GroupID > 0)
784
                    {
785
786
                    }
787
                }
788
            }
789
            if (adornerSet.Count > 0)
790
            {
791
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
792
                {
793
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
794
                });
795 b79d6e7f humkyung
                ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup);
796 53880c83 ljiyeon
797
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
798
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
799 702abd98 humkyung
            }
800
        }
801
802 f816dd63 humkyung
        ///private Move move;
803 702abd98 humkyung
        #region Symbol DoubleClick Event
804
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
805
        {
806 16d13764 djkim
            try
807 702abd98 humkyung
            {
808 16d13764 djkim
                Type type = e.OriginalSource.GetType();
809
                string id = string.Empty;
810 664ea2e1 taeseongkim
                //Logger.sendResLog("Move_Symbol", type.Name, 0);
811 16d13764 djkim
                if (type.Name == "Image")
812
                {
813
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
814
                }
815
                else if (type.Name == "Border")
816
                {
817
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
818
                }
819 53880c83 ljiyeon
                else if (type.Name == "TextBox")
820 be31927d djkim
                {
821 53880c83 ljiyeon
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
822 be31927d djkim
                }
823 16d13764 djkim
824
                IsMouseDown = true;
825 53880c83 ljiyeon
826 16d13764 djkim
                if (e.ClickCount > 1)
827
                {
828 c7fde400 taeseongkim
                    this.PlaceSymbol(id,ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
829 16d13764 djkim
                }
830 702abd98 humkyung
            }
831 16d13764 djkim
            catch(Exception ex)
832
            {
833 664ea2e1 taeseongkim
                //Logger.sendResLog("Move_Symbol", ex.Message, 0);
834 53880c83 ljiyeon
            }
835 5ce56a3a KangIngu
        }
836
        #endregion
837
838 498f0fc9 ljiyeon
        #region Private Symbol Rename Event
839 5ce56a3a KangIngu
        private void Rename_Symbol(object sender, RoutedEventArgs e)
840
        {
841
            if (lstSymbolPrivate.SelectedItem == null)
842 787a4489 KangIngu
            {
843 5ce56a3a KangIngu
                DialogMessage_Alert("Please Select Symbol", "Alert");
844
                return;
845 787a4489 KangIngu
            }
846
847 5ce56a3a KangIngu
            DialogParameters parameters = new DialogParameters()
848 787a4489 KangIngu
            {
849 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
850 5ce56a3a KangIngu
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
851
                //DefaultPromptResultValue = "Custom State",
852
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
853
                Content = "Name :",
854
                Header = "Update Custom Symbol Name",
855
                Theme = new VisualStudio2013Theme(),
856
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
857
            };
858
            RadWindow.Prompt(parameters);
859 787a4489 KangIngu
860 5ce56a3a KangIngu
        }
861
        #endregion
862 787a4489 KangIngu
863 498f0fc9 ljiyeon
        #region Public Symbol Rename Event
864
        private void Rename_Symbol_Public(object sender, RoutedEventArgs e)
865
        {
866
            if (lstSymbolPublic.SelectedItem == null)
867
            {
868
                DialogMessage_Alert("Please Select Symbol", "Alert");
869
                return;
870
            }
871
872
            DialogParameters parameters = new DialogParameters()
873
            {
874 b9b01f8e ljiyeon
                Owner = Application.Current.MainWindow,
875 498f0fc9 ljiyeon
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
876
                //DefaultPromptResultValue = "Custom State",
877
                DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name,
878
                Content = "Name :",
879
                Header = "Update Custom Symbol Name",
880
                Theme = new VisualStudio2013Theme(),
881
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
882
            };
883
            RadWindow.Prompt(parameters);
884
885
        }
886
        #endregion
887 5ce56a3a KangIngu
        #region Symbol Rename Close Event
888
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
889
        {
890
            if (args.DialogResult != null && args.DialogResult.Value)
891
            {
892 498f0fc9 ljiyeon
                if(RadTab.SelectedIndex == 0)
893
                {
894
                    string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
895
                    string _name = args.PromptResult;
896
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
897 664ea2e1 taeseongkim
                    //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
898 498f0fc9 ljiyeon
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
899
                }
900
                else
901
                {
902
                    string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
903
                    string _name = args.PromptResult;
904
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
905 664ea2e1 taeseongkim
                    //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
906 498f0fc9 ljiyeon
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
907 53880c83 ljiyeon
                }
908 787a4489 KangIngu
            }
909 5ce56a3a KangIngu
        }
910 6c781c0c djkim
911 f65e6c02 taeseongkim
        private async void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e)
912 6c781c0c djkim
        {
913 664ea2e1 taeseongkim
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
914 f65e6c02 taeseongkim
            await DataBindAsync();
915 6c781c0c djkim
        }
916 5ce56a3a KangIngu
        #endregion
917
918
        #region Wheel Event
919
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
920
        {
921
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
922
        }
923
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
924
        {
925
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
926
        }
927
        #endregion
928
929
        #region Tab Selection Event
930
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
931
        {
932
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
933 787a4489 KangIngu
            {
934 5ce56a3a KangIngu
                (item as RadTabItem).FontWeight = FontWeights.Normal;
935 787a4489 KangIngu
            }
936 5ce56a3a KangIngu
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
937
        }
938
        #endregion
939 787a4489 KangIngu
940 5ce56a3a KangIngu
        #region Department Selection Event
941 f65e6c02 taeseongkim
        private async void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
942 5ce56a3a KangIngu
        {
943 f65e6c02 taeseongkim
            await DataBindAsync();
944 787a4489 KangIngu
        }
945 5ce56a3a KangIngu
        #endregion
946 787a4489 KangIngu
947 5ce56a3a KangIngu
        #endregion
948 29010418 ljiyeon
949 5ce56a3a KangIngu
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
950
        {
951
952
        }
953
954
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
955
        {
956
957
        }
958
959
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
960 787a4489 KangIngu
        {
961
962
        }
963 29010418 ljiyeon
964 5ce56a3a KangIngu
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
965 787a4489 KangIngu
        {
966 5ce56a3a KangIngu
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
967
            {
968
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
969
            }
970
            else
971
            {
972
                IsMouseDown = false;
973
            }
974
        }
975 787a4489 KangIngu
976 5ce56a3a KangIngu
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
977
        {
978
            IsMouseDown = false;
979 787a4489 KangIngu
        }
980 702abd98 humkyung
981
        /// <summary>
982
        /// place symbol which user select
983
        /// </summary>
984
        /// <author>humkyung</author>
985
        /// <date>2018.06.14</date>
986
        /// <param name="sender"></param>
987
        /// <param name="e"></param>
988
        private void Place_Symbol(object sender, RoutedEventArgs e)
989
        {
990
            if (lstSymbolPrivate.SelectedItem == null)
991
            {
992
                DialogMessage_Alert("Please Select Symbol",  "Alert");
993
                return;
994
            }
995
996
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
997 c7fde400 taeseongkim
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
998 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
999 702abd98 humkyung
        }
1000 ffcc8124 ljiyeon
1001
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
1002
        {
1003
            if (lstSymbolPublic.SelectedItem == null)
1004
            {
1005
                DialogMessage_Alert("Please Select Symbol", "Alert");
1006
                return;
1007
            }
1008
1009
            string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
1010 c7fde400 taeseongkim
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
1011 53880c83 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1012
        }
1013
1014
        private void Image_Place_Register(object sender, RoutedEventArgs e)
1015
        {
1016
            SyncInit();
1017
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
1018
            //캡쳐 하기 전에 코멘트 저장
1019
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
1020
            {
1021
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
1022 077896be humkyung
                SelectionSet.Instance.UnSelect(menu);
1023 53880c83 ljiyeon
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
1024
                {
1025 cb5c7f06 humkyung
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
1026 53880c83 ljiyeon
                }
1027
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
1028
                {
1029
1030
                }
1031
                else
1032
                {
1033 cb5c7f06 humkyung
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
1034 53880c83 ljiyeon
                }
1035
            }
1036
            Application.Current.MainWindow.Focus();
1037
            Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
1038
            (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
1039
        }
1040
1041
1042
        private void SyncInit()
1043
        {
1044
            try
1045
            {
1046
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
1047
                {
1048
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
1049
                    ViewerDataModel.Instance.PageBalanceMode = false;
1050
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
1051 752b18ef taeseongkim
                    ViewerDataModel.Instance.SyncPageNumber = 0;
1052 53880c83 ljiyeon
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1053
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
1054
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
1055
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
1056
                }
1057
            }
1058
            catch (Exception ex)
1059
            {
1060 664ea2e1 taeseongkim
                //Logger.sendResLog("SyncInit", ex.Message, 0);
1061 53880c83 ljiyeon
            }
1062
        }
1063
1064
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1065
        {
1066
            var block = sender as TextBox;
1067
            block.Focusable = true;
1068
               
1069
        }
1070
1071
        private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
1072
        {
1073
            var block = sender as TextBox;
1074
            if (block != null)
1075
            {
1076
                //block.Text = "Enter";
1077
1078
            }
1079
        }
1080
1081
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
1082
        {
1083
            if (e.Key == Key.Return)
1084
            {
1085
                Type type = e.OriginalSource.GetType();
1086
                string id = string.Empty;
1087 664ea2e1 taeseongkim
                //Logger.sendResLog("Move_Symbol", type.Name, 0);
1088 53880c83 ljiyeon
                if (type.Name == "Image")
1089
                {
1090
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
1091
                }
1092
                else if (type.Name == "Border")
1093
                {
1094
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
1095
                }
1096
                else if (type.Name == "TextBox")
1097
                {
1098
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
1099
                }
1100
1101
                //((System.Windows.Controls.TextBox)sender).Text;
1102
1103
                if (RadTab.SelectedIndex == 0)
1104
                {
1105
                    //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
1106
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1107
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1108 664ea2e1 taeseongkim
                    //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1109 53880c83 ljiyeon
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1110
                }
1111
                else
1112
                {
1113
                    //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
1114
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1115
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1116 664ea2e1 taeseongkim
                    //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1117 53880c83 ljiyeon
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1118
                }
1119
                
1120
            }
1121 ffcc8124 ljiyeon
        }
1122 8e5a4a6a taeseongkim
        
1123 787a4489 KangIngu
    }
1124
}
클립보드 이미지 추가 (최대 크기: 500 MB)