프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ 97eba451

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

1 e0cfc73c ljiyeon
using KCOM.Common;
2
using KCOM.Views;
3 787a4489 KangIngu
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6 0c997b99 ljiyeon
using System.Diagnostics;
7 787a4489 KangIngu
using System.Linq;
8
using System.Text;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Data;
12
using System.Windows.Documents;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using System.Windows.Navigation;
17
using System.Windows.Shapes;
18
using Telerik.Windows.Controls;
19
namespace KCOM.Messenger
20
{
21
    /// <summary>
22
    /// Interaction logic for ConversationView.xaml
23
    /// </summary>
24
    public partial class ConversationView : UserControl, INotifyPropertyChanged
25
    {
26
        public Telerik.Windows.Controls.DelegateCommand ClickAnchorCommand { get; set; }
27
        MainWindow main;
28
29
        public ConversationView()
30
        {
31 e0cfc73c ljiyeon
            App.splashString(ISplashMessage.CONVERSATIONVIEW);
32 fd4e6a36 djkim
            InitializeComponent();
33 787a4489 KangIngu
            this.DataContext = this;
34 e0cfc73c ljiyeon
            
35 787a4489 KangIngu
            this.Loaded += ConversationView_Loaded;
36 fd4e6a36 djkim
            btnMark.MouseLeftButtonDown += BtnMark_Click;
37
            btnMail.MouseLeftButtonDown += BtnMail_Click;
38
            btnFile.MouseLeftButtonDown += BtnFile_Click;
39
            //강인구 추가
40
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
41 787a4489 KangIngu
        }
42
43
        private void BtnMark_Click(object sender, RoutedEventArgs e)
44
        {
45
            if (main.dzMainMenu.SelectLayer.Children.Count > 0)
46
            {
47
                DialogParameters parameters = new DialogParameters()
48
                {
49 b9b01f8e ljiyeon
                    Owner = Application.Current.MainWindow,
50 787a4489 KangIngu
                    Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args),
51 f65e6c02 taeseongkim
                    Content = "Memo :",
52
                    Header = "Make a note About the Anchor",
53 787a4489 KangIngu
                    Theme = new VisualStudio2013Theme(),
54
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
55
                };
56
                RadWindow.Prompt(parameters);
57
58
59
            }
60
            else
61
            {
62 f65e6c02 taeseongkim
                MessageBox.Show("Please Select a comment first", "Info");
63 787a4489 KangIngu
            }
64
        }
65
66
        private void BtnFile_Click(object sender, RoutedEventArgs e)
67
        {
68
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
69
        }
70
71
        private void BtnMail_Click(object sender, RoutedEventArgs e)
72
        {
73
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
74
        }
75
76
        //강인구 추가
77
        private void BtnSend_Click(object sender, MouseButtonEventArgs e)
78
        {
79
            AddText();
80
        }
81
82
        private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args)
83
        {
84 f65e6c02 taeseongkim
            if (args.DialogResult.GetValueOrDefault())
85 787a4489 KangIngu
            {
86
                if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null)
87
                {
88
                    MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내");
89
                }
90
                else
91
                {
92
                    Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal;
93
                    Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100));
94 d974f3f8 ljiyeon
95
                    var instanceMain = this.ParentOfType<MainWindow>();
96
                    if (instanceMain.dzMainMenu.rotate.Angle == 90)
97
                    {
98 29010418 ljiyeon
                        rect = new Rect(new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100), new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100));
99 d974f3f8 ljiyeon
                        double y = rect.Y;
100 29010418 ljiyeon
                        double x = rect.X;
101 d974f3f8 ljiyeon
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
102
                        rect.Y = y;
103
                    }
104 29010418 ljiyeon
                    else if (instanceMain.dzMainMenu.rotate.Angle == 180)
105 d974f3f8 ljiyeon
                    {
106
                        rect = new Rect(new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100), new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100));
107
                        double y = rect.Y;
108
                        double x = rect.X;
109
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
110
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
111
                    }
112 29010418 ljiyeon
                    else if (instanceMain.dzMainMenu.rotate.Angle == 270)
113 d974f3f8 ljiyeon
                    {
114
                        rect = new Rect(new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100), new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100));
115
                        double y = rect.Y;
116
                        double x = rect.X;
117
                        rect.X = x;
118
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
119
                    }
120
121
                    // Load 시 페이지 이동 없이 TALK 작성 시 Page값이 0으로 들어감, TALK TABLE에 PAGENUMBER가 0일 경우 Angle이 적용되지 않음.                 
122 29010418 ljiyeon
                    if (Common.ViewerDataModel.Instance.PageNumber == 0)
123 d974f3f8 ljiyeon
                    {
124
                        Common.ViewerDataModel.Instance.PageNumber = 1;
125
                    }
126 90e7968d ljiyeon
                    //Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
127 c460df05 djkim
                    KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
128
                    {
129
                        TEXT = args.PromptResult,
130
                        MSGSIDE = (int)MessageSide.Me,
131
                        MEMBER_ID = App.ViewInfo.UserID,
132
                        MEMBER_NAME = App.UserName,
133
                        MSGTYPE = (int)MessageType.Anchor,
134
                        TIMESTAMP = DateTime.Now,
135
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
136
                        RECT_X = rect.X,
137
                        RECT_Y = rect.Y,
138
                        RECT_WIDTH = rect.Width,
139
                        RECT_HEIGHT = rect.Height,
140 d974f3f8 ljiyeon
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
141
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
142 c460df05 djkim
                    };
143
144 0f065e57 ljiyeon
                    Logger.sendReqLog("AddMessage: ", App.ViewInfo.ProjectNO + "," + message, 1);
145 29010418 ljiyeon
                    Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
146 0f065e57 ljiyeon
                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
147 c460df05 djkim
148 29010418 ljiyeon
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
149
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
150
                    if (messagelist.Count() > 0)
151 0f065e57 ljiyeon
                    {
152
                        Logger.sendResLog("GetMessage", "TRUE", 1);
153
                    }
154
                    else
155
                    {
156
                        Logger.sendResLog("GetMessage", "FALSE", 1);
157
                    }
158 c460df05 djkim
                    messagelist.ForEach(a =>
159 787a4489 KangIngu
                    {
160 c460df05 djkim
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
161
                    });
162 787a4489 KangIngu
163
                    tbContent.Text = "";
164
                    tbContent.Focus();
165 c460df05 djkim
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
166 787a4489 KangIngu
                }
167
            }
168
        }
169
170
        protected virtual void OnPropertyChanged(String info)
171
        {
172
            if (PropertyChanged != null)
173
                PropertyChanged(this, new PropertyChangedEventArgs(info));
174
        }
175
176
        private void SaveAuthorization(object parameter)
177
        {
178
            KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK;
179 29010418 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = instance.ANGLE;
180 d974f3f8 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPageTALK(instance.PAGENUMBER.Value, instance.ANGLE);
181 29010418 ljiyeon
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomToTalk(new Rect { X = instance.RECT_X.Value, Y = instance.RECT_Y.Value, Width = instance.RECT_WIDTH.Value, Height = instance.RECT_HEIGHT.Value }, instance.ANGLE);
182 787a4489 KangIngu
        }
183
184
        public event PropertyChangedEventHandler PropertyChanged;
185
186 e8557bd7 taeseongkim
        private async void ConversationView_Loaded(object sender, RoutedEventArgs e)
187 787a4489 KangIngu
        {
188 0c997b99 ljiyeon
            //측정
189
            //Stopwatch sw = new Stopwatch();
190
            //sw.Start();
191 fd4e6a36 djkim
            //InitializeComponent();
192 0c997b99 ljiyeon
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
193 29010418 ljiyeon
194 787a4489 KangIngu
            main = this.ParentOfType<MainWindow>();
195
            if (App.ParameterMode)
196
            {
197 0af41bf0 djkim
                try
198 c460df05 djkim
                {
199 e8557bd7 taeseongkim
                    var mainMenu = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu;
200
201 0af41bf0 djkim
                    ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
202 e8557bd7 taeseongkim
                    if (string.IsNullOrEmpty(App.UserName) && mainMenu.userData == null)
203 0f065e57 ljiyeon
                    {
204 e8557bd7 taeseongkim
                        var member = await mainMenu.BaseTaskClient.GetMemberAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
205 0af41bf0 djkim
                        if (member != null)
206
                            App.UserName = member.NAME;
207 0f065e57 ljiyeon
                    }
208 0af41bf0 djkim
                    if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
209 0f065e57 ljiyeon
                    {
210 0af41bf0 djkim
                        Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
211 e8557bd7 taeseongkim
                        List<KCOMDataModel.DataModel.TALK> messagelist = await mainMenu.BaseTaskClient.GetMessageAsync(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
212
213 0af41bf0 djkim
                        Logger.sendResLog("GetMessage", "messagelist.Count:" + messagelist.Count(), 1);
214
215
                        messagelist.ForEach(a =>
216
                        {
217
                            Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
218
                        });
219
                        (lstMessage.Parent as ScrollViewer).ScrollToEnd();
220 29010418 ljiyeon
                    }
221 e8557bd7 taeseongkim
222 97eba451 taeseongkim
                    tbContent.KeyDown += OnKeyDownHandler;
223 c460df05 djkim
                }
224 ff01c725 humkyung
                catch (Exception ex)
225 787a4489 KangIngu
                {
226 0af41bf0 djkim
                    throw;
227 787a4489 KangIngu
                }
228
            }
229
        }
230
231 97eba451 taeseongkim
        private void OnKeyDownHandler(object sender, KeyEventArgs e)
232 787a4489 KangIngu
        {
233
            if (e.Key == Key.Return)
234
            {
235
                if (Keyboard.Modifiers != ModifierKeys.Shift)
236
                {
237
                    AddText();
238
                    e.Handled = true;
239
                }
240
                else
241
                {
242
                    tbContent.Text = tbContent.Text + Environment.NewLine;
243
                    tbContent.CaretIndex = tbContent.Text.Length;
244
                    e.Handled = true;
245
                }
246
            }
247
        }
248
249
        private void AddText()
250
        {
251 c460df05 djkim
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
252 29010418 ljiyeon
253 c460df05 djkim
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
254 787a4489 KangIngu
            {
255 c460df05 djkim
                TEXT = tbContent.Text,
256
                MSGSIDE = (int)MessageSide.Me,
257
                MEMBER_ID = App.ViewInfo.UserID,
258
                MEMBER_NAME = App.UserName,
259
                MSGTYPE = (int)MessageType.Normal,
260
                TIMESTAMP = DateTime.Now,
261
                DOCUMENT_ID = App.ViewInfo.DocumentItemID
262
            };
263 787a4489 KangIngu
264 0f065e57 ljiyeon
            Logger.sendReqLog("AddMessage", App.ViewInfo.ProjectNO + "," + message, 1);
265
            Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
266
            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
267 787a4489 KangIngu
268 0f065e57 ljiyeon
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
269 29010418 ljiyeon
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
270 0f065e57 ljiyeon
            if (messagelist.Count() > 0)
271
            {
272
                Logger.sendResLog("GetMessage", "TRUE", 1);
273
            }
274
            else
275
            {
276
                Logger.sendResLog("GetMessage", "FALSE", 1);
277
            }
278 787a4489 KangIngu
279 c460df05 djkim
            messagelist.ForEach(a =>
280
            {
281
                Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
282
            });
283
            tbContent.Text = "";
284 29010418 ljiyeon
            tbContent.Focus();
285 c460df05 djkim
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
286 29010418 ljiyeon
287 787a4489 KangIngu
        }
288
    }
289
}
클립보드 이미지 추가 (최대 크기: 500 MB)