QuickToolsContent.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using PDF_Office.CustomControl;
  2. using PDF_Office.Helper;
  3. using PDF_Office.Model.PDFTool;
  4. using PDF_Office.ViewModels.HomePanel;
  5. using PDF_Office.Views.HomePanel.PDFTools;
  6. using PDFSettings;
  7. using System.Collections.Generic;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Media;
  11. namespace PDF_Office.Views.HomePanel.PDFTools
  12. {
  13. /// <summary>
  14. /// HomeToolIControl.xaml 的交互逻辑0
  15. ///
  16. /// </summary>
  17. public partial class QuickToolsContent : UserControl
  18. {
  19. PDFToolsHelper PDFtools;
  20. public QuickToolsContent()
  21. {
  22. InitializeComponent();
  23. PDFtools = new PDFToolsHelper();
  24. ListBoxToolBars.ItemsSource = PDFtools.QuickTools;
  25. }
  26. private void BtnMore_Click(object sender, RoutedEventArgs e)
  27. {
  28. if (GridAllTools.Height != 270)
  29. {
  30. GridAllTools.Height = 270;
  31. ShowToolsUI(false);
  32. }
  33. else
  34. {
  35. GridAllTools.Height = 184;
  36. ShowToolsUI(true);
  37. }
  38. }
  39. /// <summary>
  40. /// 扩展收缩UI
  41. /// </summary>
  42. /// <param name="IsShowConciseContent">是否收缩</param>
  43. private void ShowToolsUI(bool IsShowConciseContent)
  44. {
  45. //foreach (var item in ListBoxToolBars.Items)
  46. //{
  47. // var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
  48. // if (listBoxItem != null)
  49. // {
  50. // var viewItem = listBoxItem.ContentTemplate;
  51. // var myContentPresenter = CommonHelper.FindVisualChild<ContentPresenter>(listBoxItem);
  52. // var obj = viewItem.FindName("data", myContentPresenter);
  53. // var checkNum = obj as PDFToolItem;
  54. // if (checkNum != null)
  55. // {
  56. // checkNum.IsShowConciseContent = IsShowConciseContent;
  57. // }
  58. // }
  59. //}
  60. }
  61. /// <summary>
  62. /// 编辑工具
  63. /// </summary>
  64. private void BtnTools_Click(object sender, RoutedEventArgs e)
  65. {
  66. }
  67. private void GridAllTools_SizeChanged(object sender, SizeChangedEventArgs e)
  68. {
  69. ListBoxToolBarsWidthChanged();
  70. }
  71. private void ListBoxToolBarsWidthChanged()
  72. {
  73. double containerWidth = ListBoxToolBars.ActualWidth - 20;
  74. int widthItem = (int)containerWidth / 5;
  75. double margin = widthItem / 3;
  76. int i = 0;
  77. foreach (var item in ListBoxToolBars.Items)
  78. {
  79. i++;
  80. var listBoxItem = ListBoxToolBars.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
  81. if (listBoxItem != null)
  82. {
  83. if (i % 4 != 0)
  84. {
  85. listBoxItem.Margin = new Thickness(0, 0, margin, 20);
  86. }
  87. else
  88. {
  89. listBoxItem.Margin = new Thickness(0, 0, 0, 20);
  90. }
  91. listBoxItem.Width = widthItem;
  92. }
  93. }
  94. }
  95. private void ListBoxShortCuts_SizeChanged(object sender, SizeChangedEventArgs e)
  96. {
  97. }
  98. private void QuickTools_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
  99. {
  100. var toolItem = (sender as FrameworkElement).DataContext as ToolItem;
  101. var veiwModel = this.DataContext as HomeGuidContentViewModel;
  102. if (veiwModel != null && toolItem != null)
  103. {
  104. veiwModel.QuickToolsCommand.Execute(toolItem);
  105. }
  106. }
  107. }
  108. }