feat: make style but not finished
This commit is contained in:
49
BallanceTasEditor/Styles/AccessoryIcon.cs
Normal file
49
BallanceTasEditor/Styles/AccessoryIcon.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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.Media;
|
||||
|
||||
namespace BallanceTasEditor.Styles {
|
||||
|
||||
public class AccessoryIcon {
|
||||
public static Object GetAccessoryIcon(DependencyObject obj) {
|
||||
return (Object)obj.GetValue(AccessoryIconProperty);
|
||||
}
|
||||
|
||||
public static void SetAccessoryIcon(DependencyObject obj, Object value) {
|
||||
obj.SetValue(AccessoryIconProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AccessoryIconProperty =
|
||||
DependencyProperty.RegisterAttached("AccessoryIcon", typeof(Object), 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
41
BallanceTasEditor/Styles/AccessoryIconControl.xaml
Normal file
41
BallanceTasEditor/Styles/AccessoryIconControl.xaml
Normal file
@@ -0,0 +1,41 @@
|
||||
<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">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentControl Content="{Binding Path=(local:AccessoryIcon.AccessoryIcon), RelativeSource={RelativeSource AncestorType=Control, AncestorLevel=1}}"
|
||||
Width="16" Height="16"/>
|
||||
<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>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
33
BallanceTasEditor/Styles/GenericButton.xaml
Normal file
33
BallanceTasEditor/Styles/GenericButton.xaml
Normal file
@@ -0,0 +1,33 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="OkButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Padding" Value="5"/>
|
||||
<Setter Property="Margin" Value="5"/>
|
||||
<Setter Property="MinWidth" Value="80"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="/Assets/Ok.ico" Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="CancelButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Padding" Value="5"/>
|
||||
<Setter Property="Margin" Value="5"/>
|
||||
<Setter Property="MinWidth" Value="80"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="/Assets/Cancel.ico" Width="16" Height="16" VerticalAlignment="Center"/>
|
||||
<ContentControl Content="{Binding}" Margin="5,0,0,0" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
8
BallanceTasEditor/Styles/NoteBanner.xaml
Normal file
8
BallanceTasEditor/Styles/NoteBanner.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="NoteBannerStyle" TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
|
||||
<Setter Property="Background" Value="#0097A7"/>
|
||||
<Setter Property="Foreground" Value="#CDDC39"/>
|
||||
<Setter Property="Padding" Value="10"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user