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
{
///
/// PDFToolItem.xaml 的交互逻辑
///
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)
{
}
}
///
/// 光标悬浮和离开区域时,各UI显示效果
///
/// 是否处于悬浮状态
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));
///
/// 是否收缩UI
///
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));
}
}