From abfcceeb4fddb69eb3737789424dcc9ecb36d09c Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 31 May 2020 00:42:00 +0300 Subject: Take snapshot. --- .../Controls/RemoteDesktopControl.xaml | 16 +++++++++--- .../Controls/RemoteDesktopControl.xaml.cs | 5 ++++ .../ViewModels/RemoteDesktopViewVM.cs | 29 ++++++++++++++++++++++ .../Views/RemoteDesktopView.xaml | 1 - .../ExtensionMethods/FrameworkElementExtensions.cs | 15 +++++------ 5 files changed, 54 insertions(+), 12 deletions(-) (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml index f12672474..e40d14668 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml @@ -4,12 +4,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:global="clr-namespace:Tango.FSE.PPCConsole" xmlns:vm="clr-namespace:Tango.FSE.PPCConsole.ViewModels" + xmlns:win="clr-namespace:Tango.FSE.Common.WindowsManager;assembly=Tango.FSE.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:controls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:local="clr-namespace:Tango.FSE.PPCConsole.Controls" mc:Ignorable="d" - d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Focusable="False"> + d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Focusable="False" x:Name="remoteDesktopControl"> @@ -32,13 +33,20 @@ - + + + + - - + + + + + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml.cs index 7006db0b3..c32ab3048 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Controls/RemoteDesktopControl.xaml.cs @@ -72,5 +72,10 @@ namespace Tango.FSE.PPCConsole.Controls { _vm.OnMouseMove(e.GetPosition(img), new Size(img.ActualWidth, img.ActualHeight)); } + + private void BtnSnapshot_Click(object sender, RoutedEventArgs e) + { + rectSnapshot.StartDoubleAnimation(Rectangle.OpacityProperty, TimeSpan.FromSeconds(0.2), 1, 0, null, null, null, true); + } } } diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs index 9bd25a99a..86129b682 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/RemoteDesktopViewVM.cs @@ -12,6 +12,7 @@ using System.Windows.Media.Imaging; using Tango.Core.Commands; using Tango.Core.Threading; using Tango.FSE.Common; +using Tango.FSE.Common.Notifications; using Tango.FSE.Common.RemoteDesktop; using Tango.RemoteDesktop.Frames; using Tango.RemoteDesktop.Network; @@ -60,6 +61,11 @@ namespace Tango.FSE.PPCConsole.ViewModels /// public RelayCommand HideAndOpenShellCommand { get; set; } + /// + /// Save current desktop frame to image + /// + public RelayCommand TakeSnapshotCommand { get; set; } + #endregion #region Constructors @@ -73,6 +79,7 @@ namespace Tango.FSE.PPCConsole.ViewModels StopCommand = new RelayCommand(StopRemoteDesktop); OpenTaskManagerCommand = new RelayCommand(OpenTaskManager); HideAndOpenShellCommand = new RelayCommand(HideAndOpenShell); + TakeSnapshotCommand = new RelayCommand(TakeSnapshot); } #endregion @@ -185,6 +192,28 @@ namespace Tango.FSE.PPCConsole.ViewModels #endregion + #region Snapshot + + private async void TakeSnapshot() + { + var snapshot = Source.Clone(); + + await Task.Delay(500); //Delay for blink animation.. + + var result = await StorageProvider.SaveFile("Save Snapshot", "Jpeg Files|*.jpg", $"TangoApp_{DateTime.Now.ToFileName()}.jpg", ".jpg"); + + if (result.Confirmed) + { + snapshot.SaveJpegFile(result.SelectedItem, 100); + NotificationProvider.PushSnackbarItem(MessageType.Success, "Remote Desktop Snapshot Saved", true, "Remote desktop snapshot saved successfully.\nTap to view the image file.", TimeSpan.FromSeconds(8), null, () => + { + StorageProvider.ShowInExplorer(result.SelectedItem); + }); + } + } + + #endregion + #region Remote Actions private void OpenTaskManager() diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index a6a0e7ca3..46327eeae 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -28,7 +28,6 @@ win:WindowsManagerHelper.PreservePlaceHolder="True" win:WindowsManagerHelper.DisableResolutionServiceInjection="True"/> - diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs index 05e204f17..426fbbd02 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/FrameworkElementExtensions.cs @@ -30,7 +30,7 @@ public static class FrameworkElementExtensions bool mousePressed = false; bool touchDown = false; - MouseButtonEventHandler mouseDownHandler = (x, e) => + MouseButtonEventHandler mouseDownHandler = (x, e) => { if (!touchDown) { @@ -57,7 +57,7 @@ public static class FrameworkElementExtensions //element.MouseDown += mouseDownHandler; element.AddHandler(FrameworkElement.MouseDownEvent, mouseDownHandler); - EventHandler touchDownHandler = (x, e) => + EventHandler touchDownHandler = (x, e) => { if (!mousePressed) { @@ -85,7 +85,7 @@ public static class FrameworkElementExtensions //element.TouchDown += touchDownHandler; element.AddHandler(FrameworkElement.TouchDownEvent, touchDownHandler); - MouseButtonEventHandler mouseUpHandler = (_, __) => + MouseButtonEventHandler mouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; @@ -236,7 +236,7 @@ public static class FrameworkElementExtensions element.AddHandler(FrameworkElement.PreviewMouseDownEvent, previewMouseDownHandler); //element.PreviewMouseDown += previewMouseDownHandler; - EventHandler previewTouchDownHandler = (x, e) => + EventHandler previewTouchDownHandler = (x, e) => { if (!mousePressed) { @@ -264,7 +264,7 @@ public static class FrameworkElementExtensions //element.PreviewTouchDown += previewTouchDownHandler; element.AddHandler(FrameworkElement.PreviewTouchDownEvent, previewTouchDownHandler); - MouseButtonEventHandler previewMouseUpHandler = (_, __) => + MouseButtonEventHandler previewMouseUpHandler = (_, __) => { touchDown = false; mousePressed = false; @@ -592,7 +592,7 @@ public static class FrameworkElementExtensions { bool isLoaded = false; - element.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler((x, y) => + element.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler((x, y) => { if (!isLoaded) { @@ -766,10 +766,11 @@ public static class FrameworkElementExtensions /// The deceleration. /// The on complete. /// - public static DoubleAnimation StartDoubleAnimation(this FrameworkElement element, DependencyProperty property, TimeSpan duration, double to, double? from = null, double? acceleration = null, double? deceleration = null, Action onComplete = null) + public static DoubleAnimation StartDoubleAnimation(this FrameworkElement element, DependencyProperty property, TimeSpan duration, double to, double? from = null, double? acceleration = null, double? deceleration = null, Action onComplete = null, bool autoReverse = false) { DoubleAnimation ani = new DoubleAnimation(); ani.Duration = duration; + ani.AutoReverse = autoReverse; if (acceleration.HasValue) { -- cgit v1.3.1