프로젝트

일반

사용자정보

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

markus / KCOM / Controls / Symbol.xaml.cs @ cbcc1a75

이력 | 보기 | 이력해설 | 다운로드 (45.8 KB)

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