프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
                    Content = "메모 :",
52
                    Header = "앵커에 대한 메모을 남겨주세요",
53
                    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
                MessageBox.Show("먼저 코멘트를 선택해주세요", "안내");
63
            }
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
            if (args.DialogResult.Value)
85
            {
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
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
187
        {
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 0af41bf0 djkim
                    ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
200
                    if (string.IsNullOrEmpty(App.UserName) && Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData == null)
201 0f065e57 ljiyeon
                    {
202 0af41bf0 djkim
                        var member = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
203
                        if (member != null)
204
                            App.UserName = member.NAME;
205 0f065e57 ljiyeon
                    }
206 0af41bf0 djkim
                    if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
207 0f065e57 ljiyeon
                    {
208 0af41bf0 djkim
                        Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
209
                        List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
210
                        Logger.sendResLog("GetMessage", "messagelist.Count:" + messagelist.Count(), 1);
211
212
                        messagelist.ForEach(a =>
213
                        {
214
                            Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
215
                        });
216
                        (lstMessage.Parent as ScrollViewer).ScrollToEnd();
217 29010418 ljiyeon
                    }
218 0af41bf0 djkim
                    tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
219 c460df05 djkim
                }
220 ff01c725 humkyung
                catch (Exception ex)
221 787a4489 KangIngu
                {
222 0af41bf0 djkim
                    throw;
223 787a4489 KangIngu
                }
224
            }
225
        }
226
227
        private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e)
228
        {
229
230
            if (e.Key == Key.Return)
231
            {
232
                if (Keyboard.Modifiers != ModifierKeys.Shift)
233
                {
234
                    AddText();
235
                    e.Handled = true;
236
                }
237
                else
238
                {
239
                    tbContent.Text = tbContent.Text + Environment.NewLine;
240
                    tbContent.CaretIndex = tbContent.Text.Length;
241
                    e.Handled = true;
242
                }
243
            }
244
        }
245
246
        private void AddText()
247
        {
248 c460df05 djkim
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
249 29010418 ljiyeon
250 c460df05 djkim
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
251 787a4489 KangIngu
            {
252 c460df05 djkim
                TEXT = tbContent.Text,
253
                MSGSIDE = (int)MessageSide.Me,
254
                MEMBER_ID = App.ViewInfo.UserID,
255
                MEMBER_NAME = App.UserName,
256
                MSGTYPE = (int)MessageType.Normal,
257
                TIMESTAMP = DateTime.Now,
258
                DOCUMENT_ID = App.ViewInfo.DocumentItemID
259
            };
260 787a4489 KangIngu
261 0f065e57 ljiyeon
            Logger.sendReqLog("AddMessage", App.ViewInfo.ProjectNO + "," + message, 1);
262
            Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);
263
            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
264 787a4489 KangIngu
265 0f065e57 ljiyeon
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
266 29010418 ljiyeon
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
267 0f065e57 ljiyeon
            if (messagelist.Count() > 0)
268
            {
269
                Logger.sendResLog("GetMessage", "TRUE", 1);
270
            }
271
            else
272
            {
273
                Logger.sendResLog("GetMessage", "FALSE", 1);
274
            }
275 787a4489 KangIngu
276 c460df05 djkim
            messagelist.ForEach(a =>
277
            {
278
                Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
279
            });
280
            tbContent.Text = "";
281 29010418 ljiyeon
            tbContent.Focus();
282 c460df05 djkim
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
283 29010418 ljiyeon
284 787a4489 KangIngu
        }
285
    }
286
}
클립보드 이미지 추가 (최대 크기: 500 MB)