mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-03 14:31:28 +08:00
tool
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class BrushOpacityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is SolidColorBrush brush)
|
||||
{
|
||||
var opacity = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
|
||||
return new SolidColorBrush(brush.Color)
|
||||
{
|
||||
Opacity = opacity
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
=> Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
48
AIStudio.Wpf.DiagramDesigner/Styles/Button.xaml
Normal file
48
AIStudio.Wpf.DiagramDesigner/Styles/Button.xaml
Normal file
@@ -0,0 +1,48 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="clr-namespace:AIStudio.Wpf.DiagramDesigner">
|
||||
|
||||
<s:BrushOpacityConverter x:Key="BrushOpacityConverter"/>
|
||||
|
||||
<Style x:Key="AIStudio.Styles.Button.Flat" TargetType="{x:Type ButtonBase}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<Setter Property="MinHeight" Value="22" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ButtonBase}">
|
||||
<Grid>
|
||||
<Border x:Name="border"
|
||||
Background="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background}"
|
||||
CornerRadius="3"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
|
||||
<ContentPresenter x:Name="content" RecognizesAccessKey="True"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<!--触发器-->
|
||||
<ControlTemplate.Triggers>
|
||||
<!--设置鼠标进入时的背景、前景样式-->
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Background" TargetName="border" Value="{Binding Foreground,
|
||||
RelativeSource={RelativeSource Mode=TemplatedParent},
|
||||
Converter={StaticResource BrushOpacityConverter},
|
||||
ConverterParameter=0.16}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value="0.5"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -1,6 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/Button.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/ScrollBar.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/Expander.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.DiagramDesigner;component/Styles/GroupBox.xaml" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<!-- Project properties -->
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net461;netcoreapp3.1;net5.0-windows</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1;net5.0-windows</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
Reference in New Issue
Block a user