From 94ce3f1c6e0b3fe10095c5b47a4d33f3a86c787c Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 26 Aug 2013 18:35:18 +0200 Subject: [PATCH 1/3] add IsWifiAvailable --- .../CampusAppWP8/Model/Setting/AppSettings.cs | 15 +++++++++++++ .../Resources/Constants.Designer.cs | 9 ++++++++ .../CampusAppWP8/Resources/Constants.resx | 3 +++ .../CampusAppWP8/Utility/Utilities.cs | 22 +++++++++++++++---- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs index f3df4c5d..29c582d4 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs @@ -76,5 +76,20 @@ namespace CampusAppWP8.Model.Setting App.SaveToAppState(Constants.AppSetting_UniNet, value); } } + + /// Gets or sets a value indicating whether this object is WiFi enable. + /// true if WiFi enable, false if not. + public bool WifiEnable + { + get + { + return App.LoadFromAppState(Constants.AppSetting_WifiEnable); + } + + set + { + App.SaveToAppState(Constants.AppSetting_WifiEnable, value); + } + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index b0390c1f..00bcf801 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -114,6 +114,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die WifiEnable ähnelt. + /// + public static string AppSetting_WifiEnable { + get { + return ResourceManager.GetString("AppSetting_WifiEnable", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index f7928283..fa445bbf 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -426,4 +426,7 @@ 802.1X + + WifiEnable + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index 8cb72693..37692a9d 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -12,14 +12,11 @@ namespace CampusAppWP8.Utility using System.Device.Location; using System.Globalization; using System.Linq; - using System.Runtime.InteropServices.WindowsRuntime; using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using CampusAppWP8.Resources; - using CampusAppWP8.Utility.NDEF; - using Windows.Networking.Proximity; using Microsoft.Phone.Net.NetworkInformation; /// @@ -288,7 +285,7 @@ namespace CampusAppWP8.Utility } } - /// Query if the phon is in the uni network. Method compares only Networkname and Description! + /// Query if the phone 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() @@ -306,5 +303,22 @@ namespace CampusAppWP8.Utility } return false; } + + /// Queries if a wifik is available. + /// Stubbfel, 26.08.2013. + /// true if a wifik is available, false if not. + public static bool IsWifiAvailable() + { + NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList(); + foreach (NetworkInterfaceInfo networkInterfaceInfo in networkInterfaceList) + { + if (networkInterfaceInfo.InterfaceType == NetworkInterfaceType.Wireless80211 + && networkInterfaceInfo.InterfaceSubtype == NetworkInterfaceSubType.WiFi) + { + return true; + } + } + return false; + } } } \ No newline at end of file From 870b5314ab7b3e5296678d485c8f936920e41e86 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 27 Aug 2013 10:13:59 +0200 Subject: [PATCH 2/3] add onlywifi option --- CampusAppWP8/CampusAppWP8/App.xaml.cs | 10 +++++++++- .../CampusAppWP8/Model/Setting/AppSettings.cs | 15 +++++++++++++++ .../Pages/Setting/AppSettingPage.xaml | 6 +++++- .../Pages/Setting/AppSettingPage.xaml.cs | 2 ++ .../Resources/AppResources.Designer.cs | 9 +++++++++ .../CampusAppWP8/Resources/AppResources.resx | 3 +++ .../CampusAppWP8/Resources/Constants.Designer.cs | 9 +++++++++ .../CampusAppWP8/Resources/Constants.resx | 3 +++ CampusAppWP8/CampusAppWP8/Utility/Utilities.cs | 6 ++++-- 9 files changed, 59 insertions(+), 4 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 12dd2832..55c47531 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -152,7 +152,15 @@ namespace CampusAppWP8 this.UserSettingsLoaded(); - Settings.AppSetting.UniNetwork = Utilities.IsUniNetworkAvailable(); + Settings.AppSetting.UniNetwork = Utilities.IsUniNetworkAvailable(); + if (!Settings.AppSetting.UniNetwork) + { + Settings.AppSetting.WifiEnable = Utilities.IsWifiAvailable(); + } + else + { + Settings.AppSetting.WifiEnable = true; + } if (Settings.AppSetting.GeoWatchEnable) { diff --git a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs index 29c582d4..65da2561 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Setting/AppSettings.cs @@ -91,5 +91,20 @@ namespace CampusAppWP8.Model.Setting App.SaveToAppState(Constants.AppSetting_WifiEnable, value); } } + + /// Gets or sets a value indicating whether the only WiFi. + /// true if only wifi, false if not. + public bool OnlyWifi + { + get + { + return App.LoadFromAppState(Constants.AppSetting_OnlyWifi); + } + + set + { + App.SaveToAppState(Constants.AppSetting_OnlyWifi, value); + } + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml index 970f9b5d..82e30fd7 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml @@ -30,12 +30,16 @@ + - + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml.cs index a7d851b7..a3406e04 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Setting/AppSettingPage.xaml.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Pages.Setting { this.InitializeComponent(); GeoWatchToggle.IsChecked = Settings.AppSetting.GeoWatchEnable; + OnlyWiFiToggle.IsChecked = Settings.AppSetting.OnlyWifi; } /// @@ -33,6 +34,7 @@ namespace CampusAppWP8.Pages.Setting if (NavigationMode.Back == e.NavigationMode) { Settings.AppSetting.GeoWatchEnable = GeoWatchToggle.IsChecked.Value; + Settings.AppSetting.OnlyWifi = OnlyWiFiToggle.IsChecked.Value; } } } diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 7b79160f..9d229538 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -771,6 +771,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Nur mit Wlan laden ähnelt. + /// + public static string Setting_AppOnlyWifi { + get { + return ResourceManager.GetString("Setting_AppOnlyWifi", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Mitarbeiter ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index db84d97c..0f2c1050 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -416,4 +416,7 @@ vorlesen + + Nur mit Wlan laden + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index 00bcf801..e8d7a953 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -87,6 +87,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die OnlyWifi ähnelt. + /// + public static string AppSetting_OnlyWifi { + get { + return ResourceManager.GetString("AppSetting_OnlyWifi", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die UniNet ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index fa445bbf..00beecb5 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -429,4 +429,7 @@ WifiEnable + + OnlyWifi + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index 37692a9d..8cb44876 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -296,7 +296,8 @@ namespace CampusAppWP8.Utility if (networkInterfaceInfo.InterfaceType == NetworkInterfaceType.Wireless80211 && networkInterfaceInfo.InterfaceSubtype == NetworkInterfaceSubType.WiFi && networkInterfaceInfo.InterfaceName.Equals(Constants.AppSetting_UniNetworkName) - && networkInterfaceInfo.Description.Equals(Constants.AppSetting_UniNetworkDesc)) + && networkInterfaceInfo.Description.Equals(Constants.AppSetting_UniNetworkDesc) + && networkInterfaceInfo.InterfaceState == ConnectState.Connected) { return true; } @@ -313,7 +314,8 @@ namespace CampusAppWP8.Utility foreach (NetworkInterfaceInfo networkInterfaceInfo in networkInterfaceList) { if (networkInterfaceInfo.InterfaceType == NetworkInterfaceType.Wireless80211 - && networkInterfaceInfo.InterfaceSubtype == NetworkInterfaceSubType.WiFi) + && networkInterfaceInfo.InterfaceSubtype == NetworkInterfaceSubType.WiFi + && networkInterfaceInfo.InterfaceState == ConnectState.Connected) { return true; } From c1eadc24527b119e89a19b8d3a657118bee665fe Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 27 Aug 2013 11:23:07 +0200 Subject: [PATCH 3/3] add getLoadmodus --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 3 +++ .../CampusAppWP8/Feed/Link/ClubLinkFeed.cs | 2 +- .../CampusAppWP8/Feed/Link/CommonLinkFeed.cs | 2 +- .../CampusAppWP8/Feed/Mensa/MensaFeed.cs | 2 +- .../Feed/StudentCouncil/StudentCouncilFeed.cs | 2 +- .../Departments/DepartmentIndexPage.xaml.cs | 4 +++- .../Pages/Events/EventIndexPage.xaml.cs | 18 +++++++++++++++++- .../Pages/Lecture/LecturePage.xaml.cs | 1 + .../CampusAppWP8/Pages/Links/LinkPage.xaml.cs | 5 +++-- .../CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs | 3 ++- .../Pages/News/NewsIndexPage.xaml.cs | 17 ++++++++++++++++- .../Openinghours/OpeninghoursPage.xaml.cs | 3 ++- .../StudentCouncil/StudentCouncilPage.xaml.cs | 3 ++- CampusAppWP8/CampusAppWP8/Utility/Utilities.cs | 16 ++++++++++++++++ 14 files changed, 69 insertions(+), 12 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 45ea5c51..b86cead6 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -483,6 +483,9 @@ + + +