diff options
| author | Roy <roy.mail.net@gmail.com> | 2017-12-07 23:09:17 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2017-12-07 23:09:17 +0200 |
| commit | b457125866deb830b379cf3873e5cda3975b077a (patch) | |
| tree | b5a17fcd198a160abbff688ce0f84057fd51c000 /Software/Visual_Studio/Utilities/Tango.MachineEM.UI | |
| parent | ab99fb80dfc78c31b1e6cf8d5e4a8458978f4ddc (diff) | |
| download | Tango-b457125866deb830b379cf3873e5cda3975b077a.tar.gz Tango-b457125866deb830b379cf3873e5cda3975b077a.zip | |
Fixed issue with protobuf nuget.
Some improvements on Stubs GUI.
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.MachineEM.UI')
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs | 53 | ||||
| -rw-r--r-- | Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml | 5 |
2 files changed, 54 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs index 8c7efd67e..24a0f6119 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/ViewModels/MainViewVM.cs @@ -71,6 +71,25 @@ namespace Tango.MachineEM.UI.ViewModels set { _selectedStub = value; RaisePropertyChanged(nameof(SelectedStub)); } } + private List<String> _ports; + /// <summary> + /// Gets or sets the ports. + /// </summary> + public List<String> Ports + { + get { return _ports; } + set { _ports = value; RaisePropertyChanged(nameof(Ports)); } + } + + private String _selectedPort; + /// <summary> + /// Gets or sets the selected port. + /// </summary> + public String SelectedPort + { + get { return _selectedPort; } + set { _selectedPort = value; RaisePropertyChanged(nameof(SelectedPort)); } + } #endregion @@ -143,6 +162,22 @@ namespace Tango.MachineEM.UI.ViewModels ClearCommand = new RelayCommand(() => Log = String.Empty); AvailableStubs = StubBase.GetAvailableStubs(StubDirection.ToMobile); + + Ports = new List<string>() + { + "TCP", + "COM1", + "COM2", + "COM3", + "COM4", + "COM5", + "COM6", + "COM7", + "COM8", + "COM9", + }; + + SelectedPort = Ports.First(); } #endregion @@ -168,9 +203,16 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> private async void Start() { - TcpServer = new TcpServer(9999); - TcpServer.ClientConnected += TcpServer_ClientConnected; - TcpServer.Start(); + if (SelectedPort == Ports.First()) + { + TcpServer = new TcpServer(9999); + TcpServer.ClientConnected += TcpServer_ClientConnected; + TcpServer.Start(); + } + else + { + Emulator.Transporter.Adapters.Add(new UsbTransportAdapter(SelectedPort)); + } await Emulator.Start(); InvalidateRelayCommands(); } @@ -180,7 +222,10 @@ namespace Tango.MachineEM.UI.ViewModels /// </summary> private async void Stop() { - TcpServer.Stop(); + if (TcpServer != null) + { + TcpServer.Stop(); + } await Emulator.Stop(); InvalidateRelayCommands(); } diff --git a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml index c2068acf7..b48001a02 100644 --- a/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/Utilities/Tango.MachineEM.UI/Views/MainView.xaml @@ -10,6 +10,10 @@ xmlns:local="clr-namespace:Tango.MachineEM.UI.Views" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1000" Foreground="Gainsboro"> + + <UserControl.Resources> + <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter> + </UserControl.Resources> <Grid> <Grid> <Grid.RowDefinitions> @@ -133,6 +137,7 @@ </Grid> <Grid x:Name="gridActions" Grid.Row="1" Background="#151515" Margin="5"> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="5"> + <ComboBox IsEnabled="{Binding Emulator.IsStarted,Converter={StaticResource BooleanInverseConverter}}" MinWidth="140" Margin="5" BorderThickness="0" ItemsSource="{Binding Ports}" SelectedItem="{Binding SelectedPort}"></ComboBox> <Button Margin="5" MinWidth="100" Style="{StaticResource AccentedSquareButtonStyle}" mahapps:ButtonHelper.PreserveTextCase="True" BorderThickness="0" Command="{Binding StopCommand}"> <StackPanel Orientation="Horizontal"> <fa:ImageAwesome Icon="Stop" Width="16"></fa:ImageAwesome> |
