markus / KCOM / Messenger / ConversationView.xaml.cs @ 3d425b19
이력 | 보기 | 이력해설 | 다운로드 (8.34 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 | if (main.dzMainMenu.SelectLayer.Children.Count > 0) |
||
42 | { |
||
43 | DialogParameters parameters = new DialogParameters() |
||
44 | { |
||
45 | Closed = (obj, args) => this.MarkupNameUpdatePromptClose(args), |
||
46 | Content = "메모 :", |
||
47 | Header = "앵커에 대한 메모을 남겨주세요", |
||
48 | Theme = new VisualStudio2013Theme(), |
||
49 | ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
||
50 | }; |
||
51 | RadWindow.Prompt(parameters); |
||
52 | |||
53 | |||
54 | } |
||
55 | else |
||
56 | { |
||
57 | MessageBox.Show("먼저 코멘트를 선택해주세요", "안내"); |
||
58 | } |
||
59 | } |
||
60 | |||
61 | private void BtnFile_Click(object sender, RoutedEventArgs e) |
||
62 | { |
||
63 | MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내"); |
||
64 | } |
||
65 | |||
66 | private void BtnMail_Click(object sender, RoutedEventArgs e) |
||
67 | { |
||
68 | MessageBox.Show("데모 버전에서는 지원하지 않습니다", "안내"); |
||
69 | } |
||
70 | |||
71 | //강인구 추가 |
||
72 | private void BtnSend_Click(object sender, MouseButtonEventArgs e) |
||
73 | { |
||
74 | AddText(); |
||
75 | } |
||
76 | |||
77 | private void MarkupNameUpdatePromptClose(WindowClosedEventArgs args) |
||
78 | { |
||
79 | if (args.DialogResult.Value) |
||
80 | { |
||
81 | if (String.IsNullOrWhiteSpace(args.PromptResult) || args.PromptResult == null) |
||
82 | { |
||
83 | MessageBox.Show("공백으로 입력하시면 등록이 불가능합니다", "안내"); |
||
84 | } |
||
85 | else |
||
86 | { |
||
87 | Controls.AdornerFinal finalItem = main.dzMainMenu.SelectLayer.Children[0] as Controls.AdornerFinal; |
||
88 | Rect rect = new Rect(new Point(finalItem.BorderSize.Left - 100, finalItem.BorderSize.Top - 100), new Point(finalItem.BorderSize.Right + 100, finalItem.BorderSize.Bottom + 100)); |
||
89 | c460df05 | djkim | KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK |
90 | { |
||
91 | TEXT = args.PromptResult, |
||
92 | MSGSIDE = (int)MessageSide.Me, |
||
93 | MEMBER_ID = App.ViewInfo.UserID, |
||
94 | MEMBER_NAME = App.UserName, |
||
95 | MSGTYPE = (int)MessageType.Anchor, |
||
96 | TIMESTAMP = DateTime.Now, |
||
97 | DOCUMENT_ID = App.ViewInfo.DocumentItemID, |
||
98 | RECT_X = rect.X, |
||
99 | RECT_Y = rect.Y, |
||
100 | RECT_WIDTH = rect.Width, |
||
101 | RECT_HEIGHT = rect.Height, |
||
102 | PAGENUMBER = Common.ViewerDataModel.Instance.PageNumber |
||
103 | }; |
||
104 | |||
105 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message); |
||
106 | |||
107 | List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
||
108 | |||
109 | messagelist.ForEach(a => |
||
110 | 787a4489 | KangIngu | { |
111 | c460df05 | djkim | Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
112 | }); |
||
113 | 787a4489 | KangIngu | |
114 | tbContent.Text = ""; |
||
115 | tbContent.Focus(); |
||
116 | c460df05 | djkim | (lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
117 | 787a4489 | KangIngu | } |
118 | } |
||
119 | } |
||
120 | |||
121 | protected virtual void OnPropertyChanged(String info) |
||
122 | { |
||
123 | if (PropertyChanged != null) |
||
124 | PropertyChanged(this, new PropertyChangedEventArgs(info)); |
||
125 | } |
||
126 | |||
127 | private void SaveAuthorization(object parameter) |
||
128 | { |
||
129 | KCOMDataModel.DataModel.TALK instance = parameter as KCOMDataModel.DataModel.TALK; |
||
130 | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.GotoPage(instance.PAGENUMBER.Value); |
||
131 | 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 }); |
||
132 | } |
||
133 | |||
134 | public event PropertyChangedEventHandler PropertyChanged; |
||
135 | |||
136 | private void ConversationView_Loaded(object sender, RoutedEventArgs e) |
||
137 | { |
||
138 | main = this.ParentOfType<MainWindow>(); |
||
139 | if (App.ParameterMode) |
||
140 | { |
||
141 | ClickAnchorCommand = new Telerik.Windows.Controls.DelegateCommand(SaveAuthorization); |
||
142 | c460df05 | djkim | if (string.IsNullOrEmpty(App.UserName)) |
143 | { |
||
144 | App.UserName = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMember(App.ViewInfo.ProjectNO, App.ViewInfo.UserID).NAME; |
||
145 | } |
||
146 | 787a4489 | KangIngu | if (Common.ViewerDataModel.Instance.k_talkMessageSet.Count() == 0) |
147 | { |
||
148 | c460df05 | djkim | List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
149 | |||
150 | messagelist.ForEach(a => |
||
151 | 787a4489 | KangIngu | { |
152 | c460df05 | djkim | Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
153 | }); |
||
154 | (lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
||
155 | 787a4489 | KangIngu | } |
156 | tbContent.KeyDown += async (s, ea) => await OnKeyDownHandler(s, ea); |
||
157 | c460df05 | djkim | |
158 | 787a4489 | KangIngu | } |
159 | } |
||
160 | |||
161 | private async System.Threading.Tasks.Task OnKeyDownHandler(object sender, KeyEventArgs e) |
||
162 | { |
||
163 | |||
164 | if (e.Key == Key.Return) |
||
165 | { |
||
166 | if (Keyboard.Modifiers != ModifierKeys.Shift) |
||
167 | { |
||
168 | AddText(); |
||
169 | e.Handled = true; |
||
170 | } |
||
171 | else |
||
172 | { |
||
173 | tbContent.Text = tbContent.Text + Environment.NewLine; |
||
174 | tbContent.CaretIndex = tbContent.Text.Length; |
||
175 | e.Handled = true; |
||
176 | } |
||
177 | } |
||
178 | } |
||
179 | |||
180 | private void AddText() |
||
181 | { |
||
182 | c460df05 | djkim | Common.ViewerDataModel.Instance.k_talkMessageSet.Clear(); |
183 | |||
184 | KCOMDataModel.DataModel.TALK message = new KCOMDataModel.DataModel.TALK |
||
185 | 787a4489 | KangIngu | { |
186 | c460df05 | djkim | TEXT = tbContent.Text, |
187 | MSGSIDE = (int)MessageSide.Me, |
||
188 | MEMBER_ID = App.ViewInfo.UserID, |
||
189 | MEMBER_NAME = App.UserName, |
||
190 | MSGTYPE = (int)MessageType.Normal, |
||
191 | TIMESTAMP = DateTime.Now, |
||
192 | DOCUMENT_ID = App.ViewInfo.DocumentItemID |
||
193 | }; |
||
194 | 787a4489 | KangIngu | |
195 | c460df05 | djkim | Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddMessage(App.ViewInfo.ProjectNO, message); |
196 | 787a4489 | KangIngu | |
197 | c460df05 | djkim | List<KCOMDataModel.DataModel.TALK> messagelist = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMessage(App.ViewInfo.ProjectNO, App.ViewInfo.DocumentItemID); |
198 | 787a4489 | KangIngu | |
199 | c460df05 | djkim | messagelist.ForEach(a => |
200 | { |
||
201 | Common.ViewerDataModel.Instance.k_talkMessageSet.Add(a); |
||
202 | }); |
||
203 | tbContent.Text = ""; |
||
204 | tbContent.Focus(); |
||
205 | (lstMessage.Parent as ScrollViewer).ScrollToEnd(); |
||
206 | |||
207 | 787a4489 | KangIngu | } |
208 | } |
||
209 | } |