diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-31 00:42:00 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-05-31 00:42:00 +0300 |
| commit | abfcceeb4fddb69eb3737789424dcc9ecb36d09c (patch) | |
| tree | f6867d51b89378ada228dbce8f4141e96e49f81f | |
| parent | 3ba50278808cb6f08a8abf7ec0c0ecdae9c472c5 (diff) | |
| download | Tango-abfcceeb4fddb69eb3737789424dcc9ecb36d09c.tar.gz Tango-abfcceeb4fddb69eb3737789424dcc9ecb36d09c.zip | |
Take snapshot.
5 files changed, 54 insertions, 12 deletions
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"> <Grid> <Border CornerRadius="15" BorderBrush="{StaticResource FSE_BorderBrush}" BorderThickness="1"> <Grid> @@ -32,13 +33,20 @@ <ImageBrush ImageSource="{StaticResource FSE_PPC_Back}" /> </Border.Background> <Border Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight,Converter={StaticResource MathOperatorConverter},ConverterParameter='/1.6',FallbackValue=500,TargetNullValue=500}"> - <Image x:Name="img" FocusVisualStyle="{x:Null}" Focusable="True" Source="{Binding Source}" RenderOptions.BitmapScalingMode="Fant" Stretch="Fill" Visibility="{Binding RemoteDesktopProvider.InSession,Converter={StaticResource BooleanToVisibilityConverter}}"></Image> + <Grid> + <Image x:Name="img" FocusVisualStyle="{x:Null}" Focusable="True" Source="{Binding Source}" RenderOptions.BitmapScalingMode="Fant" Stretch="Fill" Visibility="{Binding RemoteDesktopProvider.InSession,Converter={StaticResource BooleanToVisibilityConverter}}"></Image> + <Rectangle x:Name="rectSnapshot" Fill="White" IsHitTestVisible="False" Opacity="0"></Rectangle> + </Grid> </Border> </Border> </Border> - <Grid IsHitTestVisible="False"> - <material:PackIcon Visibility="{Binding RemoteDesktopProvider.IsWebRtcActive,Converter={StaticResource BooleanToVisibilityConverter}}" Kind="LightningBoltCircle" HorizontalAlignment="Right" VerticalAlignment="Top" Width="16" Height="16" Margin="10 8 30 10" Foreground="{StaticResource FSE_GreenBrush}" /> + <Grid HorizontalAlignment="Right" VerticalAlignment="Top"> + <StackPanel Margin="0 5 27 0" Orientation="Horizontal"> + <controls:IconButton Cursor="Hand" ToolTip="Take snapshot" x:Name="btnSnapshot" Click="BtnSnapshot_Click" Command="{Binding TakeSnapshotCommand}" IsEnabled="{Binding RemoteDesktopProvider.InSession}" Icon="ImagePlus" Width="24" Height="24" Padding="0" /> + <material:PackIcon Margin="2 0 0 0" ToolTip="Active communication channel is active" Visibility="{Binding RemoteDesktopProvider.IsWebRtcActive,Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Center" Kind="LightningBoltCircle" Width="16" Height="16" Foreground="{StaticResource FSE_GreenBrush}" /> + <controls:IconButton Margin="5 0 0 0" Cursor="Hand" ToolTip="Open in separate window" Icon="OpenInNew" Width="24" Height="24" Padding="0" Command="{Binding WindowsManager.DetachToWindowCommand}" CommandParameter="{Binding ElementName=remoteDesktopControl}" Visibility="{Binding ElementName=remoteDesktopControl,Path=(win:WindowsManagerHelper.IsDetached),Converter={StaticResource BooleanToVisibilityInverseConverter}}" /> + </StackPanel> </Grid> </Grid> </Border> 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 /// </summary> public RelayCommand HideAndOpenShellCommand { get; set; } + /// <summary> + /// Save current desktop frame to image + /// </summary> + 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"/> </Border> - <controls:IconButton Cursor="Hand" ToolTip="Open in separate window" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="5" Icon="OpenInNew" Width="24" Height="24" Padding="0" Command="{Binding WindowsManager.DetachToWindowCommand}" CommandParameter="{Binding ElementName=remoteDesktopControl}" Visibility="{Binding ElementName=remoteDesktopControl,Path=(win:WindowsManagerHelper.IsDetached),Converter={StaticResource BooleanToVisibilityInverseConverter}}" /> </Grid> <Grid> 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<TouchEventArgs> touchDownHandler = (x, e) => + EventHandler<TouchEventArgs> 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<TouchEventArgs> previewTouchDownHandler = (x, e) => + EventHandler<TouchEventArgs> 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 /// <param name="deceleration">The deceleration.</param> /// <param name="onComplete">The on complete.</param> /// <returns></returns> - 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) { |
