프로젝트

일반

사용자정보

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

markus / KCOM / Messenger / ConversationView.xaml.cs @ 787a4489

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

1 787a4489 KangIngu
using KCOM.Views;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Linq;
6
using System.Text;
7
using System.Windows;
8
using System.Windows.Controls;
9
using System.Windows.Data;
10
using System.Windows.Documents;
11
using System.Windows.Input;
12
using System.Windows.Media;
13
using System.Windows.Media.Imaging;
14
using System.Windows.Navigation;
15
using System.Windows.Shapes;
16
using Telerik.Windows.Controls;
17
namespace KCOM.Messenger
18
{
19
    /// <summary>
20
    /// Interaction logic for ConversationView.xaml
21
    /// </summary>
22
    public partial class ConversationView : UserControl, INotifyPropertyChanged
23
    {
24
        public Telerik.Windows.Controls.DelegateCommand ClickAnchorCommand { get; set; }
25
        MainWindow main;
26
27
        public ConversationView()
28
        {
29
            InitializeComponent();
30
            this.DataContext = this;
31
            this.Loaded += ConversationView_Loaded;
32
            btnMark.MouseLeftButtonDown += BtnMark_Click;
33
            btnMail.MouseLeftButtonDown += BtnMail_Click;
34
            btnFile.MouseLeftButtonDown += BtnFile_Click;
35
            //강인구 추가
36
            btnSend.PreviewMouseLeftButtonDown += BtnSend_Click;
37
        }
38
39
        private void BtnMark_Click(object sender, RoutedEventArgs e)
40
        {
41
            //MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
42
            if (main.dzMainMenu.SelectLayer.Children.Count > 0)
43
            {
44
                //this.ParentOfType<KCOM.Views.MainMenu>().zoomAndPanControl.ZoomTo(rect);
45
46
                DialogParameters parameters = new DialogParameters()
47
                {
48
                    Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args),
49
                    //DefaultPromptResultValue = "Custom State",
50
                    Content = "메모 :",
51
                    Header = "앵커에 대한 메모을 남겨주세요",
52
                    Theme = new VisualStudio2013Theme(),
53
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
54
                };
55
                RadWindow.Prompt(parameters);
56
57
58
            }
59
            else
60
            {
61
                MessageBox.Show("먼저 코멘트를 선택해주세요", "안내");
62
            }
63
        }
64
65
        private void BtnFile_Click(object sender, RoutedEventArgs e)
66
        {
67
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
68
        }
69
70
        private void BtnMail_Click(object sender, RoutedEventArgs e)
71
        {
72
            MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내");
73
        }
74
75
        //강인구 추가
76
        private void BtnSend_Click(object sender, MouseButtonEventArgs e)
77
        {
78
            AddText();
79
        }
80
81
        private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args)
82
        {
83
            if (args.DialogResult.Value)
84
            {
85
                if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null)
86
                {
87
                    MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내");
88
                }
89
                else
90
                {
91
                    Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal;
92
                    Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100));
93
94
                    using (KCOMDataModel.DataModel.CIEntities entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
95
                    {
96
                        Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
97
                        entity.TALK.AddObject(new KCOMDataModel.DataModel.TALK
98
                        {
99
                            TEXT = args.PromptResult,
100
                            MSGSIDE = (int)MessageSide.Me,
101
                            MEMBER_ID = App.ViewInfo.UserID,
102
                            MEMBER_NAME = String.IsNullOrEmpty(App.UserName) ? entity.MEMBER.Where(d => d.ID == App.ViewInfo.UserID).FirstOrDefault().NAME : App.UserName,
103
                            MSGTYPE = (int)MessageType.Anchor,
104
                            TIMESTAMP = DateTime.Now,
105
                            DOCUMENT_ID = App.ViewInfo.DocumentItemID,
106
                            RECT_X = rect.X,
107
                            RECT_Y = rect.Y,
108
                            RECT_WIDTH = rect.Width,
109
                            RECT_HEIGHT = rect.Height,
110
                            PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber,                             
111
                        });
112
                        entity.SaveChanges();
113
114
                        entity.TALK.Where(data => data.DOCUMENT_ID == App.ViewInfo.DocumentItemID).ToList().ForEach(a =>
115
                        {
116
                            Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
117
                        });
118
                    }
119
120
                    tbContent.Text = "";
121
                    tbContent.Focus();
122
123
                    //Common.ViewerDataModel.Instance.k_talkMessageSet.Add(new KCOMDataModel.DataModel.TALK
124
                    //{
125
                    //    Text = args.PromptResult,
126
                    //    Side = MessageSide.Me,
127
                    //    AnchorBound = rect,
128
                    //    UserName = "조장원",
129
                    //    PageNumber = main.dzMainMenu.pageNavigator.CurrentPage.PageNumber,
130
                    //    MsgStype = MessageType.Anchor,
131
                    //    Timestamp = DateTime.Now,
132
                    //});
133
                    //this.DataContext = this;
134
                }
135
            }
136
        }
137
138
        protected virtual void OnPropertyChanged(String info)
139
        {
140
            if (PropertyChanged != null)
141
                PropertyChanged(this, new PropertyChangedEventArgs(info));
142
        }
143
144
        private void SaveAuthorization(object parameter)
145
        {
146
            KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK;
147
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instance.PAGENUMBER.Value);
148
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(new Rect { X = instance.RECT_X.Value, Y = instance.RECT_Y.Value, Width = instance.RECT_WIDTH.Value, Height = instance.RECT_HEIGHT.Value });
149
        }
150
151
        public event PropertyChangedEventHandler PropertyChanged;
152
153
        private void ConversationView_Loaded(object sender, RoutedEventArgs e)
154
        {
155
            main = this.ParentOfType<MainWindow>();
156
            if (App.ParameterMode)
157
            {
158
                ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization);
159
160
                if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0)
161
                {
162
                    using (KCOMDataModel.DataModel.CIEntities entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
163
                    {
164
                        entity.TALK.Where(data => data.DOCUMENT_ID == App.ViewInfo.DocumentItemID).ToList().ForEach(a =>
165
                        {
166
                            Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
167
                        });
168
                    }
169
                }
170
                tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea);
171
            }
172
        }
173
174
        private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e)
175
        {
176
177
            if (e.Key == Key.Return)
178
            {
179
                if (Keyboard.Modifiers != ModifierKeys.Shift)
180
                {
181
                    AddText();
182
                    e.Handled = true;
183
                }
184
                else
185
                {
186
                    tbContent.Text = tbContent.Text + Environment.NewLine;
187
                    tbContent.CaretIndex = tbContent.Text.Length;
188
                    e.Handled = true;
189
                }
190
            }
191
        }
192
193
        private void AddText()
194
        {
195
            using (KCOMDataModel.DataModel.CIEntities entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
196
            {
197
                Common.ViewerDataModel.Instance.k_talkMessageSet.Clear();
198
                entity.TALK.AddObject(new KCOMDataModel.DataModel.TALK
199
                {
200
                    TEXT = tbContent.Text,
201
                    MSGSIDE = (int)MessageSide.Me,
202
                    MEMBER_ID = App.ViewInfo.UserID,
203
                    MEMBER_NAME = String.IsNullOrEmpty(App.UserName) ? entity.MEMBER.Where(d => d.ID == App.ViewInfo.UserID).FirstOrDefault().NAME : App.UserName ,
204
                    MSGTYPE = (int)MessageType.Normal,
205
                    TIMESTAMP = DateTime.Now,
206
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
207
                });
208
                entity.SaveChanges();
209
210
                entity.TALK.Where(data => data.DOCUMENT_ID == App.ViewInfo.DocumentItemID).ToList().ForEach(a =>
211
                {
212
                    Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a);
213
                });
214
            }
215
216
            tbContent.Text = "";
217
            tbContent.Focus();
218
219
            //강인구 추가
220
            (lstMessage.Parent as ScrollViewer).ScrollToEnd();
221
222
            //ReLoadTalkMessageSet();
223
            //Common.ViewerDataModel.Instance.k_talkMessageSet.Add(new Message
224
            //{
225
            //    Text = tbContent.Text,
226
            //    Side = MessageSide.Me,
227
            //    Timestamp = DateTime.Now,
228
            //});
229
230
            //tbContent.Text = "";
231
            //tbContent.Focus();
232
        }
233
    }
234
}
클립보드 이미지 추가 (최대 크기: 500 MB)