diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-16 12:06:36 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-16 12:06:36 +0300 |
| commit | 9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6 (patch) | |
| tree | cd5ace2339d8f3f4a4b92381843497d4f6b21301 | |
| parent | a3aedf6ba1e0f9cc65877c88f66af6f330484086 (diff) | |
| download | Tango-9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6.tar.gz Tango-9dbb8f8eb3d07ee07cf7ce1beab72df056e157c6.zip | |
New Implementation of PPC WiFI networks management!
32 files changed, 896 insertions, 561 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex 32f89c29f..4e4ae505a 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 30c41a0c1..de69c2ab7 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf 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> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml new file mode 100644 index 000000000..80581551e --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml @@ -0,0 +1,91 @@ +<UserControl x:Class="Tango.PPC.Common.Connectivity.AvailableWiFiConnectionsControl" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.PPC.Common.Connectivity" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="350" d:DataContext="{d:DesignInstance Type=local:IConnectivityProvider, IsDesignTimeCreatable=False}"> + <Grid> + <StackPanel> + <DockPanel LastChildFill="False"> + <TextBlock DockPanel.Dock="Left" FontSize="{StaticResource TangoDefaultFontSize}" VerticalAlignment="Center">Available WiFi Connections</TextBlock> + <touch:TouchIconButton Padding="20" RippleBrush="{StaticResource TangoRippleDarkBrush}" CornerRadius="50" Foreground="{StaticResource TangoPrimaryAccentBrush}" Command="{Binding RefreshAvailableWiFiNetworksCommand}" DockPanel.Dock="Right" Icon="Refresh" Height="60" /> + </DockPanel> + <touch:TouchNativeListBox PreventTouchDownSelect="False" Margin="0 20 0 30" Height="300" ItemsSource="{Binding AvailableWiFiNetworksViewSource}" SelectionMode="Single"> + <touch:TouchNativeListBox.ItemTemplate> + <DataTemplate> + <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 Name,Mode=OneWay}"></TextBlock> + + <StackPanel Orientation="Horizontal"> + <TextBlock Foreground="{StaticResource TangoPrimaryAccentBrush}" FontWeight="Normal" Text="Connected, " Visibility="{Binding IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" FontWeight="Normal" Text="Secure" Visibility="{Binding IsSecure,Converter={StaticResource BooleanToVisibilityConverter}}"></TextBlock> + <TextBlock Foreground="{StaticResource TangoGrayTextBrush}" FontWeight="Normal" Text="Open" Visibility="{Binding 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"> + <touch:TouchCheckBox VerticalAlignment="Top" Margin="60 0 0 0" IsChecked="{Binding AutoConnect}" Visibility="{Binding 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 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 IsConnected,Converter={StaticResource BooleanToVisibilityConverter}}">Disconnect</touch:TouchButton> + </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 Visibility="{Binding Disconnecting,Converter={StaticResource BooleanToVisibilityConverter}}" Background="{StaticResource TangoMidBackgroundBrush}"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="60 0 0 0" VerticalAlignment="Center"> + <touch:TouchBusyIndicator IsIndeterminate="{Binding Disconnecting}" Width="50" Height="50" /> + <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Disconnecting...</TextBlock> + </StackPanel> + </Grid> + </Grid> + </StackPanel> + </DataTemplate> + </touch:TouchNativeListBox.ItemTemplate> + </touch:TouchNativeListBox> + </StackPanel> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.xaml.cs new file mode 100644 index 000000000..8d85aa5ad --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/AvailableWiFiConnectionsControl.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.PPC.Common.Connectivity +{ + /// <summary> + /// Interaction logic for AvailableWiFiConnectionsControl.xaml + /// </summary> + public partial class AvailableWiFiConnectionsControl : UserControl + { + public AvailableWiFiConnectionsControl() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/ConnectionStateEventArgs.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/ConnectionStateEventArgs.cs new file mode 100644 index 000000000..ff20161a0 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/ConnectionStateEventArgs.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.Connectivity +{ + public class ConnectionStateEventArgs : EventArgs + { + public bool IsConnected { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs new file mode 100644 index 000000000..85c25128a --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/IConnectivityProvider.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; + +namespace Tango.PPC.Common.Connectivity +{ + /// <summary> + /// Represents an internet connection manager. + /// </summary> + public interface IConnectivityProvider + { + /// <summary> + /// Occurs when the connectivity provider state has changed (e.g network connected/disconnected). + /// </summary> + event EventHandler<ConnectionStateEventArgs> ConnectionStateChanged; + + /// <summary> + /// Gets a value indicating whether there is any Internet connection available. + /// </summary> + bool IsConnected { get; } + + /// <summary> + /// Gets the available WiFi networks. + /// </summary> + ObservableCollection<WiFiNetwork> AvailableWiFiNetworks { get; } + + /// <summary> + /// Gets the available WiFi networks as a sorted view source by signal strength. + /// </summary> + ICollectionView AvailableWiFiNetworksViewSource { get; set; } + + /// <summary> + /// Gets the available WiFi networks. + /// </summary> + /// <returns></returns> + Task<List<WiFiNetwork>> GetAvailableWiFiNetworks(); + + /// <summary> + /// Resets the available WiFi networks collection. + /// </summary> + Task RefreshAvailableWiFiNetworks(); + + /// <summary> + /// Checks the Internet connection. + /// </summary> + /// <returns></returns> + Task<bool> CheckInternetConnection(); + + /// <summary> + /// Gets the connect to WiFi command. + /// </summary> + RelayCommand<WiFiNetwork> ConnectToWiFiCommand { get; } + + /// <summary> + /// Gets the disconnect from WiFi command. + /// </summary> + RelayCommand<WiFiNetwork> DisconnectFromWiFiCommand { get; } + + /// <summary> + /// Gets or sets the refresh available WiFi networks command. + /// </summary> + RelayCommand RefreshAvailableWiFiNetworksCommand { get; set; } + + /// <summary> + /// Connects the specified network. + /// </summary> + /// <param name="network">The network.</param> + /// <returns></returns> + Task<bool> Connect(WiFiNetwork network); + + /// <summary> + /// Disconnects the specified network. + /// </summary> + /// <param name="network">The network.</param> + /// <returns></returns> + void Disconnect(WiFiNetwork network); + } +} diff --git a/Software/Visual_Studio/Tango.WiFi/NetworkAuthenticationRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiAuthentication.cs index 238161987..dfa3576c4 100644 --- a/Software/Visual_Studio/Tango.WiFi/NetworkAuthenticationRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiAuthentication.cs @@ -4,10 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.Core; +using Tango.WiFi; -namespace Tango.WiFi +namespace Tango.PPC.Common.Connectivity { - public class NetworkAuthenticationRequest : ExtendedObject + public class WiFiAuthentication : ExtendedObject { public AuthRequest AuthRequest { get; set; } @@ -33,7 +34,7 @@ namespace Tango.WiFi set { AuthRequest.Password = value; RaisePropertyChangedAuto(); } } - public NetworkAuthenticationRequest(AuthRequest request) + public WiFiAuthentication(AuthRequest request) { AuthRequest = request; } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs new file mode 100644 index 000000000..766e25e40 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Connectivity/WiFiNetwork.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Tango.Core; +using Tango.Core.Commands; +using Tango.WiFi; + +namespace Tango.PPC.Common.Connectivity +{ + public class WiFiNetwork : ExtendedObject + { + private Wifi _wifi; + + public bool IsConnected + { + get { return AccessPoint.IsConnected; } + } + + public String Name + { + get { return AccessPoint.Name; } + } + + public double SignalStrength + { + get { return AccessPoint.SignalStrength; } + } + + public bool IsSecure + { + get { return AccessPoint.IsSecure; } + } + + public bool HasProfile + { + get { return AccessPoint.HasProfile; } + } + + private AccessPoint _accessPoint; + public AccessPoint AccessPoint + { + get { return _accessPoint; } + set + { + _accessPoint = value; + + foreach (var prop in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public)) + { + RaisePropertyChanged(prop.Name); + } + } + } + + private bool _autoConnect; + public bool AutoConnect + { + get { return _autoConnect; } + set { _autoConnect = value; RaisePropertyChangedAuto(); } + } + + private bool _connecting; + public bool Connecting + { + get { return _connecting; } + set { _connecting = value; RaisePropertyChangedAuto(); } + } + + private bool _disconnecting; + public bool Disconnecting + { + get { return _disconnecting; } + set { _disconnecting = value; RaisePropertyChangedAuto(); } + } + + public WiFiNetwork(AccessPoint accessPoint, Wifi wifi) + { + _wifi = wifi; + AccessPoint = accessPoint; + } + + public WiFiAuthentication CreateAuthenticationRequest() + { + return new WiFiAuthentication(new AuthRequest(AccessPoint)); + } + + public Task<bool> Connect(WiFiAuthentication request) + { + return Task.Factory.StartNew<bool>(() => + { + try + { + Connecting = true; + return AccessPoint.Connect(request.AuthRequest, false); + } + catch (Exception) + { + throw; + } + finally + { + Connecting = false; + } + }); + } + + public Task Disconnect() + { + return Task.Factory.StartNew(() => + { + try + { + Disconnecting = true; + _wifi.Disconnect(); + AccessPoint.DeleteProfile(); + } + catch (Exception) + { + throw; + } + finally + { + Disconnecting = false; + } + }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index 3e908f3a4..9b1fa961c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -41,6 +41,11 @@ namespace Tango.PPC.Common public int MachineScanningTimeoutSeconds { get; set; } /// <summary> + /// Gets or sets the name of the name of a WiFi network to automatically connect to when the application starts. + /// </summary> + public String AutoConnectWiFiName { get; set; } + + /// <summary> /// Initializes a new instance of the <see cref="PPCSettings"/> class. /// </summary> public PPCSettings() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs index 0fb2be851..23213f194 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCViewModel.cs @@ -8,6 +8,7 @@ using Tango.Core.DI; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.ExternalBridge; using Tango.PPC.Common.Navigation; using Tango.PPC.Common.Notifications; @@ -74,6 +75,12 @@ namespace Tango.PPC.Common [TangoInject] public IPrintingManager PrintingManager { get; set; } + /// <summary> + /// Gets or sets the connectivity provider. + /// </summary> + [TangoInject] + public IConnectivityProvider ConnectivityProvider { get; set; } + private PPCSettings _settings; /// <summary> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 0fe4f3f42..5de2fbf81 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -106,6 +106,13 @@ <Compile Include="Connection\DefaultMachineProvider.cs" /> <Compile Include="Connection\IMachineProvider.cs" /> <Compile Include="Connection\MachineOperatorChangedEventArgs.cs" /> + <Compile Include="Connectivity\AvailableWiFiConnectionsControl.xaml.cs"> + <DependentUpon>AvailableWiFiConnectionsControl.xaml</DependentUpon> + </Compile> + <Compile Include="Connectivity\ConnectionStateEventArgs.cs" /> + <Compile Include="Connectivity\WiFiAuthentication.cs" /> + <Compile Include="Connectivity\WiFiNetwork.cs" /> + <Compile Include="Connectivity\IConnectivityProvider.cs" /> <Compile Include="Controls\AsyncAdornerControl.cs" /> <Compile Include="Controls\TwineCatalogControl.xaml.cs"> <DependentUpon>TwineCatalogControl.xaml</DependentUpon> @@ -144,6 +151,10 @@ <Compile Include="Update\UploadCompletedRequest.cs" /> <Compile Include="Update\UploadVersionRequest.cs" /> <Compile Include="Update\UploadVersionResponse.cs" /> + <Page Include="Connectivity\AvailableWiFiConnectionsControl.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Controls\MultiPieChart.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -260,6 +271,10 @@ <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.WiFi\Tango.WiFi.csproj"> + <Project>{6aa425c9-ea6a-4b01-aaed-5ff122e8b663}</Project> + <Name>Tango.WiFi</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <BootstrapperPackage Include=".NETFramework,Version=v4.6"> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs new file mode 100644 index 000000000..ec51b9a98 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/DefaultConnectivityProvider.cs @@ -0,0 +1,265 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.BL; +using Tango.Core; +using Tango.Core.Commands; +using Tango.Core.Cryptography; +using Tango.PPC.Common; +using Tango.PPC.Common.Application; +using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Connectivity; +using Tango.PPC.Common.Notifications; +using Tango.Settings; +using Tango.WiFi; + +namespace Tango.PPC.UI.Connectivity +{ + public class DefaultConnectivityProvider : ExtendedObject, IConnectivityProvider + { + private Wifi _wifi; + private INotificationProvider _notification; + + /// <summary> + /// Occurs when the connectivity provider state has changed (e.g network connected/disconnected). + /// </summary> + public event EventHandler<ConnectionStateEventArgs> ConnectionStateChanged; + + private bool _isConnected; + /// <summary> + /// Gets a value indicating whether there is any Internet connection available. + /// </summary> + public bool IsConnected + { + get { return _isConnected; } + set { _isConnected = value; RaisePropertyChangedAuto(); } + } + + /// <summary> + /// Gets the available WiFi networks. + /// </summary> + public ObservableCollection<WiFiNetwork> AvailableWiFiNetworks { get; } + + /// <summary> + /// Gets the available WiFi networks as a sorted view source by signal strength. + /// </summary> + public ICollectionView AvailableWiFiNetworksViewSource { get; set; } + + /// <summary> + /// Gets the connect to WiFi command. + /// </summary> + public RelayCommand<WiFiNetwork> ConnectToWiFiCommand { get; private set; } + + /// <summary> + /// Gets the disconnect from WiFi command. + /// </summary> + public RelayCommand<WiFiNetwork> DisconnectFromWiFiCommand { get; private set; } + + /// <summary> + /// + /// </summary> + public RelayCommand RefreshAvailableWiFiNetworksCommand { get; set; } + + /// <summary> + /// Initializes a new instance of the <see cref="DefaultConnectivityProvider"/> class. + /// </summary> + public DefaultConnectivityProvider(IPPCApplicationManager applicationManager, INotificationProvider notificationProvider) + { + _notification = notificationProvider; + + AvailableWiFiNetworks = new ObservableCollection<WiFiNetwork>(); + AvailableWiFiNetworks.EnableCrossThreadOperations(); + AvailableWiFiNetworksViewSource = CollectionViewSource.GetDefaultView(AvailableWiFiNetworks); + + AvailableWiFiNetworksViewSource.SortDescriptions.Add(new SortDescription(nameof(WiFiNetwork.IsConnected), ListSortDirection.Descending)); + AvailableWiFiNetworksViewSource.SortDescriptions.Add(new SortDescription(nameof(WiFiNetwork.SignalStrength), ListSortDirection.Descending)); + + _wifi = new Wifi(); + + applicationManager.Ready += ApplicationManager_Ready; + + ConnectToWiFiCommand = new RelayCommand<WiFiNetwork>(async (x) => + { + await Connect(x); + }); + + DisconnectFromWiFiCommand = new RelayCommand<WiFiNetwork>((x) => + { + Disconnect(x); + }); + + RefreshAvailableWiFiNetworksCommand = new RelayCommand(() => + { + RefreshAvailableWiFiNetworks(); + }); + } + + /// <summary> + /// Handles the application manager ApplicationReady event. + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ApplicationManager_Ready(object sender, EventArgs e) + { + Task.Factory.StartNew(async () => + { + Thread.Sleep(2000); + + await RefreshAvailableWiFiNetworks(); + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + + var auto_connect_network = AvailableWiFiNetworks.ToList().FirstOrDefault(x => x.Name == settings.AutoConnectWiFiName); + + if (auto_connect_network != null && !auto_connect_network.IsConnected) + { + await Connect(auto_connect_network); + } + }); + } + + /// <summary> + /// Gets the available WiFi networks. + /// </summary> + /// <returns></returns> + public Task<List<WiFiNetwork>> GetAvailableWiFiNetworks() + { + return Task.Factory.StartNew<List<WiFiNetwork>>(() => + { + var accessPoints = _wifi.GetAccessPoints(); + + AvailableWiFiNetworks.Where(x => !accessPoints.ToList().Exists(y => y.Name == x.Name)).ToList().ForEach(x => AvailableWiFiNetworks.Remove(x)); + + foreach (var ap in accessPoints.ToList()) + { + var network = AvailableWiFiNetworks.FirstOrDefault(x => x.Name == ap.Name); + + if (network == null) + { + network = new WiFiNetwork(ap, _wifi); + AvailableWiFiNetworks.Add(network); + } + else + { + network.AccessPoint = ap; + } + } + + return AvailableWiFiNetworks.ToList(); + }); + } + + /// <summary> + /// Resets the available WiFi networks collection. + /// </summary> + public Task RefreshAvailableWiFiNetworks() + { + return Task.Factory.StartNew(() => + { + AvailableWiFiNetworks.Clear(); + GetAvailableWiFiNetworks().Wait(); + }); + } + + /// <summary> + /// Checks the Internet connection. + /// </summary> + /// <returns></returns> + public Task<bool> CheckInternetConnection() + { + return Task.Factory.StartNew<bool>(() => + { + try + { + using (var client = new WebClient()) + using (client.OpenRead("http://clients3.google.com/generate_204")) + { + return true; + } + } + catch + { + return false; + } + }); + } + + /// <summary> + /// Connects the specified network. + /// </summary> + /// <param name="network">The network.</param> + /// <returns></returns> + public async Task<bool> Connect(WiFiNetwork network) + { + var auth = network.CreateAuthenticationRequest(); + + bool result = false; + + if ((auth.IsPasswordRequired || auth.IsUserNameRequired) && !network.HasProfile) + { + var vm = await _notification.ShowDialog<WiFiAuthenticationViewVM>(new WiFiAuthenticationViewVM(auth, network)); + + if (vm.DialogResult) + { + result = await network.Connect(auth); + await RefreshAvailableWiFiNetworks(); + } + else + { + return false; + } + } + else + { + result = await network.Connect(auth); + await RefreshAvailableWiFiNetworks(); + return result; + } + + if (result) + { + OnConnectionStateChanged(true); + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + settings.AutoConnectWiFiName = network.AutoConnect ? network.Name : null; + settings.Save(); + } + + return result; + } + + /// <summary> + /// Disconnects the specified network. + /// </summary> + /// <param name="network">The network.</param> + /// <returns></returns> + public void Disconnect(WiFiNetwork network) + { + Task.Factory.StartNew(() => + { + var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + settings.AutoConnectWiFiName = null; + settings.Save(); + network.AutoConnect = false; + network.Disconnect().Wait(); + RefreshAvailableWiFiNetworks().Wait(); + OnConnectionStateChanged(false); + }); + } + + /// <summary> + /// Called when the connection state has been changed + /// </summary> + /// <param name="connected">if set to <c>true</c> [connected].</param> + protected virtual void OnConnectionStateChanged(bool connected) + { + IsConnected = connected; + ConnectionStateChanged?.Invoke(this, new ConnectionStateEventArgs() { IsConnected = connected }); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml new file mode 100644 index 000000000..311c3ce99 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml @@ -0,0 +1,45 @@ +<UserControl x:Class="Tango.PPC.UI.Connectivity.WiFiAuthenticationView" + 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:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" + xmlns:local="clr-namespace:Tango.PPC.UI.Connectivity" + mc:Ignorable="d" + Background="{StaticResource TangoPrimaryBackgroundBrush}" MinWidth="500" Height="570" d:DataContext="{d:DesignInstance Type=local:WiFiAuthenticationViewVM, IsDesignTimeCreatable=False}"> + <Grid Margin="10"> + <Grid.RowDefinitions> + <RowDefinition Height="200"/> + <RowDefinition Height="1*"/> + <RowDefinition Height="50"/> + </Grid.RowDefinitions> + + <StackPanel> + <touch:TouchIcon Icon="WifiStrength3Lock" Width="100" Height="100" Foreground="{StaticResource TangoPrimaryAccentBrush}" Margin="10" /> + <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}"> + <Run>Connect to </Run> + <Run Foreground="{StaticResource TangoPrimaryAccentBrush}" FontStyle="Italic" Text="{Binding WiFiNetwork.Name,Mode=OneWay}"></Run> + </TextBlock> + </StackPanel> + + <Grid Grid.Row="1"> + <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> + <StackPanel Margin="0 0 0 40" Visibility="{Binding WiFiAuthentication.IsUserNameRequired,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock TextAlignment="Center">Enter user name</TextBlock> + <touch:TouchTextBox Margin="0 10 0 0" Background="{StaticResource TangoPrimaryBackgroundBrush}" Text="{Binding WiFiAuthentication.UserName}"></touch:TouchTextBox> + </StackPanel> + <StackPanel Margin="0 0 0 0" Visibility="{Binding WiFiAuthentication.IsPasswordRequired,Converter={StaticResource BooleanToVisibilityConverter}}"> + <TextBlock x:Name="txtPassword" TextAlignment="Center">Enter the network security key</TextBlock> + <touch:TouchTextBox Margin="0 10 0 0" IsPassword="True" Background="{StaticResource TangoPrimaryBackgroundBrush}" Text="{Binding WiFiAuthentication.Password}"></touch:TouchTextBox> + </StackPanel> + </StackPanel> + </Grid> + + <Grid Grid.Row="2"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> + <touch:TouchButton Command="{Binding CloseCommand}" CornerRadius="25" Width="170" Height="50" Style="{StaticResource TangoHollowButton}">CANCEL</touch:TouchButton> + <touch:TouchButton CornerRadius="25" Width="170" Height="50" Margin="10 0 0 0" Command="{Binding OKCommand}">CONNECT</touch:TouchButton> + </StackPanel> + </Grid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml.cs new file mode 100644 index 000000000..690f2321f --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationView.xaml.cs @@ -0,0 +1,35 @@ +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.PPC.UI.Connectivity +{ + /// <summary> + /// Interaction logic for WiFiAuthenticationView.xaml + /// </summary> + public partial class WiFiAuthenticationView : UserControl + { + public WiFiAuthenticationView() + { + InitializeComponent(); + + this.Loaded += WiFiAuthenticationView_Loaded; + } + + private void WiFiAuthenticationView_Loaded(object sender, RoutedEventArgs e) + { + txtPassword.Focus(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationViewVM.cs new file mode 100644 index 000000000..68fb2496b --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Connectivity/WiFiAuthenticationViewVM.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PPC.Common.Connectivity; +using Tango.SharedUI; + +namespace Tango.PPC.UI.Connectivity +{ + public class WiFiAuthenticationViewVM : DialogViewVM + { + public WiFiAuthentication WiFiAuthentication { get; set; } + + public WiFiNetwork WiFiNetwork { get; set; } + + public WiFiAuthenticationViewVM(WiFiAuthentication wifiAuthentication,WiFiNetwork wifiNetwork) : base() + { + WiFiAuthentication = wifiAuthentication; + WiFiNetwork = wifiNetwork; + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index db9ee3863..2d0ac96fa 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -108,14 +108,19 @@ namespace Tango.PPC.UI.PPCApplication /// <summary> /// Called when the main window content has been rendered /// </summary> - private async void OnMainWindowContentRendered() + private void OnMainWindowContentRendered() { LogManager.Log("Main window content rendered."); - PPCSettings settings = null; - ContentRendered?.Invoke(this, new EventArgs()); + StartApplication(); + } + + private async void StartApplication() + { + PPCSettings settings = null; + await Task.Factory.StartNew(() => { LogManager.Log("Reading PPC settings..."); @@ -154,14 +159,14 @@ namespace Tango.PPC.UI.PPCApplication } else { - OnDbInitialized(); + PostDbInitialize(); } } /// <summary> /// Called when the database has been initialized /// </summary> - private void OnDbInitialized() + private void PostDbInitialize() { LogManager.Log($"Raising {nameof(ApplicationStarted)} event..."); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj index d1772d0a0..d91bee884 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj @@ -112,6 +112,11 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="Authentication\DefaultAuthenticationProvider.cs" /> + <Compile Include="Connectivity\DefaultConnectivityProvider.cs" /> + <Compile Include="Connectivity\WiFiAuthenticationView.xaml.cs"> + <DependentUpon>WiFiAuthenticationView.xaml</DependentUpon> + </Compile> + <Compile Include="Connectivity\WiFiAuthenticationViewVM.cs" /> <Compile Include="Converters\AppBarItemConverter.cs" /> <Compile Include="Converters\NotificationItemConverter.cs" /> <Compile Include="Modules\DefaultStudioModuleLoader.cs" /> @@ -149,6 +154,10 @@ <Compile Include="Views\MainView.xaml.cs"> <DependentUpon>MainView.xaml</DependentUpon> </Compile> + <Page Include="Connectivity\WiFiAuthenticationView.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="MainWindow.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> @@ -285,6 +294,10 @@ <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> <Name>Tango.Transport</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.WiFi\Tango.WiFi.csproj"> + <Project>{6aa425c9-ea6a-4b01-aaed-5ff122e8b663}</Project> + <Name>Tango.WiFi</Name> + </ProjectReference> <ProjectReference Include="..\Modules\Tango.PPC.Jobs\Tango.PPC.Jobs.csproj"> <Project>{096f16c8-6d06-4b5f-9496-b9d2df2d94a3}</Project> <Name>Tango.PPC.Jobs</Name> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 61c2ca7c4..5c416a289 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -6,6 +6,7 @@ using Tango.Logging; using Tango.PPC.Common.Application; using Tango.PPC.Common.Authentication; using Tango.PPC.Common.Connection; +using Tango.PPC.Common.Connectivity; using Tango.PPC.Common.Diagnostics; using Tango.PPC.Common.EventLogging; using Tango.PPC.Common.ExternalBridge; @@ -16,6 +17,7 @@ using Tango.PPC.Common.Notifications; using Tango.PPC.Common.Printing; using Tango.PPC.Common.Threading; using Tango.PPC.UI.Authentication; +using Tango.PPC.UI.Connectivity; using Tango.PPC.UI.Modules; using Tango.PPC.UI.Navigation; using Tango.PPC.UI.Notifications; @@ -54,6 +56,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Unregister<IPPCExternalBridgeService>(); TangoIOC.Default.Unregister<IMachineSetupManager>(); TangoIOC.Default.Unregister<IPrintingManager>(); + TangoIOC.Default.Unregister<IConnectivityProvider>(); TangoIOC.Default.Register<IDispatcherProvider, DefaultDispetcherProvider>(new DefaultDispetcherProvider(Application.Current.Dispatcher)); TangoIOC.Default.Register<INotificationProvider, DefaultNotificationProvider>(); @@ -68,6 +71,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register<IPPCExternalBridgeService, PPCExternalBridgeService>(); TangoIOC.Default.Register<IMachineSetupManager, MachineSetupManager>(); TangoIOC.Default.Register<IPrintingManager, DefaultPrintingManager>(); + TangoIOC.Default.Register<IConnectivityProvider, DefaultConnectivityProvider>(); //TangoIOC.Default.Register<TeamFoundationServiceExtendedClient>(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs index c5eaaf4af..141daf731 100644 --- a/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs +++ b/Software/Visual_Studio/SideChains/RealTimeGraphEx/RealTimeGraphExBase.cs @@ -1036,7 +1036,11 @@ namespace RealTimeGraphEx { while (!_requestTermination.WaitOne(0)) { - OnRenderGraph(); + try + { + OnRenderGraph(); + } + catch { } Thread.Sleep(_refreshRate); } diff --git a/Software/Visual_Studio/Tango.BL/Entities/Job.cs b/Software/Visual_Studio/Tango.BL/Entities/Job.cs index 346e6fd19..1482003a1 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Job.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Job.cs @@ -434,11 +434,8 @@ namespace Tango.BL.Entities /// <summary> /// 0 = Draft - /// 1 = PendingApproval - /// 2 = Ready - /// 3 = Approved - /// 4 = Disrupted - /// 5 = Completed + /// 1 = Completed + /// 2 = Disrupted /// </summary> [Column("STATUS")] diff --git a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs index 3c9271fff..c5d033dc4 100644 --- a/Software/Visual_Studio/Tango.BL/Entities/Machine.cs +++ b/Software/Visual_Studio/Tango.BL/Entities/Machine.cs @@ -159,6 +159,28 @@ namespace Tango.BL.Entities } + protected Boolean _enablewifi; + + /// <summary> + /// Gets or sets the machine enable wifi. + /// </summary> + + [Column("ENABLE_WIFI")] + + public Boolean EnableWifi + { + get + { + return _enablewifi; + } + + set + { + _enablewifi = value; RaisePropertyChanged(nameof(EnableWifi)); + } + + } + protected Boolean _enableexternalbridge; /// <summary> diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs index 615012c19..d1917e428 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/MACHINE.cs @@ -32,6 +32,7 @@ namespace Tango.DAL.Remote.DB public string ORGANIZATION_GUID { get; set; } public string MACHINE_VERSION_GUID { get; set; } public string CONFIGURATION_GUID { get; set; } + public bool ENABLE_WIFI { get; set; } public bool ENABLE_EXTERNAL_BRIDGE { get; set; } public string EXTERNAL_BRIDGE_PASSWORD { get; set; } public string DEFAULT_RML_GUID { get; set; } diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx index 8809518b5..ea08f9446 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx @@ -684,6 +684,7 @@ <Property Name="ORGANIZATION_GUID" Type="varchar" MaxLength="36" Nullable="false" /> <Property Name="MACHINE_VERSION_GUID" Type="varchar" MaxLength="36" Nullable="false" /> <Property Name="CONFIGURATION_GUID" Type="varchar" MaxLength="36" Nullable="false" /> + <Property Name="ENABLE_WIFI" Type="bit" Nullable="false" /> <Property Name="ENABLE_EXTERNAL_BRIDGE" Type="bit" Nullable="false" /> <Property Name="EXTERNAL_BRIDGE_PASSWORD" Type="varchar" MaxLength="100" /> <Property Name="DEFAULT_RML_GUID" Type="varchar" MaxLength="36" /> @@ -3735,6 +3736,7 @@ <Property Name="ORGANIZATION_GUID" Type="String" Nullable="false" MaxLength="36" FixedLength="false" Unicode="false" /> <Property Name="MACHINE_VERSION_GUID" Type="String" Nullable="false" MaxLength="36" FixedLength="false" Unicode="false" /> <Property Name="CONFIGURATION_GUID" Type="String" Nullable="false" MaxLength="36" FixedLength="false" Unicode="false" /> + <Property Name="ENABLE_WIFI" Type="Boolean" Nullable="false" /> <Property Name="ENABLE_EXTERNAL_BRIDGE" Type="Boolean" Nullable="false" /> <Property Name="EXTERNAL_BRIDGE_PASSWORD" Type="String" MaxLength="100" FixedLength="false" Unicode="false" /> <Property Name="DEFAULT_RML_GUID" Type="String" MaxLength="36" FixedLength="false" Unicode="false" /> @@ -5968,6 +5970,7 @@ <ScalarProperty Name="DEFAULT_RML_GUID" ColumnName="DEFAULT_RML_GUID" /> <ScalarProperty Name="EXTERNAL_BRIDGE_PASSWORD" ColumnName="EXTERNAL_BRIDGE_PASSWORD" /> <ScalarProperty Name="ENABLE_EXTERNAL_BRIDGE" ColumnName="ENABLE_EXTERNAL_BRIDGE" /> + <ScalarProperty Name="ENABLE_WIFI" ColumnName="ENABLE_WIFI" /> <ScalarProperty Name="CONFIGURATION_GUID" ColumnName="CONFIGURATION_GUID" /> <ScalarProperty Name="MACHINE_VERSION_GUID" ColumnName="MACHINE_VERSION_GUID" /> <ScalarProperty Name="ORGANIZATION_GUID" ColumnName="ORGANIZATION_GUID" /> diff --git a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram index 7683026fb..406d3e7fb 100644 --- a/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram +++ b/Software/Visual_Studio/Tango.DAL.Remote/DB/RemoteADO.edmx.diagram @@ -5,80 +5,80 @@ <!-- Diagram content (shape and connector positions) --> <edmx:Diagrams> <Diagram DiagramId="f9ae01d708754bbd997add25a4bacc79" Name="Diagram1"> - <EntityTypeShape EntityType="RemoteModel.ACTION_TYPES" Width="1.5" PointX="10.25" PointY="43.875" /> - <EntityTypeShape EntityType="RemoteModel.ADDRESS" Width="1.5" PointX="0.75" PointY="40.625" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_DISPLAY_PANEL_VERSIONS" Width="1.5" PointX="0.75" PointY="44.875" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_FIRMWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="50.75" /> - <EntityTypeShape EntityType="RemoteModel.APPLICATION_OS_VERSIONS" Width="1.5" PointX="0.75" PointY="47.75" /> - <EntityTypeShape EntityType="RemoteModel.BRUSH_STOPS" Width="1.5" PointX="15" PointY="20.25" /> - <EntityTypeShape EntityType="RemoteModel.CARTRIDGE_TYPES" Width="1.5" PointX="6" PointY="38.125" /> - <EntityTypeShape EntityType="RemoteModel.CAT" Width="1.5" PointX="7.5" PointY="20.5" /> - <EntityTypeShape EntityType="RemoteModel.CCT" Width="1.5" PointX="5.25" PointY="41.5" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS" Width="1.5" PointX="12.75" PointY="26.625" /> - <EntityTypeShape EntityType="RemoteModel.COLOR_SPACES" Width="1.5" PointX="3" PointY="7.875" /> - <EntityTypeShape EntityType="RemoteModel.CONFIGURATION" Width="1.5" PointX="3" PointY="50.125" /> - <EntityTypeShape EntityType="RemoteModel.CONTACT" Width="1.5" PointX="0.75" PointY="36.5" /> - <EntityTypeShape EntityType="RemoteModel.CUSTOMER" Width="1.5" PointX="8.25" PointY="32" /> - <EntityTypeShape EntityType="RemoteModel.DISPENSER_TYPES" Width="1.5" PointX="6" PointY="68.125" /> - <EntityTypeShape EntityType="RemoteModel.EMBEDDED_FIRMWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="57.875" /> - <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES" Width="1.5" PointX="5.25" PointY="58" /> - <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_ACTIONS" Width="1.5" PointX="12.5" PointY="53.875" /> - <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_CATEGORIES" Width="1.5" PointX="3" PointY="59" /> - <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_GROUPS" Width="1.5" PointX="3" PointY="62.125" /> - <EntityTypeShape EntityType="RemoteModel.FIBER_SHAPES" Width="1.5" PointX="0.75" PointY="13.5" /> - <EntityTypeShape EntityType="RemoteModel.FIBER_SYNTHS" Width="1.5" PointX="0.75" PointY="16.375" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWER_TYPES" Width="1.5" PointX="3.75" PointY="65.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWERS" Width="1.5" PointX="6" PointY="54" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSOR_TYPES" Width="1.5" PointX="5.75" PointY="76.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSORS" Width="1.5" PointX="8" PointY="58" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCER_TYPES" Width="1.5" PointX="5.75" PointY="80.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCERS" Width="1.5" PointX="8" PointY="62.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTOR_TYPES" Width="1.5" PointX="8.75" PointY="68.125" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTORS" Width="1.5" PointX="11" PointY="57.875" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROL_TYPES" Width="1.5" PointX="7.75" PointY="42.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROLS" Width="1.5" PointX="10" PointY="47.625" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSOR_TYPES" Width="1.5" PointX="0.75" PointY="61.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSORS" Width="1.5" PointX="3" PointY="46" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="53.625" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDER_TYPES" Width="1.5" PointX="6.75" PointY="72.25" /> - <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDERS" Width="1.5" PointX="9" PointY="54.125" /> - <EntityTypeShape EntityType="RemoteModel.HTML_PAGES" Width="1.5" PointX="3" PointY="55.625" /> - <EntityTypeShape EntityType="RemoteModel.IDS_PACK_FORMULAS" Width="1.5" PointX="6" PointY="34.875" /> - <EntityTypeShape EntityType="RemoteModel.IDS_PACKS" Width="1.5" PointX="8.25" PointY="35.5" /> - <EntityTypeShape EntityType="RemoteModel.JOB_RUNS" Width="1.5" PointX="12.75" PointY="19" /> - <EntityTypeShape EntityType="RemoteModel.JOB" Width="1.5" PointX="10.5" PointY="17.25" /> - <EntityTypeShape EntityType="RemoteModel.LINEAR_MASS_DENSITY_UNITS" Width="1.5" PointX="0.75" PointY="30.5" /> - <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES" Width="1.5" PointX="6" PointY="14.625" /> - <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES_RMLS" Width="1.5" PointX="8.25" PointY="16.75" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE_STUDIO_VERSIONS" Width="1.5" PointX="10.5" PointY="12.5" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE_VERSIONS" Width="1.5" PointX="3" PointY="4.375" /> - <EntityTypeShape EntityType="RemoteModel.MACHINE" Width="1.5" PointX="5.25" PointY="19" /> - <EntityTypeShape EntityType="RemoteModel.MACHINES_CONFIGURATIONS" Width="1.5" PointX="13.5" PointY="15.875" /> - <EntityTypeShape EntityType="RemoteModel.MACHINES_EVENTS" Width="1.5" PointX="7.5" PointY="24.375" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_COLORS" Width="1.5" PointX="0.75" PointY="24.25" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_CONDITIONS" Width="1.5" PointX="0.75" PointY="27.625" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_MATERIALS" Width="1.5" PointX="0.75" PointY="21" /> - <EntityTypeShape EntityType="RemoteModel.MEDIA_PURPOSES" Width="1.5" PointX="0.75" PointY="33.5" /> - <EntityTypeShape EntityType="RemoteModel.MID_TANK_TYPES" Width="1.5" PointX="6" PointY="31.75" /> - <EntityTypeShape EntityType="RemoteModel.ORGANIZATION" Width="1.5" PointX="3" PointY="38.75" /> - <EntityTypeShape EntityType="RemoteModel.PERMISSION" Width="1.5" PointX="11.25" PointY="0.75" /> - <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES" Width="1.5" PointX="7.5" PointY="45.5" /> - <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES_GROUPS" Width="1.5" PointX="5.25" PointY="47.125" /> - <EntityTypeShape EntityType="RemoteModel.RML" Width="1.5" PointX="3" PointY="18.125" /> - <EntityTypeShape EntityType="RemoteModel.ROLE" Width="1.5" PointX="11.25" PointY="4.625" /> - <EntityTypeShape EntityType="RemoteModel.ROLES_PERMISSIONS" Width="1.5" PointX="13.5" PointY="4.75" /> - <EntityTypeShape EntityType="RemoteModel.SEGMENT" Width="1.5" PointX="12.75" PointY="22.375" /> - <EntityTypeShape EntityType="RemoteModel.SPOOL_TYPES" Width="1.5" PointX="3" PointY="33.875" /> - <EntityTypeShape EntityType="RemoteModel.sysdiagram" Width="1.5" PointX="5.75" PointY="2.5" /> - <EntityTypeShape EntityType="RemoteModel.TANGO_VERSIONS" Width="1.5" PointX="10.5" PointY="8.25" /> - <EntityTypeShape EntityType="RemoteModel.TECH_CONTROLLERS" Width="1.5" PointX="5.75" PointY="5.5" /> - <EntityTypeShape EntityType="RemoteModel.TECH_DISPENSERS" Width="1.5" PointX="7.75" PointY="2.5" /> - <EntityTypeShape EntityType="RemoteModel.TECH_IOS" Width="1.5" PointX="7.75" PointY="5.5" /> - <EntityTypeShape EntityType="RemoteModel.TECH_MONITORS" Width="1.5" PointX="2.75" PointY="11.5" /> - <EntityTypeShape EntityType="RemoteModel.TECH_VALVES" Width="1.5" PointX="4.75" PointY="11.5" /> - <EntityTypeShape EntityType="RemoteModel.USER" Width="1.5" PointX="8.25" PointY="10.75" /> - <EntityTypeShape EntityType="RemoteModel.USERS_ROLES" Width="1.5" PointX="13.5" PointY="11.625" /> - <EntityTypeShape EntityType="RemoteModel.WINDING_METHODS" Width="1.5" PointX="8.25" PointY="28.875" /> + <EntityTypeShape EntityType="RemoteModel.ACTION_TYPES" Width="1.5" PointX="11.25" PointY="41.125" /> + <EntityTypeShape EntityType="RemoteModel.ADDRESS" Width="1.5" PointX="0.75" PointY="34.875" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_DISPLAY_PANEL_VERSIONS" Width="1.5" PointX="0.75" PointY="53.875" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_FIRMWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="43.75" /> + <EntityTypeShape EntityType="RemoteModel.APPLICATION_OS_VERSIONS" Width="1.5" PointX="0.75" PointY="56.75" /> + <EntityTypeShape EntityType="RemoteModel.BRUSH_STOPS" Width="1.5" PointX="15" PointY="15.125" /> + <EntityTypeShape EntityType="RemoteModel.CARTRIDGE_TYPES" Width="1.5" PointX="9" PointY="62.875" /> + <EntityTypeShape EntityType="RemoteModel.CAT" Width="1.5" PointX="7.5" PointY="18.625" /> + <EntityTypeShape EntityType="RemoteModel.CCT" Width="1.5" PointX="5.25" PointY="39.875" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_CATALOGS" Width="1.5" PointX="12.75" PointY="9.5" /> + <EntityTypeShape EntityType="RemoteModel.COLOR_SPACES" Width="1.5" PointX="3" PointY="7.25" /> + <EntityTypeShape EntityType="RemoteModel.CONFIGURATION" Width="1.5" PointX="3" PointY="49" /> + <EntityTypeShape EntityType="RemoteModel.CONTACT" Width="1.5" PointX="0.75" PointY="39.125" /> + <EntityTypeShape EntityType="RemoteModel.CUSTOMER" Width="1.5" PointX="8.25" PointY="30.25" /> + <EntityTypeShape EntityType="RemoteModel.DISPENSER_TYPES" Width="1.5" PointX="9" PointY="5.25" /> + <EntityTypeShape EntityType="RemoteModel.EMBEDDED_FIRMWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="50.875" /> + <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES" Width="1.5" PointX="11.25" PointY="36.25" /> + <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_ACTIONS" Width="1.5" PointX="13.5" PointY="37.125" /> + <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_CATEGORIES" Width="1.5" PointX="9" PointY="40.25" /> + <EntityTypeShape EntityType="RemoteModel.EVENT_TYPES_GROUPS" Width="1.5" PointX="9" PointY="33.875" /> + <EntityTypeShape EntityType="RemoteModel.FIBER_SHAPES" Width="1.5" PointX="0.75" PointY="19.125" /> + <EntityTypeShape EntityType="RemoteModel.FIBER_SYNTHS" Width="1.5" PointX="0.75" PointY="14.625" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWER_TYPES" Width="1.5" PointX="3.75" PointY="59.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BLOWERS" Width="1.5" PointX="6" PointY="51" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSOR_TYPES" Width="1.5" PointX="0.75" PointY="64.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_BREAK_SENSORS" Width="1.5" PointX="3" PointY="55" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCER_TYPES" Width="1.5" PointX="0.75" PointY="60.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_DANCERS" Width="1.5" PointX="3" PointY="43.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTOR_TYPES" Width="1.5" PointX="9.75" PointY="69.125" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_MOTORS" Width="1.5" PointX="12" PointY="51.875" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROL_TYPES" Width="1.5" PointX="7.75" PointY="59.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_PID_CONTROLS" Width="1.5" PointX="10" PointY="44.625" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSOR_TYPES" Width="1.5" PointX="3.75" PointY="63.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_SPEED_SENSORS" Width="1.5" PointX="6" PointY="55" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_VERSIONS" Width="1.5" PointX="0.75" PointY="46.625" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDER_TYPES" Width="1.5" PointX="6.75" PointY="63.25" /> + <EntityTypeShape EntityType="RemoteModel.HARDWARE_WINDERS" Width="1.5" PointX="9" PointY="51.125" /> + <EntityTypeShape EntityType="RemoteModel.HTML_PAGES" Width="1.5" PointX="9" PointY="37" /> + <EntityTypeShape EntityType="RemoteModel.IDS_PACK_FORMULAS" Width="1.5" PointX="9" PointY="54.625" /> + <EntityTypeShape EntityType="RemoteModel.IDS_PACKS" Width="1.5" PointX="11.25" PointY="31" /> + <EntityTypeShape EntityType="RemoteModel.JOB_RUNS" Width="1.5" PointX="12.75" PointY="20.75" /> + <EntityTypeShape EntityType="RemoteModel.JOB" Width="1.5" PointX="10.5" PointY="15.5" /> + <EntityTypeShape EntityType="RemoteModel.LINEAR_MASS_DENSITY_UNITS" Width="1.5" PointX="0.75" PointY="28.75" /> + <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES" Width="1.5" PointX="6" PointY="12.75" /> + <EntityTypeShape EntityType="RemoteModel.LIQUID_TYPES_RMLS" Width="1.5" PointX="8.25" PointY="15" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE_STUDIO_VERSIONS" Width="1.5" PointX="10.5" PointY="1.125" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE_VERSIONS" Width="1.5" PointX="3" PointY="25.25" /> + <EntityTypeShape EntityType="RemoteModel.MACHINE" Width="1.5" PointX="5.25" PointY="17" /> + <EntityTypeShape EntityType="RemoteModel.MACHINES_CONFIGURATIONS" Width="1.5" PointX="7.5" PointY="23.125" /> + <EntityTypeShape EntityType="RemoteModel.MACHINES_EVENTS" Width="1.5" PointX="13.5" PointY="24.625" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_COLORS" Width="1.5" PointX="0.75" PointY="22.5" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_CONDITIONS" Width="1.5" PointX="0.75" PointY="31.625" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_MATERIALS" Width="1.5" PointX="0.75" PointY="25.875" /> + <EntityTypeShape EntityType="RemoteModel.MEDIA_PURPOSES" Width="1.5" PointX="0.75" PointY="11.625" /> + <EntityTypeShape EntityType="RemoteModel.MID_TANK_TYPES" Width="1.5" PointX="9" PointY="65.875" /> + <EntityTypeShape EntityType="RemoteModel.ORGANIZATION" Width="1.5" PointX="3" PointY="37.125" /> + <EntityTypeShape EntityType="RemoteModel.PERMISSION" Width="1.5" PointX="9.25" PointY="77" /> + <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES" Width="1.5" PointX="7.5" PointY="44" /> + <EntityTypeShape EntityType="RemoteModel.PROCESS_PARAMETERS_TABLES_GROUPS" Width="1.5" PointX="5.25" PointY="45.5" /> + <EntityTypeShape EntityType="RemoteModel.RML" Width="1.5" PointX="3" PointY="16.25" /> + <EntityTypeShape EntityType="RemoteModel.ROLE" Width="1.5" PointX="9.25" PointY="72.875" /> + <EntityTypeShape EntityType="RemoteModel.ROLES_PERMISSIONS" Width="1.5" PointX="11.5" PointY="73" /> + <EntityTypeShape EntityType="RemoteModel.SEGMENT" Width="1.5" PointX="12.75" PointY="17.25" /> + <EntityTypeShape EntityType="RemoteModel.SPOOL_TYPES" Width="1.5" PointX="3" PointY="2.5" /> + <EntityTypeShape EntityType="RemoteModel.sysdiagram" Width="1.5" PointX="5.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.TANGO_VERSIONS" Width="1.5" PointX="10.5" PointY="11" /> + <EntityTypeShape EntityType="RemoteModel.TECH_CONTROLLERS" Width="1.5" PointX="5.75" PointY="3.75" /> + <EntityTypeShape EntityType="RemoteModel.TECH_DISPENSERS" Width="1.5" PointX="7.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.TECH_IOS" Width="1.5" PointX="2.75" PointY="11.75" /> + <EntityTypeShape EntityType="RemoteModel.TECH_MONITORS" Width="1.5" PointX="12.75" PointY="0.75" /> + <EntityTypeShape EntityType="RemoteModel.TECH_VALVES" Width="1.5" PointX="13.75" PointY="5.75" /> + <EntityTypeShape EntityType="RemoteModel.USER" Width="1.5" PointX="8.25" PointY="8.875" /> + <EntityTypeShape EntityType="RemoteModel.USERS_ROLES" Width="1.5" PointX="11.5" PointY="5.875" /> + <EntityTypeShape EntityType="RemoteModel.WINDING_METHODS" Width="1.5" PointX="8.25" PointY="27.125" /> <AssociationConnector Association="RemoteModel.FK_EVENTS_ACTIONS_ACTIONS" /> <AssociationConnector Association="RemoteModel.FK_ORGANIZATIONS_ADDRESSES" /> <AssociationConnector Association="RemoteModel.FK_USERS_ADDRESSES" /> diff --git a/Software/Visual_Studio/Tango.WiFi/AvailableWifiNetwork.cs b/Software/Visual_Studio/Tango.WiFi/AvailableWifiNetwork.cs deleted file mode 100644 index c9aeb0722..000000000 --- a/Software/Visual_Studio/Tango.WiFi/AvailableWifiNetwork.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.WiFi -{ - public class AvailableWifiNetwork : ExtendedObject - { - private Wifi _wifi; - - private bool _isConnected; - public bool IsConnected - { - get { return _isConnected; } - set { _isConnected = value; RaisePropertyChangedAuto(); } - } - - private String _name; - public String Name - { - get { return _name; } - set { _name = value; RaisePropertyChangedAuto(); } - } - - private double _signalStregth; - public double SignalStrength - { - get { return _signalStregth; } - set { _signalStregth = value; RaisePropertyChangedAuto(); } - } - - private bool _isSecure; - public bool IsSecure - { - get { return _isSecure; } - set { _isSecure = value; RaisePropertyChangedAuto(); } - } - - private bool _hasProfile; - public bool HasProfile - { - get { return _hasProfile; } - set { _hasProfile = value; RaisePropertyChangedAuto(); } - } - - private AccessPoint _accessPoint; - public AccessPoint AccessPoint - { - get { return _accessPoint; } - set { _accessPoint = value; RaisePropertyChangedAuto(); } - } - - public AvailableWifiNetwork(AccessPoint accessPoint, Wifi wifi) - { - _wifi = wifi; - AccessPoint = accessPoint; - } - - public NetworkAuthenticationRequest CreateAuthenticationRequest() - { - return new NetworkAuthenticationRequest(new AuthRequest(AccessPoint)); - } - - public Task<bool> Connect(NetworkAuthenticationRequest request) - { - return Task.Factory.StartNew<bool>(() => - { - return AccessPoint.Connect(request.AuthRequest, false); - }); - } - - public void Forget() - { - AccessPoint.DeleteProfile(); - HasProfile = false; - } - - public void Disconnect() - { - _wifi.Disconnect(); - IsConnected = false; - } - } -} diff --git a/Software/Visual_Studio/Tango.WiFi/Tango.WiFi.csproj b/Software/Visual_Studio/Tango.WiFi/Tango.WiFi.csproj index c7d345402..7e4d85621 100644 --- a/Software/Visual_Studio/Tango.WiFi/Tango.WiFi.csproj +++ b/Software/Visual_Studio/Tango.WiFi/Tango.WiFi.csproj @@ -62,12 +62,9 @@ <Link>GlobalVersionInfo.cs</Link> </Compile> <Compile Include="AccessPoint.cs" /> - <Compile Include="AvailableWifiNetwork.cs" /> <Compile Include="EapUserFactory.cs" /> <Compile Include="AuthRequest.cs" /> - <Compile Include="NetworkAuthenticationRequest.cs" /> <Compile Include="ProfileFactory.cs" /> - <Compile Include="WiFiManager.cs" /> <Compile Include="Win32\Helpers\WlanHelpers.cs" /> <Compile Include="Win32\Interop\Enums.cs" /> <Compile Include="Win32\Interop\Exceptions.cs" /> diff --git a/Software/Visual_Studio/Tango.WiFi/WiFiManager.cs b/Software/Visual_Studio/Tango.WiFi/WiFiManager.cs deleted file mode 100644 index 68f020ae0..000000000 --- a/Software/Visual_Studio/Tango.WiFi/WiFiManager.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Tango.Core; - -namespace Tango.WiFi -{ - public class WiFiManager : ExtendedObject - { - private Wifi _wifi; - private Thread _scanThread; - - private bool _enabled; - public bool Enabled - { - get { return _enabled; } - set - { - if (_enabled != value) - { - _enabled = value; - RaisePropertyChangedAuto(); - - if (_enabled) - { - Start(); - } - } - } - } - - public ObservableCollection<AvailableWifiNetwork> AvailableWifiNetworks { get; set; } - - public WiFiManager() - { - _wifi = new Wifi(); - AvailableWifiNetworks = new ObservableCollection<AvailableWifiNetwork>(); - AvailableWifiNetworks.EnableCrossThreadOperations(); - } - - public void Start() - { - Enabled = true; - _scanThread = new Thread(ScanThreadMethod); - _scanThread.IsBackground = true; - _scanThread.Start(); - } - - private void ScanThreadMethod() - { - while (_enabled) - { - var accessPoints = _wifi.GetAccessPoints().OrderByDescending(ap => ap.SignalStrength).ToList(); - - AvailableWifiNetworks.Where(x => !accessPoints.Exists(y => y.Name == x.Name)).ToList().ForEach(x => AvailableWifiNetworks.Remove(x)); - - foreach (AccessPoint ap in accessPoints) - { - var network = AvailableWifiNetworks.FirstOrDefault(x => x.Name == ap.Name); - - if (network == null) - { - network = new AvailableWifiNetwork(ap, _wifi); - AvailableWifiNetworks.Add(network); - } - - network.AccessPoint = ap; - network.Name = ap.Name; - network.IsConnected = ap.IsConnected; - network.SignalStrength = ap.SignalStrength; - network.IsSecure = ap.IsSecure; - network.HasProfile = ap.HasProfile; - } - - Thread.Sleep(5000); - } - } - - public void Stop() - { - Enabled = false; - _scanThread = null; - } - } -} |
