From 399138ca39af14e5632e0a89f03a3f74071d14ee Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 26 Aug 2013 18:16:49 +0200 Subject: [PATCH] add IsUniNetworkAvailable() --- CampusAppWP8/CampusAppWP8/App.xaml.cs | 4 +++ .../CampusAppWP8/Model/Setting/AppSettings.cs | 15 +++++++++++ .../Pages/Mensa/MensaPage.xaml.cs | 2 +- .../Resources/Constants.Designer.cs | 27 +++++++++++++++++++ .../CampusAppWP8/Resources/Constants.resx | 9 +++++++ .../CampusAppWP8/Utility/Utilities.cs | 26 +++++++++++++++--- 6 files changed, 79 insertions(+), 4 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index d6d91181..12dd2832 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -2,6 +2,7 @@ using CampusAppWP8.Resources; using CampusAppWP8.Utility; using Microsoft.Phone.Controls; +using Microsoft.Phone.Net.NetworkInformation; using Microsoft.Phone.Shell; using System; using System.Diagnostics; @@ -150,6 +151,9 @@ namespace CampusAppWP8 } this.UserSettingsLoaded(); + + Settings.AppSetting.UniNetwork = Utilities.IsUniNetworkAvailable(); + if (Settings.AppSetting.GeoWatchEnable) { Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPosition)); diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs index 5f9d0e92..f3df4c5d 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs @@ -61,5 +61,20 @@ namespace CampusAppWP8.Model.Setting App.SaveToAppState(Constants.AppSetting_DevMode, value); } } + + /// Gets or sets a value indicating whether the uni network. + /// true if uni network, false if not. + public bool UniNetwork + { + get + { + return App.LoadFromAppState(Constants.AppSetting_UniNet); + } + + set + { + App.SaveToAppState(Constants.AppSetting_UniNet, value); + } + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index caf02add..ffb6d246 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -185,7 +185,7 @@ namespace CampusAppWP8.Pages.Mensa /// private void InitializeFeed() { - if (Settings.AppSetting.GeoWatchEnable) + if (Settings.AppSetting.GeoWatchEnable && Settings.AppSetting.UniNetwork) { Thread thread = new Thread(new ThreadStart(this.DeterminCurrentCampusAndLoadFeed)); thread.Start(); diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 038352db..b0390c1f 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -87,6 +87,33 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die UniNet ähnelt. + /// + public static string AppSetting_UniNet { + get { + return ResourceManager.GetString("AppSetting_UniNet", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 802.1X ähnelt. + /// + public static string AppSetting_UniNetworkDesc { + get { + return ResourceManager.GetString("AppSetting_UniNetworkDesc", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die 802.1X ähnelt. + /// + public static string AppSetting_UniNetworkName { + get { + return ResourceManager.GetString("AppSetting_UniNetworkName", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index d80c68d3..f7928283 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -417,4 +417,13 @@ DevMode + + UniNet + + + 802.1X + + + 802.1X + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index f138e4e6..8cb72693 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -6,13 +6,13 @@ // 16.07.2013 //----------------------------------------------------------------------------- namespace CampusAppWP8.Utility -{ +{ using System; using System.Collections.Generic; using System.Device.Location; using System.Globalization; using System.Linq; - using System.Runtime.InteropServices.WindowsRuntime; + using System.Runtime.InteropServices.WindowsRuntime; using System.Threading; using System.Windows; using System.Windows.Controls; @@ -20,6 +20,7 @@ namespace CampusAppWP8.Utility using CampusAppWP8.Resources; using CampusAppWP8.Utility.NDEF; using Windows.Networking.Proximity; + using Microsoft.Phone.Net.NetworkInformation; /// /// Collection of utility functions. @@ -212,7 +213,7 @@ namespace CampusAppWP8.Utility { if (!Settings.AppSetting.GeoWatchEnable) { - return null; + return null; } GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); @@ -286,5 +287,24 @@ namespace CampusAppWP8.Utility } } } + + /// Query if the phon is in the uni network. Method compares only Networkname and Description! + /// Stubbfel, 26.08.2013. + /// true if uni networkavailable, false if not. + public static bool IsUniNetworkAvailable() + { + NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList(); + foreach (NetworkInterfaceInfo networkInterfaceInfo in networkInterfaceList) + { + if (networkInterfaceInfo.InterfaceType == NetworkInterfaceType.Wireless80211 + && networkInterfaceInfo.InterfaceSubtype == NetworkInterfaceSubType.WiFi + && networkInterfaceInfo.InterfaceName.Equals(Constants.AppSetting_UniNetworkName) + && networkInterfaceInfo.Description.Equals(Constants.AppSetting_UniNetworkDesc)) + { + return true; + } + } + return false; + } } } \ No newline at end of file