123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- namespace PDF_Office.Views.HomePanel.PDFTools
- {
- /// <summary>
- /// PDFToolItem.xaml 的交互逻辑
- /// </summary>
- public partial class PDFToolItem : UserControl
- {
- public PDFToolItem()
- {
- InitializeComponent();
- this.Loaded += usercontrol_Loaded;
- }
- private void usercontrol_Loaded(object sender, RoutedEventArgs e)
- {
- try
- {
- Grid Control = sender as Grid;
- if (Control != null)
- {
- ShowisHover(false);
- }
- if (IconPath != string.Empty)
- {
- // BitmapImage ImageItem = new BitmapImage(new Uri(IconPath));
- // IconBrush.ImageSource = ImageItem;
- // IconConcise.ImageSource = ImageItem;
- }
- InitContent();
- }
- catch (Exception ex)
- {
- }
- }
- private void InitContent()
- {
- if(ToolTitile != string.Empty)
- {
- // TitleBlock_Hov.Text = TitleBlock.Text = App.HomePageLoader.GetString(ToolTitile);
- }
- if(ToolInfo != string.Empty)
- {
- // ToolInfoBlock.Text = ToolInfoBlock_Hov.Text = App.HomePageLoader.GetString(ToolInfo);
- }
- }
- private void Border_MouseEnter(object sender, MouseEventArgs e)
- {
- try
- {
- Grid Control = sender as Grid;
- if (Control != null)
- {
- ShowisHover(true);
- }
- if (IconHoverPath != string.Empty)
- {
- // BitmapImage ImageItem = new BitmapImage(new Uri(IconHoverPath));
- // IconBrush.ImageSource = ImageItem;
- // IconConcise.ImageSource = ImageItem;
- }
-
- }
- catch (Exception ex)
- {
- }
- }
- private void Border_MouseLeave(object sender, MouseEventArgs e)
- {
- try
- {
- Grid Control = sender as Grid;
- if (Control != null)
- {
- ShowisHover(false);
- }
- if (IconPath != string.Empty)
- {
- // BitmapImage ImageItem = new BitmapImage(new Uri(IconPath));
- // IconBrush.ImageSource = ImageItem;
- // IconConcise.ImageSource = ImageItem;
- }
-
- }
- catch (Exception ex)
- {
- }
- }
- /// <summary>
- /// 光标悬浮和离开区域时,各UI显示效果
- /// </summary>
- /// <param name="ishover">是否处于悬浮状态</param>
- private void ShowisHover(bool ishover)
- {
- if(ishover)
- {
- BorderConcise.Background = BorderExtend.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#477EDE"));
- BorderConcise.BorderThickness = BorderExtend.BorderThickness = new Thickness(2);
- TxbTitleConcise.Foreground = TxbTitle.Foreground = new SolidColorBrush(Colors.White);
- ToolInfoBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
-
- }
- else
- {
- BorderConcise.Background = BorderExtend.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
- BorderConcise.BorderThickness = BorderExtend.BorderThickness = new Thickness(0);
- TxbTitleConcise.Foreground = TxbTitle.Foreground = new SolidColorBrush(Colors.Black);
- ToolInfoBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#666666"));
-
- }
- }
- public string IconPath
- {
- get
- {
- return (string)GetValue(IconPathProperty);
- }
- set
- {
- SetValue(IconPathProperty, value);
- }
- }
- public static readonly DependencyProperty IconPathProperty = DependencyProperty.Register("IconPath", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
- public string IconHoverPath
- {
- get
- {
- return (string)GetValue(IconHoverPathProperty);
- }
- set
- {
- SetValue(IconHoverPathProperty, value);
- }
- }
- public static readonly DependencyProperty IconHoverPathProperty = DependencyProperty.Register("IconHoverPath", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
- public string ToolTitile
- {
- get
- {
- return (string)GetValue(ToolTitileProperty);
- }
- set
- {
- SetValue(ToolTitileProperty, value);
- }
- }
- public static readonly DependencyProperty ToolTitileProperty = DependencyProperty.Register("ToolTitile", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
- public string ToolInfo
- {
- get
- {
- return (string)GetValue(ToolInfoProperty);
- }
- set
- {
- SetValue(ToolInfoProperty, value);
- }
- }
- public static readonly DependencyProperty ToolInfoProperty = DependencyProperty.Register("ToolInfo", typeof(string), typeof(PDFToolItem), new PropertyMetadata(string.Empty));
- /// <summary>
- /// 是否收缩UI
- /// </summary>
- public bool IsShowConciseContent
- {
- get
- {
- return (bool)GetValue(IsShowConciseContentProperty);
- }
- set
- {
- SetValue(IsShowConciseContentProperty, value);
- }
- }
- public static readonly DependencyProperty IsShowConciseContentProperty = DependencyProperty.Register("IsShowConciseContent", typeof(bool), typeof(PDFToolItem), new PropertyMetadata(false));
- }
- }
|