Skip to content

Commit

Permalink
feat: 加入 "设计风格" 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimeNull committed Apr 17, 2024
1 parent 5e27c4e commit 217b66f
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 53 deletions.
3 changes: 3 additions & 0 deletions EleCho.WpfSuite.SimpleDesign/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Windows.Markup;

[assembly: XmlnsDefinition("https://github.com/OrgEleCho/EleCho.WpfSuite/SimpleDesign", "EleCho.WpfSuite.SimpleDesign")]
35 changes: 35 additions & 0 deletions EleCho.WpfSuite.SimpleDesign/EleCho.WpfSuite.SimpleDesign.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-windows;net6.0-windows;net48;net47;net46;net45</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<RootNamespace>EleCho.WpfSuite</RootNamespace>

<Version>0.0.1</Version>

<Authors>EleCho</Authors>
<Copyright>Copyright © 2024 EleCho</Copyright>
<PackageProjectUrl>https://github.com/OrgEleCho/EleCho.WpfSuite</PackageProjectUrl>
<PackageIcon>logo.png</PackageIcon>
<PackageTags>WPF;MVVM;Toolkit;Controls;Converters;BindingProxy</PackageTags>
<Description>WPF layout panels, controls, value converters, utilities suite</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<Page Remove="SimpleDesignResources.xaml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EleCho.WpfSuite\EleCho.WpfSuite.csproj" />
</ItemGroup>

<ItemGroup>
<Resource Include="SimpleDesignResources.xaml" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions EleCho.WpfSuite.SimpleDesign/SimpleDesignResources.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Windows;

namespace EleCho.WpfSuite.SimpleDesign
{
public class SimpleDesignResources : ResourceDictionary
{
public SimpleDesignResources()
{
MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/EleCho.WpfSuite.SimpleDesign;component/SimpleDesignResources.xaml") });
}
}
}
33 changes: 33 additions & 0 deletions EleCho.WpfSuite.SimpleDesign/SimpleDesignResources.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ws="clr-namespace:EleCho.WpfSuite;assembly=EleCho.WpfSuite"
xmlns:sys="clr-namespace:System;assembly=mscorlib">

<sys:String x:Key="WpfSuiteDesignName">SimpleDesign</sys:String>

<Style TargetType="{x:Type ws:TextBox}"
BasedOn="{StaticResource {x:Type ws:TextBox}}">
<Setter Property="CornerRadius" Value="4"/>
</Style>

<Style TargetType="{x:Type ws:Button}"
BasedOn="{StaticResource {x:Type ws:Button}}">
<Setter Property="CornerRadius" Value="4"/>
</Style>

<Style TargetType="{x:Type ws:ToggleButton}"
BasedOn="{StaticResource {x:Type ws:ToggleButton}}">
<Setter Property="CornerRadius" Value="4"/>
</Style>

<Style TargetType="{x:Type ws:ListBox}"
BasedOn="{StaticResource {x:Type ws:ListBox}}">
<Setter Property="CornerRadius" Value="4"/>
</Style>

<Style TargetType="{x:Type ws:ListBoxItem}"
BasedOn="{StaticResource {x:Type ws:ListBoxItem}}">
<Setter Property="CornerRadius" Value="4"/>
</Style>

</ResourceDictionary>
6 changes: 6 additions & 0 deletions EleCho.WpfSuite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EleCho.WpfSuite.SimpleDesign", "EleCho.WpfSuite.SimpleDesign\EleCho.WpfSuite.SimpleDesign.csproj", "{EAD122E7-549D-4057-83C4-DCD2A04E4481}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,6 +28,10 @@ Global
{8F0B4AE1-61E7-44A7-9FDA-C17D37EECC7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F0B4AE1-61E7-44A7-9FDA-C17D37EECC7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F0B4AE1-61E7-44A7-9FDA-C17D37EECC7A}.Release|Any CPU.Build.0 = Release|Any CPU
{EAD122E7-549D-4057-83C4-DCD2A04E4481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAD122E7-549D-4057-83C4-DCD2A04E4481}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAD122E7-549D-4057-83C4-DCD2A04E4481}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAD122E7-549D-4057-83C4-DCD2A04E4481}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions EleCho.WpfSuite/EleCho.WpfSuite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<RootNamespace>EleCho.WpfSuite</RootNamespace>

<Version>0.1.2</Version>

Expand Down
3 changes: 3 additions & 0 deletions WpfTest/App.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Application x:Class="WpfTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ws="https://github.com/OrgEleCho/EleCho.WpfSuite"
xmlns:wsd="https://github.com/OrgEleCho/EleCho.WpfSuite/SimpleDesign"
xmlns:utils="clr-namespace:WpfTest.Utilities"
StartupUri="MainWindow.xaml">
<Application.Resources>

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<wsd:SimpleDesignResources/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Expand Down
8 changes: 1 addition & 7 deletions WpfTest/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@
DockPanel.Dock="Left"
Width="180"
BorderThickness="0 0 1 0"
CornerRadius="0 5 5 0"
ItemsSource="{Binding NavigationItems}"
d:ItemsSource="{d:SampleData ItemCount=3}"
SelectionChanged="ListBox_SelectionChanged">
<ws:ListBox.ItemContainerStyle>
<Style TargetType="ws:ListBoxItem">
<Setter Property="CornerRadius" Value="3"/>
</Style>
</ws:ListBox.ItemContainerStyle>
<ws:ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
Expand All @@ -42,7 +36,7 @@
</ws:ListBox.ItemTemplate>
</ws:ListBox>
<ws:Frame Name="AppFrame"
NavigationUIVisibility="Visible"
NavigationUIVisibility="Hidden"
ClipToBounds="True">
<ws:Frame.Transition>
<ws:ScaleTransition Duration="0:0:0.300">
Expand Down
7 changes: 2 additions & 5 deletions WpfTest/Tests/CollectionTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
HorizontalAlignment="Left"
Spacing="8">
<ws:Button Content="Add item" Command="{Binding AddItemCommand}"
Padding="5 3" CornerRadius="3"/>
Padding="5 3"/>
<ws:Button Content="Remove item" Command="{Binding RemoveItemCommand}"
Padding="5 3" CornerRadius="3"/>
Padding="5 3"/>
</ws:StackPanel>

<GroupBox Header="Items (WrapPanel)"
Expand All @@ -49,7 +49,6 @@
<DataTemplate>
<Border BorderBrush="Gray"
BorderThickness="1"
CornerRadius="3"
Padding="5 3">
<ContentPresenter Content="{Binding}"/>
</Border>
Expand All @@ -75,7 +74,6 @@
<DataTemplate>
<Border BorderBrush="Gray"
BorderThickness="1"
CornerRadius="3"
Padding="5 3">
<ContentPresenter Content="{Binding}"/>
</Border>
Expand All @@ -98,7 +96,6 @@
<DataTemplate>
<Border BorderBrush="Gray"
BorderThickness="1"
CornerRadius="3"
Padding="5 3">
<ContentPresenter Content="{Binding}"/>
</Border>
Expand Down
4 changes: 2 additions & 2 deletions WpfTest/Tests/ConditionalControlTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<DataTemplate>
<Border BorderBrush="Red"
BorderThickness="3"
CornerRadius="3"
CornerRadius="4"
Padding="5">
<ws:StackPanel Spacing="4">
<TextBlock Text="Current value is false"/>
Expand All @@ -66,7 +66,7 @@
<ws:ToggleButton x:Name="ConditionButton"
Content="Toggle Condition"
Padding="5 3"
CornerRadius="3"/>
CornerRadius="4"/>
<StackPanel>
<TextBlock Text="ContentWhenTrue:"/>
<ws:TextBox x:Name="ContentWhenTrueBox"
Expand Down
83 changes: 44 additions & 39 deletions WpfTest/Tests/PanelsTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,59 @@
Padding="8">
<ws:StackPanel Orientation="Horizontal"
Spacing="8">
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
</ws:StackPanel>
</GroupBox>
<GroupBox Header="WrapPanel (HorizontalSpacing=8,VerticalSpacing=8)"
Padding="8">
<ws:WrapPanel Orientation="Horizontal"
HorizontalSpacing="8"
VerticalSpacing="8">
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
</ws:WrapPanel>
</GroupBox>
<GroupBox Header="FlexPanel (HorizontalSpacing=8,VerticalSpacing=8)"
Padding="8">
<ws:FlexPanel MainSpacing="8"
CrossSpacing="8"
Wrap="Wrap">
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
<ws:Button Content="QWQ"/>
</ws:FlexPanel>
</GroupBox>

Expand Down Expand Up @@ -103,6 +103,11 @@
<Button Content="QWQ" Margin="0 0 8 8"/>
</WrapPanel>
</GroupBox>

<TextBlock Margin="0 48 0 0">
<Run Text="Current design name:"/>
<Run Text="{DynamicResource WpfSuiteDesignName}"/>
</TextBlock>
</ws:StackPanel>
</ws:ScrollViewer>
</Page>
1 change: 1 addition & 0 deletions WpfTest/WpfTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EleCho.WpfSuite.SimpleDesign\EleCho.WpfSuite.SimpleDesign.csproj" />
<ProjectReference Include="..\EleCho.WpfSuite\EleCho.WpfSuite.csproj" />
</ItemGroup>

Expand Down

0 comments on commit 217b66f

Please sign in to comment.