프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ ca16abb2

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

1 787a4489 KangIngu
using KCOM.Common;
2
using KCOMDataModel;
3
using KCOMDataModel.DataModel;
4
using System;
5
using System.Collections.Generic;
6 6707a5c7 ljiyeon
using System.IO;
7 787a4489 KangIngu
using System.Linq;
8 71bfd53e ljiyeon
using System.Runtime.InteropServices;
9 787a4489 KangIngu
using System.Text;
10
using System.Windows;
11
using System.Windows.Controls;
12
using System.Windows.Data;
13
using System.Windows.Documents;
14
using System.Windows.Input;
15
using System.Windows.Media;
16
using System.Windows.Media.Imaging;
17
using System.Windows.Navigation;
18
using System.Windows.Shapes;
19 6707a5c7 ljiyeon
using System.Xml;
20 992a98b4 KangIngu
using Telerik.Windows.Controls;
21 787a4489 KangIngu
22
namespace KCOM
23
{
24
    /// <summary>
25
    /// MainWindow.xaml에 대한 상호 작용 논리
26
    /// </summary>
27
    public partial class MainWindow : Window
28
    {
29
        
30
        public MainWindow()
31
        {
32 0c997b99 ljiyeon
            //InitializeComponent();
33 787a4489 KangIngu
            this.Loaded += MainWindow_Loaded;
34
            this.KeyDown += new KeyEventHandler(KeyEventDownAction);
35
            this.KeyUp += new KeyEventHandler(KeyEventUpAction);
36
        }
37 ca16abb2 ljiyeon
38
        public static BitmapImage CursorChange()
39
        {
40
            BitmapImage bmp = new BitmapImage();
41
            bmp.BeginInit();
42
            bmp.StreamSource = System.Windows.Application.GetResourceStream(new Uri("/KCOM;Component/Resources/Cursor/customCursor2.cur", UriKind.Relative)).Stream;
43
            return bmp;
44
        }
45
46 787a4489 KangIngu
        public void DialogMessage_Alert(string content, string header)
47
        {
48
            var box = new TextBlock();
49
            box.MinWidth = 400;
50
            box.FontSize = 12;
51
            box.Text = content;
52
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
53
54
            Telerik.Windows.Controls.DialogParameters parameters = new Telerik.Windows.Controls.DialogParameters()
55
            {
56
                Content = box,
57
                Header = header,
58
                Theme = new Telerik.Windows.Controls.VisualStudio2013Theme(),
59
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
60
            };
61
            Telerik.Windows.Controls.RadWindow.Alert(parameters);
62
        }
63 6c781c0c djkim
                
64 787a4489 KangIngu
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
65
        {
66 0c997b99 ljiyeon
            InitializeComponent();
67 ca16abb2 ljiyeon
68
            //cursor change  
69
            this.Cursor = new Cursor(CursorChange().StreamSource);
70
71 787a4489 KangIngu
            double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
72
            double screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
73 9f473fb7 KangIngu
            //this.Width += 40;
74 787a4489 KangIngu
            double windowWidth = this.Width;
75
            double windowHeight = this.Height;
76
            this.Left = (screenWidth / 2) - (windowWidth / 2);
77
            this.Top = (screenHeight / 2) - (windowHeight / 2);
78
79
80
            ViewerDataModel.Instance.SystemMain = this;
81
82
            if (!App.ParameterMode)
83
            {
84
                //App.ViewInfo = new IKCOM.ViewInfo
85
                //{
86
                //    DocumentItemID = "11111112",
87
                //    //DocumentItemID = "10001",
88
                //    bPartner = false,
89
                //    CreateFinalPDFPermission = true,
90
                //    NewCommentPermission = true,
91
                //    ProjectNO = "000000",
92
                //    UserID = "H2011357",
93
                //    //UserID = "H2009115",
94
                //    //Mode = 0 , 1 , 2
95
                //};
96
                //DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
97
98
//#if DEBUG
99
//                App.ViewInfo = new IKCOM.ViewInfo
100
//                {
101
//                    DocumentItemID = "11111112",
102
//                    //DocumentItemID = "10001",
103
//                    bPartner = false,
104
//                    CreateFinalPDFPermission = true,
105
//                    NewCommentPermission = true,
106
//                    ProjectNO = "000000",
107
//                    UserID = "H2011357",
108
//                    //UserID = "H2009115",
109
//                    //Mode = 0 , 1 , 2
110
//                };
111
//                App.ParameterMode = true;
112
//                this.dzMainMenu.ServiceOn();
113
//                this.dzMainMenu.SetView(App.ViewInfo);
114
//#else
115
116
                DialogMessage_Alert("데모버전은 단독 실행모드를 지원하지 않습니다", "안내");
117
                this.dzMainMenu.pageNavigator.Visibility = Visibility.Collapsed;
118
                this.dzMainMenu.historyPane.Visibility = Visibility.Collapsed;
119
                this.dzMainMenu.infoListPane.Visibility = Visibility.Collapsed;
120
                this.dzMainMenu.searchPane.Visibility = Visibility.Collapsed;
121
                this.dzMainMenu.talkPane.Visibility = Visibility.Collapsed;
122
//#endif
123
            }
124
            else
125
            {
126
                this.dzMainMenu.ServiceOn();
127 992a98b4 KangIngu
128
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
129
                {
130
                    this.dzTopMenu.radRibbonView.HelpButtonVisibility = Visibility.Collapsed;
131
                    var list = this.dzTopMenu.ChildrenOfType<RadRibbonTab>().ToList();
132
                    list.ForEach(item => item.Visibility = Visibility.Collapsed);
133
                    this.dzTopMenu.ribbontab_ReadOnly.Visibility = Visibility.Visible;
134
                    this.dzTopMenu.radRibbonView.SelectedItem = this.dzTopMenu.ribbontab_ReadOnly;
135 e0204db0 djkim
                    //this.dzMainMenu.SymbolPane.Visibility = Visibility.Collapsed;
136
                    //this.dzMainMenu.FavoritePane.Visibility = Visibility.Collapsed;
137
                    //this.dzMainMenu.drawingRotateCanvas.IsHitTestVisible = false;
138 992a98b4 KangIngu
                }
139 787a4489 KangIngu
                this.dzMainMenu.SetView(App.ViewInfo);
140 6707a5c7 ljiyeon
                this.dzMainMenu.HubSet();              
141 787a4489 KangIngu
            }
142 6707a5c7 ljiyeon
143 787a4489 KangIngu
            //App.ViewInfo = new IKCOM.ViewInfo
144
            //{
145
            //    DocumentItemID = "11111112",
146
            //    //DocumentItemID = "10001",
147
            //    bPartner = false,
148
            //    CreateFinalPDFPermission = true,
149
            //    NewCommentPermission = true,
150
            //    ProjectNO = "000000",
151
            //    UserID = "H2011357",
152
            //    //UserID = "H2009115",
153
            //    //Mode = 0 , 1 , 2
154
            //};
155
156
            //this.dzMainMenu.ServiceOn();
157
            //this.dzMainMenu.SetView(App.ViewInfo);
158
        }
159 6707a5c7 ljiyeon
160 71bfd53e ljiyeon
161
        bool restoreIfMove = false;        
162
163 787a4489 KangIngu
        private void WindowDragEvent(object sender, MouseButtonEventArgs e)
164
        {
165 71bfd53e ljiyeon
            if (e.ClickCount == 2)
166 787a4489 KangIngu
            {
167 71bfd53e ljiyeon
                if ((ResizeMode == ResizeMode.CanResize) ||
168
                    (ResizeMode == ResizeMode.CanResizeWithGrip))
169 787a4489 KangIngu
                {
170 71bfd53e ljiyeon
                    SwitchState();
171 787a4489 KangIngu
                }
172
            }
173
            else
174
            {
175 71bfd53e ljiyeon
                if (WindowState == WindowState.Maximized)
176
                {
177
                    restoreIfMove = true;
178
                }
179
180 787a4489 KangIngu
                this.DragMove();
181
            }
182
        }
183
184 71bfd53e ljiyeon
        private void WindowDragEventUp(object sender, MouseButtonEventArgs e)
185
        {
186
            restoreIfMove = false;
187
        }
188
189
        private void WindowDragEventMove(object sender, MouseEventArgs e)
190
        {
191
            if (restoreIfMove)
192
            {
193
                if (Mouse.LeftButton == MouseButtonState.Pressed)
194
                {
195
                    //this.WindowState = WindowState.Normal;
196
197
                    restoreIfMove = false;
198
199
                    double percentHorizontal = e.GetPosition(this).X / ActualWidth;
200
                    double targetHorizontal = RestoreBounds.Width * percentHorizontal;
201
202
                    double percentVertical = e.GetPosition(this).Y / ActualHeight;
203
                    double targetVertical = RestoreBounds.Height * percentVertical;
204
205
                    POINT lMousePosition;
206
                    GetCursorPos(out lMousePosition);                    
207
208
                    Left = lMousePosition.X - targetHorizontal;
209
                    Top = lMousePosition.Y - targetVertical;
210
211
212
                    WindowState = WindowState.Normal;
213
214
                    this.DragMove();
215
                }
216
            }
217
        }
218
219
        [DllImport("user32.dll")]
220
        [return: MarshalAs(UnmanagedType.Bool)]
221
        static extern bool GetCursorPos(out POINT lpPoint);
222
223
        [StructLayout(LayoutKind.Sequential)]
224
        public struct POINT
225
        {
226
            public int X;
227
            public int Y;
228
229
            public POINT(int x, int y)
230
            {
231
                this.X = x;
232
                this.Y = y;
233
            }
234
        }
235
236
        private void SwitchState()
237
        {
238
            switch (WindowState)
239
            {
240
                case WindowState.Normal:
241
                    {
242
                        WindowState = WindowState.Maximized;
243
                        break;
244
                    }
245
                case WindowState.Maximized:
246
                    {
247
                        WindowState = WindowState.Normal;
248
                        break;
249
                    }
250
            }
251
        }
252
253 787a4489 KangIngu
        private void RadButton_Click(object sender, RoutedEventArgs e)
254
        {
255
            Telerik.Windows.Controls.RadButton button = sender as Telerik.Windows.Controls.RadButton;
256
257
            switch (button.CommandParameter.ToString())
258
            {
259
                case ("Min"):
260
                    {
261
                        WindowState = WindowState.Minimized;
262
                    }
263
                    break;
264
                case ("Max"):
265
                    {
266
                        WindowState = WindowState.Maximized;
267
                    }
268
                    break;
269
                case ("Exit"):
270
                    {
271
272
                    }
273
                    break;
274
            }
275
        }
276
277
        private void WinState(object sender, MouseButtonEventArgs e)
278
        {
279 af177ca1 djkim
            switch ((e.Source as Image).Name)
280 787a4489 KangIngu
            {
281 af177ca1 djkim
                case ("Win_min"):
282 787a4489 KangIngu
                    {
283
                        WindowState = WindowState.Minimized;
284
                    }
285
                    break;
286 af177ca1 djkim
                case ("Win_max"):
287 787a4489 KangIngu
                    {
288 af177ca1 djkim
                        if (WindowState == WindowState.Maximized)
289
                        {
290 787a4489 KangIngu
                            WindowState = WindowState.Normal;
291 af177ca1 djkim
                        }
292 787a4489 KangIngu
                        else
293 af177ca1 djkim
                        {
294 787a4489 KangIngu
                            WindowState = WindowState.Maximized;
295 af177ca1 djkim
                        }
296 787a4489 KangIngu
                    }
297
                    break;
298 af177ca1 djkim
                case ("Win_Close"):
299 787a4489 KangIngu
                    {
300 316d0f5c KangIngu
                        if (ViewerDataModel.Instance.UndoDataList.Count > 0)
301 69ef0800 KangIngu
                        {
302 316d0f5c KangIngu
                            DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
303 d2cd1e16 djkim
                            DateTime updatetime = DateTime.Now.AddDays(-1);
304
                            if (ViewerDataModel.Instance._markupInfoList.Count > 0)
305
                            {
306
                                updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
307
                            }
308 6707a5c7 ljiyeon
309 316d0f5c KangIngu
                            if (undoTime > updatetime)
310
                            {
311 69ef0800 KangIngu
                                var box = new TextBlock();
312
                                box.MinWidth = 400;
313
                                box.FontSize = 11;
314
                                box.Text = "저장되지 않은 코멘트가 있습니다. 저장 하시겠습니까?";
315
                                box.TextWrapping = System.Windows.TextWrapping.Wrap;
316
317
                                DialogParameters parameters = new DialogParameters()
318
                                {
319
                                    Content = box,
320
                                    Header = "Confirm",
321
                                    Theme = new VisualStudio2013Theme(),
322
                                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
323
                                    Closed = Onclose,
324
                                };
325
                                RadWindow.Confirm(parameters);
326
                            }
327 316d0f5c KangIngu
                        }
328 787a4489 KangIngu
                        this.Close();
329
                    }
330
                    break;
331
            }
332
        }
333
334 69ef0800 KangIngu
        private void Onclose(object sender, WindowClosedEventArgs e)
335
        {
336
            if (e.DialogResult == true)
337
            {
338
                dzTopMenu.SaveEvent(null, null);
339
            }
340
        }
341 787a4489 KangIngu
    }
342
}
클립보드 이미지 추가 (최대 크기: 500 MB)