XAML, верстка окон и создание UI элементов

This commit is contained in:
maksim 2024-11-26 13:37:12 +04:00
parent 8d396328dd
commit 4312b9fca9
7 changed files with 184 additions and 8 deletions

View File

@ -2,8 +2,66 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:EmployeeManager"
StartupUri="MainWindow.xaml">
StartupUri="View/MainWindow.xaml">
<Application.Resources>
<!-- Стиль для закругленных кнопок -->
<Style x:Key="RoundedButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<!-- Тень кнопки -->
<Border Background="{TemplateBinding Background}"
CornerRadius="15"
BorderBrush="Transparent"
BorderThickness="0"
x:Name="ButtonBorder">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="10" ShadowDepth="2" Opacity="0.4" />
</Border.Effect>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<!-- Анимация цвета при наведении -->
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBorder"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#0066CC" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBorder"
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
To="#004890" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<!-- Анимация сжатия при нажатии -->
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransform" TargetName="ButtonBorder">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95" />
</Setter.Value>
</Setter>
<Setter TargetName="ButtonBorder" Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Black" BlurRadius="15" ShadowDepth="0" Opacity="0.6" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>

View File

@ -57,6 +57,12 @@
</ApplicationDefinition>
<Compile Include="Model\DataWorker.cs" />
<Compile Include="ViewModel\DataManageViewModel.cs" />
<Compile Include="View\MessageWindow.xaml.cs">
<DependentUpon>MessageWindow.xaml</DependentUpon>
</Compile>
<Compile Include="View\PhysicalPerson\WorkInPhysicalPerson.xaml.cs">
<DependentUpon>WorkInPhysicalPerson.xaml</DependentUpon>
</Compile>
<Page Include="View\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -69,6 +75,14 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="View\MessageWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\PhysicalPerson\WorkInPhysicalPerson.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Model\Employees.cs" />

View File

@ -1,12 +1,26 @@
<Window x:Class="EmployeeManager.View.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:EmployeeManager.View"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="Отдел кадров УлГТУ" Height="450" Width="800" Background="#0D2D4F">
<Grid>
<!-- Заголовок -->
<TextBlock Text="Отдел кадров УлГТУ"
HorizontalAlignment="Center" VerticalAlignment="Top"
FontSize="24" FontWeight="Bold"
Foreground="#FFFFFF" Margin="0,20,0,0" />
<!-- Центральный StackPanel -->
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,40">
<!-- Кнопка 1 -->
<Button Content="Работа с сотрудниками" Width="200" Height="50" Margin="0,10"
Background="#004890" Foreground="#FFFFFF" FontSize="16"
Style="{StaticResource RoundedButtonStyle}"/>
<!-- Кнопка 2 -->
<Button Content="Работа с физ. лицами" Width="200" Height="50" Margin="0,10"
Background="#004890" Foreground="#FFFFFF" FontSize="16"
Style="{StaticResource RoundedButtonStyle}"/>
</StackPanel>
</Grid>
</Window>

24
View/MessageWindow.xaml Normal file
View File

@ -0,0 +1,24 @@
<Window x:Class="EmployeeManager.View.MessageWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Сообщение"
Height="200" Width="400"
ResizeMode="NoResize"
WindowStartupLocation="CenterScreen"
Background="#0D2D4F">
<Grid>
<!-- Текст сообщения -->
<TextBlock Text="Ваше сообщение здесь"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="16" FontWeight="Bold"
Foreground="#FFFFFF"
Margin="0,0,0,40"/>
<!-- Кнопка "Ок" -->
<Button Content="Ок"
Width="100" Height="40"
HorizontalAlignment="Center" VerticalAlignment="Top"
Margin="0,114,0,0"
Style="{StaticResource RoundedButtonStyle}" />
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
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.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManager.View
{
/// <summary>
/// Логика взаимодействия для MessageWindow.xaml
/// </summary>
public partial class MessageWindow : Window
{
public MessageWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<Window x:Class="EmployeeManager.View.PhysicalPerson.WorkInPhysicalPerson"
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:EmployeeManager.View.PhysicalPerson"
mc:Ignorable="d"
Title="WorkInPhysicalPerson" Height="450" Width="800">
<Grid>
</Grid>
</Window>

View File

@ -0,0 +1,27 @@
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.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace EmployeeManager.View.PhysicalPerson
{
/// <summary>
/// Логика взаимодействия для WorkInPhysicalPerson.xaml
/// </summary>
public partial class WorkInPhysicalPerson : Window
{
public WorkInPhysicalPerson()
{
InitializeComponent();
}
}
}