프로젝트

일반

사용자정보

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

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

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

1
using KCOM.Views;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Diagnostics;
6
using System.Linq;
7
using System.Text;
8
using System.Windows;
9
using System.Windows.Controls;
10
using System.Windows.Data;
11
using System.Windows.Documents;
12
using System.Windows.Input;
13
using System.Windows.Media;
14
using System.Windows.Media.Imaging;
15
using System.Windows.Navigation;
16
using System.Windows.Shapes;
17
using Telerik.Windows.Controls;
18
namespace KCOM.Messenger
19
{
20
    /// <summary>
21
    /// Interaction logic for ConversationView.xaml
22
    /// </summary>
23
    public partial class ConversationView : UserControl, INotifyPropertyChanged
24
    {
25
        public Telerik.Windows.Controls.DelegateCommand ClickAnchorCommand { get; set; }
26
        MainWindow main;
27

    
28
        public ConversationView()
29
        {
30
            InitializeComponent();
31
            
32
            this.DataContext = this;
33
            this.Loaded += ConversationView_Loaded;
34
            btnMark.MouseLeftButtonDown += BtnMark_Click;
35
            btnMail.MouseLeftButtonDown += BtnMail_Click;
36
            btnFile.MouseLeftButtonDown += BtnFile_Click;
37
            //강인구 추가
38
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
39
        }
40

    
41
        private void BtnMark_Click(object sender, RoutedEventArgs e)
42
        {
43
            if (main.dzMainMenu.SelectLayer.Children.Count > 0)
44
            {
45
                DialogParameters parameters = new DialogParameters()
46
                {
47
                    Owner = Application.Current.MainWindow,
48
                    Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args),
49
                    Content = "메모 :",
50
                    Header = "앵커에 대한 메모을 남겨주세요",
51
                    Theme = new VisualStudio2013Theme(),
52
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
53
                };
54
                RadWindow.Prompt(parameters);
55

    
56

    
57
            }
58
            else
59
            {
60
                MessageBox.Show("먼저 코멘트를 선택해주세요", "안내");
61
            }
62
        }
63

    
64
        private void BtnFile_Click(object sender, RoutedEventArgs e)
65
        {
66
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
67
        }
68

    
69
        private void BtnMail_Click(object sender, RoutedEventArgs e)
70
        {
71
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
72
        }
73

    
74
        //강인구 추가
75
        private void BtnSend_Click(object sender, MouseButtonEventArgs e)
76
        {
77
            AddText();
78
        }
79

    
80
        private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args)
81
        {
82
            if (args.DialogResult.Value)
83
            {
84
                if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null)
85
                {
86
                    MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내");
87
                }
88
                else
89
                {
90
                    Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal;
91
                    Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100));
92

    
93
                    var instanceMain = this.ParentOfType<MainWindow>();
94
                    if (instanceMain.dzMainMenu.rotate.Angle == 90)
95
                    {
96
                        rect = new Rect(new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100), new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100));                         
97
                        double y = rect.Y;
98
                        double x = rect.X;     
99
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
100
                        rect.Y = y;
101
                    }
102
                    else if(instanceMain.dzMainMenu.rotate.Angle == 180)
103
                    {
104
                        rect = new Rect(new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100), new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100));
105
                        double y = rect.Y;
106
                        double x = rect.X;
107
                        rect.X = instanceMain.dzMainMenu.zoomAndPanCanvas.Width - x - rect.Width;
108
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
109
                    }
110
                    else if(instanceMain.dzMainMenu.rotate.Angle == 270)
111
                    {
112
                        rect = new Rect(new Point(finalItem.BorderSize.Bottom + 100, finalItem.BorderSize.Left - 100), new Point(finalItem.BorderSize.Top - 100, finalItem.BorderSize.Right + 100));
113
                        double y = rect.Y;
114
                        double x = rect.X;
115
                        rect.X = x;
116
                        rect.Y = instanceMain.dzMainMenu.zoomAndPanCanvas.Height - y - rect.Height;
117
                    }
118

    
119
                    // Load 시 페이지 이동 없이 TALK 작성 시 Page값이 0으로 들어감, TALK TABLE에 PAGENUMBER가 0일 경우 Angle이 적용되지 않음.                 
120
                    if (Common.ViewerDataModel.Instance.PageNumber == 0) 
121
                    {
122
                        Common.ViewerDataModel.Instance.PageNumber = 1;
123
                    }
124
                    Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
125
                    KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
126
                    {
127
                        TEXT = args.PromptResult,
128
                        MSGSIDE = (int)MessageSide.Me,
129
                        MEMBER_ID = App.ViewInfo.UserID,
130
                        MEMBER_NAME = App.UserName,
131
                        MSGTYPE = (int)MessageType.Anchor,
132
                        TIMESTAMP = DateTime.Now,
133
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
134
                        RECT_X = rect.X,
135
                        RECT_Y = rect.Y,
136
                        RECT_WIDTH = rect.Width,
137
                        RECT_HEIGHT = rect.Height,
138
                        PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,
139
                        ANGLE = (int)instanceMain.dzMainMenu.rotate.Angle
140
                    };
141

    
142
                    Logger.sendReqLog("AddMessage: ", App.ViewInfo.ProjectNO + "," + message, 1);
143
                    Logger.sendResLog("AddMessage", Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message).ToString(), 1);                   
144
                    //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
145

    
146
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);                  
147
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);                    
148
                    if(messagelist.Count() > 0)
149
                    {
150
                        Logger.sendResLog("GetMessage", "TRUE", 1);
151
                    }
152
                    else
153
                    {
154
                        Logger.sendResLog("GetMessage", "FALSE", 1);
155
                    }
156
                    messagelist.ForEach(a =>
157
                    {
158
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
159
                    });
160

    
161
                    tbContent.Text = "";
162
                    tbContent.Focus();
163
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
164
                }
165
            }
166
        }
167

    
168
        protected virtual void OnPropertyChanged(String info)
169
        {
170
            if (PropertyChanged != null)
171
                PropertyChanged(this, new PropertyChangedEventArgs(info));
172
        }
173

    
174
        private void SaveAuthorization(object parameter)
175
        {
176
            KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK;
177
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle = instance.ANGLE; 
178
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPageTALK(instance.PAGENUMBER.Value, instance.ANGLE);
179
            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);
180
        }
181

    
182
        public event PropertyChangedEventHandler PropertyChanged;
183

    
184
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
185
        {
186
            //측정
187
            //Stopwatch sw = new Stopwatch();
188
            //sw.Start();
189
            //InitializeComponent();
190
            //System.Diagnostics.Debug.WriteLine("ConversationView() : " + sw.ElapsedMilliseconds.ToString() + "ms");
191
            
192
            main = this.ParentOfType<MainWindow>();
193
            if (App.ParameterMode)
194
            {
195
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
196
                if (string.IsNullOrEmpty(App.UserName))
197
                {
198
                    Logger.sendReqLog("GetMember: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.UserID, 1);                  
199
                    App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME;
200
                    if(App.UserName != null || App.UserName != "")
201
                    {
202
                        Logger.sendResLog("AddMessage", "TRUE", 1);
203
                    }
204
                    else
205
                    {
206
                        Logger.sendResLog("AddMessage", "FALSE", 1);
207
                    }                    
208
                }
209
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
210
                {
211
                    Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
212
                    List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);
213
                    if (messagelist.Count() > 0)
214
                    {
215
                        Logger.sendResLog("GetMessage", "TRUE", 1);
216
                    }
217
                    else
218
                    {
219
                        Logger.sendResLog("GetMessage", "FALSE", 1);
220
                    }
221
                    messagelist.ForEach(a =>
222
                    {
223
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
224
                    });
225
                    (lstMessage.Parent as ScrollViewer).ScrollToEnd();
226
                }
227
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
228

    
229
            }
230
        }
231

    
232
        private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e)
233
        {
234

    
235
            if (e.Key == Key.Return)
236
            {
237
                if (Keyboard.Modifiers != ModifierKeys.Shift)
238
                {
239
                    AddText();
240
                    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
        private void AddText()
252
        {
253
            Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
254
            
255
            KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK
256
            {
257
                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

    
266
            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
            //Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message);
269

    
270
            Logger.sendReqLog("GetMessage: ", App.ViewInfo.ProjectNO + "," + App.ViewInfo.DocumentItemID, 1);
271
            List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID);            
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
            
289
        }
290
    }
291
}
클립보드 이미지 추가 (최대 크기: 500 MB)