프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ master

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