|
@@ -1,12 +1,16 @@
|
|
|
using InABox.Core;
|
|
|
using InABox.WPF;
|
|
|
+using Microsoft.Win32;
|
|
|
+using Syncfusion.XPS;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using System.Windows.Media;
|
|
|
|
|
|
namespace InABox.DynamicGrid
|
|
|
{
|
|
@@ -14,21 +18,24 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
Button PlayButton;
|
|
|
Button PauseButton;
|
|
|
+ Button DownloadButton;
|
|
|
MediaElement Player;
|
|
|
+ Grid grid;
|
|
|
+ Point center;
|
|
|
+ int rotation = 90;
|
|
|
bool firstPlay = true;
|
|
|
|
|
|
byte[]? Data;
|
|
|
|
|
|
protected override FrameworkElement Create()
|
|
|
{
|
|
|
- var grid = new Grid();
|
|
|
+ grid = new Grid();
|
|
|
|
|
|
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
|
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
|
|
|
|
|
|
- grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
|
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
|
|
|
-
|
|
|
+ grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
|
|
|
|
PlayButton = new Button
|
|
|
{
|
|
@@ -42,51 +49,94 @@ namespace InABox.DynamicGrid
|
|
|
Source = Wpf.Resources.play_button.AsBitmapImage(),
|
|
|
};
|
|
|
PlayButton.Click += PlayButton_Click;
|
|
|
- PlayButton.SetGridPosition(0, 0);
|
|
|
|
|
|
PauseButton = new Button
|
|
|
{
|
|
|
Width = 25,
|
|
|
Height = 25,
|
|
|
- Margin = new Thickness(5),
|
|
|
- Visibility = Visibility.Hidden
|
|
|
+ Margin = new Thickness(5)
|
|
|
};
|
|
|
PauseButton.Content = new Image
|
|
|
{
|
|
|
- Source = Wpf.Resources.pause_button.AsBitmapImage()
|
|
|
+ Source = Wpf.Resources.pause_button.AsBitmapImage(),
|
|
|
};
|
|
|
PauseButton.Click += PauseButton_Click;
|
|
|
- PauseButton.SetGridPosition(0, 0);
|
|
|
+
|
|
|
+ DownloadButton = new Button
|
|
|
+ {
|
|
|
+ Width = 25,
|
|
|
+ Height = 25,
|
|
|
+ Margin = new Thickness(5)
|
|
|
+ };
|
|
|
+ DownloadButton.Content = new Image
|
|
|
+ {
|
|
|
+ Source = Wpf.Resources.download.AsBitmapImage(),
|
|
|
+ };
|
|
|
+ DownloadButton.Click += DownloadButton_Click;
|
|
|
+
|
|
|
+ StackPanel panel = new StackPanel();
|
|
|
+ panel.Orientation = Orientation.Horizontal;
|
|
|
+ panel.Children.Add(PlayButton);
|
|
|
+ panel.Children.Add(PauseButton);
|
|
|
+ panel.Children.Add(DownloadButton);
|
|
|
+ panel.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
+ panel.SetGridPosition(1, 0, 1, 2);
|
|
|
|
|
|
Player = new MediaElement();
|
|
|
Player.Stretch = System.Windows.Media.Stretch.Fill;
|
|
|
Player.Visibility = Visibility.Visible;
|
|
|
- Player.SetGridPosition(1, 0, 1, 2);
|
|
|
+ Player.VerticalAlignment = VerticalAlignment.Center;
|
|
|
+ Player.HorizontalAlignment = HorizontalAlignment.Center;
|
|
|
+ Player.SetGridPosition(0, 0, 1, 2);
|
|
|
+ Player.LoadedBehavior = MediaState.Manual;
|
|
|
|
|
|
- grid.Children.Add(PlayButton);
|
|
|
- grid.Children.Add(PauseButton);
|
|
|
+ grid.Children.Add(panel);
|
|
|
grid.Children.Add(Player);
|
|
|
|
|
|
return grid;
|
|
|
}
|
|
|
|
|
|
+ private void DownloadButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var dlg = new SaveFileDialog();
|
|
|
+ dlg.AddExtension = true;
|
|
|
+ dlg.DefaultExt = ".mp4";
|
|
|
+ dlg.ShowDialog();
|
|
|
+ if (!string.IsNullOrWhiteSpace(dlg.FileName))
|
|
|
+ {
|
|
|
+ System.IO.File.WriteAllBytes(dlg.FileName, GetValue());
|
|
|
+ MessageBox.Show("Success - file saved to: "
|
|
|
+ + System.Environment.NewLine
|
|
|
+ + dlg.FileName);
|
|
|
+
|
|
|
+ var dir = System.IO.Path.GetDirectoryName(dlg.FileName);
|
|
|
+
|
|
|
+ ProcessStartInfo startInfo = new ProcessStartInfo
|
|
|
+ {
|
|
|
+ Arguments = dir,
|
|
|
+ FileName = "explorer.exe"
|
|
|
+ };
|
|
|
+ Process.Start(startInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PauseButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ Player.Pause();
|
|
|
+ }
|
|
|
+
|
|
|
private void PlayButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var path = System.IO.Path.GetTempFileName();
|
|
|
path = path.Substring(0, path.Length - 4) + ".mp4";
|
|
|
|
|
|
System.IO.File.WriteAllBytes(path, GetValue());
|
|
|
+
|
|
|
Player.Source = new Uri(path);
|
|
|
|
|
|
- firstPlay = false;
|
|
|
+ Player.Play();
|
|
|
}
|
|
|
|
|
|
- private void PauseButton_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- Player.Pause();
|
|
|
- PauseButton.Visibility = Visibility.Hidden;
|
|
|
- PlayButton.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
|
|
|
public override byte[] GetValue()
|
|
|
{
|