diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-23 21:44:05 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-02-23 21:44:05 +0200 |
| commit | 41fb02ff132d3adc9083981fd64e3f82de979ca0 (patch) | |
| tree | b3bce0e110aca3fc5d291b3908389a40388c3fd8 /Software | |
| parent | 561ece8919db3e213bb9777b256ec51c61d14e82 (diff) | |
| download | Tango-41fb02ff132d3adc9083981fd64e3f82de979ca0.tar.gz Tango-41fb02ff132d3adc9083981fd64e3f82de979ca0.zip | |
Implemented FSE focus for AutoComplete.
Implemented persistent connection pane heights.
Diffstat (limited to 'Software')
14 files changed, 125 insertions, 27 deletions
diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/IconButton.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/IconButton.xaml index 0530d852a..571e86bcf 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/IconButton.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/IconButton.xaml @@ -5,6 +5,7 @@ <Style TargetType="{x:Type local:IconButton}" BasedOn="{StaticResource MaterialDesignToolForegroundButton}"> + <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter> <Setter Property="Cursor" Value="Arrow"></Setter> <Setter Property="ContentTemplate"> <Setter.Value> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/ExtensionMethods/ViewModelExtensionMethods.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/ExtensionMethods/ViewModelExtensionMethods.cs index f6b8e2587..73ecd990b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/ExtensionMethods/ViewModelExtensionMethods.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/ExtensionMethods/ViewModelExtensionMethods.cs @@ -11,6 +11,7 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; +using Tango.AutoComplete.Editors; using Tango.SharedUI; public static class ViewModelExtensionMethods @@ -87,6 +88,11 @@ public static class ViewModelExtensionMethods bindingExpression = child.GetBindingExpression(Tango.SharedUI.Helpers.PasswordHelper.PasswordProperty); } + if (bindingExpression == null) + { + bindingExpression = child.GetBindingExpression(AutoCompleteTextBox.SelectedItemProperty); + } + if (bindingExpression != null) { if (bindingExpression.ResolvedSourcePropertyName == propName) diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEApplication/IFSEApplicationManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEApplication/IFSEApplicationManager.cs index 56a95ea70..750f9d8a8 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEApplication/IFSEApplicationManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEApplication/IFSEApplicationManager.cs @@ -82,5 +82,10 @@ namespace Tango.FSE.Common.FSEApplication /// Gets or sets the application folder. /// </summary> String StartPath { get; } + + /// <summary> + /// Gets or sets a value indicating whether to display the main window controls. + /// </summary> + bool DisplayWindowControls { get; set; } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs index 9ecb67980..16edfccad 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSESettings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using Tango.FSE.Common.Diagnostics; using Tango.Settings; @@ -66,9 +67,27 @@ namespace Tango.FSE.Common /// </summary> public bool EnableExternalBridgeSignalR { get; set; } + /// <summary> + /// Gets or sets the diagnostics throttling mode. + /// </summary> public DiagnosticsThrottlingMode DiagnosticsThrottlingMode { get; set; } /// <summary> + /// Gets or sets a value indicating whether to enable the machine emulator. + /// </summary> + public bool EnableMachineEmulator { get; set; } + + /// <summary> + /// Gets or sets the height of the machine connection pane USB area. + /// </summary> + public GridLength MachineConnectionUsbHeight { get; set; } + + /// <summary> + /// Gets or sets the height of the machine connection pane WIFI area. + /// </summary> + public GridLength MachineConnectionWifiHeight { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="FSESettings"/> class. /// </summary> public FSESettings() @@ -77,6 +96,8 @@ namespace Tango.FSE.Common ExternalBridgeSignalRHub = "ExternalBridgeHub"; EnableExternalBridgeSignalR = true; DiagnosticsThrottlingMode = DiagnosticsThrottlingMode.Delayed; + MachineConnectionUsbHeight = new GridLength(1, GridUnitType.Star); + MachineConnectionWifiHeight = new GridLength(1, GridUnitType.Star); } } -} +}
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionUsbViewVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionUsbViewVM.cs index 637467602..820f3774c 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionUsbViewVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/MachineConnectionUsbViewVM.cs @@ -73,6 +73,11 @@ namespace Tango.FSE.UI.Dialogs { LogManager.Log(ex, "Error retrieving last virtualized machine."); } + + if (SelectedMachine == null) + { + this.SetFocus(() => SelectedMachine); + } } protected override void Accept() diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FSEApplication/DefaultFSEApplicationManager.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FSEApplication/DefaultFSEApplicationManager.cs index 087d12cd5..3f975d009 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FSEApplication/DefaultFSEApplicationManager.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FSEApplication/DefaultFSEApplicationManager.cs @@ -111,11 +111,22 @@ namespace Tango.FSE.UI.FSEApplication /// </summary> public String StartPath { get; private set; } + private bool _displayWindowControls; + /// <summary> + /// Gets or sets a value indicating whether to display the main window controls. + /// </summary> + public bool DisplayWindowControls + { + get { return _displayWindowControls; } + set { _displayWindowControls = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Initializes a new instance of the <see cref="DefaultFSEApplicationManager"/> class. /// </summary> public DefaultFSEApplicationManager(IDispatcherProvider dispatcherProvider, IFSEModuleLoader moduleLoader, INotificationProvider notificationProvider) { + DisplayWindowControls = true; StartPath = AssemblyHelper.GetCurrentAssemblyFolder(); StartupArgs = Environment.GetCommandLineArgs().Skip(1).ToList(); @@ -286,6 +297,8 @@ namespace Tango.FSE.UI.FSEApplication _dispatcher.Invoke(() => { + DisplayWindowControls = true; + LogManager.Log($"Invoking {nameof(ApplicationReady)} event."); ApplicationReady?.Invoke(this, new EventArgs()); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml index b7ed1bb75..25919916b 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:global="clr-namespace:Tango.FSE.UI" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:views="clr-namespace:Tango.FSE.UI.Views" @@ -14,14 +15,24 @@ TextElement.Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Background="{StaticResource FSE_PrimaryBackgroundBrush}" TextElement.FontSize="{StaticResource FSE_DefaultFontSize}" - TitleCharacterCasing="Normal" UseNoneWindowStyle="True" EnableDWMDropShadow="True" MinWidth="800" MinHeight="600" BorderThickness="1" BorderBrush="Gray" FontFamily="{StaticResource flexo}" WindowTitleBrush="{StaticResource PrimaryHueMidBrush}"> + TitleCharacterCasing="Normal" + UseNoneWindowStyle="True" + EnableDWMDropShadow="True" + MinWidth="800" + MinHeight="600" + BorderThickness="1" + BorderBrush="Gray" + FontFamily="{StaticResource flexo}" + WindowTitleBrush="{StaticResource PrimaryHueMidBrush}" + d:DataContext="{d:DesignInstance Type=global:MainWindowVM, IsDesignTimeCreatable=False}" + DataContext="{x:Static global:ViewModelLocator.MainWindowVM}"> <Grid> <views:MainView/> <Grid VerticalAlignment="Top" Height="40"> <DockPanel> - <UniformGrid DockPanel.Dock="Right" Columns="3" HorizontalAlignment="Right" Width="130"> + <UniformGrid DockPanel.Dock="Right" Columns="3" HorizontalAlignment="Right" Width="130" Visibility="{Binding ApplicationManager.DisplayWindowControls,Converter={StaticResource BooleanToVisibilityConverter}}"> <commonControls:IconButton Padding="8" x:Name="btnMinimize" Icon="WindowMinimize" /> <commonControls:IconButton Padding="8" x:Name="btnMaximize" Icon="WindowMaximize" /> <commonControls:IconButton Padding="8" x:Name="btnClose" Icon="WindowClose" /> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml.cs index 733d6e8ca..116592b40 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindow.xaml.cs @@ -13,6 +13,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Core.DI; +using Tango.FSE.Common.FSEApplication; namespace Tango.FSE.UI { @@ -30,6 +32,8 @@ namespace Tango.FSE.UI Instance = this; InitializeComponent(); + IFSEApplicationManager appManager = TangoIOC.Default.GetInstance<IFSEApplicationManager>(); + btnMinimize.Click += (_, __) => WindowState = WindowState.Minimized; btnMaximize.Click += (_, __) => WindowState = WindowState == WindowState.Maximized ? WindowState = WindowState.Normal : WindowState = WindowState.Maximized; btnClose.Click += (_, __) => Close(); @@ -39,7 +43,7 @@ namespace Tango.FSE.UI _startPoint = e.GetPosition(this); - if (e.ClickCount > 1) + if (e.ClickCount > 1 && appManager.DisplayWindowControls) { WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal; return; diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindowVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindowVM.cs new file mode 100644 index 000000000..c1710d91a --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/MainWindowVM.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Common; + +namespace Tango.FSE.UI +{ + public class MainWindowVM : FSEViewModel + { + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPane.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPane.xaml index 9e9050201..ea3680caf 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPane.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPane.xaml @@ -14,14 +14,14 @@ </Button> <Grid> <Grid.RowDefinitions> - <RowDefinition Height="60" /> - <RowDefinition Height="1*" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="{Binding Settings.MachineConnectionUsbHeight,Mode=TwoWay}" /> <RowDefinition Height="5" /> - <RowDefinition Height="1*" /> + <RowDefinition Height="{Binding Settings.MachineConnectionWifiHeight,Mode=TwoWay}" /> <RowDefinition Height="5" /> <RowDefinition Height="1*" /> </Grid.RowDefinitions> - <Grid Margin="0 10 0 0" Grid.Row="0"> + <Grid Margin="0 10 0 0" Grid.Row="0" Height="60" Visibility="{Binding Settings.EnableMachineEmulator,Converter={StaticResource BooleanToVisibilityConverter}}"> <DockPanel> <ListBox x:Name="listEmulator" ItemsSource="{Binding EmulatorMachines}" SelectedItem="{Binding SelectedMachine,Mode=OneWay}" PreviewMouseDoubleClick="ListBox_PreviewMouseDoubleClick"> <ListBox.ItemTemplate> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPaneVM.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPaneVM.cs index 8a3e0b52b..390423496 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPaneVM.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/MachineConnectionPaneVM.cs @@ -18,7 +18,6 @@ namespace Tango.FSE.UI.Panes { private ExternalBridgeScanner _scanner; private EmulatorExternalBridge _emulator; - private FSESettings _settings; public event EventHandler<IExternalBridgeClient> MachineSelected; @@ -51,16 +50,14 @@ namespace Tango.FSE.UI.Panes _scanner = new ExternalBridgeScanner(); _scanner.MachineDiscovered += _scanner_MachineDiscovered; _scanner.MachineLost += _scanner_MachineLost; - - _settings = SettingsManager.Default.GetOrCreate<FSESettings>(); } internal void ConnectToMachine() { if (SelectedMachine != null) { - _settings.LastSelectedMachine = SelectedMachine.GetUniqueString(); - _settings.Save(); + Settings.LastSelectedMachine = SelectedMachine.GetUniqueString(); + Settings.Save(); MachineSelected?.Invoke(this, SelectedMachine); } @@ -108,13 +105,13 @@ namespace Tango.FSE.UI.Panes private void TryAutoSelectMachine() { - if (SelectedMachine == null && _settings.LastSelectedMachine != null) + if (SelectedMachine == null && Settings.LastSelectedMachine != null) { SelectedMachine = UsbMachines.Select(x => x.As<IExternalBridgeClient>()) .Concat(TcpMachines.Select(x => x.As<IExternalBridgeClient>())) .Concat(SignalRMachines.Select(x => x.As<IExternalBridgeClient>())) .Concat(EmulatorMachines.Select(x => x.As<IExternalBridgeClient>())) - .ToList().SingleOrDefault(x => x.GetUniqueString() == _settings.LastSelectedMachine); + .ToList().SingleOrDefault(x => x.GetUniqueString() == Settings.LastSelectedMachine); if (SelectedMachine != null) { @@ -130,26 +127,29 @@ namespace Tango.FSE.UI.Panes EmulatorMachines.Clear(); SelectedMachine = null; - if (_emulator != null) + if (Settings.EnableMachineEmulator) { - await _emulator.Disconnect(); - } + if (_emulator != null) + { + await _emulator.Disconnect(); + } - _emulator = new EmulatorExternalBridge(); - EmulatorMachines.Add(_emulator); + _emulator = new EmulatorExternalBridge(); + EmulatorMachines.Add(_emulator); + } TryAutoSelectMachine(); - _scanner.SignalRConfiguration.Enabled = _settings.EnableExternalBridgeSignalR; + _scanner.SignalRConfiguration.Enabled = Settings.EnableExternalBridgeSignalR; if (Environment.GetCommandLineArgs().Contains("-webDebug")) { _scanner.SignalRConfiguration.Address = "http://localhost:1111/"; } else { - _scanner.SignalRConfiguration.Address = _settings.MachineServiceAddress; + _scanner.SignalRConfiguration.Address = Settings.MachineServiceAddress; } - _scanner.SignalRConfiguration.Hub = _settings.ExternalBridgeSignalRHub; + _scanner.SignalRConfiguration.Hub = Settings.ExternalBridgeSignalRHub; _scanner.Start(); } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj index 04391b747..fc27d51e6 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Tango.FSE.UI.csproj @@ -109,6 +109,7 @@ <Compile Include="Dialogs\MachineConnectionWifiViewVM.cs" /> <Compile Include="Gateway\DefaultGatewayService.cs" /> <Compile Include="InternalModule.cs" /> + <Compile Include="MainWindowVM.cs" /> <Compile Include="Modules\DefaultFSEModuleLoader.cs" /> <Compile Include="Navigation\DefaultNavigationManager.cs" /> <Compile Include="FSEApplication\DefaultFSEApplicationManager.cs" /> diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs index d71acda36..d527b0d7e 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModelLocator.cs @@ -63,6 +63,7 @@ namespace Tango.FSE.UI //TangoIOC.Default.Register<IMachineProvider, DefaultMachineProvider>(); TangoIOC.Default.Register<IFSEApplicationManager, DefaultFSEApplicationManager>(); + TangoIOC.Default.Register<MainWindowVM>(); TangoIOC.Default.Register<MainViewVM>(); TangoIOC.Default.Register<LoadingViewVM>(); TangoIOC.Default.Register<LayoutViewVM>(); @@ -71,6 +72,14 @@ namespace Tango.FSE.UI TangoIOC.Default.Register<DashboardViewVM>(); } + public static MainWindowVM MainWindowVM + { + get + { + return TangoIOC.Default.GetInstance<MainWindowVM>(); + } + } + public static MainViewVM MainViewVM { get diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml index 04d7d236b..f35505519 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/LayoutView.xaml @@ -186,11 +186,20 @@ </StackPanel> </Button> - <Grid HorizontalAlignment="Right" Margin="0 0 25 0" Visibility="{Binding MachineProvider.IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}"> - <Ellipse Fill="White" Width="42" Height="42" Stroke="{StaticResource FSE_PrimaryBackgroundLightBrush}" StrokeThickness="4"> - + <Grid HorizontalAlignment="Right" Margin="0 0 25 0"> + <Ellipse Width="42" Height="42" Stroke="{StaticResource FSE_PrimaryBackgroundLightBrush}" StrokeThickness="4"> + <Ellipse.Style> + <Style TargetType="Ellipse"> + <Setter Property="Fill" Value="{StaticResource FSE_PrimaryBackgroundLighterBrush}"></Setter> + <Style.Triggers> + <DataTrigger Binding="{Binding MachineProvider.IsConnected}" Value="True"> + <Setter Property="Fill" Value="White"></Setter> + </DataTrigger> + </Style.Triggers> + </Style> + </Ellipse.Style> </Ellipse> - <Image Stretch="Fill" Margin="0 2 0 0" RenderOptions.BitmapScalingMode="Fant" Width="32" Height="32" VerticalAlignment="Center" + <Image Stretch="Fill" Margin="0 2 0 0" RenderOptions.BitmapScalingMode="Fant" Width="32" Height="32" VerticalAlignment="Center" Visibility="{Binding MachineProvider.IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}" gif:ImageBehavior.EnableAnimation="True" gif:ImageBehavior.SpeedRatio="1"> <Image.Style> |
