Преглед на файлове

图标按钮

样式分支
pry преди 2 години
родител
ревизия
0381f2e93c
променени са 8 файла, в които са добавени 257 реда и са изтрити 170 реда
  1. +0
    -4
      BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
  2. +16
    -0
      BPASmartClient.CustomResource/Properties/AssemblyInfo.cs
  3. +16
    -2
      BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml
  4. +46
    -0
      BPASmartClient.CustomResource/Themes/Generic.xaml
  5. +173
    -0
      BPASmartClient.CustomResource/UserControls/IcoButton.cs
  6. +0
    -69
      BPASmartClient.CustomResource/UserControls/IcoButton.xaml
  7. +0
    -88
      BPASmartClient.CustomResource/UserControls/IcoButton.xaml.cs
  8. +6
    -7
      BPASmartClient/Control/ShopDeviceConfigView.xaml

+ 0
- 4
BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj Целия файл

@@ -199,10 +199,6 @@
<Resource Include="Image\顶部切图\黑菠萝智慧餐饮管理系统.png" />
</ItemGroup>

<ItemGroup>
<Folder Include="Themes\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.12" />
</ItemGroup>


+ 16
- 0
BPASmartClient.CustomResource/Properties/AssemblyInfo.cs Целия файл

@@ -0,0 +1,16 @@
using System.Runtime.InteropServices;

[assembly: System.Windows.ThemeInfo(System.Windows.ResourceDictionaryLocation.None, System.Windows.ResourceDictionaryLocation.SourceAssembly)]

// 在此类的 SDK 样式项目中,现在,在此文件中早前定义的几个程序集属性将在生成期间自动添加,并使用在项目属性中定义的值进行填充。有关包含的属性以及如何定制此过程的详细信息,请参阅
// https://aka.ms/assembly-info-properties


// 将 ComVisible 设置为 false 会使此程序集中的类型对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,请将该类型的 ComVisible
// 属性设置为 true。

[assembly: ComVisible(false)]

// 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID。

[assembly: Guid("ad425ef8-378d-4499-b279-09b566451a3e")]

+ 16
- 2
BPASmartClient.CustomResource/RecDictionarys/RecIcoButtonStyle.xaml Целия файл

@@ -1,5 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls">


<ControlTemplate x:Key="IcoButtonTemp" TargetType="Button">
<Border
x:Name="br"
@@ -28,4 +32,14 @@

</ControlTemplate.Triggers>
</ControlTemplate>

<Style x:Key="NewButtonStyle" TargetType="local:IcoButton">
<Setter Property="FontFamily" Value="../Fonts/#iconfont" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#ff19b7ec" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="EnterBackground" Value="#2219b7ec" />
</Style>

</ResourceDictionary>

+ 46
- 0
BPASmartClient.CustomResource/Themes/Generic.xaml Целия файл

@@ -0,0 +1,46 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls">

<!--#region icoButton-->
<Style TargetType="{x:Type local:IcoButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:IcoButton}">
<Grid Name="PART_gr">
<Border
Name="PART_br"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Name="PART_icoText"
Margin="0,0,10,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" />
<TextBlock
Name="PART_content"
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->

</ResourceDictionary>

+ 173
- 0
BPASmartClient.CustomResource/UserControls/IcoButton.cs Целия файл

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.CustomResource.UserControls
{
/// <summary>
/// 按照步骤 1a 或 1b 操作,然后执行步骤 2 以在 XAML 文件中使用此自定义控件。
///
/// 步骤 1a) 在当前项目中存在的 XAML 文件中使用该自定义控件。
/// 将此 XmlNamespace 特性添加到要使用该特性的标记文件的根
/// 元素中:
///
/// xmlns:MyNamespace="clr-namespace:BPASmartClient.CustomResource.UserControls"
///
///
/// 步骤 1b) 在其他项目中存在的 XAML 文件中使用该自定义控件。
/// 将此 XmlNamespace 特性添加到要使用该特性的标记文件的根
/// 元素中:
///
/// xmlns:MyNamespace="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource.UserControls"
///
/// 您还需要添加一个从 XAML 文件所在的项目到此项目的项目引用,
/// 并重新生成以避免编译错误:
///
/// 在解决方案资源管理器中右击目标项目,然后依次单击
/// “添加引用”->“项目”->[浏览查找并选择此项目]
///
///
/// 步骤 2)
/// 继续操作并在 XAML 文件中使用控件。
///
/// <MyNamespace:IcoButton/>
///
/// </summary>
public class IcoButton : Control
{
static IcoButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(IcoButton), new FrameworkPropertyMetadata(typeof(IcoButton)));
}

private Brush tempBackground;

private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as IcoButton)?.Refresh();
}

private void Refresh()
{
tempBackground = this.Background;
}

public Action Command
{
get { return (Action)GetValue(CommandProperty); }
set { SetValue(CommandProperty, value); }
}
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register("Command", typeof(Action), typeof(IcoButton),
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));

public string Content
{
get { return (string)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(string), typeof(IcoButton),
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));

public string IcoText
{
get { return (string)GetValue(IcoTextProperty); }
set { SetValue(IcoTextProperty, value); }
}
public static readonly DependencyProperty IcoTextProperty =
DependencyProperty.Register("IcoText", typeof(string), typeof(IcoButton),
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));

public Brush EnterBackground
{
get { return (Brush)GetValue(EnterBackgroundProperty); }
set { SetValue(EnterBackgroundProperty, value); }
}
public static readonly DependencyProperty EnterBackgroundProperty =
DependencyProperty.Register("EnterBackground", typeof(Brush), typeof(IcoButton),
new PropertyMetadata(Brushes.DarkGray, new PropertyChangedCallback(OnPropertyChanged)));


public Brush PressedBackground
{
get { return (Brush)GetValue(PressedBackgroundProperty); }
set { SetValue(PressedBackgroundProperty, value); }
}
public static readonly DependencyProperty PressedBackgroundProperty =
DependencyProperty.Register("PressedBackground", typeof(Brush), typeof(IcoButton),
new PropertyMetadata(Brushes.Gray, new PropertyChangedCallback(OnPropertyChanged)));


public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var icon = base.GetTemplateChild("PART_icoText") as TextBlock;
var content = base.GetTemplateChild("PART_content") as TextBlock;
var gr = base.GetTemplateChild("PART_gr") as Grid;

if (icon != null)
{
Binding binding = new Binding("IcoText");
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
binding.RelativeSource = new RelativeSource() { AncestorType = typeof(IcoButton), Mode = RelativeSourceMode.FindAncestor };
icon.SetBinding(TextBlock.TextProperty, binding);
}

if (content != null)
{
Binding binding = new Binding("Content");
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
binding.RelativeSource = new RelativeSource() { AncestorType = typeof(IcoButton), Mode = RelativeSourceMode.FindAncestor };
content.SetBinding(TextBlock.TextProperty, binding);
}

if (gr != null)
{
gr.MouseLeftButtonDown += Gr_MouseLeftButtonDown;
gr.MouseEnter += Gr_MouseEnter;
gr.MouseLeave += Gr_MouseLeave;
}
}

/// <summary>
/// 鼠标离开颜色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Gr_MouseLeave(object sender, MouseEventArgs e)
{
//VisualStateManager.GoToState(this, "Leave", true);
this.Background = tempBackground;
}

/// <summary>
/// 鼠标进入颜色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Gr_MouseEnter(object sender, MouseEventArgs e)
{
//VisualStateManager.GoToState(this, "Enter", true);
this.Background = EnterBackground;
}

private void Gr_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (Command != null) Command();
this.Background = PressedBackground;
}

}
}

+ 0
- 69
BPASmartClient.CustomResource/UserControls/IcoButton.xaml Целия файл

@@ -1,69 +0,0 @@
<Button
x:Class="BPASmartClient.CustomResource.UserControls.IcoButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:con="clr-namespace:BPASmartClient.CustomResource.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.CustomResource.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="30"
d:DesignWidth="130"
mc:Ignorable="d">

<!--<UserControl.Resources>
<Style x:Key="IcoButtonStyle" TargetType="Button">
<Setter Property="FontFamily" Value="../Fonts/#iconfont" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
x:Name="br"
Background="Transparent"
BorderBrush="#FF19B7EC"
BorderThickness="2">
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{Binding}"
Text="{Binding ElementName=br}" />
<ContentControl
Margin="10,0,5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="br" Property="Background" Value="#2219B7EC" />
</Trigger>

<Trigger Property="IsPressed" Value="true">
<Setter TargetName="br" Property="Background" Value="#2219B7EC" />
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>-->

<Grid>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Name="ico"
FontFamily="../Fonts/#iconfont"
Text="{Binding IcoText, RelativeSource={RelativeSource AncestorType=Button, Mode=FindAncestor}}" />
<TextBlock Name="con" Margin="10 0 0 0" Text="{Binding Context, RelativeSource={RelativeSource AncestorType=Button, Mode=FindAncestor}}" />
</StackPanel>
</Grid>
</Button>

+ 0
- 88
BPASmartClient.CustomResource/UserControls/IcoButton.xaml.cs Целия файл

@@ -1,88 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BPASmartClient.CustomResource.UserControls
{
/// <summary>
/// IcoButton.xaml 的交互逻辑
/// </summary>
public partial class IcoButton : Button
{
public IcoButton()
{
InitializeComponent();
}

public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as IcoButton).Refresh();
}

private void Refresh()
{
this.ico.Text = IcoText;
this.con.Text = Context;

this.ico.FontSize = PryFontSize;
this.con.FontSize = PryFontSize;

this.ico.Foreground = PryForeground;
this.con.Foreground = PryForeground;

}


public Brush PryForeground
{
get { return (Brush)GetValue(PryForegroundProperty); }
set { SetValue(PryForegroundProperty, value); }
}
public static readonly DependencyProperty PryForegroundProperty =
DependencyProperty.Register("PryForeground", typeof(Brush), typeof(IcoButton),
new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged)));


public double PryFontSize
{
get { return (double)GetValue(PryFontSizeProperty); }
set { SetValue(PryFontSizeProperty, value); }
}
public static readonly DependencyProperty PryFontSizeProperty =
DependencyProperty.Register("PryFontSize", typeof(double), typeof(IcoButton),
new PropertyMetadata(12, new PropertyChangedCallback(OnPropertyChanged)));


public string IcoText
{
get { return (string)GetValue(IcoTextProperty); }
set { SetValue(IcoTextProperty, value); }
}
public static readonly DependencyProperty IcoTextProperty =
DependencyProperty.Register("IcoText", typeof(string), typeof(IcoButton),
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));


public string Context
{
get { return (string)GetValue(ContextProperty); }
set { SetValue(ContextProperty, value); }
}
public static readonly DependencyProperty ContextProperty =
DependencyProperty.Register("Context", typeof(string), typeof(IcoButton),
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged)));


}
}

+ 6
- 7
BPASmartClient/Control/ShopDeviceConfigView.xaml Целия файл

@@ -76,7 +76,7 @@
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<StackPanel x:Name="sp" HorizontalAlignment="Right" Orientation="Horizontal">

<TextBlock Style="{StaticResource TextBlockStyle}" Text="请选择店铺:" />

@@ -95,15 +95,14 @@
Style="{StaticResource ComboBoxStyle}"
Text="{Binding ClientDeviceType}" />

<!--<Button Content="aaaa"/>-->
<pry:IcoButton
Width="100"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Context="新建"
Content="新建"
FontSize="16"
Foreground="{StaticResource TextBlockForeground}"
IcoText="&#xe626;"
PryForeground="{StaticResource TextBlockForeground}"
Template="{StaticResource IcoButtonTemp}" />
Style="{StaticResource NewButtonStyle}" />

<!--<Button
Width="140"


Зареждане…
Отказ
Запис