fix: fix accessory icon and update project nuget system
This commit is contained in:
@@ -10,40 +10,42 @@ using System.Windows.Media;
|
||||
namespace BallanceTasEditor.Styles {
|
||||
|
||||
public class AccessoryIcon {
|
||||
public static Object GetAccessoryIcon(DependencyObject obj) {
|
||||
return (Object)obj.GetValue(AccessoryIconProperty);
|
||||
public static ImageSource GetIcon(DependencyObject obj) {
|
||||
return (ImageSource)obj.GetValue(IconProperty);
|
||||
}
|
||||
|
||||
public static void SetAccessoryIcon(DependencyObject obj, Object value) {
|
||||
obj.SetValue(AccessoryIconProperty, value);
|
||||
public static void SetIcon(DependencyObject obj, ImageSource value) {
|
||||
obj.SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AccessoryIconProperty =
|
||||
DependencyProperty.RegisterAttached("AccessoryIcon", typeof(Object), typeof(AccessoryIcon), new PropertyMetadata(null));
|
||||
}
|
||||
// Using a DependencyProperty as the backing store for Icon. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IconProperty =
|
||||
DependencyProperty.RegisterAttached("Icon", typeof(ImageSource), typeof(AccessoryIcon), new PropertyMetadata(null));
|
||||
|
||||
public class AccessoryIconContentTemplateSelector : DataTemplateSelector {
|
||||
private static ImageSourceConverter Converter = new ImageSourceConverter();
|
||||
|
||||
/// <summary>
|
||||
/// 给定的图标是已经加载的数据。
|
||||
/// </summary>
|
||||
public DataTemplate LoadedIconTemplate { get; set; }
|
||||
/// <summary>
|
||||
/// 给定的图标是来源字符串。
|
||||
/// </summary>
|
||||
public DataTemplate SourceIconTemplate { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
|
||||
var ctl = VisualTreeHelper.GetParent(container);
|
||||
var accessoryIcon = ctl.GetValue(AccessoryIcon.AccessoryIconProperty);
|
||||
|
||||
if (accessoryIcon is null || !Converter.CanConvertFrom(accessoryIcon.GetType())) {
|
||||
return LoadedIconTemplate;
|
||||
} else {
|
||||
return SourceIconTemplate;
|
||||
}
|
||||
public static double GetIconWidth(DependencyObject obj) {
|
||||
return (double)obj.GetValue(IconWidthProperty);
|
||||
}
|
||||
|
||||
public static void SetIconWidth(DependencyObject obj, double value) {
|
||||
obj.SetValue(IconWidthProperty, value);
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for IconWidth. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IconWidthProperty =
|
||||
DependencyProperty.RegisterAttached("IconWidth", typeof(double), typeof(AccessoryIcon), new PropertyMetadata(0.0));
|
||||
|
||||
public static double GetIconHeight(DependencyObject obj) {
|
||||
return (double)obj.GetValue(IconHeightProperty);
|
||||
}
|
||||
|
||||
public static void SetIconHeight(DependencyObject obj, double value) {
|
||||
obj.SetValue(IconHeightProperty, value);
|
||||
}
|
||||
|
||||
// Using a DependencyProperty as the backing store for IconHeight. This enables animation, styling, binding, etc...
|
||||
public static readonly DependencyProperty IconHeightProperty =
|
||||
DependencyProperty.RegisterAttached("IconHeight", typeof(double), typeof(AccessoryIcon), new PropertyMetadata(0.0));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +1,19 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:BallanceTasEditor.Styles">
|
||||
<!--<ImageSourceConverter x:Key="AccessorySourceIconConverter"/>
|
||||
<DataTemplate x:Key="AccessoryLoadedIconDataTemplate">
|
||||
<DataTemplate x:Key="AccessoryIconDataTemplate">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentControl Content="{Binding Path=(local:AccessoryIcon.AccessoryIcon), RelativeSource={RelativeSource AncestorType=Control, AncestorLevel=1}}"
|
||||
Width="16" Height="16"/>
|
||||
<Image Source="{Binding Path=(local:AccessoryIcon.Icon), RelativeSource={RelativeSource AncestorType=Control, AncestorLevel=1}}"
|
||||
Width="16" Height="16" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="AccessorySourceIconDataTemplate" >
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="{Binding Path=(local:AccessoryIcon.AccessoryIcon), RelativeSource={RelativeSource AncestorType=Control, AncestorLevel=1}, Converter={StaticResource AccessorySourceIconConverter}}"
|
||||
Width="16" Height="16"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
<local:AccessoryIconContentTemplateSelector x:Key="AccessoryIconDataTemplateSelector"
|
||||
LoadedIconTemplate="{StaticResource AccessoryLoadedIconDataTemplate}"
|
||||
SourceIconTemplate="{StaticResource AccessorySourceIconDataTemplate}"/>-->
|
||||
|
||||
<ControlTemplate x:Key="shit" TargetType="ContentControl">
|
||||
<ContentPresenter x:Name="Icon" ContentSource="Content"/>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="AccessoryIconButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentControl Content="{Binding Path=(local:AccessoryIcon.AccessoryIcon), RelativeSource={RelativeSource AncestorType=Button, AncestorLevel=1}}"
|
||||
Width="16" Height="16" Template="{StaticResource shit}">
|
||||
</ContentControl>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource AccessoryIconDataTemplate}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="AccessoryIconGroupBox" TargetType="GroupBox" BasedOn="{StaticResource {x:Type GroupBox}}">
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource AccessoryIconDataTemplate}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -8,7 +8,8 @@
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="/Assets/Ok.ico" Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<Image Source="/Assets/Ok.ico" RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
@@ -23,7 +24,8 @@
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="/Assets/Cancel.ico" Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<Image Source="/Assets/Cancel.ico" RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
Reference in New Issue
Block a user