aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-15 12:29:05 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-15 12:29:05 +0200
commitd6f46df0e9ccd08276912bcdcded246de0bc4447 (patch)
tree12b743658b9ef5b48c4e938bc63633eed2465594 /Software/Visual_Studio
parent8356b90e200c1124e6dc89fe88f18f62c68b7623 (diff)
downloadTango-d6f46df0e9ccd08276912bcdcded246de0bc4447.tar.gz
Tango-d6f46df0e9ccd08276912bcdcded246de0bc4447.zip
Implemented virtual machine selection when connecting via USB.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs29
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj1
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj12
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs32
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs35
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml73
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml.cs28
-rw-r--r--Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs5
8 files changed, 203 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs
new file mode 100644
index 000000000..e486ec79a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/AutoComplete/MachinesProvider.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.AutoComplete.Editors;
+using Tango.BL;
+using Tango.BL.Entities;
+
+namespace Tango.MachineStudio.Common.AutoComplete
+{
+ /// <summary>
+ /// Represents an auto-complete machines suggestions provider.
+ /// </summary>
+ /// <seealso cref="Tango.AutoComplete.Editors.ISuggestionProvider" />
+ public class MachinesProvider : ISuggestionProvider
+ {
+ /// <summary>
+ /// Gets the suggestions.
+ /// </summary>
+ /// <param name="filter">The filter.</param>
+ /// <returns></returns>
+ public IEnumerable GetSuggestions(string filter)
+ {
+ return ObservablesEntitiesAdapter.Instance.Machines.Where(x => x.SerialNumber.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase) || x.Name.ToLower().Contains(filter.ToLower())).ToList();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
index 529419bd7..7c28cb4c8 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj
@@ -80,6 +80,7 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="AutoComplete\MachinesProvider.cs" />
<Compile Include="Controls\HiveColorPickerControl.xaml.cs">
<DependentUpon>HiveColorPickerControl.xaml</DependentUpon>
</Compile>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
index 6fc530627..6a879e965 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj
@@ -159,6 +159,7 @@
<Compile Include="ViewModels\LoginViewVM.cs" />
<Compile Include="ViewModels\MachineConnectionViewVM.cs" />
<Compile Include="ViewModels\MachineLoginViewVM.cs" />
+ <Compile Include="ViewModels\MachineSerialViewVM.cs" />
<Compile Include="ViewModels\MainViewVM.cs" />
<Compile Include="ViewModelLocator.cs" />
<Compile Include="ViewModels\ModuleWindowVM.cs" />
@@ -176,6 +177,9 @@
<Compile Include="Views\MachineLoginView.xaml.cs">
<DependentUpon>MachineLoginView.xaml</DependentUpon>
</Compile>
+ <Compile Include="Views\MachineSerialView.xaml.cs">
+ <DependentUpon>MachineSerialView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
</Compile>
@@ -238,6 +242,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\MachineSerialView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\MainView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -299,6 +307,10 @@
<Project>{b9ae25d6-be35-492f-9079-21a7f3e6f7cc}</Project>
<Name>RealTimeGraphEx</Name>
</ProjectReference>
+ <ProjectReference Include="..\..\SideChains\Tango.AutoComplete\Tango.AutoComplete.csproj">
+ <Project>{bb2abb74-ba58-4812-83aa-ec8171f42df4}</Project>
+ <Name>Tango.AutoComplete</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj">
<Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
<Name>Tango.BL</Name>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs
new file mode 100644
index 000000000..219bd9e63
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MachineSerialViewVM.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Entities;
+using Tango.Core.Commands;
+using Tango.MachineStudio.Common.Notifications;
+using Tango.Settings;
+
+namespace Tango.MachineStudio.UI.ViewModels
+{
+ public class MachineSerialViewVM : DialogViewVM
+ {
+ private Machine _selectedMachine;
+
+ public Machine SelectedMachine
+ {
+ get { return _selectedMachine; }
+ set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+ public RelayCommand OKCommand { get; set; }
+
+ public MachineSerialViewVM()
+ {
+ OKCommand = new RelayCommand(Accept, () => SelectedMachine != null);
+ SelectedMachine = ObservablesEntitiesAdapter.Instance.Machines.SingleOrDefault(x => x.SerialNumber == SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber);
+ }
+ }
+}
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 57f1d704c..84c4e2dd3 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
@@ -26,6 +26,7 @@ using Tango.MachineStudio.UI.SupervisingController;
using Tango.MachineStudio.UI.Views;
using Tango.MachineStudio.UI.Windows;
using Tango.PMR.Stubs;
+using Tango.Settings;
using Tango.SharedUI;
using Tango.SharedUI.Helpers;
using Tango.Transport.Adapters;
@@ -333,21 +334,31 @@ namespace Tango.MachineStudio.UI.ViewModels
}
else
{
- using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ _notificationProvider.ShowModalDialog<MachineSerialViewVM>(async (vm) =>
{
- try
+ if (vm.SelectedMachine != null)
{
- await x.SelectedMachine.Connect();
- ApplicationManager.ConnectedMachine = x.SelectedMachine;
- }
- catch (Exception ex)
- {
- logManager.Log(ex);
- _notificationProvider.ShowError(ex.Message);
- }
+ using (NotificationProvider.PushTaskItem("Connecting to " + x.SelectedMachine.ToString() + "..."))
+ {
+ try
+ {
+ await x.SelectedMachine.Connect();
+ x.SelectedMachine.SerialNumber = vm.SelectedMachine.SerialNumber;
+ ApplicationManager.ConnectedMachine = x.SelectedMachine;
- InvalidateRelayCommands();
- }
+ SettingsManager.Default.MachineStudio.LastVirtualMachineSerialNumber = vm.SelectedMachine.SerialNumber;
+ SettingsManager.SaveDefaultSettings();
+ }
+ catch (Exception ex)
+ {
+ logManager.Log(ex);
+ _notificationProvider.ShowError(ex.Message);
+ }
+
+ InvalidateRelayCommands();
+ }
+ }
+ });
}
InvalidateRelayCommands();
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml
new file mode 100644
index 000000000..83a6eece6
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml
@@ -0,0 +1,73 @@
+<UserControl x:Class="Tango.MachineStudio.UI.Views.MachineSerialView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:autoComplete="clr-namespace:Tango.AutoComplete.Editors;assembly=Tango.AutoComplete"
+ xmlns:autoCompleteMachine="clr-namespace:Tango.MachineStudio.Common.AutoComplete;assembly=Tango.MachineStudio.Common"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:vm="clr-namespace:Tango.MachineStudio.UI.ViewModels"
+ xmlns:local="clr-namespace:Tango.MachineStudio.UI.Views"
+ mc:Ignorable="d" Width="600" Height="400" Background="White" d:DataContext="{d:DesignInstance Type=vm:MachineSerialViewVM, IsDesignTimeCreatable=False}">
+
+ <UserControl.Resources>
+ <autoCompleteMachine:MachinesProvider x:Key="MachinesProvider" />
+ </UserControl.Resources>
+
+ <Grid>
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="80"/>
+ <RowDefinition Height="1*"/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <StackPanel Orientation="Horizontal" Margin="10">
+ <Image Source="/Images/machine-trans.png" RenderOptions.BitmapScalingMode="Fant"></Image>
+ <TextBlock Text="Virtual Machine" VerticalAlignment="Center" Margin="10 0 0 0" FontSize="20"></TextBlock>
+ </StackPanel>
+ </Grid>
+
+ <Grid Grid.Row="1" Margin="10 0 10 10">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="50"/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <StackPanel Margin="0 10 0 0" >
+ <TextBlock TextWrapping="Wrap" TextAlignment="Center">
+ <Run>Connecting directly to a machine's embedded firmware requires the selection of an existing machine from the database in order for machine studio to function properly.</Run>
+ <LineBreak/>
+ <LineBreak/>
+ <Run>Please select a 'virtual machine' by entering the machine serial number</Run>
+ </TextBlock>
+
+ <StackPanel Orientation="Horizontal" Margin="0 80 0 0" Width="300">
+ <materialDesign:PackIcon Kind="Key" Width="24" Height="24" />
+ <autoComplete:AutoCompleteTextBox HorizontalContentAlignment="Stretch" Width="300" Margin="10 0 0 0" FontSize="16" Provider="{StaticResource MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}" materialDesign:HintAssist.Hint="Serial Number / Name" DisplayMember="SerialNumber">
+ <autoComplete:AutoCompleteTextBox.ItemTemplate>
+ <DataTemplate>
+ <Border Padding="5">
+ <DockPanel LastChildFill="False" Width="250">
+ <StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
+ <Image Source="/Images/machine-trans.png" Width="24" RenderOptions.BitmapScalingMode="Fant" />
+ <TextBlock Margin="10 0 0 0" FontWeight="SemiBold" Text="{Binding SerialNumber}" VerticalAlignment="Center"></TextBlock>
+ </StackPanel>
+ <TextBlock DockPanel.Dock="Right" HorizontalAlignment="Right" Text="{Binding Name}" Foreground="Gray" VerticalAlignment="Center"></TextBlock>
+ </DockPanel>
+ </Border>
+ </DataTemplate>
+ </autoComplete:AutoCompleteTextBox.ItemTemplate>
+ </autoComplete:AutoCompleteTextBox>
+ </StackPanel>
+ </StackPanel>
+ </Grid>
+
+ <Grid Grid.Row="1">
+ <Button HorizontalAlignment="Right" Width="140" Command="{Binding OKCommand}">OK</Button>
+ </Grid>
+ </Grid>
+ </Grid>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml.cs
new file mode 100644
index 000000000..0d6c0413a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MachineSerialView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.UI.Views
+{
+ /// <summary>
+ /// Interaction logic for MachineSerialView.xaml
+ /// </summary>
+ public partial class MachineSerialView : UserControl
+ {
+ public MachineSerialView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs
index ecaa15153..6895f30a1 100644
--- a/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs
+++ b/Software/Visual_Studio/Tango.Settings/MachineStudioSettings/MachineStudio.cs
@@ -29,6 +29,11 @@ namespace Tango.Settings.MachineStudioSettings
public bool RememberMe { get; set; }
/// <summary>
+ /// Gets or sets the last virtual machine serial number.
+ /// </summary>
+ public String LastVirtualMachineSerialNumber { get; set; }
+
+ /// <summary>
/// Gets or sets the update service address.
/// </summary>
public String UpdateServiceAddress { get; set; }