프로젝트

일반

사용자정보

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

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

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

1
using IKCOM;
2
using KCOM.Common;
3
using KCOM.Events;
4
using KCOMDataModel.Common;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Parsing;
8
using System;
9
using System.Collections.Generic;
10
using System.ComponentModel;
11
using System.Linq;
12
using System.Text;
13
using System.Threading.Tasks;
14
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
using Telerik.Windows.Controls.DragDrop;
25

    
26
namespace KCOM.Controls
27
{
28
    public class Symbol_Custom
29
    {
30
        public string ID { get; set; }
31
        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
        bool IsMouseDown = false;
42
        string moveItem_id = "";
43
        public string filename { get; set; }
44
        bool _Initialize = false;
45

    
46
        public Symbol()
47
        {
48
            //App.splashString(ISplashMessage.SYMBOL);
49
            InitializeComponent();
50

    
51
            //RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo);
52
            //RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery);
53
            //RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true);
54
            this.Loaded += Symbol_Loaded;
55
 
56
        }
57

    
58
        
59

    
60
        private async void Symbol_Loaded(object sender, RoutedEventArgs e)
61
        {
62
            if (!App.IsDesignMode)
63
            {
64
                if (!_Initialize)
65
                {
66
                    _Initialize = true;
67
                    await DataBindAsync();
68

    
69
                }
70
            }
71
        }
72

    
73
        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
        private async Task DataBindAsync()
108
        {
109
            //lstSymbolPrivate.ItemsSource = null;
110
            //lstSymbolPublic.ItemsSource = null;
111

    
112
            Symbol_Custom Custom = new Symbol_Custom();
113
            List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
114

    
115
            try
116
            {
117

    
118
                var symbol_Private = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSymbolListAsync(App.ViewInfo.UserID);
119

    
120
                foreach (var item in symbol_Private)
121
                {
122
                    Custom.Name = item.NAME;
123
                    Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//","/").Replace(":/", "://"), App.isExternal);
124
                    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
            {
132
                System.Diagnostics.Debug.WriteLine(ex.ToString());
133
            }
134

    
135
            Custom = new Symbol_Custom();
136
            Custom_List = new List<Symbol_Custom>();
137

    
138
            deptlist.ItemsSource = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolDeptListAsync();
139

    
140
            List<SYMBOL_PUBLIC> symbol_Public;
141

    
142

    
143
            if (deptlist.SelectedValue != null)
144
            {
145
                symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(deptlist.SelectedValue.ToString());
146
            }
147
            else
148
            {
149
                symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(null);
150
            }
151

    
152
            if (symbol_Public != null)
153
            {
154
                foreach (var item in symbol_Public)
155
                {
156
                    Custom.Name = item.NAME;
157
                    Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//", "/").Replace(":/", "://"), App.isExternal);
158
                    Custom.ID = item.ID;
159
                    Custom_List.Add(Custom);
160
                    Custom = new Symbol_Custom();
161
                }
162

    
163
                lstSymbolPublic.ItemsSource = Custom_List;
164
            }
165
        }
166

    
167
        public async Task<PngBitmapEncoder> symImageAsync_old(string data,double PageAngle)
168
        {
169

    
170
            Canvas _canvas = new Canvas();
171
            _canvas.Background = Brushes.White;
172
            _canvas.Width = finalItem.BorderSize.Width;
173
            _canvas.Height = finalItem.BorderSize.Height;
174
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
175

    
176
            BitmapEncoder encoder = new PngBitmapEncoder();
177

    
178

    
179
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32);
180

    
181
            DrawingVisual dv = new DrawingVisual();
182

    
183
            _canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50));
184
            //_canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 50, Y = -finalItem.BorderSize.Y - 50 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
185
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
186

    
187
            using (DrawingContext ctx = dv.RenderOpen())
188
            {
189
                VisualBrush vb = new VisualBrush(_canvas);
190
                //ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
191
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X, Y = -finalItem.BorderSize.Y }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20)));
192
            }
193

    
194
            try
195
            {
196
                renderBitmap.Render(dv);
197

    
198
                GC.Collect();
199
                GC.WaitForPendingFinalizers();
200
                GC.Collect();
201
                //bitmap.Render(controlToConvert);
202
                // encode png data
203
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
204
                // puch rendered bitmap into it
205
                pngEncoder.Interlace = PngInterlaceOption.Off;
206
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
207
                return pngEncoder;
208

    
209
            }
210
            catch //(Exception ex)
211
            {
212
                return null;
213
            }
214

    
215
        }
216

    
217
        public async Task<PngBitmapEncoder> symImageAsync(string data, double PageAngle)
218
        {
219

    
220
            Canvas _canvas = new Canvas();
221
            _canvas.Background = Brushes.White;
222

    
223
            List<Rect> rects = new List<Rect>();
224

    
225
            finalItem.Members.ForEach(member =>
226
            {
227
                if(member?.DrawingData is MarkupToPDF.ICommentRect comment)
228
                {
229
                    rects.Add(comment.GetCommentRect());
230
                }
231
            });
232

    
233
            var rect = MathHelper.CombineRects(rects);
234

    
235
            _canvas.Width = rect.Width;
236
            _canvas.Height = rect.Height;
237

    
238
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
239

    
240
            BitmapEncoder encoder = new PngBitmapEncoder();
241
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96d, 96d, PixelFormats.Pbgra32);
242

    
243
            DrawingVisual dv = new DrawingVisual();
244
            //Window window = new Window();
245
            //window.Content = _canvas;
246
            //var result = window.ShowDialog();
247
            //if(result.GetValueOrDefault())
248
            //{
249

    
250
            //}
251

    
252
            _canvas.Measure(rect.Size);
253
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -rect.X + 35, Y = -rect.Y + 35 }, new Point(rect.Width + 35, rect.Height + 35)));
254

    
255
            using (DrawingContext ctx = dv.RenderOpen())
256
            {
257
                VisualBrush vb = new VisualBrush(_canvas);
258
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -rect.X, Y = -rect.Y }, new Point(rect.Width, rect.Height)));
259
            }
260
            Window window2 = new Window();
261
            window2.Content = _canvas;
262
            var result2 = window2.ShowDialog();
263
            if (result2.GetValueOrDefault())
264
            {
265

    
266
            }
267
            try
268
            {
269
                renderBitmap.Render(dv);
270

    
271
                GC.Collect();
272
                GC.WaitForPendingFinalizers();
273
                GC.Collect();
274
                //bitmap.Render(controlToConvert);
275
                // encode png data
276
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
277
                // puch rendered bitmap into it
278
                pngEncoder.Interlace = PngInterlaceOption.Off;
279
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
280
                return pngEncoder;
281

    
282
            }
283
            catch //(Exception ex)
284
            {
285
                return null;
286
            }
287

    
288
        }
289

    
290
        public void DialogMessage_Alert(string content, string header)
291
        {
292
            App.splashScreen.Close();
293

    
294
            DialogParameters parameters = new DialogParameters()
295
            {
296
                Owner = Application.Current.MainWindow,
297
                Content = new TextBlock()
298
                {
299
                    MinWidth = 400,
300
                    FontSize = 11,
301
                    Text = content,
302
                    TextWrapping = System.Windows.TextWrapping.Wrap
303
                },
304
                Header = header,
305
                Theme = new VisualStudio2013Theme(),
306
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
307
            };
308
            RadWindow.Alert(parameters);
309
        }
310

    
311
        #region Event
312

    
313
        #region Private Symbol Add Event
314
        private void Create_Symbol(object sender, RoutedEventArgs e)
315
        {
316
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
317

    
318
            if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면
319
            {
320
                DialogMessage_Alert("Please Select Controls", "Alert");
321
            }
322
            else //선택된 것이 있으면
323
            {
324
                string MarkupData = "";
325
                finalItem = new AdornerFinal();
326

    
327
                foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children)
328
                {
329
                    if (item.GetType().Name == "AdornerFinal")
330
                    {
331
                        finalItem = (item as Controls.AdornerFinal);
332
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
333
                        {
334
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
335
                            {
336
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
337
                                MarkupData += markupReturn.ConvertData;
338
                            }
339
                        }
340
                    }
341
                }
342
                DialogParameters parameters = new DialogParameters()
343
                {
344
                    Owner = Application.Current.MainWindow,
345
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
346
                    DefaultPromptResultValue = "Custom State",
347
                    Content = "Name :",
348
                    Header = "Insert Custom Symbol Name",
349
                    Theme = new VisualStudio2013Theme(),
350
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
351
                };
352
                RadWindow.Prompt(parameters);
353
            }
354

    
355
        }
356
        #endregion
357

    
358
        #region Symbol Add Close Event 
359
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
360
        {
361
            try
362
            {
363
                if (args.PromptResult != null)
364
                {
365
                    if (args.DialogResult.Value)
366
                    {
367
                        PngBitmapEncoder _Encoder = null;
368
                        
369
                        if (finalItem.Members.Any(x=> x.DrawingData is MarkupToPDF.ICommentRect comment))
370
                        {
371
                            _Encoder = await symImageAsync(data, ViewerDataModel.Instance.MarkupAngle);
372
                        }
373
                        else
374
                        {
375
                            _Encoder = await symImageAsync_old(data, ViewerDataModel.Instance.MarkupAngle);
376
                        }
377

    
378
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
379
                        _Encoder.Save(fs);
380
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
381

    
382
                        byte[] Img_byte = fs.ToArray();
383

    
384
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
385
                        filename = fileUploader.RunSymbol(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
386
                        Check_Uri.UriCheck(filename);
387
                        if (RadTab.SelectedIndex == 0)
388
                        {
389
                            SymbolSave(args.PromptResult, filename, data);
390
                        }
391
                        else
392
                        {
393
                            SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
394
                        }
395

    
396
                        await DataBindAsync();
397
                    }
398
                }
399
            }
400
            catch(Exception ex)
401
            {
402
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert");
403
            }
404
        }
405
        #endregion
406

    
407
        public void SymbolSave(string Name, string Url, string Data)
408
        {
409
            try
410
            {
411
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
412
                {
413
                    ID = Commons.shortGuid(),
414
                    MEMBER_USER_ID = App.ViewInfo.UserID,
415
                    NAME = Name,
416
                    IMAGE_URL = Url,
417
                    DATA = Data
418
                };
419

    
420
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
421
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
422
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
423
            }
424
            catch (Exception)
425
            {
426
                throw;
427
            }
428
        }
429

    
430
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
431
        {
432
            try
433
            {
434
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
435
                {
436
                    ID = Commons.shortGuid(),
437
                    DEPARTMENT = Department,
438
                    NAME = Name,
439
                    IMAGE_URL = Url,
440
                    DATA = Data
441
                };
442
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
443
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
444
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
445
            }
446
            catch (Exception)
447
            {
448
                throw;
449
            }
450
        }
451

    
452
        private async void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
453
        {
454
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
455
            await DataBindAsync();
456
        }
457

    
458
        private async void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
459
        {
460
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
461
            await DataBindAsync();
462
        }
463

    
464
        #region Private Symbol Delete Event
465
        private void Remove_Symbol(object sender, RoutedEventArgs e)
466
        {
467
            if (lstSymbolPrivate.SelectedItem == null)
468
            {
469
                DialogMessage_Alert("Please Select Symbol", "Alert");
470
                return;
471
            }
472
            string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
473

    
474
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
475
            //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
476
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
477
        }
478
        #endregion
479
        #region Public Symbol Delete Event
480
        private void Remove_Symbol_Public(object sender, RoutedEventArgs e)
481
        {
482
            if (lstSymbolPublic.SelectedItem == null)
483
            {
484
                DialogMessage_Alert("Please Select Symbol", "Alert");
485
                return;
486
            }
487
            string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
488

    
489
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted;
490
            //Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1);
491
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex);
492
        }
493

    
494
        private async void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e)
495
        {
496
            //Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
497
             await DataBindAsync();
498
        }
499
        #endregion
500

    
501
        public Undo_data UndoData { get; set; }
502
        /// <summary>
503
        /// place symbol which has given id to original position which is created
504
        /// </summary>
505
        /// <date>2018.06.14</date>
506
        /// <param name="id"></param>
507
        private async void PlaceSymbol(string id,Point CurrentMousePoint)
508
        {
509
            string Data_ = "";
510

    
511
            var systemMain = Common.ViewerDataModel.Instance.SystemMain;
512
            var mainMenu = systemMain.dzMainMenu;
513
            
514
            SelectionSet.Instance.UnSelect(mainMenu);  /// unselect alreay selected items
515

    
516
            try
517
            {
518
                //Logger.sendReqLog("GetSymbolData: ", id + "," + RadTab.SelectedIndex, 1);
519
                Data_ = mainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex);
520

    
521
                if (Data_ != null || Data_ != "")
522
                {
523
                    //Logger.sendResLog("GetSymbolData", "TRUE", 1);
524
                }
525
                else
526
                {
527
                    //Logger.sendResLog("GetSymbolData", "FALSE", 1);
528
                }
529

    
530
                //MARKUP_DATA_GROUP INSERT
531
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
532
                //{
533
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
534
                //    STATE = 0,
535
                //};
536
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
537
                ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
538

    
539
                if (Data_.Contains("|DZ|"))
540
                {
541
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
542

    
543
                    string[] delimiterChars = { "|DZ|" };
544
                    string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
545

    
546
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
547
                    UndoData = new Undo_data()
548
                    {
549
                        IsUndo = false,
550
                        Event = Event_Type.Create,
551
                        EventTime = DateTime.Now,
552
                        Markup_List = new List<Multi_Undo_data>()
553
                    };
554
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
555
                    {
556
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
557
                    });
558

    
559
                    foreach (string parse in data)
560
                    {
561
                        if (parse != "")
562
                        {
563
                            System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(),App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, string.Empty, string.Empty);
564
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
565
                            (item as MarkupToPDF.Common.CommentUserInfo).SymbolID = id;
566
                            //(item as MarkupToPDF.Common.CommentUserInfo).GroupID = group_id;
567

    
568
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
569
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
570

    
571
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
572

    
573
                            multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
574

    
575
                            UndoData.Markup_List.Add(multi_Undo_Data);
576
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
577
                        }
578
                    }
579

    
580
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
581

    
582
                    // 마우스 클릭된 페이지 위치
583

    
584
                    var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
585
                    var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
586
                    var angle = Common.ViewerDataModel.Instance.MarkupAngle;
587

    
588
                    Point pagePoint = new Point(pageWidth/2, pageHeight/2);
589

    
590
                    var rotatePoint = Rotate(mainMenu.CanvasDrawingMouseDownPoint,pagePoint,angle);
591

    
592
                    var diff = Point.Subtract(rotatePoint, final.Centeroid);
593
                    final.TranslateItems(diff.X, diff.Y);
594

    
595
                    mainMenu.SelectLayer.Children.Add(final);
596
                    //var finalPosition = new Point(Canvas.GetLeft(final), Canvas.GetTop(final));
597
                    //Rect rect = new Rect(finalPosition, Point.Add(finalPosition,new Vector(final.Width,final.Height)));
598

    
599
                    //SelectionSet.Instance.SelectItemByRect(final.getAdornerSize(), mainMenu);
600

    
601
                }
602
                else
603
                {
604
                    PlaceImageSymbol(id, 0);
605
                }
606
            }
607
            catch (Exception ex)
608
            {
609
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
610
            }
611
        }
612

    
613

    
614
        //출처: https://icodebroker.tistory.com/3189 [ICODEBROKER]
615
        public Point Rotate(Point sourcePoint, Point centerPoint, double rotateAngle)
616
        {
617
            Point targetPoint = new Point();
618

    
619
            double radian = rotateAngle / 180 * Math.PI;
620

    
621
            targetPoint.X = Math.Cos(radian) * (sourcePoint.X - centerPoint.X) - Math.Sin(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.X;
622
            targetPoint.Y = Math.Sin(radian) * (sourcePoint.X - centerPoint.X) + Math.Cos(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.Y;
623

    
624
            return targetPoint;
625
        }
626

    
627

    
628

    
629
        private void PlaceImageSymbol(string id, long group_id)
630
        {
631
           
632
            //canvasZoommovingMouseDownPoint
633
            string Data_ = "";
634

    
635
            try
636
            {
637
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + RadTab.SelectedIndex, 1);
638
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex);
639
                if (Data_ != null || Data_ != "")
640
                {
641
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
642
                }
643
                else
644
                {
645
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
646
                }
647

    
648
                //MARKUP_DATA_GROUP INSERT
649
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
650
                //{
651
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
652
                //    STATE = 0,
653
                //};
654
                //long group_id = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMarkupDataGroup(mARKUP_DATA_GROUP, App.ViewInfo.ProjectNO);
655
                ////Logger.sendReqLog("AddMarkupDataGroup: ", "", 1);
656

    
657
                if (Data_ != null)
658
                {
659
                    Image img = new Image();
660
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
661
                    if (Data_.Contains(".svg"))
662
                    {
663
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
664
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
665
                    }
666
                    else
667
                    {
668
                        img.Source = new BitmapImage(new Uri(Data_));
669
                    }
670

    
671
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
672
                    {
673
                        PointSet = new List<Point>(),
674
                        FilePath = Data_,
675
                        ImageData = img.Source,
676
                        StartPoint = new Point(0, 0),
677
                        EndPoint = new Point(img.Source.Width, img.Source.Height),
678
                        TopRightPoint = new Point(img.Source.Width, 0),
679
                        LeftBottomPoint = new Point(0, img.Source.Height)
680
                    };
681

    
682
                    currentControl.PointSet = new List<Point>
683
                                        {
684
                                            currentControl.StartPoint,
685
                                            currentControl.LeftBottomPoint,
686
                                            currentControl.EndPoint,
687
                                            currentControl.TopRightPoint,
688
                                        };
689
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
690
                    UndoData = new Undo_data()
691
                    {
692
                        IsUndo = false,
693
                        Event = Event_Type.Create,
694
                        EventTime = DateTime.Now,
695
                        Markup_List = new List<Multi_Undo_data>()
696
                    };
697
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
698
                    {
699
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
700
                    });
701

    
702
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
703
                    multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
704
                    UndoData.Markup_List.Add(multi_Undo_Data);
705
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
706

    
707
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
708
                    currentControl.CommentID = Commons.shortGuid();
709
                    currentControl.SymbolID = id;
710
                    currentControl.GroupID = group_id;
711
                    currentControl.ApplyTemplate();
712
                    currentControl.SetImage();
713

    
714
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
715
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
716
                    this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
717

    
718
                    /*
719
                    // this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true;
720
                    // final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
721
                    double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
722
                    double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
723
                      final.TranslateItems(realPointX, realPointY);
724
                    // move.control_Select(item, dragRect);
725
                    ApplyDragSelectionRect();
726
                    //this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol;
727
                    ///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left;
728
                    //this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/
729
                    
730
                }
731
            }
732
            catch(Exception ex)
733
            {
734
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
735
            }
736
        }
737

    
738
        public Multi_Undo_data multi_Undo_Data;
739
        private void ApplyDragSelectionRect()
740
        {
741
            multi_Undo_Data = new Multi_Undo_data();
742

    
743
            UndoData = new Undo_data()
744
            {
745
                IsUndo = false,
746
                Event = Event_Type.Select,
747
                EventTime = DateTime.Now,
748
                Markup_List = new List<Multi_Undo_data>()
749
            };
750

    
751
            this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed;
752

    
753
            double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
754
            double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder);
755
            double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width;
756
            double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height;
757
            Rect dragRect = new Rect(x, y, width, height);
758
            Boolean Flag = false;
759
            dragRect.Inflate(width / 10, height / 10);
760
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
761
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
762

    
763
            dragRect = new Rect(x, y, width, height);
764
            dragRect.Inflate(width / 10, height / 10);
765

    
766
            //move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting;
767
            //move.
768
            foreach (var item in Items)
769
            {
770
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
771

    
772
                if (Flag)
773
                {
774
                    adornerSet.Add(item);
775
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
776

    
777
                    this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item);
778
                    UndoData.Markup_List.Add(multi_Undo_Data);
779
                    multi_Undo_Data = new Multi_Undo_data();
780
                    if (item.GroupID > 0)
781
                    {
782

    
783
                    }
784
                }
785
            }
786
            if (adornerSet.Count > 0)
787
            {
788
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
789
                {
790
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
791
                });
792
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
793

    
794
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
795
                this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final);
796
            }
797
        }
798

    
799
        ///private Move move;
800
        #region Symbol DoubleClick Event
801
        private void Move_Symbol(object sender, MouseButtonEventArgs e)
802
        {
803
            try
804
            {
805
                Type type = e.OriginalSource.GetType();
806
                string id = string.Empty;
807
                //Logger.sendResLog("Move_Symbol", type.Name, 0);
808
                if (type.Name == "Image")
809
                {
810
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
811
                }
812
                else if (type.Name == "Border")
813
                {
814
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
815
                }
816
                else if (type.Name == "TextBox")
817
                {
818
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
819
                }
820

    
821
                IsMouseDown = true;
822

    
823
                if (e.ClickCount > 1)
824
                {
825
                    this.PlaceSymbol(id,ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
826
                }
827
            }
828
            catch(Exception ex)
829
            {
830
                //Logger.sendResLog("Move_Symbol", ex.Message, 0);
831
            }
832
        }
833
        #endregion
834

    
835
        #region Private Symbol Rename Event
836
        private void Rename_Symbol(object sender, RoutedEventArgs e)
837
        {
838
            if (lstSymbolPrivate.SelectedItem == null)
839
            {
840
                DialogMessage_Alert("Please Select Symbol", "Alert");
841
                return;
842
            }
843

    
844
            DialogParameters parameters = new DialogParameters()
845
            {
846
                Owner = Application.Current.MainWindow,
847
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
848
                //DefaultPromptResultValue = "Custom State",
849
                DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name,
850
                Content = "Name :",
851
                Header = "Update Custom Symbol Name",
852
                Theme = new VisualStudio2013Theme(),
853
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
854
            };
855
            RadWindow.Prompt(parameters);
856

    
857
        }
858
        #endregion
859

    
860
        #region Public Symbol Rename Event
861
        private void Rename_Symbol_Public(object sender, RoutedEventArgs e)
862
        {
863
            if (lstSymbolPublic.SelectedItem == null)
864
            {
865
                DialogMessage_Alert("Please Select Symbol", "Alert");
866
                return;
867
            }
868

    
869
            DialogParameters parameters = new DialogParameters()
870
            {
871
                Owner = Application.Current.MainWindow,
872
                Closed = (obj, args) => this.MarkupReNamePromptClose("", args),
873
                //DefaultPromptResultValue = "Custom State",
874
                DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name,
875
                Content = "Name :",
876
                Header = "Update Custom Symbol Name",
877
                Theme = new VisualStudio2013Theme(),
878
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
879
            };
880
            RadWindow.Prompt(parameters);
881

    
882
        }
883
        #endregion
884
        #region Symbol Rename Close Event
885
        private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args)
886
        {
887
            if (args.DialogResult != null && args.DialogResult.Value)
888
            {
889
                if(RadTab.SelectedIndex == 0)
890
                {
891
                    string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
892
                    string _name = args.PromptResult;
893
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
894
                    //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
895
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
896
                }
897
                else
898
                {
899
                    string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
900
                    string _name = args.PromptResult;
901
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
902
                    //Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1);
903
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex);
904
                }
905
            }
906
        }
907

    
908
        private async void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e)
909
        {
910
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
911
            await DataBindAsync();
912
        }
913
        #endregion
914

    
915
        #region Wheel Event
916
        private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
917
        {
918
            ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2));
919
        }
920
        private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
921
        {
922
            ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2));
923
        }
924
        #endregion
925

    
926
        #region Tab Selection Event
927
        private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
928
        {
929
            foreach (var item in (e.OriginalSource as RadTabControl).Items)
930
            {
931
                (item as RadTabItem).FontWeight = FontWeights.Normal;
932
            }
933
            ((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold;
934
        }
935
        #endregion
936

    
937
        #region Department Selection Event
938
        private async void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
939
        {
940
            await DataBindAsync();
941
        }
942
        #endregion
943

    
944
        #endregion
945

    
946
        private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e)
947
        {
948

    
949
        }
950

    
951
        private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e)
952
        {
953

    
954
        }
955

    
956
        private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e)
957
        {
958

    
959
        }
960

    
961
        private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
962
        {
963
            if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed)
964
            {
965
                ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id;
966
            }
967
            else
968
            {
969
                IsMouseDown = false;
970
            }
971
        }
972

    
973
        private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
974
        {
975
            IsMouseDown = false;
976
        }
977

    
978
        /// <summary>
979
        /// place symbol which user select
980
        /// </summary>
981
        /// <author>humkyung</author>
982
        /// <date>2018.06.14</date>
983
        /// <param name="sender"></param>
984
        /// <param name="e"></param>
985
        private void Place_Symbol(object sender, RoutedEventArgs e)
986
        {
987
            if (lstSymbolPrivate.SelectedItem == null)
988
            {
989
                DialogMessage_Alert("Please Select Symbol",  "Alert");
990
                return;
991
            }
992

    
993
            string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
994
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
995
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
996
        }
997

    
998
        private void Place_Symbol_Public(object sender, RoutedEventArgs e)
999
        {
1000
            if (lstSymbolPublic.SelectedItem == null)
1001
            {
1002
                DialogMessage_Alert("Please Select Symbol", "Alert");
1003
                return;
1004
            }
1005

    
1006
            string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
1007
            this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint);
1008
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None;
1009
        }
1010

    
1011
        private void Image_Place_Register(object sender, RoutedEventArgs e)
1012
        {
1013
            SyncInit();
1014
            ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl;
1015
            //캡쳐 하기 전에 코멘트 저장
1016
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0)
1017
            {
1018
                var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu;
1019
                SelectionSet.Instance.UnSelect(menu);
1020
                if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true)
1021
                {
1022
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
1023
                }
1024
                else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID)
1025
                {
1026

    
1027
                }
1028
                else
1029
                {
1030
                    (Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null);
1031
                }
1032
            }
1033
            Application.Current.MainWindow.Focus();
1034
            Common.ViewerDataModel.Instance.Capture_Opacity = 0.49;
1035
            (Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture;
1036
        }
1037

    
1038

    
1039
        private void SyncInit()
1040
        {
1041
            try
1042
            {
1043
                if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden)
1044
                {
1045
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true;
1046
                    ViewerDataModel.Instance.PageBalanceMode = false;
1047
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
1048
                    ViewerDataModel.Instance.SyncPageNumber = 0;
1049
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1050
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed;
1051
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false;
1052
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false;
1053
                }
1054
            }
1055
            catch (Exception ex)
1056
            {
1057
                //Logger.sendResLog("SyncInit", ex.Message, 0);
1058
            }
1059
        }
1060

    
1061
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1062
        {
1063
            var block = sender as TextBox;
1064
            block.Focusable = true;
1065
               
1066
        }
1067

    
1068
        private void TextBlock_MouseEnter(object sender, MouseEventArgs e)
1069
        {
1070
            var block = sender as TextBox;
1071
            if (block != null)
1072
            {
1073
                //block.Text = "Enter";
1074

    
1075
            }
1076
        }
1077

    
1078
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
1079
        {
1080
            if (e.Key == Key.Return)
1081
            {
1082
                Type type = e.OriginalSource.GetType();
1083
                string id = string.Empty;
1084
                //Logger.sendResLog("Move_Symbol", type.Name, 0);
1085
                if (type.Name == "Image")
1086
                {
1087
                    id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID;
1088
                }
1089
                else if (type.Name == "Border")
1090
                {
1091
                    id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID;
1092
                }
1093
                else if (type.Name == "TextBox")
1094
                {
1095
                    id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID;
1096
                }
1097

    
1098
                //((System.Windows.Controls.TextBox)sender).Text;
1099

    
1100
                if (RadTab.SelectedIndex == 0)
1101
                {
1102
                    //string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID;
1103
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1104
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1105
                    //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1106
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1107
                }
1108
                else
1109
                {
1110
                    //string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID;
1111
                    string _name = ((System.Windows.Controls.TextBox)sender).Text;
1112
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted;
1113
                    //Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1);
1114
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex);
1115
                }
1116
                
1117
            }
1118
        }
1119
        
1120
    }
1121
}
클립보드 이미지 추가 (최대 크기: 500 MB)