aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-16 12:06:36 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-16 12:06:36 +0300
commit9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6 (patch)
treecd5ace2339d8f3f4a4b92381843497d4f6b21301 /Software/Visual_Studio/PPC/Modules
parenta3aedf6ba1e0f9cc65877c88f66af6f330484086 (diff)
downloadTango-9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6.tar.gz
Tango-9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6.zip
New Implementation of PPC WiFI networks management!
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/MachineSettingsModuleSettings.cs14
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Models/AvailableNetworkVM.cs80
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj4
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs120
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml94
5 files changed, 18 insertions, 294 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/MachineSettingsModuleSettings.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/MachineSettingsModuleSettings.cs
new file mode 100644
index 000000000..869ecc5d6
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/MachineSettingsModuleSettings.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.Settings;
+
+namespace Tango.PPC.MachineSettings
+{
+ public class MachineSettingsModuleSettings : SettingsBase
+ {
+
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Models/AvailableNetworkVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Models/AvailableNetworkVM.cs
deleted file mode 100644
index b4b4db45a..000000000
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Models/AvailableNetworkVM.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core;
-using Tango.Core.Commands;
-using Tango.WiFi;
-
-namespace Tango.PPC.MachineSettings.Models
-{
- public class AvailableNetworkVM : ExtendedObject
- {
- public AvailableWifiNetwork Network { get; set; }
-
- private bool _connectAutomatically;
- public bool ConnectAutomatically
- {
- get { return _connectAutomatically; }
- set { _connectAutomatically = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _connecting;
- public bool Connecting
- {
- get { return _connecting; }
- set { _connecting = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _requireAuthentication;
- public bool RequireAuthentication
- {
- get { return _requireAuthentication; }
- set { _requireAuthentication = value; RaisePropertyChangedAuto(); }
- }
-
- private String _userName;
- public String UserName
- {
- get { return _userName; }
- set { _userName = value; RaisePropertyChangedAuto(); }
- }
-
- private String _password;
- public String Password
- {
- get { return _password; }
- set { _password = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _requiresPassword;
- public bool IsPasswordRequired
- {
- get { return _requiresPassword; }
- set { _requiresPassword = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _requiresUserName;
- public bool IsUserNameRequired
- {
- get { return _requiresUserName; }
- set { _requiresUserName = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _isInCredentialsStage;
-
- public bool IsInCredentialsStage
- {
- get { return _isInCredentialsStage; }
- set { _isInCredentialsStage = value; RaisePropertyChangedAuto(); }
- }
-
-
- public double SignalStrength
- {
- get { return Network.SignalStrength; }
- }
-
- }
-}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj
index 0a5c02268..8a81a8add 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Tango.PPC.MachineSettings.csproj
@@ -78,7 +78,7 @@
<Link>GlobalVersionInfo.cs</Link>
</Compile>
<Compile Include="MachineSettingsModule.cs" />
- <Compile Include="Models\AvailableNetworkVM.cs" />
+ <Compile Include="MachineSettingsModuleSettings.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@@ -160,7 +160,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs
index a0996f110..310a09846 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs
@@ -16,7 +16,6 @@ using Tango.PPC.Common;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.Messages;
-using Tango.PPC.MachineSettings.Models;
using Tango.SharedUI.Components;
using Tango.WiFi;
@@ -44,34 +43,6 @@ namespace Tango.PPC.MachineSettings.ViewModels
set { _selectedJobTypes = value; RaisePropertyChangedAuto(); }
}
- private WiFiManager _wiFiManager;
- public WiFiManager WiFiManager
- {
- get { return _wiFiManager; }
- set { _wiFiManager = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _enableWifi;
- public bool EnableWiFi
- {
- get { return _enableWifi; }
- set { _enableWifi = value; RaisePropertyChangedAuto(); }
- }
-
- private ObservableCollection<AvailableNetworkVM> _networks;
- public ObservableCollection<AvailableNetworkVM> Networks
- {
- get { return _networks; }
- set { _networks = value; RaisePropertyChangedAuto(); }
- }
-
- private ICollectionView _networksView;
- public ICollectionView NetworksView
- {
- get { return _networksView; }
- set { _networksView = value; RaisePropertyChangedAuto(); }
- }
-
#endregion
@@ -87,96 +58,12 @@ namespace Tango.PPC.MachineSettings.ViewModels
/// </summary>
public RelayCommand DiscardCommand { get; set; }
- public RelayCommand<AvailableNetworkVM> ConnectToWiFiCommand { get; set; }
-
- public RelayCommand<AvailableNetworkVM> DisconnectFromWiFiCommand { get; set; }
-
#endregion
public MainViewVM()
{
- Networks = new ObservableCollection<AvailableNetworkVM>();
- NetworksView = CollectionViewSource.GetDefaultView(Networks);
- NetworksView.SortDescriptions.Add(new SortDescription(nameof(AvailableNetworkVM.SignalStrength), ListSortDirection.Descending));
-
SaveCommand = new RelayCommand(Save);
DiscardCommand = new RelayCommand(Discard);
- WiFiManager = new WiFiManager();
-
- WiFiManager.AvailableWifiNetworks.CollectionChanged += AvailableWifiNetworks_CollectionChanged;
-
- EnableWiFi = true;
-
- ConnectToWiFiCommand = new RelayCommand<AvailableNetworkVM>(ConnectToWiFi);
- DisconnectFromWiFiCommand = new RelayCommand<AvailableNetworkVM>(DisconnectFromWiFi);
- }
-
- private void DisconnectFromWiFi(AvailableNetworkVM network)
- {
- network.Network.Disconnect();
- }
-
- private async void ConnectToWiFi(AvailableNetworkVM network)
- {
- var request = network.Network.CreateAuthenticationRequest();
-
- if (!network.IsInCredentialsStage)
- {
- if (request.IsPasswordRequired || request.IsUserNameRequired)
- {
- network.IsInCredentialsStage = true;
- network.IsUserNameRequired = request.IsUserNameRequired;
- network.IsPasswordRequired = request.IsPasswordRequired;
- return;
- }
- else
- {
- network.Connecting = true;
- await network.Network.Connect(request);
- }
- }
- else
- {
- network.IsInCredentialsStage = false;
-
- if (request.IsUserNameRequired)
- {
- request.UserName = network.UserName;
- }
- if (request.IsPasswordRequired)
- {
- request.Password = network.Password;
- }
-
- network.Connecting = true;
- var connected = await network.Network.Connect(request);
- network.Connecting = false;
-
- if (connected)
- {
- network.Network.IsConnected = true;
- }
- }
- }
-
- private void AvailableWifiNetworks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- InvokeUI(() =>
- {
- Networks.Where(x => !WiFiManager.AvailableWifiNetworks.ToList().Exists(y => y.Name == x.Network.Name)).ToList().ForEach(x => Networks.Remove(x));
-
- foreach (var n in WiFiManager.AvailableWifiNetworks.ToList())
- {
- var network = Networks.FirstOrDefault(x => x.Network.Name == n.Name);
-
- if (network == null)
- {
- network = new AvailableNetworkVM();
- network.Network = n;
- Networks.Add(network);
- }
- }
- });
}
private void Discard()
@@ -211,13 +98,6 @@ namespace Tango.PPC.MachineSettings.ViewModels
RaisePropertyChanged(nameof(Machine));
SelectedJobTypes = new SelectedObjectCollection<JobTypes>(Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection());
-
-
- //Wifi
- if (EnableWiFi)
- {
- WiFiManager.Enabled = true;
- }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml
index ec41e0b03..4823f0811 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml
@@ -7,8 +7,8 @@
xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI"
xmlns:vm="clr-namespace:Tango.PPC.MachineSettings.ViewModels"
+ xmlns:connectivity="clr-namespace:Tango.PPC.Common.Connectivity;assembly=Tango.PPC.Common"
xmlns:global="clr-namespace:Tango.PPC.MachineSettings"
- xmlns:models="clr-namespace:Tango.PPC.MachineSettings.Models"
xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}">
@@ -39,100 +39,10 @@
<Grid x:Name="Container">
<touch:LightTouchScrollViewer>
<StackPanel Margin="50">
-
<!--WIFI-->
<touch:TouchExpander Header="Connectivity" IsExpanded="True" FontSize="{StaticResource TangoExpanderHeaderFontSize}">
<StackPanel Margin="10 30 10 10">
- <DockPanel TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
- <TextBlock VerticalAlignment="Center">Enable WiFi Adapter</TextBlock>
- <touch:TouchToggleSlider Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Margin="0 0 110 0" Width="90" IsChecked="{Binding Machine.EnableExternalBridge}"></touch:TouchToggleSlider>
- </DockPanel>
-
- <touch:TouchNativeListBox PreventTouchDownSelect="False" Margin="0 30 0 30" Height="300" ItemsSource="{Binding NetworksView}" SelectionMode="Single">
- <touch:TouchNativeListBox.ItemTemplate>
- <DataTemplate DataType="{x:Type models:AvailableNetworkVM}">
- <StackPanel Margin="0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}">
- <StackPanel.Style>
- <Style TargetType="StackPanel">
- <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected}" Value="True">
- <Setter Property="Background" Value="{StaticResource TangoMidBackgroundBrush}"></Setter>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </StackPanel.Style>
- <StackPanel Orientation="Horizontal" Margin="10 15">
- <touch:TouchIcon Foreground="{StaticResource TangoPrimaryAccentBrush}" Width="48" Height="48">
- <touch:TouchIcon.Style>
- <Style TargetType="touch:TouchIcon">
- <Setter Property="Icon" Value="WifiStrengthOff"></Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding SignalStrength,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter='0'}" Value="True">
- <Setter Property="Icon" Value="WifiStrength1"></Setter>
- </DataTrigger>
- <DataTrigger Binding="{Binding SignalStrength,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter='20'}" Value="True">
- <Setter Property="Icon" Value="WifiStrength2"></Setter>
- </DataTrigger>
- <DataTrigger Binding="{Binding SignalStrength,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter='50'}" Value="True">
- <Setter Property="Icon" Value="WifiStrength3"></Setter>
- </DataTrigger>
- <DataTrigger Binding="{Binding SignalStrength,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter='80'}" Value="True">
- <Setter Property="Icon" Value="WifiStrength4"></Setter>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </touch:TouchIcon.Style>
- </touch:TouchIcon>
-
- <StackPanel Margin="20 0 0 0" VerticalAlignment="Center">
- <TextBlock VerticalAlignment="Center" Text="{Binding Network.Name,Mode=OneWay}"></TextBlock>
-
- <StackPanel Orientation="Horizontal">
- <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" FontWeight="Normal" Text="Connected, " Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock>
- <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" FontWeight="Normal" Text="Secure" Visibility="{Binding Network.IsSecure,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock>
- <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" FontWeight="Normal" Text="Open" Visibility="{Binding Network.IsSecure,Converter={StaticResource BooleanToVisibilityInverseConverter}}"></TextBlock>
- </StackPanel>
- </StackPanel>
- </StackPanel>
-
- <Grid Margin="20" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem},Path=IsSelected,Converter={StaticResource BooleanToVisibilityConverter}}">
- <Grid Height="80" Visibility="{Binding IsInCredentialsStage,Converter={StaticResource BooleanToVisibilityInverseConverter}}">
- <touch:TouchCheckBox VerticalAlignment="Top" Margin="60 0 0 0" IsChecked="{Binding ConnectAutomatically}" Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityInverseConverter}}">Connect automatically</touch:TouchCheckBox>
-
- <touch:TouchButton Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.ConnectToWiFiCommand}" CommandParameter="{Binding}" Width="150" CornerRadius="17" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityInverseConverter}}">Connect</touch:TouchButton>
- <touch:TouchButton Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.DisconnectFromWiFiCommand}" CommandParameter="{Binding}" Width="150" CornerRadius="17" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}">Disconnect</touch:TouchButton>
- </Grid>
-
- <Grid Visibility="{Binding IsInCredentialsStage,Converter={StaticResource BooleanToVisibilityConverter}}">
- <StackPanel>
- <StackPanel Width="300" HorizontalAlignment="Left" Visibility="{Binding IsUserNameRequired,Converter={StaticResource BooleanToVisibilityConverter}}">
- <TextBlock>Enter user name</TextBlock>
- <touch:TouchTextBox Margin="0 5 0 0" Background="{StaticResource TangoPrimaryBackgroundBrush}" Text="{Binding UserName}"></touch:TouchTextBox>
- </StackPanel>
- <StackPanel Margin="0 10 0 0" Width="300" HorizontalAlignment="Left" Visibility="{Binding IsPasswordRequired,Converter={StaticResource BooleanToVisibilityConverter}}">
- <TextBlock>Enter the network security</TextBlock>
- <touch:TouchTextBox Margin="0 5 0 0" IsPassword="True" Background="{StaticResource TangoPrimaryBackgroundBrush}" Text="{Binding Password}"></touch:TouchTextBox>
- </StackPanel>
-
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 20 0 0">
- <touch:TouchButton Style="{StaticResource TangoHollowButton}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.CancelConnectToWiFiCommand}" CommandParameter="{Binding}" Width="150" CornerRadius="17" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityInverseConverter}}">Cancel</touch:TouchButton>
- <touch:TouchButton Margin="10 0 0 0" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.ConnectToWiFiCommand}" CommandParameter="{Binding}" Width="150" CornerRadius="17" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="{Binding Network.IsConnected,Converter={StaticResource BooleanToVisibilityInverseConverter}}">Next</touch:TouchButton>
- </StackPanel>
- </StackPanel>
- </Grid>
-
- <Grid Visibility="{Binding Connecting,Converter={StaticResource BooleanToVisibilityConverter}}" Background="{StaticResource TangoMidBackgroundBrush}">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="60 0 0 0" VerticalAlignment="Center">
- <touch:TouchBusyIndicator IsIndeterminate="{Binding Connecting}" Width="50" Height="50" />
- <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Connecting...</TextBlock>
- </StackPanel>
- </Grid>
- </Grid>
- </StackPanel>
- </DataTemplate>
- </touch:TouchNativeListBox.ItemTemplate>
- </touch:TouchNativeListBox>
+ <connectivity:AvailableWiFiConnectionsControl DataContext="{Binding ConnectivityProvider}" />
</StackPanel>
</touch:TouchExpander>