样式制作

This commit is contained in:
Bunny 2024-12-28 22:36:52 +08:00
commit 400d5eae63
16 changed files with 271 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
logs/
application-prod.yml
[b|B]in
[o|O]bj
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

9
WPF基础-1/App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="WPF基础_1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF基础_1"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

12
WPF基础-1/App.xaml.cs Normal file
View File

@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace WPF基础_1;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

View File

@ -0,0 +1,47 @@
<Window x:Class="WPF基础_1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Icon="public/images/1.png"
Title="我的xxx" Height="450" Width="800">
<Grid Name="Grid">
<Grid.Background>
<LinearGradientBrush>
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.00" Color="Red" />
<GradientStop Offset="0.50" Color="Indigo" />
<GradientStop Offset="1.00" Color="Violet" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,10,13,10" TextWrapping="Wrap"
Grid.Row="0" Name="TextQuestion" FontFamily="Verdana"
FontSize="24" Foreground="Green">
有什么问题吗
</TextBox>
<Button VerticalAlignment="Top" Name="CmdAnswer" HorizontalAlignment="Left" Margin="10,0" Width="127"
Height="23" Grid.Row="1">
<Button.Foreground>
<x:Static Member="SystemColors.GradientActiveCaptionBrush" />
</Button.Foreground>
<!-- <Rectangle Fill="Blue" Height="10" Width="100" /> -->
&lt; &quot; 你想问什么 &quot; &gt;
</Button>
<TextBox Grid.Row="2" Name="TextAnswer" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Margin="10,10,13,10" FontSize="24" Foreground="Green">
回答就在这关于xaml受到一些影响[&lt;] [&gt;] " "
</TextBox>
</Grid>
</Window>

View File

@ -0,0 +1,40 @@
using System.Windows;
using System.Windows.Media;
namespace WPF基础_1;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var brush = new LinearGradientBrush();
var gradientStop1 = new GradientStop
{
Offset = 0,
Color = Colors.Red
};
brush.GradientStops.Add(gradientStop1);
var gradientStop2 = new GradientStop
{
Offset = 0.5,
Color = Colors.Indigo
};
brush.GradientStops.Add(gradientStop2);
var gradientStop3 = new GradientStop
{
Offset = 1,
Color = Colors.Violet
};
brush.GradientStops.Add(gradientStop3);
Grid.Background = brush;
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<RootNamespace>WPF基础_1</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="public\images\1.ico"/>
<Resource Include="public\images\1.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
<None Remove="public\images\1.png"/>
<Resource Include="public\images\1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

22
WPF基础.sln Normal file
View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础", "WPF基础\WPF基础.csproj", "{49C77780-54C3-4DFF-BE0D-D4B9A62ABA3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-1", "WPF基础-1\WPF基础-1.csproj", "{170C5C64-A7D4-4507-B11E-8DB65F1AF1E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{49C77780-54C3-4DFF-BE0D-D4B9A62ABA3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{49C77780-54C3-4DFF-BE0D-D4B9A62ABA3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{49C77780-54C3-4DFF-BE0D-D4B9A62ABA3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{49C77780-54C3-4DFF-BE0D-D4B9A62ABA3C}.Release|Any CPU.Build.0 = Release|Any CPU
{170C5C64-A7D4-4507-B11E-8DB65F1AF1E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{170C5C64-A7D4-4507-B11E-8DB65F1AF1E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{170C5C64-A7D4-4507-B11E-8DB65F1AF1E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{170C5C64-A7D4-4507-B11E-8DB65F1AF1E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

9
WPF基础/App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="WPF基础.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF基础"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

12
WPF基础/App.xaml.cs Normal file
View File

@ -0,0 +1,12 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace WPF基础;
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

10
WPF基础/AssemblyInfo.cs Normal file
View File

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

12
WPF基础/MainWindow.xaml Normal file
View File

@ -0,0 +1,12 @@
<Window x:Class="WPF基础.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPF基础"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid Name="Grid">
</Grid>
</Window>

View File

@ -0,0 +1,16 @@
using System.Windows;
namespace WPF基础;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MessageBox.Show(string.Format($"这个Grid的宽高是{Grid.ActualWidth}和{Grid.ActualHeight}"));
}
}

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>