PDFViewerControl.xaml.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. using ComPDFKitDemo.AnntControl;
  2. using ComPDFKitDemo.BOTA;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Input;
  9. using ComPDFKitViewer;
  10. using ComPDFKitViewer.AnnotEvent;
  11. using ComPDFKitViewer.PdfViewer;
  12. using ComPDFKitDemo.WidgetForm;
  13. using ComPDFKit.PDFAnnotation.Form;
  14. using ComPDFKitViewer.AnnotView.Form;
  15. using Microsoft.Win32;
  16. using System.IO;
  17. using System.Windows.Media.Imaging;
  18. using System.Linq;
  19. using ComPDFKit.Import;
  20. namespace ComPDFKitDemo
  21. {
  22. public partial class PDFViewerControl : UserControl
  23. {
  24. private SideWindowControl sideControl;
  25. private MainWindow currentMain;
  26. public CPDFViewer currentViewer { get; private set; }
  27. public AnnotPropertiesControl AnnotSetControl;
  28. private string filePath="";
  29. private double[] zoomLevel = { 1.00f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800,1000 };
  30. public double NaviWidth
  31. {
  32. get { return DocViewerGrid.ColumnDefinitions[0].Width.Value; }
  33. set { DocViewerGrid.ColumnDefinitions[0].Width = new GridLength(value); }
  34. }
  35. public PDFViewerControl(MainWindow mainWindow)
  36. {
  37. InitializeComponent();
  38. currentMain = mainWindow;
  39. currentViewer = new CPDFViewer();
  40. sideControl = new SideWindowControl();
  41. AnnotSetControl = new AnnotPropertiesControl();
  42. AnnotSetControl.pdfViewerControl = this;
  43. NaviBarGrid.Children.Add(sideControl);
  44. PDFGrid.Children.Add(currentViewer);
  45. AnnotCtrlGrid.Children.Add(AnnotSetControl);
  46. DocViewerGrid.ColumnDefinitions[4].Width = new GridLength(200);
  47. AnnotSplitter.Visibility = Visibility.Visible;
  48. currentMain.btn_collapse.IsEnabled = false;
  49. currentMain.btn_expand.IsEnabled = true;
  50. currentViewer.AnnotActiveHandler += CurrentView_AnnotActiveHandler;
  51. currentViewer.AnnotCommandHandler += CurrentViewer_AnnotCommandHandler;
  52. currentViewer.TextEditCommandHandler += CurrentViewer_TextEditCommandHandler;
  53. currentViewer.TextEditActiveHandler += CurrentViewer_TextEditActiveHandler;
  54. currentViewer.SnapshotCommandHandler += CurrentViewer_SnapshotCommandHandler;
  55. currentViewer.MouseWheelZoomHandler += CurrentViewer_MouseWheelZoomHandler;
  56. currentViewer.AnnotEditHandler += CurrentViewer_AnnotEditHandler;
  57. currentViewer.WidgetClickHander += CurrentViewer_WidgetClickHander;
  58. }
  59. private void CurrentViewer_WidgetClickHander(object sender, WidgetArgs e)
  60. {
  61. if (e is WidgetSignArgs)
  62. {
  63. WidgetSignArgs signArgs = (WidgetSignArgs)e;
  64. //set text ap
  65. //signArgs.UpdateApWithText("hhh", "Courier-Bold", Colors.Red, 0);
  66. //set image ap
  67. OpenFileDialog openFileDialog = new OpenFileDialog();
  68. openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
  69. if (openFileDialog.ShowDialog() == true)
  70. {
  71. string ImagePath = openFileDialog.FileName;
  72. using (FileStream fileData = File.OpenRead(ImagePath))
  73. {
  74. string fileExt = Path.GetExtension(ImagePath).ToLower();
  75. BitmapFrame frame = null;
  76. BitmapDecoder decoder = BitmapDecoder.Create(fileData, BitmapCreateOptions.None, BitmapCacheOption.Default);
  77. if (decoder != null && decoder.Frames.Count > 0)
  78. {
  79. frame = decoder.Frames[0];
  80. }
  81. if (frame != null)
  82. {
  83. byte[] ImageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
  84. int ImageWidth = frame.PixelWidth;
  85. int ImageHeight = frame.PixelHeight;
  86. frame.CopyPixels(ImageArray, frame.PixelWidth * 4, 0);
  87. signArgs.UpdateApWithImage(ImageArray, ImageWidth, ImageHeight, C_Scale_Type.fitCenter, 0);
  88. }
  89. }
  90. }
  91. }
  92. }
  93. public void CurrentViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
  94. {
  95. sideControl.LoadAnnot();
  96. }
  97. private double CheckZoomLevel(double zoom, bool IsGrowth)
  98. {
  99. double standardZoom = 100;
  100. if(zoom<=0.01)
  101. {
  102. return 0.01;
  103. }
  104. if (zoom >= 10)
  105. {
  106. return 10;
  107. }
  108. zoom *= 100;
  109. for (int i = 0; i < zoomLevel.Length - 1; i++)
  110. {
  111. if (zoom > zoomLevel[i] && zoom <= zoomLevel[i + 1] && IsGrowth)
  112. {
  113. standardZoom = zoomLevel[i + 1];
  114. break;
  115. }
  116. if (zoom >= zoomLevel[i] && zoom < zoomLevel[i + 1] && !IsGrowth)
  117. {
  118. standardZoom = zoomLevel[i];
  119. break;
  120. }
  121. }
  122. return standardZoom / 100;
  123. }
  124. private void CurrentViewer_MouseWheelZoomHandler(object sender, bool e)
  125. {
  126. double newZoom = CheckZoomLevel(currentViewer.ZoomFactor+(e?0.01:-0.01), e);
  127. currentViewer.Zoom(newZoom);
  128. }
  129. private void CurrentViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
  130. {
  131. switch (e.CommandType)
  132. {
  133. case CommandType.Context:
  134. e.Handle = true;
  135. e.PopupMenu = new ContextMenu();
  136. if(e.HitSnapshotTool)
  137. {
  138. e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  139. }
  140. e.PopupMenu.Items.Add(new MenuItem() { Header = "Select All", Command = ApplicationCommands.SelectAll, CommandTarget = (UIElement)sender });
  141. break;
  142. case CommandType.Copy:
  143. {
  144. e.DoCommand();
  145. }
  146. break;
  147. default:
  148. break;
  149. }
  150. }
  151. private void CurrentViewer_TextEditActiveHandler(object sender, TextEditArgs e)
  152. {
  153. AnnotSetControl.ProcessTextEditEvent(e);
  154. }
  155. private void CurrentViewer_TextEditCommandHandler(object sender, TextEditCommand e)
  156. {
  157. switch (e.CommandType)
  158. {
  159. case CommandType.Context:
  160. e.Handle = true;
  161. e.PopupMenu = new ContextMenu();
  162. e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  163. e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  164. e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  165. e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  166. e.PopupMenu.Items.Add(new MenuItem() { Header = "Select All", Command = ApplicationCommands.SelectAll, CommandTarget = (UIElement)sender });
  167. break;
  168. case CommandType.Copy:
  169. case CommandType.Cut:
  170. case CommandType.Delete:
  171. case CommandType.SelectAll:
  172. e.DoCommand();
  173. break;
  174. case CommandType.Paste:
  175. e.DoCommand();
  176. break;
  177. }
  178. }
  179. private void CurrentViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
  180. {
  181. switch(e.CommandType)
  182. {
  183. case CommandType.Context:
  184. e.Handle = true;
  185. e.PopupMenu = new ContextMenu();
  186. e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
  187. e.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
  188. e.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
  189. e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
  190. if(e.CommandTarget==TargetType.WidgetView)
  191. {
  192. MenuItem propertyMenu = new MenuItem();
  193. propertyMenu.Header = "Property";
  194. propertyMenu.Click += PropertyMenu_Click;
  195. propertyMenu.CommandParameter = (e as WidgetViewCommandArgs);
  196. e.PopupMenu.Items.Add(propertyMenu);
  197. }
  198. if(e.CommandTarget== TargetType.Annot && e.AnnotEventArgsList.AsEnumerable().Where(x=>x.EventType==AnnotArgsType.AnnotRedaction).Count()>0)
  199. {
  200. MenuItem propertyMenu = new MenuItem();
  201. propertyMenu.Header = "Apply Redaction";
  202. propertyMenu.Click += ApplyRedaction_Click;
  203. propertyMenu.CommandParameter = e;
  204. e.PopupMenu.Items.Add(propertyMenu);
  205. }
  206. if(e.CommandTarget==TargetType.ImageSelection)
  207. {
  208. e.PopupMenu = new ContextMenu();
  209. int count = 0;
  210. if (currentViewer!=null)
  211. {
  212. count= currentViewer.GetSelectImageCount();
  213. }
  214. MenuItem copyMenu=new MenuItem();
  215. copyMenu.Header = "Copy Images";
  216. copyMenu.Click += CopyMenu_Click;
  217. copyMenu.CommandParameter = e;
  218. if(count>1)
  219. {
  220. copyMenu.IsEnabled = false;
  221. }
  222. e.PopupMenu.Items.Add(copyMenu);
  223. MenuItem extractMenu = new MenuItem();
  224. extractMenu.Header = "Extract Images";
  225. extractMenu.Click += ExtractMenu_Click;
  226. extractMenu.CommandParameter = e;
  227. e.PopupMenu.Items.Add(extractMenu);
  228. }
  229. if(e.PressOnMedia || e.PressOnSound)
  230. {
  231. e.PopupMenu = new ContextMenu();
  232. //if(e.PressOnSound)
  233. //{
  234. // e.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender,CommandParameter=e});
  235. //}
  236. e.PopupMenu.Items.Add(new MenuItem() { Header = "Play", Command = MediaCommands.Play, CommandTarget = (UIElement)sender,CommandParameter=e });
  237. }
  238. break;
  239. default:
  240. e.DoCommand();
  241. break;
  242. }
  243. }
  244. private void ExtractMenu_Click(object sender, RoutedEventArgs e)
  245. {
  246. System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
  247. if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  248. {
  249. string choosePath = folderDialog.SelectedPath;
  250. try
  251. {
  252. Dictionary<int, List<System.Drawing.Bitmap>> imageDict = currentViewer?.GetSelectedImages();
  253. if (imageDict != null && imageDict.Count > 0)
  254. {
  255. foreach (int pageIndex in imageDict.Keys)
  256. {
  257. List<System.Drawing.Bitmap> imageList = imageDict[pageIndex];
  258. foreach (System.Drawing.Bitmap image in imageList)
  259. {
  260. string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
  261. image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  262. }
  263. }
  264. }
  265. Process.Start("explorer", "/select,\"" + choosePath + "\"");
  266. }
  267. catch (Exception ex)
  268. {
  269. }
  270. }
  271. }
  272. private void CopyMenu_Click(object sender, RoutedEventArgs e)
  273. {
  274. try
  275. {
  276. Dictionary<int, List<System.Drawing.Bitmap>> imageDict = currentViewer?.GetSelectedImages();
  277. if (imageDict != null && imageDict.Count > 0)
  278. {
  279. foreach (int pageIndex in imageDict.Keys)
  280. {
  281. List<System.Drawing.Bitmap> imageList = imageDict[pageIndex];
  282. foreach (System.Drawing.Bitmap image in imageList)
  283. {
  284. MemoryStream ms = new MemoryStream();
  285. image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
  286. BitmapImage imageData = new BitmapImage();
  287. imageData.BeginInit();
  288. imageData.StreamSource = ms;
  289. imageData.CacheOption = BitmapCacheOption.OnLoad;
  290. imageData.EndInit();
  291. imageData.Freeze();
  292. Clipboard.SetImage(imageData);
  293. break;
  294. }
  295. }
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. }
  301. }
  302. private void ApplyRedaction_Click(object sender, RoutedEventArgs e)
  303. {
  304. if(currentViewer!=null)
  305. {
  306. currentViewer.Document.ApplyRedaction();
  307. currentViewer.Document.ReleasePages();
  308. currentViewer.ReloadDocument();
  309. }
  310. }
  311. private void MenuItem_Click(object sender, RoutedEventArgs e)
  312. {
  313. }
  314. private void PopFormDialog(WidgetAttribEvent attribEvent)
  315. {
  316. switch (attribEvent.WidgeType)
  317. {
  318. #region 不同表单控件属性弹窗
  319. case C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  320. {
  321. RadioFormProperty formProperty = new RadioFormProperty();
  322. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  323. formProperty.ShowInTaskbar = false;
  324. formProperty.Owner = Window.GetWindow(this);
  325. formProperty.CurrentAttribEvent = null;
  326. formProperty.SetFormData(attribEvent);
  327. formProperty.CurrentAttribEvent = attribEvent;
  328. formProperty.Show();
  329. }
  330. break;
  331. case C_WIDGET_TYPE.WIDGET_CHECKBOX:
  332. {
  333. CheckBoxFormProperty formProperty = new CheckBoxFormProperty();
  334. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  335. formProperty.ShowInTaskbar = false;
  336. formProperty.Owner = Window.GetWindow(this);
  337. formProperty.CurrentAttribEvent = null;
  338. formProperty.SetFormData(attribEvent);
  339. formProperty.CurrentAttribEvent = attribEvent;
  340. formProperty.Show();
  341. }
  342. break;
  343. case C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  344. {
  345. TextFieldFormProperty formProperty = new TextFieldFormProperty();
  346. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  347. formProperty.ShowInTaskbar = false;
  348. formProperty.Owner = Window.GetWindow(this);
  349. formProperty.CurrentAttribEvent = null;
  350. formProperty.SetFormData(attribEvent);
  351. formProperty.CurrentAttribEvent = attribEvent;
  352. formProperty.Show();
  353. }
  354. break;
  355. case C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  356. {
  357. PushButtonFormProperty formProperty = new PushButtonFormProperty();
  358. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  359. formProperty.ShowInTaskbar = false;
  360. formProperty.Owner = Window.GetWindow(this);
  361. formProperty.CurrentAttribEvent = null;
  362. formProperty.SetFormData(attribEvent);
  363. formProperty.CurrentAttribEvent = attribEvent;
  364. formProperty.Show();
  365. }
  366. break;
  367. case C_WIDGET_TYPE.WIDGET_LISTBOX:
  368. {
  369. ListBoxFormProperty formProperty = new ListBoxFormProperty();
  370. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  371. formProperty.ShowInTaskbar = false;
  372. formProperty.Owner = Window.GetWindow(this);
  373. formProperty.CurrentAttribEvent = null;
  374. formProperty.SetFormData(attribEvent);
  375. formProperty.CurrentAttribEvent = attribEvent;
  376. formProperty.Show();
  377. }
  378. break;
  379. case C_WIDGET_TYPE.WIDGET_COMBOBOX:
  380. {
  381. ComboBoxFormProperty formProperty = new ComboBoxFormProperty();
  382. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  383. formProperty.ShowInTaskbar = false;
  384. formProperty.Owner = Window.GetWindow(this);
  385. formProperty.CurrentAttribEvent = null;
  386. formProperty.SetFormData(attribEvent);
  387. formProperty.CurrentAttribEvent = attribEvent;
  388. formProperty.Show();
  389. }
  390. break;
  391. case C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  392. {
  393. SignFormProperty formProperty = new SignFormProperty();
  394. formProperty.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  395. formProperty.ShowInTaskbar = false;
  396. formProperty.Owner = Window.GetWindow(this);
  397. formProperty.CurrentAttribEvent = null;
  398. formProperty.SetFormData(attribEvent);
  399. formProperty.CurrentAttribEvent = attribEvent;
  400. formProperty.Show();
  401. }
  402. break;
  403. #endregion
  404. default:
  405. break;
  406. }
  407. }
  408. private void PropertyMenu_Click(object sender, RoutedEventArgs e)
  409. {
  410. MenuItem menuItem = sender as MenuItem;
  411. if(menuItem != null && menuItem.CommandParameter is WidgetViewCommandArgs)
  412. {
  413. WidgetViewCommandArgs widgetArgs=menuItem.CommandParameter as WidgetViewCommandArgs;
  414. PopFormDialog(widgetArgs.AnnotEvent);
  415. }
  416. }
  417. #region Events
  418. public void CurrentView_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  419. {
  420. if (sideControl!=null)
  421. {
  422. Dictionary<int, List<int>> pageAnnots = new Dictionary<int, List<int>>();
  423. if (e != null)
  424. {
  425. pageAnnots= e.GetPageAnnotsIndex();
  426. }
  427. sideControl.SetSelectAnnotList(pageAnnots);
  428. }
  429. if((e is WidgetAttribEvent) || (e!=null &&e.GetAnnotTypes()==AnnotArgsType.WidgetViewForm))
  430. {
  431. }
  432. else
  433. {
  434. AnnotSetControl.ProcessAnnotEvents(e);
  435. }
  436. }
  437. #endregion
  438. #region Method
  439. public bool OpenPDF(string fileName)
  440. {
  441. try
  442. {
  443. currentViewer.InitDocument(fileName);
  444. if (currentViewer.Document == null)
  445. {
  446. MessageBox.Show("Open File Failed");
  447. return false;
  448. }
  449. /* //old
  450. while(currentViewer.Document.IsLocked)
  451. {
  452. PasswordDlg dlg = new PasswordDlg();
  453. System.Windows.Forms.DialogResult dlg_result = dlg.ShowDialog();
  454. if (dlg_result == System.Windows.Forms.DialogResult.Cancel && dlg.press_key != 13)
  455. {
  456. currentViewer.CloseDocument();
  457. return false;
  458. }
  459. currentViewer.Document.UnlockWithPassword(dlg.password);
  460. if(currentViewer.Document.IsLocked)
  461. MessageBox.Show("Password error.");
  462. }
  463. */
  464. if(currentViewer.Document.IsLocked)
  465. {
  466. EnterPasswordDlg dlg = new EnterPasswordDlg(currentViewer);
  467. bool? res = dlg.ShowDialog();
  468. }
  469. currentViewer.Load();
  470. }
  471. catch (Exception ex)
  472. {
  473. return false;
  474. }
  475. if (currentViewer.Document == null || currentViewer.Document.IsLocked)
  476. return false;
  477. filePath = fileName;
  478. currentMain.filePathList.Add(fileName);
  479. return true;
  480. }
  481. public void ClosePDF()
  482. {
  483. currentViewer.CloseDocument();
  484. currentMain.filePathList.Remove(filePath);
  485. sideControl = null;
  486. currentMain = null;
  487. AnnotSetControl = null;
  488. }
  489. public void OpenNavibar()
  490. {
  491. DocViewerGrid.ColumnDefinitions[0].Width = new GridLength(400);
  492. currentMain.btn_expand.IsEnabled = false;
  493. currentMain.btn_collapse.IsEnabled = true;
  494. SideWindowSplitter.Visibility = Visibility.Visible;
  495. if(sideControl.ThumbnailGrid!=null && sideControl.ThumbnailGrid.Children.Count>0)
  496. {
  497. ThumbnailsControl thumbnailCtrl = sideControl.ThumbnailGrid.Children[0] as ThumbnailsControl;
  498. if(thumbnailCtrl!=null)
  499. {
  500. thumbnailCtrl.Visibility = Visibility.Visible;
  501. }
  502. }
  503. sideControl.Visibility = Visibility.Visible;
  504. sideControl.CreateSideWindow(currentViewer);
  505. }
  506. public void CloseNavibar()
  507. {
  508. DocViewerGrid.ColumnDefinitions[0].Width = new GridLength(0);
  509. currentMain.btn_collapse.IsEnabled = false;
  510. currentMain.btn_expand.IsEnabled = true;
  511. SideWindowSplitter.Visibility = Visibility.Collapsed;
  512. if (sideControl.ThumbnailGrid != null && sideControl.ThumbnailGrid.Children.Count > 0)
  513. {
  514. ThumbnailsControl thumbnailCtrl = sideControl.ThumbnailGrid.Children[0] as ThumbnailsControl;
  515. if (thumbnailCtrl != null)
  516. {
  517. thumbnailCtrl.Visibility = Visibility.Collapsed;
  518. }
  519. }
  520. sideControl.Visibility = Visibility.Collapsed;
  521. }
  522. public void HorizontalSplit()
  523. {
  524. currentViewer.SetSplitMode(SplitMode.Horizontal);
  525. }
  526. public void VerticalSplit()
  527. {
  528. currentViewer.SetSplitMode(SplitMode.Vertical);
  529. }
  530. public void NoneSplit()
  531. {
  532. currentViewer.SetSplitMode(SplitMode.None);
  533. }
  534. public void SetMouseMode(MouseModes mouseMode)
  535. {
  536. currentViewer.SetMouseMode(mouseMode);
  537. }
  538. public void SetToolParam(AnnotHandlerEventArgs args)
  539. {
  540. currentViewer.SetToolParam(args);
  541. }
  542. public ToolManager CurrentToolManager
  543. {
  544. get
  545. {
  546. if(currentViewer!=null)
  547. {
  548. return currentViewer.ToolManager;
  549. }
  550. return null;
  551. }
  552. }
  553. public UndoManager CurrentUndoManager
  554. {
  555. get
  556. {
  557. if (currentViewer != null)
  558. {
  559. return currentViewer.UndoManager;
  560. }
  561. return null;
  562. }
  563. }
  564. #endregion
  565. }
  566. }