Лабораторная работа 6

This commit is contained in:
nikbel2004@outlook.com 2024-04-08 16:04:03 +04:00
parent 07f331ec78
commit 0c6c75b191
20 changed files with 343 additions and 88 deletions

View File

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

View File

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Lab5
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34202.233
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab5", "Lab5\Lab5.csproj", "{6E87FC45-CDAB-4A76-A01A-D44F275756B4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab6", "Lab6\Lab6.csproj", "{89D87EF0-C674-45F3-8DEE-EDAB39D2AF21}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6E87FC45-CDAB-4A76-A01A-D44F275756B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E87FC45-CDAB-4A76-A01A-D44F275756B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E87FC45-CDAB-4A76-A01A-D44F275756B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E87FC45-CDAB-4A76-A01A-D44F275756B4}.Release|Any CPU.Build.0 = Release|Any CPU
{89D87EF0-C674-45F3-8DEE-EDAB39D2AF21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89D87EF0-C674-45F3-8DEE-EDAB39D2AF21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89D87EF0-C674-45F3-8DEE-EDAB39D2AF21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89D87EF0-C674-45F3-8DEE-EDAB39D2AF21}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7579837F-AA08-4D2A-8320-610BB818B417}
SolutionGuid = {6933EF1A-3810-40B0-B781-FCA51C06FFD5}
EndGlobalSection
EndGlobal

View File

@ -1,7 +1,7 @@
<Application x:Class="Lab5.App"
<Application x:Class="Lab6.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Lab5"
xmlns:local="clr-namespace:Lab6"
StartupUri="MainWindow.xaml">
<Application.Resources>

View File

@ -6,7 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Lab5
namespace Lab6
{
/// <summary>
/// Interaction logic for App.xaml

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 278 KiB

After

Width:  |  Height:  |  Size: 278 KiB

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

31
Lab6/Lab6/Lab6.csproj Normal file
View File

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Update="Source\Forsazh.mp4">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Source\Hobbit.mp4">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Source\Kung-Fu-Panda.mp4">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Source\Piraty-Caribean.mp4">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Page>
</ItemGroup>
</Project>

View File

@ -1,48 +1,48 @@
<Window x:Class="Lab5.MainWindow"
<Window x:Class="Lab6.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:Lab5"
xmlns:local="clr-namespace:Lab6"
mc:Ignorable="d"
Title="MainWindow" Height="640" Width="900">
Title="MainWindow" Height="640" Width="900">
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity" TargetName="btnAnimation1" RepeatBehavior="Forever">
<DoubleAnimation From="1.0"
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
<DoubleAnimation From="0.1"
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity" TargetName="btnAnimation2" RepeatBehavior="Forever">
<DoubleAnimation From="1.0"
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
<DoubleAnimation From="0.1"
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
</Storyboard>
</BeginStoryboard>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity" TargetName="btnAnimation3" RepeatBehavior="Forever">
<DoubleAnimation From="1.0"
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
To="0.1"
Duration="0:0:2"
AutoReverse="True"/>
<DoubleAnimation From="0.1"
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
To="1.0"
Duration="0:0:2"
BeginTime="0:0:2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
@ -51,11 +51,11 @@
<Window.Resources>
<ImageBrush x:Key="TileBrush" TileMode="Tile"
ViewportUnits="Absolute" Viewport="0 0 30 20"
ImageSource="E:\2 cource\TSCHMI\Labs\Lab3\Lab3\Lab3\Images\exit.png" Opacity="0.3"/>
ViewportUnits="Absolute" Viewport="0 0 30 20"
ImageSource="E:\2 cource\TSCHMI\Labs\Lab3\Lab3\Lab3\Images\exit.png" Opacity="0.3"/>
<ImageBrush x:Key="TileBrushCourse" TileMode="Tile"
ViewportUnits="Absolute" Viewport="0 0 30 20"
ImageSource="E:\2 cource\TSCHMI\Labs\Lab3\Lab3\Lab3\Images\unnamed.jpg" Opacity="0.3"></ImageBrush>
ViewportUnits="Absolute" Viewport="0 0 30 20"
ImageSource="E:\2 cource\TSCHMI\Labs\Lab3\Lab3\Lab3\Images\unnamed.jpg" Opacity="0.3"></ImageBrush>
<Style x:Key="btnPicture" TargetType="Button">
<Setter Property="Control.HorizontalAlignment" Value="Center" />
@ -106,10 +106,10 @@
<Border BorderBrush="#FFA500" BorderThickness="4" Grid.Column="0" Grid.Row="0" Grid.RowSpan="3">
<StackPanel Name="ButtonPanel" Background="#5F5F5F">
<Image Source="E:\2 cource\TSCHMI\Labs\Lab3\Lab3\Lab3\Images\unnamed.jpg" Margin="25"/>
<Button Margin="20" Foreground="Blue" BorderThickness="3" BorderBrush="{StaticResource OrangeBrush}" Background="#90F5DF">
<Button Margin="20" Foreground="Blue" BorderThickness="3" BorderBrush="{StaticResource OrangeBrush}" Background="#90F5DF" Click="Button_Click_playZvuk">
Галерея
</Button>
<Button Margin="20" Foreground="Blue" BorderBrush="{StaticResource OrangeBrush}" BorderThickness="3" Background="#90F5DF">
<Button Margin="20" Foreground="Blue" BorderBrush="{StaticResource OrangeBrush}" BorderThickness="3" Background="#90F5DF" Click="Button_Click_playSound">
Клипы
</Button>
@ -146,23 +146,23 @@
<Label FontSize="18" Foreground="#FFA500" Style="{StaticResource textStyle}" >
<Bold>Инструменты</Bold>
</Label>
<Button Name="btn1" Style="{StaticResource buttons}" Margin="10" >Добавить видео</Button>
<Button Name="btn2" Style="{StaticResource buttons}" Margin="10" >Удалить видео</Button>
<Button Name="btn3" Style="{StaticResource buttons}" Margin="10" >Сменить видео</Button>
<Button Name="btn1" Style="{StaticResource buttons}" Margin="10" Click="Button_Click_AddVideo">Добавить видео</Button>
<Button Name="btn2" Style="{StaticResource buttons}" Margin="10" Click="Button_Click_DeliteVideo" >Удалить видео</Button>
<Button Name="btn3" Style="{StaticResource buttons}" Margin="10" Click="Button_Click_ChangeVideo" >Сменить видео</Button>
<Button Name="btn4" Style="{StaticResource buttons}" Margin="10" Background="{StaticResource TileBrushCourse}" >Включить звук</Button>
<Button Name="btn5" Style="{StaticResource buttons}" Background="{StaticResource TileBrush}" Margin="10" >Выключить звук</Button>
<Button Name="btn4" Style="{StaticResource buttons}" Margin="10" Background="{StaticResource TileBrushCourse}" Click="Button_Click_onzvuk">Включить звук</Button>
<Button Name="btn5" Style="{StaticResource buttons}" Background="{StaticResource TileBrush}" Margin="10" Click="Button_Click_offzvuk">Выключить звук</Button>
<Button Name="btn6" Margin="15" Foreground="Blue" BorderBrush="#FFA500" BorderThickness="3" Background="#90F5DF" >Запуск</Button>
<Button Name="btn7" Margin="15" Foreground="Blue" BorderBrush="#FFA500" BorderThickness="3" Background="#90F5DF" >Стоп</Button>
<Button Name="btn6" Margin="15" Foreground="Blue" BorderBrush="#FFA500" BorderThickness="3" Background="#90F5DF" Click="Button_Click_Play">Запуск</Button>
<Button Name="btn7" Margin="15" Foreground="Blue" BorderBrush="#FFA500" BorderThickness="3" Background="#90F5DF" Click="Button_Click_Pause">Стоп</Button>
<Button Margin="10" Style="{StaticResource btnPicture}" >Спрятать интерфейс</Button>
<Button Margin="10" Style="{StaticResource btnPicture}" >Показать интерфейс</Button>
<Button Margin="10" Style="{StaticResource btnPicture}" Click="Button_Click_UnShowButtons">Спрятать интерфейс</Button>
<Button Margin="10" Style="{StaticResource btnPicture}" Click=" Button_Click_ShowButtons">Показать интерфейс</Button>
</StackPanel>
</Border>
<ListBox x:Name="videoListBox" Grid.Column="2" Grid.Row="2" Visibility="Collapsed">
<ListBox x:Name="videoListBox" Grid.Column="2" Grid.Row="2" SelectionChanged="videoListBox_SelectionChanged" Visibility="Collapsed">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
@ -170,8 +170,11 @@
</ListBox.ItemTemplate>
</ListBox>
<MediaElement x:Name="media" Source="Source/Kung-Fu-Panda.mp4" Grid.Row="1" Grid.Column="1" LoadedBehavior="Manual" Margin="10"/>
<Rectangle Stroke="Black" StrokeThickness="3" Margin="10" Grid.Column="1" Grid.Row="1" MaxHeight="250"/>
<Slider Name="vol" Grid.Column="1" Grid.Row="2" Maximum="1" Value="0.5" LargeChange="0.1" SmallChange="0.01" Margin="10" VerticalAlignment="Center"/>
<Slider Name="vol" ValueChanged="vol_ValueChanged" Grid.Column="1" Grid.Row="2" Maximum="1" Value="0.5" LargeChange="0.1" SmallChange="0.01" Margin="10" VerticalAlignment="Center"/>
</Grid>
</Window>

View File

@ -0,0 +1,262 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Lab6
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
videoListBox.ItemsSource = videos;
}
private void Button_Click_onzvuk(object sender, RoutedEventArgs e)
{
MessageBox.Show("Кнопка находится в разработке", "Не тыкай");
}
private void Button_Click_offzvuk(object sender, RoutedEventArgs e)
{
MessageBox.Show("Кнопка не работает. Оформите платную подписку", "Мышку сломаешь...");
}
private void Button_Click_playZvuk(object sender, RoutedEventArgs e)
{
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\zv2.wav"));
player.Play();
}
private void Button_Click_playSound(object sender, RoutedEventArgs e)
{
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\zvuk1.mp3"));
player.Play();
}
bool ButtonVideoAdd = true;
bool VideoAdd = false;
int CountLogo = 1;
string password = "";
bool ChangeVid = false;
bool Animate = false;
private void Button_Click_ShowButtons(object sender, RoutedEventArgs e)
{
DoubleAnimation animation = new DoubleAnimation();
animation.From = 0;
animation.To = 1;
animation.Duration = TimeSpan.FromSeconds(0.5);
if (!ButtonVideoAdd)
{
btn1.BeginAnimation(Button.OpacityProperty, animation);
btn1.Visibility = Visibility.Visible;
btn2.BeginAnimation(Button.OpacityProperty, animation);
btn2.Visibility = Visibility.Visible;
btn3.BeginAnimation(Button.OpacityProperty, animation);
btn3.Visibility = Visibility.Visible;
btn4.BeginAnimation(Button.OpacityProperty, animation);
btn4.Visibility = Visibility.Visible;
btn5.BeginAnimation(Button.OpacityProperty, animation);
btn5.Visibility = Visibility.Visible;
btn6.BeginAnimation(Button.OpacityProperty, animation);
btn6.Visibility = Visibility.Visible;
btn7.BeginAnimation(Button.OpacityProperty, animation);
btn7.Visibility = Visibility.Visible;
btn1.Cursor = Cursors.Hand;
btn2.Cursor = Cursors.Hand;
btn3.Cursor = Cursors.Hand;
btn4.Cursor = Cursors.Hand;
btn5.Cursor = Cursors.Hand;
btn6.Cursor = Cursors.Hand;
btn7.Cursor = Cursors.Hand;
ButtonVideoAdd = true;
}
password += "1";
}
private void Button_Click_UnShowButtons(object sender, RoutedEventArgs e)
{
DoubleAnimation animation = new DoubleAnimation();
animation.From = 1;
animation.To = 0;
animation.Duration = TimeSpan.FromSeconds(0.5);
if (ButtonVideoAdd)
{
btn1.BeginAnimation(Button.OpacityProperty, animation);
btn2.BeginAnimation(Button.OpacityProperty, animation);
btn3.BeginAnimation(Button.OpacityProperty, animation);
btn4.BeginAnimation(Button.OpacityProperty, animation);
btn5.BeginAnimation(Button.OpacityProperty, animation);
btn6.BeginAnimation(Button.OpacityProperty, animation);
btn7.BeginAnimation(Button.OpacityProperty, animation);
videoListBox.Visibility = Visibility.Hidden;
btn1.Cursor = Cursors.Arrow;
btn2.Cursor = Cursors.Arrow;
btn3.Cursor = Cursors.Arrow;
btn4.Cursor = Cursors.Arrow;
btn5.Cursor = Cursors.Arrow;
btn6.Cursor = Cursors.Arrow;
btn7.Cursor = Cursors.Arrow;
videoListBox.Cursor = Cursors.Arrow;
ButtonVideoAdd = false;
}
password += "2";
}
private void Button_Click_Play(object sender, RoutedEventArgs e)
{
if (VideoAdd && ButtonVideoAdd)
{
media.Play();
}
}
private void Button_Click_Pause(object sender, RoutedEventArgs e)
{
if (VideoAdd && ButtonVideoAdd)
{
media.Pause();
}
}
private void vol_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
media.Volume = (double)vol.Value;
}
private void Button_Click_AddVideo(object sender, RoutedEventArgs e)
{
if (ButtonVideoAdd)
{
if (!VideoAdd)
{
media.Play();
media.Visibility = Visibility.Visible;
VideoAdd = true;
}
else
{
media.Visibility = Visibility.Visible;
}
}
}
private void Button_Click_DeliteVideo(object sender, RoutedEventArgs e)
{
if (VideoAdd && ButtonVideoAdd)
{
media.Pause();
media.Visibility = Visibility.Hidden;
media.Position = TimeSpan.Zero;
VideoAdd = false;
videoListBox.Visibility = Visibility.Hidden;
}
}
private List<Video> videos = new List<Video>
{
new Video { Path = "E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\Kung-Fu-Panda.mp4", Name = "Видео 1" },
new Video { Path = "E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\Hobbit.mp4", Name = "Видео 2" },
new Video { Path = "E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\Piraty-Caribean.mp4", Name = "Видео 3" },
new Video { Path = "E:\\2 cource\\TSCHMI\\Labs\\Lab3\\Lab3\\Lab3\\Source\\Forsazh.mp4", Name = "Видео 4" }
};
private void videoListBox_SelectionChanged(object sender, RoutedEventArgs e)
{
Video selectedVideo = videoListBox.SelectedItem as Video;
if (selectedVideo != null)
{
media.Source = new System.Uri(selectedVideo.Path, UriKind.RelativeOrAbsolute);
media.Play();
}
}
private void Button_Click_ChangeVideo(object sender, RoutedEventArgs e)
{
if (VideoAdd && ButtonVideoAdd)
{
if (!ChangeVid)
{
videoListBox.Visibility = Visibility.Visible;
ChangeVid = true;
}
else
{
videoListBox.Visibility = Visibility.Collapsed;
ChangeVid = false;
}
}
}
public class Video : INotifyPropertyChanged
{
private string _path;
public string Path
{
get { return _path; }
set
{
_path = value;
NotifyPropertyChanged();
}
}
private string _name;
public string Name
{
get { return _name; }
set
{
_name = value;
NotifyPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}