@@ -0,0 +1,42 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Data; | |||
using System.Windows.Data; | |||
using System.Globalization; | |||
using System.Text.RegularExpressions; | |||
namespace BPASmartClient.CustomResource.Converters | |||
{ | |||
public class StringToIconConverter : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
if (value != null) | |||
{ | |||
return Regex.Unescape(StringToUnicode(value.ToString())); | |||
} | |||
return value; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
/// <summary> | |||
/// 字符串转为UniCode码字符串 | |||
/// </summary> | |||
public static string StringToUnicode(string s) | |||
{ | |||
if (!string.IsNullOrEmpty(s)) | |||
{ | |||
//这里把格式 转为 \ue625 | |||
return s.Replace(@"&#x", @"\u").Replace(";", ""); | |||
} | |||
return s; | |||
} | |||
} | |||
} |
@@ -1,4 +1,7 @@ | |||
<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:con="clr-namespace:BPASmartClient.CustomResource.Converters" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |||
<!-- 文本框的字体颜色 --> | |||
<SolidColorBrush x:Key="TextBlockForeground" Color="#9934F7F7" /> | |||
<!--<con:StringToIconConverter x:Key="StringToIconConverter"/>--> | |||
</ResourceDictionary> |
@@ -2,6 +2,7 @@ | |||
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" | |||
@@ -52,35 +53,44 @@ | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources>--> | |||
<UserControl.Resources> | |||
<con:StringToIconConverter x:Key="StringToIconConverter" /> | |||
</UserControl.Resources> | |||
<Grid> | |||
<!--<Canvas Width="auto" Height="auto">--> | |||
<Button Name="a"> | |||
<!--<TextBlock | |||
x:Name="tbx" | |||
FontFamily="../Fonts/#iconfont" | |||
Text="{Binding Path=IcoText, Mode=TwoWay, Converter={StaticResource StringToIconConverter}}" />--> | |||
<TextBlock x:Name="tbx" Foreground="Red" FontSize="14" /> | |||
<!--<Button Name="a"> | |||
<Button.Style> | |||
<Style TargetType="Button"> | |||
<Setter Property="FontFamily" Value="../Fonts/#iconfont" /> | |||
--> | |||
<!--<Setter Property="FontFamily" Value="../Fonts/#iconfont" />--> | |||
<!-- | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="Button"> | |||
<Border | |||
x:Name="br" | |||
Background="Transparent" | |||
BorderBrush="#FF19B7EC" | |||
BorderThickness="2"> | |||
x:Name="br" | |||
Background="Transparent" | |||
BorderBrush="#FF19B7EC" | |||
BorderThickness="2"> | |||
<StackPanel | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
<TextBlock | |||
Margin="0,0,5,0" | |||
FontFamily="../Fonts/#iconfont" | |||
Text="我是图标" /> | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Orientation="Horizontal"> | |||
--> | |||
<!--<TextBlock FontFamily="../Fonts/#iconfont" Text="{Binding Path=IcoText, Converter={StaticResource StringToIconConverter}}" />--> | |||
<!-- | |||
<ContentControl | |||
Margin="10,0,5,0" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
Margin="10,0,5,0" | |||
VerticalAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
@@ -98,7 +108,7 @@ | |||
</Setter> | |||
</Style> | |||
</Button.Style> | |||
</Button> | |||
</Button>--> | |||
<!--</Canvas>--> | |||
</Grid> | |||
</UserControl> |
@@ -32,7 +32,7 @@ namespace BPASmartClient.CustomResource.UserControls | |||
private void Refresh() | |||
{ | |||
tbx.Text = this.IcoText; | |||
} | |||
public int BorderThickness | |||
@@ -52,7 +52,7 @@ namespace BPASmartClient.CustomResource.UserControls | |||
} | |||
public static readonly DependencyProperty IcoTextProperty = | |||
DependencyProperty.Register("IcoText", typeof(string), typeof(IcoButton), | |||
new PropertyMetadata("", new PropertyChangedCallback(OnPropertyChanged))); | |||
new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnPropertyChanged))); | |||
} | |||
} |
@@ -102,7 +102,7 @@ | |||
VerticalAlignment="Center" | |||
Content="新建" | |||
Foreground="{StaticResource TextBlockForeground}" | |||
IcoText="" /> | |||
IcoText="AA" /> | |||
<!--<Button | |||
Width="140" | |||