markus / KCOM / Controls / Symbol.xaml.cs @ 284ed1c7
이력 | 보기 | 이력해설 | 다운로드 (45.3 KB)
1 |
using IKCOM; |
---|---|
2 |
using KCOM.Common; |
3 |
using KCOM.Events; |
4 |
using KCOMDataModel.Common; |
5 |
using KCOMDataModel.DataModel; |
6 |
using MarkupToPDF.Common; |
7 |
using MarkupToPDF.Controls.Parsing; |
8 |
using System; |
9 |
using System.Collections.Generic; |
10 |
using System.ComponentModel; |
11 |
using System.Linq; |
12 |
using System.Text; |
13 |
using System.Threading.Tasks; |
14 |
using System.Windows; |
15 |
using System.Windows.Controls; |
16 |
using System.Windows.Data; |
17 |
using System.Windows.Documents; |
18 |
using System.Windows.Input; |
19 |
using System.Windows.Media; |
20 |
using System.Windows.Media.Imaging; |
21 |
using System.Windows.Navigation; |
22 |
using System.Windows.Shapes; |
23 |
using Telerik.Windows.Controls; |
24 |
using Telerik.Windows.Controls.DragDrop; |
25 |
|
26 |
namespace KCOM.Controls |
27 |
{ |
28 |
public class Symbol_Custom |
29 |
{ |
30 |
public string ID { get; set; } |
31 |
public string Name { get; set; } |
32 |
public string ImageUri { get; set; } |
33 |
} |
34 |
|
35 |
/// <summary> |
36 |
/// Symbol.xaml에 대한 상호 작용 논리 |
37 |
/// </summary> |
38 |
public partial class Symbol : UserControl |
39 |
{ |
40 |
AdornerFinal finalItem; |
41 |
bool IsMouseDown = false; |
42 |
string moveItem_id = ""; |
43 |
public string filename { get; set; } |
44 |
bool _Initialize = false; |
45 |
|
46 |
public Symbol() |
47 |
{ |
48 |
//App.splashString(ISplashMessage.SYMBOL); |
49 |
InitializeComponent(); |
50 |
|
51 |
//RadDragAndDropManager.AddDragInfoHandler(lstSymbolPrivate, OnDragPrivateInfo); |
52 |
//RadDragAndDropManager.AddDragQueryHandler(lstSymbolPrivate, OnDragPrivateQuery); |
53 |
//RadDragAndDropManager.SetAllowDrag(lstSymbolPrivate, true); |
54 |
this.Loaded += Symbol_Loaded; |
55 |
|
56 |
} |
57 |
|
58 |
|
59 |
|
60 |
private async void Symbol_Loaded(object sender, RoutedEventArgs e) |
61 |
{ |
62 |
if (!App.IsDesignMode) |
63 |
{ |
64 |
if (!_Initialize) |
65 |
{ |
66 |
_Initialize = true; |
67 |
await DataBindAsync(); |
68 |
|
69 |
} |
70 |
} |
71 |
} |
72 |
|
73 |
private void OnDragPrivateInfo(object sender, DragDropEventArgs e) |
74 |
{ |
75 |
} |
76 |
|
77 |
private void OnDragPrivateQuery(object sender, DragDropQueryEventArgs e) |
78 |
{ |
79 |
if (e.Options.Status == DragStatus.DragQuery) |
80 |
{ |
81 |
//var draggedListBoxItem = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem; |
82 |
//BitmapImage im = new BitmapImage(new Uri((draggedListBoxItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate).ImageUri)); |
83 |
//ImageSource _source = im; |
84 |
//Image img = new Image(); |
85 |
//img.Source = _source; |
86 |
|
87 |
//e.Options.Payload = im; |
88 |
//var dragCue = new Image(); |
89 |
//dragCue.Source = img.Source; |
90 |
//dragCue.Width = 0; |
91 |
//dragCue.Height = 0; |
92 |
//e.Options.DragCue = dragCue; |
93 |
|
94 |
|
95 |
//PayLoadAdorner = new AdornerFinal(); |
96 |
//DeepView.ServiceDeepView_Symbol.SymbolPrivate tempDragableControl = (e.Options.Source as System.Windows.Controls.ListBox).SelectedItem as DeepView.ServiceDeepView_Symbol.SymbolPrivate; |
97 |
//var xamldata = tempDragableControl.Data; |
98 |
////this.DeepLayer.markupParse(xamldata, this.DeepLayer._TempLayer, "복사된 데이터_이름으로 수정해야함"); |
99 |
//PayLoadAdorner = this.DeepLayer.markupParseToAdorner(xamldata, this.DeepLayer._SelectLayer, ""); |
100 |
//this.DeepLayer._SelectLayer.Children.Add(PayLoadAdorner); |
101 |
} |
102 |
|
103 |
e.QueryResult = true; |
104 |
e.Handled = true; |
105 |
} |
106 |
|
107 |
private async Task DataBindAsync() |
108 |
{ |
109 |
try |
110 |
{ |
111 |
List<Symbol_Custom> PrivateSymbolList = new List<Symbol_Custom>(); |
112 |
|
113 |
var symbol_Private = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetSymbolListAsync(App.ViewInfo.UserID); |
114 |
foreach (var item in symbol_Private) |
115 |
{ |
116 |
var Custom = new Symbol_Custom(); |
117 |
Custom.Name = item.NAME; |
118 |
Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//","/").Replace(":/", "://"), App.isExternal); |
119 |
Custom.ID = item.ID; |
120 |
PrivateSymbolList.Add(Custom); |
121 |
} |
122 |
lstSymbolPrivate.ItemsSource = PrivateSymbolList; |
123 |
} |
124 |
catch (Exception ex) |
125 |
{ |
126 |
System.Diagnostics.Debug.WriteLine(ex.ToString()); |
127 |
} |
128 |
|
129 |
deptlist.ItemsSource = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolDeptListAsync(); |
130 |
|
131 |
List<SYMBOL_PUBLIC> symbol_Public; |
132 |
if (deptlist.SelectedValue != null) |
133 |
{ |
134 |
symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(deptlist.SelectedValue.ToString()); |
135 |
} |
136 |
else |
137 |
{ |
138 |
symbol_Public = await ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseTaskClient.GetPublicSymbolListAsync(null); |
139 |
} |
140 |
|
141 |
if (symbol_Public != null) |
142 |
{ |
143 |
var PublicSymbolList = new List<Symbol_Custom>(); |
144 |
foreach (var item in symbol_Public) |
145 |
{ |
146 |
var Custom = new Symbol_Custom(); |
147 |
Custom.Name = item.NAME; |
148 |
Custom.ImageUri = CommonLib.Common.IPReplace(item.IMAGE_URL.Replace("//", "/").Replace(":/", "://"), App.isExternal); |
149 |
Custom.ID = item.ID; |
150 |
PublicSymbolList.Add(Custom); |
151 |
} |
152 |
|
153 |
lstSymbolPublic.ItemsSource = PublicSymbolList; |
154 |
} |
155 |
} |
156 |
|
157 |
public async Task<PngBitmapEncoder> symImageAsync_old(string data,double PageAngle) |
158 |
{ |
159 |
Canvas _canvas = new Canvas(); |
160 |
_canvas.Background = Brushes.White; |
161 |
_canvas.Width = finalItem.BorderSize.Width; |
162 |
_canvas.Height = finalItem.BorderSize.Height; |
163 |
await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(), |
164 |
STAMP_Contents: App.SystemInfo.STAMP_CONTENTS); |
165 |
|
166 |
BitmapEncoder encoder = new PngBitmapEncoder(); |
167 |
|
168 |
|
169 |
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width + 50, (int)_canvas.Height + 50, 96d, 96d, PixelFormats.Pbgra32); |
170 |
|
171 |
DrawingVisual dv = new DrawingVisual(); |
172 |
|
173 |
_canvas.Measure(new System.Windows.Size(finalItem.BorderSize.Width + 50, finalItem.BorderSize.Height + 50)); |
174 |
//_canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 50, Y = -finalItem.BorderSize.Y - 50 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
175 |
_canvas.Arrange(new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
176 |
|
177 |
using (DrawingContext ctx = dv.RenderOpen()) |
178 |
{ |
179 |
VisualBrush vb = new VisualBrush(_canvas); |
180 |
//ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X - 20, Y = -finalItem.BorderSize.Y - 20 }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
181 |
ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -finalItem.BorderSize.X, Y = -finalItem.BorderSize.Y }, new Point(finalItem.BorderSize.Width + 20, finalItem.BorderSize.Height + 20))); |
182 |
} |
183 |
|
184 |
try |
185 |
{ |
186 |
renderBitmap.Render(dv); |
187 |
|
188 |
GC.Collect(); |
189 |
GC.WaitForPendingFinalizers(); |
190 |
GC.Collect(); |
191 |
//bitmap.Render(controlToConvert); |
192 |
// encode png data |
193 |
PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); |
194 |
// puch rendered bitmap into it |
195 |
pngEncoder.Interlace = PngInterlaceOption.Off; |
196 |
pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
197 |
return pngEncoder; |
198 |
|
199 |
} |
200 |
catch //(Exception ex) |
201 |
{ |
202 |
return null; |
203 |
} |
204 |
|
205 |
} |
206 |
|
207 |
public async Task<PngBitmapEncoder> symImageAsync(string data, double PageAngle) |
208 |
{ |
209 |
|
210 |
Canvas _canvas = new Canvas(); |
211 |
_canvas.Background = Brushes.White; |
212 |
|
213 |
List<Rect> rects = new List<Rect>(); |
214 |
|
215 |
finalItem.Members.ForEach(member => |
216 |
{ |
217 |
if(member?.DrawingData is MarkupToPDF.ICommentRect comment) |
218 |
{ |
219 |
rects.Add(comment.GetCommentRect()); |
220 |
} |
221 |
}); |
222 |
|
223 |
var rect = MathHelper.CombineRects(rects); |
224 |
|
225 |
_canvas.Width = rect.Width; |
226 |
_canvas.Height = rect.Height; |
227 |
|
228 |
await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas, PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken(), |
229 |
STAMP_Contents: App.SystemInfo.STAMP_CONTENTS); |
230 |
|
231 |
BitmapEncoder encoder = new PngBitmapEncoder(); |
232 |
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96d, 96d, PixelFormats.Pbgra32); |
233 |
|
234 |
DrawingVisual dv = new DrawingVisual(); |
235 |
//Window window = new Window(); |
236 |
//window.Content = _canvas; |
237 |
//var result = window.ShowDialog(); |
238 |
//if(result.GetValueOrDefault()) |
239 |
//{ |
240 |
|
241 |
//} |
242 |
|
243 |
_canvas.Measure(rect.Size); |
244 |
_canvas.Arrange(new Rect(new System.Windows.Point { X = -rect.X + 35, Y = -rect.Y + 35 }, new Point(rect.Width + 35, rect.Height + 35))); |
245 |
|
246 |
using (DrawingContext ctx = dv.RenderOpen()) |
247 |
{ |
248 |
VisualBrush vb = new VisualBrush(_canvas); |
249 |
ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -rect.X, Y = -rect.Y }, new Point(rect.Width, rect.Height))); |
250 |
} |
251 |
Window window2 = new Window(); |
252 |
window2.Content = _canvas; |
253 |
var result2 = window2.ShowDialog(); |
254 |
if (result2.GetValueOrDefault()) |
255 |
{ |
256 |
|
257 |
} |
258 |
try |
259 |
{ |
260 |
renderBitmap.Render(dv); |
261 |
|
262 |
GC.Collect(); |
263 |
GC.WaitForPendingFinalizers(); |
264 |
GC.Collect(); |
265 |
//bitmap.Render(controlToConvert); |
266 |
// encode png data |
267 |
PngBitmapEncoder pngEncoder = new PngBitmapEncoder(); |
268 |
// puch rendered bitmap into it |
269 |
pngEncoder.Interlace = PngInterlaceOption.Off; |
270 |
pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap)); |
271 |
return pngEncoder; |
272 |
|
273 |
} |
274 |
catch //(Exception ex) |
275 |
{ |
276 |
return null; |
277 |
} |
278 |
|
279 |
} |
280 |
|
281 |
public void DialogMessage_Alert(string content, string header) |
282 |
{ |
283 |
App.splashScreen.Close(); |
284 |
|
285 |
DialogParameters parameters = new DialogParameters() |
286 |
{ |
287 |
Owner = Application.Current.MainWindow, |
288 |
Content = new TextBlock() |
289 |
{ |
290 |
MinWidth = 400, |
291 |
FontSize = 11, |
292 |
Text = content, |
293 |
TextWrapping = System.Windows.TextWrapping.Wrap |
294 |
}, |
295 |
Header = header, |
296 |
Theme = new VisualStudio2013Theme(), |
297 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
298 |
}; |
299 |
RadWindow.Alert(parameters); |
300 |
} |
301 |
|
302 |
#region Event |
303 |
|
304 |
#region Private Symbol Add Event |
305 |
private void Create_Symbol(object sender, RoutedEventArgs e) |
306 |
{ |
307 |
MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn(); |
308 |
|
309 |
if (Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Count < 1) //선택된 것이 없으면 |
310 |
{ |
311 |
DialogMessage_Alert("Please Select Controls", "Alert"); |
312 |
} |
313 |
else //선택된 것이 있으면 |
314 |
{ |
315 |
string MarkupData = ""; |
316 |
finalItem = new AdornerFinal(); |
317 |
|
318 |
foreach (var item in Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children) |
319 |
{ |
320 |
if (item.GetType().Name == "AdornerFinal") |
321 |
{ |
322 |
finalItem = (item as Controls.AdornerFinal); |
323 |
foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>()) |
324 |
{ |
325 |
if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData)) |
326 |
{ |
327 |
markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID); |
328 |
MarkupData += markupReturn.ConvertData; |
329 |
} |
330 |
} |
331 |
} |
332 |
} |
333 |
DialogParameters parameters = new DialogParameters() |
334 |
{ |
335 |
Owner = Application.Current.MainWindow, |
336 |
Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args), |
337 |
DefaultPromptResultValue = "Custom State", |
338 |
Content = "Name :", |
339 |
Header = "Insert Custom Symbol Name", |
340 |
Theme = new VisualStudio2013Theme(), |
341 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
342 |
}; |
343 |
RadWindow.Prompt(parameters); |
344 |
} |
345 |
|
346 |
} |
347 |
#endregion |
348 |
|
349 |
#region Symbol Add Close Event |
350 |
private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args) |
351 |
{ |
352 |
try |
353 |
{ |
354 |
if (args.PromptResult != null) |
355 |
{ |
356 |
if (args.DialogResult.Value) |
357 |
{ |
358 |
PngBitmapEncoder _Encoder = null; |
359 |
|
360 |
if (finalItem.Members.Any(x=> x.DrawingData is MarkupToPDF.ICommentRect comment)) |
361 |
{ |
362 |
_Encoder = await symImageAsync(data, ViewerDataModel.Instance.MarkupAngle); |
363 |
} |
364 |
else |
365 |
{ |
366 |
_Encoder = await symImageAsync_old(data, ViewerDataModel.Instance.MarkupAngle); |
367 |
} |
368 |
|
369 |
System.IO.MemoryStream fs = new System.IO.MemoryStream(); |
370 |
_Encoder.Save(fs); |
371 |
System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs); |
372 |
|
373 |
byte[] Img_byte = fs.ToArray(); |
374 |
|
375 |
kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader; |
376 |
filename = fileUploader.RunSymbol(App.ViewInfo.ProjectNO, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.ShortGuid() + ".png", Img_byte); |
377 |
Check_Uri.UriCheck(filename); |
378 |
if (RadTab.SelectedIndex == 0) |
379 |
{ |
380 |
SymbolSave(args.PromptResult, filename, data); |
381 |
} |
382 |
else |
383 |
{ |
384 |
SymbolSave_Public(args.PromptResult, filename, data, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT); |
385 |
} |
386 |
|
387 |
await DataBindAsync(); |
388 |
} |
389 |
} |
390 |
} |
391 |
catch(Exception ex) |
392 |
{ |
393 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.DialogMessage_Alert("" + ex, "Alert"); |
394 |
} |
395 |
} |
396 |
#endregion |
397 |
|
398 |
public void SymbolSave(string Name, string Url, string Data) |
399 |
{ |
400 |
try |
401 |
{ |
402 |
SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE |
403 |
{ |
404 |
ID = Commons.ShortGuid(), |
405 |
MEMBER_USER_ID = App.ViewInfo.UserID, |
406 |
NAME = Name, |
407 |
IMAGE_URL = Url, |
408 |
DATA = Data |
409 |
}; |
410 |
|
411 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted; |
412 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private); |
413 |
} |
414 |
catch (Exception) |
415 |
{ |
416 |
throw; |
417 |
} |
418 |
} |
419 |
|
420 |
public void SymbolSave_Public(string Name, string Url, string Data, string Department) |
421 |
{ |
422 |
try |
423 |
{ |
424 |
SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC |
425 |
{ |
426 |
ID = Commons.ShortGuid(), |
427 |
DEPARTMENT = Department, |
428 |
NAME = Name, |
429 |
IMAGE_URL = Url, |
430 |
DATA = Data |
431 |
}; |
432 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted; |
433 |
//Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1); |
434 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public); |
435 |
} |
436 |
catch (Exception) |
437 |
{ |
438 |
throw; |
439 |
} |
440 |
} |
441 |
|
442 |
private async void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e) |
443 |
{ |
444 |
await DataBindAsync(); |
445 |
} |
446 |
|
447 |
private async void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e) |
448 |
{ |
449 |
await DataBindAsync(); |
450 |
} |
451 |
|
452 |
#region Private Symbol Delete Event |
453 |
private void Remove_Symbol(object sender, RoutedEventArgs e) |
454 |
{ |
455 |
if (lstSymbolPrivate.SelectedItem == null) |
456 |
{ |
457 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
458 |
return; |
459 |
} |
460 |
string delItem_ID = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
461 |
|
462 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted; |
463 |
//Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1); |
464 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex); |
465 |
} |
466 |
#endregion |
467 |
#region Public Symbol Delete Event |
468 |
private void Remove_Symbol_Public(object sender, RoutedEventArgs e) |
469 |
{ |
470 |
if (lstSymbolPublic.SelectedItem == null) |
471 |
{ |
472 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
473 |
return; |
474 |
} |
475 |
string delItem_ID = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
476 |
|
477 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolCompleted += BaseClient_DeleteSymbolCompleted; |
478 |
//Logger.sendReqLog("DeleteSymbolAsync: ", delItem_ID, 1); |
479 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.DeleteSymbolAsync(delItem_ID, RadTab.SelectedIndex); |
480 |
} |
481 |
|
482 |
private async void BaseClient_DeleteSymbolCompleted(object sender, ServiceDeepView.DeleteSymbolCompletedEventArgs e) |
483 |
{ |
484 |
//Logger.sendResLog("DeleteSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
485 |
await DataBindAsync(); |
486 |
} |
487 |
#endregion |
488 |
|
489 |
public UndoDataGroup UndoDataGroup { get; set; } |
490 |
|
491 |
/// <summary> |
492 |
/// place symbol which has given id to original position which is created |
493 |
/// </summary> |
494 |
/// <date>2018.06.14</date> |
495 |
/// <param name="id"></param> |
496 |
private async Task PlaceSymbol(string id, Point CurrentMousePoint) |
497 |
{ |
498 |
var systemMain = Common.ViewerDataModel.Instance.SystemMain; |
499 |
var mainMenu = systemMain.dzMainMenu; |
500 |
|
501 |
SelectionSet.Instance.UnSelect(mainMenu); /// unselect alreay selected items |
502 |
|
503 |
try |
504 |
{ |
505 |
string Data_ = mainMenu.BaseClient.GetSymbolData(id, RadTab.SelectedIndex); |
506 |
if (!string.IsNullOrEmpty(Data_) && Data_.Contains("|DZ|")) |
507 |
{ |
508 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
509 |
|
510 |
string[] delimiterChars = { "|DZ|" }; |
511 |
string[] data = Data_.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries); |
512 |
|
513 |
UndoDataGroup = new UndoDataGroup() |
514 |
{ |
515 |
IsUndo = false, |
516 |
Event = EventType.Create |
517 |
}; |
518 |
ViewerDataModel.Instance.UndoDataList.Where(x => x.IsUndo).ToList().ForEach(i => |
519 |
{ |
520 |
ViewerDataModel.Instance.UndoDataList.Remove(i); |
521 |
}); |
522 |
|
523 |
string GroupID = Guid.NewGuid().ToString(); |
524 |
foreach (string parse in data) |
525 |
{ |
526 |
if (!string.IsNullOrEmpty(parse)) |
527 |
{ |
528 |
System.Windows.Controls.Control item = await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(),App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, ViewerDataModel.Instance.PageAngle, string.Empty, string.Empty, |
529 |
STAMP_Contents: App.SystemInfo.STAMP_CONTENTS); |
530 |
if (item is MarkupToPDF.Common.CommentUserInfo comment) |
531 |
{ |
532 |
comment.CommentID = Commons.ShortGuid(); |
533 |
comment.SymbolID = id; |
534 |
comment.GroupID = GroupID; |
535 |
comment.ZIndex = CommentUserInfo.MaxZIndex; |
536 |
|
537 |
adornerSet.Add(comment); |
538 |
|
539 |
var UndoData = new UndoData(comment); |
540 |
UndoDataGroup.MarkupDataColl.Add(UndoData); |
541 |
ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup); |
542 |
} |
543 |
} |
544 |
} |
545 |
|
546 |
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
547 |
|
548 |
// 마우스 클릭된 페이지 위치 |
549 |
|
550 |
var pageWidth = ViewerDataModel.Instance.ImageViewWidth; |
551 |
var pageHeight = ViewerDataModel.Instance.ImageViewHeight; |
552 |
var angle = Common.ViewerDataModel.Instance.MarkupAngle; |
553 |
|
554 |
Point pagePoint = new Point(pageWidth/2, pageHeight/2); |
555 |
|
556 |
var rotatePoint = Rotate(mainMenu.CanvasDrawingMouseDownPoint,pagePoint,angle); |
557 |
|
558 |
var diff = Point.Subtract(rotatePoint, final.Centeroid); |
559 |
final.TranslateItems(diff.X, diff.Y); |
560 |
|
561 |
mainMenu.SelectLayer.Children.Add(final); |
562 |
|
563 |
//var finalPosition = new Point(Canvas.GetLeft(final), Canvas.GetTop(final)); |
564 |
//Rect rect = new Rect(finalPosition, Point.Add(finalPosition,new Vector(final.Width,final.Height))); |
565 |
|
566 |
//SelectionSet.Instance.SelectItemByRect(final.getAdornerSize(), mainMenu); |
567 |
|
568 |
} |
569 |
else |
570 |
{ |
571 |
await PlaceImageSymbol(id, string.Empty); |
572 |
} |
573 |
} |
574 |
catch (Exception ex) |
575 |
{ |
576 |
this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error"); |
577 |
} |
578 |
} |
579 |
|
580 |
|
581 |
//출처: https://icodebroker.tistory.com/3189 [ICODEBROKER] |
582 |
public Point Rotate(Point sourcePoint, Point centerPoint, double rotateAngle) |
583 |
{ |
584 |
Point targetPoint = new Point(); |
585 |
|
586 |
double radian = rotateAngle / 180 * Math.PI; |
587 |
|
588 |
targetPoint.X = Math.Cos(radian) * (sourcePoint.X - centerPoint.X) - Math.Sin(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.X; |
589 |
targetPoint.Y = Math.Sin(radian) * (sourcePoint.X - centerPoint.X) + Math.Cos(radian) * (sourcePoint.Y - centerPoint.Y) + centerPoint.Y; |
590 |
|
591 |
return targetPoint; |
592 |
} |
593 |
|
594 |
/// <summary> |
595 |
/// 이미지 심볼을 배치한다. |
596 |
/// </summary> |
597 |
/// <param name="id"></param> |
598 |
/// <param name="group_id"></param> |
599 |
private async Task PlaceImageSymbol(string id, string groupID) |
600 |
{ |
601 |
try |
602 |
{ |
603 |
string FilePath = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, RadTab.SelectedIndex); |
604 |
if (!string.IsNullOrEmpty(FilePath)) |
605 |
{ |
606 |
bool exists = await Commons.DoesFileExist(FilePath); |
607 |
if (!exists) |
608 |
{ |
609 |
this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert($"{FilePath} doesn't exist", "Warning"); |
610 |
return; |
611 |
} |
612 |
|
613 |
Image img = new Image(); |
614 |
if (FilePath.Contains(".svg")) |
615 |
{ |
616 |
SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(FilePath); |
617 |
img.Source = (DrawingImage)svgImage.ProvideValue(null); |
618 |
} |
619 |
else |
620 |
{ |
621 |
img.Source = new BitmapImage(new Uri(FilePath)); |
622 |
} |
623 |
|
624 |
var currentControl = new MarkupToPDF.Controls.Etc.ImgControl |
625 |
{ |
626 |
PointSet = new List<Point>(), |
627 |
FilePath = FilePath, |
628 |
ImageData = img.Source, |
629 |
StartPoint = new Point(0, 0), |
630 |
EndPoint = new Point(img.Source.Width, img.Source.Height), |
631 |
TopRightPoint = new Point(img.Source.Width, 0), |
632 |
LeftBottomPoint = new Point(0, img.Source.Height), |
633 |
ZIndex = CommentUserInfo.MaxZIndex |
634 |
}; |
635 |
|
636 |
currentControl.PointSet = new List<Point> |
637 |
{ |
638 |
currentControl.StartPoint, |
639 |
currentControl.LeftBottomPoint, |
640 |
currentControl.EndPoint, |
641 |
currentControl.TopRightPoint, |
642 |
}; |
643 |
UndoDataGroup = new UndoDataGroup() |
644 |
{ |
645 |
IsUndo = false, |
646 |
Event = EventType.Create |
647 |
}; |
648 |
ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo).ToList().ForEach(i => |
649 |
{ |
650 |
ViewerDataModel.Instance.UndoDataList.Remove(i); |
651 |
}); |
652 |
|
653 |
var UndoData = new UndoData(currentControl as MarkupToPDF.Common.CommentUserInfo); |
654 |
UndoDataGroup.MarkupDataColl.Add(UndoData); |
655 |
ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup); |
656 |
|
657 |
ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo); |
658 |
currentControl.CommentID = Commons.ShortGuid(); |
659 |
currentControl.SymbolID = id; |
660 |
currentControl.GroupID = groupID; |
661 |
currentControl.ApplyTemplate(); |
662 |
currentControl.SetImage(); |
663 |
|
664 |
///ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo); |
665 |
Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo); |
666 |
this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final); |
667 |
|
668 |
#region 마우스 위치에 배치 |
669 |
/* |
670 |
// this.ParentOfType<MainWindow>().dzMainMenu.isLeftMouseButtonDownOnWindow = true; |
671 |
// final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY)); |
672 |
double realPointX = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2); |
673 |
double realPointY = this.ParentOfType<MainWindow>().dzMainMenu.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2); |
674 |
final.TranslateItems(realPointX, realPointY); |
675 |
// move.control_Select(item, dragRect); |
676 |
ApplyDragSelectionRect(); |
677 |
//this.ParentOfType<MainWindow>().dzMainMenu.mouseHandlingMode = MouseHandlingMode.DragSymbol; |
678 |
///this.ParentOfType<MainWindow>().dzMainMenu.mouseButtonDown = MouseButton.Left; |
679 |
//this.ParentOfType<MainWindow>().dzMainMenu.symboldata(id, group_id, RadTab.SelectedIndex, Data_, img.Source);*/ |
680 |
#endregion |
681 |
} |
682 |
} |
683 |
catch(Exception ex) |
684 |
{ |
685 |
this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error"); |
686 |
} |
687 |
} |
688 |
|
689 |
/// <summary> |
690 |
/// |
691 |
/// </summary> |
692 |
/* |
693 |
private void ApplyDragSelectionRect() |
694 |
{ |
695 |
var multi_UndoData = new UndoData(); |
696 |
|
697 |
UndoDataGroup = new UndoDataGroup() |
698 |
{ |
699 |
IsUndo = false, |
700 |
Event = EventType.Operation, |
701 |
EventTime = DateTime.Now, |
702 |
MarkupDataColl = new List<UndoData>() |
703 |
}; |
704 |
|
705 |
this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Visibility = Visibility.Collapsed; |
706 |
|
707 |
double x = Canvas.GetLeft(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder); |
708 |
double y = Canvas.GetTop(this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder); |
709 |
double width = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Width; |
710 |
double height = this.ParentOfType<MainWindow>().dzMainMenu.dragSelectionBorder.Height; |
711 |
Rect dragRect = new Rect(x, y, width, height); |
712 |
Boolean Flag = false; |
713 |
dragRect.Inflate(width / 10, height / 10); |
714 |
List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>(); |
715 |
var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList(); |
716 |
|
717 |
dragRect = new Rect(x, y, width, height); |
718 |
dragRect.Inflate(width / 10, height / 10); |
719 |
|
720 |
//move.mousemode = MarkupToPDF.Controls.Common.MouseMode.Selecting; |
721 |
//move. |
722 |
foreach (var item in Items) |
723 |
{ |
724 |
Flag = SelectionSet.Instance.SelectControl(item, dragRect); |
725 |
|
726 |
if (Flag) |
727 |
{ |
728 |
adornerSet.Add(item); |
729 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(item); |
730 |
|
731 |
this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item); |
732 |
UndoDataGroup.MarkupDataColl.Add(multi_UndoData); |
733 |
multi_UndoData = new UndoData(); |
734 |
if (item.GroupID > 0) |
735 |
{ |
736 |
} |
737 |
} |
738 |
} |
739 |
if (adornerSet.Count > 0) |
740 |
{ |
741 |
ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
742 |
{ |
743 |
ViewerDataModel.Instance.UndoDataList.Remove(i); |
744 |
}); |
745 |
ViewerDataModel.Instance.UndoDataList.Add(UndoDataGroup); |
746 |
|
747 |
Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet); |
748 |
this.ParentOfType<MainWindow>().dzMainMenu.SelectLayer.Children.Add(final); |
749 |
} |
750 |
} |
751 |
*/ |
752 |
|
753 |
///private Move move; |
754 |
#region Symbol DoubleClick Event |
755 |
private void Move_Symbol(object sender, MouseButtonEventArgs e) |
756 |
{ |
757 |
try |
758 |
{ |
759 |
Type type = e.OriginalSource.GetType(); |
760 |
string id = string.Empty; |
761 |
//Logger.sendResLog("Move_Symbol", type.Name, 0); |
762 |
if (type.Name == "Image") |
763 |
{ |
764 |
id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID; |
765 |
} |
766 |
else if (type.Name == "Border") |
767 |
{ |
768 |
id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID; |
769 |
} |
770 |
else if (type.Name == "TextBox") |
771 |
{ |
772 |
id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID; |
773 |
} |
774 |
|
775 |
IsMouseDown = true; |
776 |
|
777 |
if (e.ClickCount > 1) |
778 |
{ |
779 |
this.PlaceSymbol(id,ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
780 |
} |
781 |
} |
782 |
catch(Exception ex) |
783 |
{ |
784 |
//Logger.sendResLog("Move_Symbol", ex.Message, 0); |
785 |
} |
786 |
} |
787 |
#endregion |
788 |
|
789 |
#region Private Symbol Rename Event |
790 |
private void Rename_Symbol(object sender, RoutedEventArgs e) |
791 |
{ |
792 |
if (lstSymbolPrivate.SelectedItem == null) |
793 |
{ |
794 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
795 |
return; |
796 |
} |
797 |
|
798 |
DialogParameters parameters = new DialogParameters() |
799 |
{ |
800 |
Owner = Application.Current.MainWindow, |
801 |
Closed = (obj, args) => this.MarkupReNamePromptClose("", args), |
802 |
//DefaultPromptResultValue = "Custom State", |
803 |
DefaultPromptResultValue = (lstSymbolPrivate.SelectedItem as Symbol_Custom).Name, |
804 |
Content = "Name :", |
805 |
Header = "Update Custom Symbol Name", |
806 |
Theme = new VisualStudio2013Theme(), |
807 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
808 |
}; |
809 |
RadWindow.Prompt(parameters); |
810 |
|
811 |
} |
812 |
#endregion |
813 |
|
814 |
#region Public Symbol Rename Event |
815 |
private void Rename_Symbol_Public(object sender, RoutedEventArgs e) |
816 |
{ |
817 |
if (lstSymbolPublic.SelectedItem == null) |
818 |
{ |
819 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
820 |
return; |
821 |
} |
822 |
|
823 |
DialogParameters parameters = new DialogParameters() |
824 |
{ |
825 |
Owner = Application.Current.MainWindow, |
826 |
Closed = (obj, args) => this.MarkupReNamePromptClose("", args), |
827 |
//DefaultPromptResultValue = "Custom State", |
828 |
DefaultPromptResultValue = (lstSymbolPublic.SelectedItem as Symbol_Custom).Name, |
829 |
Content = "Name :", |
830 |
Header = "Update Custom Symbol Name", |
831 |
Theme = new VisualStudio2013Theme(), |
832 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
833 |
}; |
834 |
RadWindow.Prompt(parameters); |
835 |
|
836 |
} |
837 |
#endregion |
838 |
#region Symbol Rename Close Event |
839 |
private void MarkupReNamePromptClose(string data, WindowClosedEventArgs args) |
840 |
{ |
841 |
if (args.DialogResult != null && args.DialogResult.Value) |
842 |
{ |
843 |
if(RadTab.SelectedIndex == 0) |
844 |
{ |
845 |
string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
846 |
string _name = args.PromptResult; |
847 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
848 |
//Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1); |
849 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex); |
850 |
} |
851 |
else |
852 |
{ |
853 |
string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
854 |
string _name = args.PromptResult; |
855 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
856 |
//Logger.sendReqLog("RenameSymbolAsync: ", _id + "," + _name, 1); |
857 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(_id, _name, RadTab.SelectedIndex); |
858 |
} |
859 |
} |
860 |
} |
861 |
|
862 |
private async void BaseClient_RenameSymbolCompleted(object sender, ServiceDeepView.RenameSymbolCompletedEventArgs e) |
863 |
{ |
864 |
//Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1); |
865 |
await DataBindAsync(); |
866 |
} |
867 |
#endregion |
868 |
|
869 |
#region Wheel Event |
870 |
private void lstSymbolPrivate_PreviewMouseWheel(object sender, MouseWheelEventArgs e) |
871 |
{ |
872 |
ScView.ScrollToVerticalOffset(ScView.ContentVerticalOffset - (e.Delta / 2)); |
873 |
} |
874 |
private void lstSymbolPublic_PreviewMouseWheel(object sender, MouseWheelEventArgs e) |
875 |
{ |
876 |
ScView_Public.ScrollToVerticalOffset(ScView_Public.ContentVerticalOffset - (e.Delta / 2)); |
877 |
} |
878 |
#endregion |
879 |
|
880 |
#region Tab Selection Event |
881 |
private void RadTabControl_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e) |
882 |
{ |
883 |
foreach (var item in (e.OriginalSource as RadTabControl).Items) |
884 |
{ |
885 |
(item as RadTabItem).FontWeight = FontWeights.Normal; |
886 |
} |
887 |
((e.OriginalSource as RadTabControl).SelectedItem as RadTabItem).FontWeight = FontWeights.Bold; |
888 |
} |
889 |
#endregion |
890 |
|
891 |
#region Department Selection Event |
892 |
private async void deptlist_SelectionChanged(object sender, SelectionChangedEventArgs e) |
893 |
{ |
894 |
await DataBindAsync(); |
895 |
} |
896 |
#endregion |
897 |
|
898 |
#endregion |
899 |
|
900 |
private void lstSymbolPrivate_PreviewMouseUp(object sender, MouseButtonEventArgs e) |
901 |
{ |
902 |
|
903 |
} |
904 |
|
905 |
private void lstSymbolPrivate_MouseLeave(object sender, MouseEventArgs e) |
906 |
{ |
907 |
|
908 |
} |
909 |
|
910 |
private void lstSymbolPrivate_MouseDown(object sender, MouseButtonEventArgs e) |
911 |
{ |
912 |
|
913 |
} |
914 |
|
915 |
private void StackPanel_MouseLeave(object sender, MouseEventArgs e) |
916 |
{ |
917 |
if(IsMouseDown && e.LeftButton == MouseButtonState.Pressed) |
918 |
{ |
919 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.Symbol_ID = moveItem_id; |
920 |
} |
921 |
else |
922 |
{ |
923 |
IsMouseDown = false; |
924 |
} |
925 |
} |
926 |
|
927 |
private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e) |
928 |
{ |
929 |
IsMouseDown = false; |
930 |
} |
931 |
|
932 |
/// <summary> |
933 |
/// place symbol which user select |
934 |
/// </summary> |
935 |
/// <author>humkyung</author> |
936 |
/// <date>2018.06.14</date> |
937 |
/// <param name="sender"></param> |
938 |
/// <param name="e"></param> |
939 |
private void Place_Symbol(object sender, RoutedEventArgs e) |
940 |
{ |
941 |
if (lstSymbolPrivate.SelectedItem == null) |
942 |
{ |
943 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
944 |
return; |
945 |
} |
946 |
|
947 |
string id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
948 |
this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
949 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
950 |
} |
951 |
|
952 |
private void Place_Symbol_Public(object sender, RoutedEventArgs e) |
953 |
{ |
954 |
if (lstSymbolPublic.SelectedItem == null) |
955 |
{ |
956 |
DialogMessage_Alert("Please Select Symbol", "Alert"); |
957 |
return; |
958 |
} |
959 |
|
960 |
string id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
961 |
this.PlaceSymbol(id, ViewerDataModel.Instance.SystemMain.dzMainMenu.CanvasDrawingMouseDownPoint); |
962 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.None; |
963 |
} |
964 |
|
965 |
private void Image_Place_Register(object sender, RoutedEventArgs e) |
966 |
{ |
967 |
SyncInit(); |
968 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.controlType = MarkupToPDF.Controls.Common.ControlType.ImgControl; |
969 |
//캡쳐 하기 전에 코멘트 저장 |
970 |
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Count > 0 || (Application.Current.MainWindow as MainWindow).dzMainMenu.SelectLayer.Children.Count > 0) |
971 |
{ |
972 |
var menu = (Application.Current.MainWindow as MainWindow).dzMainMenu; |
973 |
SelectionSet.Instance.UnSelect(menu); |
974 |
if (menu.PreviewUserMarkupInfoItem != null && menu.PreviewUserMarkupInfoItem.IsPreviewUser == true) |
975 |
{ |
976 |
(Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null); |
977 |
} |
978 |
else if (menu.gridViewMarkup.SelectedItems.Count == 0 || (menu.gridViewMarkup.SelectedItems.FirstOrDefault() as IKCOM.MarkupInfoItem).UserID != App.ViewInfo.UserID) |
979 |
{ |
980 |
|
981 |
} |
982 |
else |
983 |
{ |
984 |
(Application.Current.MainWindow as MainWindow).dzTopMenu.SaveEventCallback(null, null); |
985 |
} |
986 |
} |
987 |
Application.Current.MainWindow.Focus(); |
988 |
Common.ViewerDataModel.Instance.Capture_Opacity = 0.49; |
989 |
(Application.Current.MainWindow as MainWindow).dzMainMenu.mouseHandlingMode = IKCOM.MouseHandlingMode.Capture; |
990 |
} |
991 |
|
992 |
|
993 |
private void SyncInit() |
994 |
{ |
995 |
try |
996 |
{ |
997 |
if (!ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden) |
998 |
{ |
999 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.testPanel2.IsHidden = true; |
1000 |
ViewerDataModel.Instance.PageBalanceMode = false; |
1001 |
ViewerDataModel.Instance.PageBalanceNumber = 0; |
1002 |
ViewerDataModel.Instance.SyncPageNumber = 0; |
1003 |
ViewerDataModel.Instance.MarkupControls_Sync.Clear(); |
1004 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.gridViewRevMarkup.Visibility = Visibility.Collapsed; |
1005 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.UserList.IsChecked = false; |
1006 |
ViewerDataModel.Instance.SystemMain.dzMainMenu.BalanceMode.IsChecked = false; |
1007 |
} |
1008 |
} |
1009 |
catch (Exception ex) |
1010 |
{ |
1011 |
//Logger.sendResLog("SyncInit", ex.Message, 0); |
1012 |
} |
1013 |
} |
1014 |
|
1015 |
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
1016 |
{ |
1017 |
var block = sender as TextBox; |
1018 |
block.Focusable = true; |
1019 |
|
1020 |
} |
1021 |
|
1022 |
private void TextBlock_MouseEnter(object sender, MouseEventArgs e) |
1023 |
{ |
1024 |
var block = sender as TextBox; |
1025 |
if (block != null) |
1026 |
{ |
1027 |
//block.Text = "Enter"; |
1028 |
|
1029 |
} |
1030 |
} |
1031 |
|
1032 |
private void OnKeyDownHandler(object sender, KeyEventArgs e) |
1033 |
{ |
1034 |
if (e.Key == Key.Return) |
1035 |
{ |
1036 |
Type type = e.OriginalSource.GetType(); |
1037 |
string id = string.Empty; |
1038 |
//Logger.sendResLog("Move_Symbol", type.Name, 0); |
1039 |
if (type.Name == "Image") |
1040 |
{ |
1041 |
id = ((e.OriginalSource as Image).DataContext as Symbol_Custom).ID; |
1042 |
} |
1043 |
else if (type.Name == "Border") |
1044 |
{ |
1045 |
id = ((e.OriginalSource as Border).DataContext as Symbol_Custom).ID; |
1046 |
} |
1047 |
else if (type.Name == "TextBox") |
1048 |
{ |
1049 |
id = ((e.OriginalSource as TextBox).DataContext as Symbol_Custom).ID; |
1050 |
} |
1051 |
|
1052 |
//((System.Windows.Controls.TextBox)sender).Text; |
1053 |
|
1054 |
if (RadTab.SelectedIndex == 0) |
1055 |
{ |
1056 |
//string _id = (lstSymbolPrivate.SelectedItem as Symbol_Custom).ID; |
1057 |
string _name = ((System.Windows.Controls.TextBox)sender).Text; |
1058 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
1059 |
//Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1); |
1060 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex); |
1061 |
} |
1062 |
else |
1063 |
{ |
1064 |
//string _id = (lstSymbolPublic.SelectedItem as Symbol_Custom).ID; |
1065 |
string _name = ((System.Windows.Controls.TextBox)sender).Text; |
1066 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolCompleted += BaseClient_RenameSymbolCompleted; |
1067 |
//Logger.sendReqLog("RenameSymbolAsync: ", id + "," + _name, 1); |
1068 |
Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.RenameSymbolAsync(id, _name, RadTab.SelectedIndex); |
1069 |
} |
1070 |
|
1071 |
} |
1072 |
} |
1073 |
|
1074 |
} |
1075 |
} |