프로젝트

일반

사용자정보

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

markus / KCOM / MainWindow.xaml.cs @ 114015fd

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