PDFToolItem.xaml.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. using System.Windows.Media;
  6. using System.Windows.Media.Imaging;
  7. namespace PDF_Office.Views.HomePanel.PDFTools
  8. {
  9. /// <summary>
  10. /// PDFToolItem.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class PDFToolItem : UserControl
  13. {
  14. public PDFToolItem()
  15. {
  16. InitializeComponent();
  17. this.Loaded += usercontrol_Loaded;
  18. }
  19. private void usercontrol_Loaded(object sender, RoutedEventArgs e)
  20. {
  21. try
  22. {
  23. Grid Control = sender as Grid;
  24. if (Control != null)
  25. {
  26. ShowisHover(false);
  27. }
  28. if (IconPath != string.Empty)
  29. {
  30. // BitmapImage ImageItem = new BitmapImage(new Uri(IconPath));
  31. // IconBrush.ImageSource = ImageItem;
  32. // IconConcise.ImageSource = ImageItem;
  33. }
  34. InitContent();
  35. }
  36. catch (Exception ex)
  37. {
  38. }
  39. }
  40. private void InitContent()
  41. {
  42. if(ToolTitile != string.Empty)
  43. {
  44. // TitleBlock_Hov.Text = TitleBlock.Text = App.HomePageLoader.GetString(ToolTitile);
  45. }
  46. if(ToolInfo != string.Empty)
  47. {
  48. // ToolInfoBlock.Text = ToolInfoBlock_Hov.Text = App.HomePageLoader.GetString(ToolInfo);
  49. }
  50. }
  51. private void Border_MouseEnter(object sender, MouseEventArgs e)
  52. {
  53. try
  54. {
  55. Grid Control = sender as Grid;
  56. if (Control != null)
  57. {
  58. ShowisHover(true);
  59. }
  60. if (IconHoverPath != string.Empty)
  61. {
  62. // BitmapImage ImageItem = new BitmapImage(new Uri(IconHoverPath));
  63. // IconBrush.ImageSource = ImageItem;
  64. // IconConcise.ImageSource = ImageItem;
  65. }
  66. }
  67. catch (Exception ex)
  68. {
  69. }
  70. }
  71. private void Border_MouseLeave(object sender, MouseEventArgs e)
  72. {
  73. try
  74. {
  75. Grid Control = sender as Grid;
  76. if (Control != null)
  77. {
  78. ShowisHover(false);
  79. }
  80. if (IconPath != string.Empty)
  81. {
  82. // BitmapImage ImageItem = new BitmapImage(new Uri(IconPath));
  83. // IconBrush.ImageSource = ImageItem;
  84. // IconConcise.ImageSource = ImageItem;
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. }
  90. }
  91. /// <summary>
  92. /// 光标悬浮和离开区域时,各UI显示效果
  93. /// </summary>
  94. /// <param name="ishover">是否处于悬浮状态</param>
  95. private void ShowisHover(bool ishover)
  96. {
  97. if(ishover)
  98. {
  99. BorderConcise.Background = BorderExtend.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE"));
  100. BorderConcise.BorderThickness = BorderExtend.BorderThickness = new Thickness(2);
  101. TxbTitleConcise.Foreground = TxbTitle.Foreground = new SolidColorBrush(Colors.White);
  102. ToolInfoBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
  103. }
  104. else
  105. {
  106. BorderConcise.Background = BorderExtend.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
  107. BorderConcise.BorderThickness = BorderExtend.BorderThickness = new Thickness(0);
  108. TxbTitleConcise.Foreground = TxbTitle.Foreground = new SolidColorBrush(Colors.Black);
  109. ToolInfoBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#666666"));
  110. }
  111. }
  112. public string IconPath
  113. {
  114. get
  115. {
  116. return (string)GetValue(IconPathProperty);
  117. }
  118. set
  119. {
  120. SetValue(IconPathProperty, value);
  121. }
  122. }
  123. public static readonly DependencyProperty IconPathProperty = DependencyProperty.Register("IconPath", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
  124. public string IconHoverPath
  125. {
  126. get
  127. {
  128. return (string)GetValue(IconHoverPathProperty);
  129. }
  130. set
  131. {
  132. SetValue(IconHoverPathProperty, value);
  133. }
  134. }
  135. public static readonly DependencyProperty IconHoverPathProperty = DependencyProperty.Register("IconHoverPath", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
  136. public string ToolTitile
  137. {
  138. get
  139. {
  140. return (string)GetValue(ToolTitileProperty);
  141. }
  142. set
  143. {
  144. SetValue(ToolTitileProperty, value);
  145. }
  146. }
  147. public static readonly DependencyProperty ToolTitileProperty = DependencyProperty.Register("ToolTitile", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
  148. public string ToolInfo
  149. {
  150. get
  151. {
  152. return (string)GetValue(ToolInfoProperty);
  153. }
  154. set
  155. {
  156. SetValue(ToolInfoProperty, value);
  157. }
  158. }
  159. public static readonly DependencyProperty ToolInfoProperty = DependencyProperty.Register("ToolInfo", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
  160. /// <summary>
  161. /// 是否收缩UI
  162. /// </summary>
  163. public bool IsShowConciseContent
  164. {
  165. get
  166. {
  167. return (bool)GetValue(IsShowConciseContentProperty);
  168. }
  169. set
  170. {
  171. SetValue(IsShowConciseContentProperty, value);
  172. }
  173. }
  174. public static readonly DependencyProperty IsShowConciseContentProperty = DependencyProperty.Register("IsShowConciseContent", typeof(bool), typeof(PDFToolItem), new PropertyMetadata(false));
  175. }
  176. }