diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-08 18:19:37 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-08 18:19:37 +0200 |
| commit | 3aa8d26fe59aeea616bda89ca325b9f9583fadc6 (patch) | |
| tree | 064470fd7ba7d2186b257544a3d1675dc7f21b64 /Software/Visual_Studio/MachineStudio | |
| parent | f95e70a118ed238bbdeea5b44c9be7e6cfb0b89c (diff) | |
| download | Tango-3aa8d26fe59aeea616bda89ca325b9f9583fadc6.tar.gz Tango-3aa8d26fe59aeea616bda89ca325b9f9583fadc6.zip | |
Added code comments for:
Integration.
Refactored ExternalBridgeClient to:
IExternalBridgeSecureClient.
ExternalBridgeTcpClient.
ExternalBridgeUsbClient.
Refactored MachineConnectionView to use the new external bridge clients by data template "data type".
Diffstat (limited to 'Software/Visual_Studio/MachineStudio')
4 files changed, 31 insertions, 50 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs index 3f8772f0e..5ea6e7aec 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/ViewModels/DirectSynchronizationViewVM.cs @@ -150,7 +150,7 @@ namespace Tango.MachineStudio.Synchronization.ViewModels private void Compare() { - if (SelectedMachine.SerialNumber != ApplicationManager.ConnectedMachine.SerialNumber) + if (SelectedMachine.SerialNumber != ApplicationManager.ConnectedMachine.As<ExternalBridgeTcpClient>().SerialNumber) { if (!_notification.ShowQuestion("The selected machine serial number does not match the connected machine. Are you sure you want to continue?")) { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index de8649c13..36b5074cb 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -50,7 +50,7 @@ namespace Tango.MachineStudio.UI.StudioApplication public bool IsMachineConnectedViaTCP { - get { return IsMachineConnected && ConnectedMachine.Type != ExternalBridgeClientType.USB; } + get { return IsMachineConnected && ConnectedMachine is ExternalBridgeTcpClient; } } private void ConnectedMachine_StateChanged(object sender, Transport.TransportComponentState e) diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index b08c259af..ceb81a66f 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using Tango.Core.Commands; +using Tango.Integration.Services; using Tango.Logging; using Tango.MachineStudio.Common; using Tango.MachineStudio.Common.Authentication; @@ -152,17 +153,17 @@ namespace Tango.MachineStudio.UI.ViewModels } } - if (x.SelectedMachine.Type != Integration.Services.ExternalBridgeClientType.USB) + if (x.SelectedMachine.RequiresAuthentication) { _notificationProvider.ShowModalDialog<MachineLoginViewVM>(async (login) => { - using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.SerialNumber + "...")) + using (NotificationProvider.PushTaskItem("Connecting to machine " + x.SelectedMachine.ToString() + "...")) { try { await x.SelectedMachine.Connect(); - var authenticated = await x.SelectedMachine.Authenticate(login.Password); + var authenticated = await x.SelectedMachine.As<IExternalBridgeSecureClient>().Authenticate(login.Password); if (!authenticated) { _notificationProvider.ShowError("It seems like you are not authorized to access the selected machine."); @@ -184,7 +185,7 @@ namespace Tango.MachineStudio.UI.ViewModels } else { - using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.Device + "...")) + using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "...")) { try { diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml index 4208c2878..ccab634db 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineConnectionView.xaml @@ -5,6 +5,7 @@ xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:integration="clr-namespace:Tango.Integration.Services;assembly=Tango.Integration" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views" mc:Ignorable="d" @@ -52,58 +53,37 @@ <Grid Grid.Row="1"> <ListBox ItemsSource="{Binding Scanner.AvailableMachines}" SelectedItem="{Binding SelectedMachine}" Margin="0 0 0 7" BorderThickness="1" BorderBrush="Gainsboro"> - <ListBox.ItemTemplate> - <DataTemplate> - <Grid> - <StackPanel Orientation="Horizontal"> - <StackPanel.Style> - <Style TargetType="StackPanel"> - <Setter Property="Visibility" Value="Visible"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Type}" Value="USB"> - <Setter Property="Visibility" Value="Collapsed"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </StackPanel.Style> - <Image Source="/Images/external-bridge-tcp.png" Width="38" Height="38" RenderOptions.BitmapScalingMode="Fant"></Image> - <StackPanel Margin="10 0 0 0"> - <TextBlock FontSize="11"> + <ListBox.Resources> + <DataTemplate DataType="{x:Type integration:ExternalBridgeTcpClient}"> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/external-bridge-tcp.png" Width="38" Height="38" RenderOptions.BitmapScalingMode="Fant"></Image> + <StackPanel Margin="10 0 0 0"> + <TextBlock FontSize="11"> <Run FontWeight="Bold">S/N:</Run> <Run Text="{Binding SerialNumber,Mode=OneWay}"></Run> - </TextBlock> - <TextBlock FontSize="11"> + </TextBlock> + <TextBlock FontSize="11"> <Run FontWeight="Bold">IP Address:</Run> <Run Text="{Binding IPAddress,Mode=OneWay}"></Run> - </TextBlock> - <TextBlock FontSize="11"> + </TextBlock> + <TextBlock FontSize="11"> <Run FontWeight="Bold">Organization:</Run> <Run Text="{Binding Organization,Mode=OneWay}"></Run> - </TextBlock> - </StackPanel> + </TextBlock> </StackPanel> - - <StackPanel Orientation="Horizontal"> - <StackPanel.Style> - <Style TargetType="StackPanel"> - <Setter Property="Visibility" Value="Collapsed"></Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding Type}" Value="USB"> - <Setter Property="Visibility" Value="Visible"></Setter> - </DataTrigger> - </Style.Triggers> - </Style> - </StackPanel.Style> - <Image Source="/Images/external-bridge-usb.png" Width="38" Height="38" RenderOptions.BitmapScalingMode="Fant"></Image> - <StackPanel Margin="10 0 0 0"> - <TextBlock FontSize="11"> + </StackPanel> + </DataTemplate> + <DataTemplate DataType="{x:Type integration:ExternalBridgeUsbClient}"> + <StackPanel Orientation="Horizontal"> + <Image Source="/Images/external-bridge-usb.png" Width="38" Height="38" RenderOptions.BitmapScalingMode="Fant"></Image> + <StackPanel Margin="10 0 0 0"> + <TextBlock FontSize="11"> <Run FontWeight="Bold">Port:</Run> <Run Text="{Binding ComPort,Mode=OneWay}"></Run> - </TextBlock> - <TextBlock FontSize="11"> + </TextBlock> + <TextBlock FontSize="11"> <Run FontWeight="Bold">Device:</Run> <Run Text="{Binding Device,Mode=OneWay}"></Run> - </TextBlock> - </StackPanel> + </TextBlock> </StackPanel> - </Grid> + </StackPanel> </DataTemplate> - </ListBox.ItemTemplate> + </ListBox.Resources> </ListBox> <mahapps:MetroProgressBar VerticalAlignment="Bottom" Height="1" IsIndeterminate="True"></mahapps:MetroProgressBar> |
