+ Лабараторная 5 и 6

This commit is contained in:
IlyasValiulov 2024-10-08 18:12:49 +04:00
parent cc7f8416bc
commit db3cd55efd
5 changed files with 87 additions and 34 deletions

View File

@ -46,8 +46,77 @@
<CheckBox Style="{StaticResource checkboxStyle}" Margin="10" Content="Я согласен на обработку данных"/>
</StackPanel>
<Button Style="{StaticResource buttonDesicion}" Background="{StaticResource BrushWheat}" MinHeight="50" MinWidth="50" Grid.Row="3" Grid.Column="1">Принять</Button>
<Button Style="{StaticResource buttonDesicion}" Background="{StaticResource BrushWheat}" MinHeight="50" MinWidth="50" Grid.Row="3" Grid.Column="2">Отмена</Button>
<Button x:Name="shakingbutton" Style="{StaticResource buttonDesicion}" Background="{StaticResource BrushWheat}" MinHeight="50" MinWidth="50" Grid.Row="3" Grid.Column="1" Content="Установить">
<Button.RenderTransform>
<TranslateTransform/>
</Button.RenderTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard Name="MouseEnter_BeginStoryboard">
<Storyboard>
<DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="0:0:0" Value="0" />
<SplineDoubleKeyFrame KeyTime="0:0:0.50" Value="-5" />
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0" />
<SplineDoubleKeyFrame KeyTime="0:0:1.50" Value="5" />
<SplineDoubleKeyFrame KeyTime="0:0:2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<ColorAnimation Storyboard.TargetName="shakingbutton"
Storyboard.TargetProperty="(Button.Foreground).(SolidColorBrush.Color)"
To="Green"
Duration="0:0:0.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<StopStoryboard BeginStoryboardName="MouseEnter_BeginStoryboard"/>
</EventTrigger>
</Button.Triggers>
</Button>
<Button x:Name="cancelbutton" Background="{StaticResource BrushWheat}" MinHeight="50" MinWidth="50" Grid.Row="3" Grid.Column="2" Content="Отмена" FontSize="18" Margin="20">
<Button.RenderTransform>
<TranslateTransform/>
</Button.RenderTransform>
<Button.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames RepeatBehavior="Forever" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="0:0:0" Value="0" />
<SplineDoubleKeyFrame KeyTime="0:0:0.50" Value="-5" />
<SplineDoubleKeyFrame KeyTime="0:0:1" Value="0" />
<SplineDoubleKeyFrame KeyTime="0:0:1.50" Value="5" />
<SplineDoubleKeyFrame KeyTime="0:0:2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<ColorAnimation Storyboard.TargetName="shakingbutton"
Storyboard.TargetProperty="(Button.Foreground).(SolidColorBrush.Color)"
To="Green"
Duration="0:0:0.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<StopStoryboard BeginStoryboardName="MouseEnter_BeginStoryboard"/>
</EventTrigger>
</Button.Triggers>
<Button.Style>
<Style>
<Style.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<SoundPlayerAction Source="sounds/button_cancel.wav"></SoundPlayerAction>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Label Content="Установка" Grid.Row="0" Grid.Column="0" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>
@ -64,5 +133,7 @@
<Image Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Source="images/hgvstrgtavc.png" Stretch="Fill" Margin="0,10"/>
<MediaElement Source="videos/pixel_loading_bar.mp4" LoadedBehavior="Play" Grid.Row="3" Grid.Column="0" Margin="14,10,265,10" Grid.ColumnSpan="2"/>
</Grid>
</Window>

View File

@ -1,4 +1,5 @@
using System.Text;
using System.Media;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -16,43 +17,13 @@ namespace WPF
/// </summary>
public partial class MainWindow : Window
{
public ICommand ShowMessageBox { get; set; }
public MainWindow()
{
InitializeComponent();
ShowMessageBox = new RelayCommand(LoginShowBox);
DataContext = this;
}
private void LoginShowBox(object parameter)
{
MessageBox.Show("Вход");
}
}
public class RelayCommand : ICommand
{
private readonly Action<object> _execute;
private readonly Func<object, bool> _canExecute;
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return _canExecute == null || _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
}
}

View File

@ -10,12 +10,23 @@
<ItemGroup>
<None Remove="images\hgvstrgtavc.png" />
<None Remove="sounds\button_cancel.wav" />
<None Remove="videos\pixel_loading_bar.mp4" />
</ItemGroup>
<ItemGroup>
<Resource Include="images\hgvstrgtavc.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Resource>
<Content Include="videos\pixel_loading_bar.mp4">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="sounds\button_cancel.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.