프로젝트

일반

사용자정보

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

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

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