using System;
|
using CoreLocation;
|
using Foundation;
|
using Shared;
|
using Shared.SimpleControl;
|
using UIKit;
|
|
namespace ON.Ios
|
{
|
public partial class ViewController : ViewControllerBase
|
{
|
|
//CLLocationManager iPhoneLocationManager = null;
|
|
public override void ViewDidLoad ()
|
{
|
base.ViewDidLoad ();
|
//NSDictionary dd =
|
//IosBinding.JPUSHService.SetupWithOption (, "d3b090625a500d4483a21a2f", "HdlIos", false);
|
if (Application.CurrentHeight < 1200) {
|
Shared.Application.FontSize = 14;
|
} else {
|
Shared.Application.FontSize = 16;
|
}
|
Console.WriteLine (UserConfig.Instance.SetLanguage);
|
if (string.IsNullOrEmpty (UserConfig.Instance.SetLanguage)) {
|
if (NSLocale.PreferredLanguages [0].Contains ("zh-")) {
|
//if (NSLocale.PreferredLanguages [0].Contains (@"zh-") && NSLocale.PreferredLanguages [0].Contains (@"-CN")) {
|
Language.CurrentLanguage = "Chinese";
|
} else if (NSLocale.PreferredLanguages [0].Contains ("cs-")) {
|
//if (NSLocale.PreferredLanguages [0].Contains (@"zh-") && NSLocale.PreferredLanguages [0].Contains (@"-CN")) {
|
Language.CurrentLanguage = "Czech";
|
} else {
|
Language.CurrentLanguage = "English";
|
}
|
} else {
|
Language.CurrentLanguage = UserConfig.Instance.SetLanguage;
|
}
|
//UIApplication.SharedApplication.SetStatusBarHidden (true, true);
|
//Shared.Application.RootFrameLayout = View;
|
//iPhoneLocationManager = new CLLocationManager ();
|
|
//// you can also set the desired accuracy:您还可以设置所需的精度:
|
//iPhoneLocationManager.DesiredAccuracy = 100; // 1000 meters/1 kilometer
|
//// you can also use presets, which simply evalute to a double value:
|
////iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
|
|
//// handle the updated location method and update the UI
|
//if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
|
// iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
|
// CLLocation newLocation = e.Locations [e.Locations.Length - 1];
|
// //Console.WriteLine ("iOS 61 " + newLocation.Altitude.ToString () + " meters");
|
// //Console.WriteLine ("iOS 61 " + newLocation.Coordinate.Longitude.ToString () + "º");
|
// //Console.WriteLine ("iOS 61 " + newLocation.Coordinate.Latitude.ToString () + "º");
|
// //Console.WriteLine ("iOS 61 " + newLocation.Course.ToString () + "º");
|
// //Console.WriteLine ("iOS 61 " + newLocation.Speed.ToString () + " meters/s");
|
// UserConfig.Current.Longitude = newLocation.Coordinate.Longitude.ToString ();
|
// UserConfig.Current.Latitude = newLocation.Coordinate.Latitude.ToString ();
|
// //UserConfig.Current.SaveUserConfig ();
|
// };
|
//} else {
|
// // this won't be called on iOS 6 (deprecated)
|
// iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
|
// CLLocation newLocation = e.NewLocation;
|
// //Console.WriteLine ("iOS 6 "+newLocation.Altitude.ToString () + " meters");
|
// //Console.WriteLine ("iOS 6 "+newLocation.Coordinate.Longitude.ToString () + "º");
|
// //Console.WriteLine ("iOS 6 "+newLocation.Coordinate.Latitude.ToString () + "º");
|
// //Console.WriteLine ("iOS 6 "+newLocation.Course.ToString () + "º");
|
// //Console.WriteLine ("iOS 6 "+newLocation.Speed.ToString () + " meters/s");
|
// UserConfig.Current.Longitude = newLocation.Coordinate.Longitude.ToString ();
|
// UserConfig.Current.Latitude = newLocation.Coordinate.Latitude.ToString ();
|
// //UserConfig.Current.SaveUserConfig ();
|
// };
|
//}
|
|
////iOS 8 requires you to manually request authorization now - Note the Info.plist file has a new key called requestWhenInUseAuthorization added to.
|
//if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
|
//{
|
// iPhoneLocationManager.RequestWhenInUseAuthorization();
|
//}
|
|
//// handle the updated heading method and update the UI
|
//iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => {
|
// //Console.WriteLine ("MagneticHeading "+e.NewHeading.MagneticHeading.ToString () + "º");
|
// //Console.WriteLine ("TrueHeading "+e.NewHeading.TrueHeading.ToString () + "º");
|
//};
|
|
//// start updating our location, et. al.
|
//if (CLLocationManager.LocationServicesEnabled)
|
// iPhoneLocationManager.StartUpdatingLocation ();
|
//if (CLLocationManager.HeadingAvailable)
|
//iPhoneLocationManager.StartUpdatingHeading ();
|
MainPage.Show ();
|
|
//侦测网络变化
|
Reachability.ReachabilityChanged += UpdateStatus;
|
|
UITapGestureRecognizer oTapRecognizer = new UITapGestureRecognizer ();
|
oTapRecognizer.CancelsTouchesInView = false;
|
oTapRecognizer.AddTarget (
|
this,
|
new ObjCRuntime.Selector ("ViewTappedSelector:")
|
);
|
this.View.AddGestureRecognizer (oTapRecognizer);
|
}
|
public override UIStatusBarStyle PreferredStatusBarStyle ()
|
{
|
return UIStatusBarStyle.LightContent;
|
}
|
|
[Export ("ViewTappedSelector:")]
|
public void ViewTapped (UIGestureRecognizer sender)
|
{
|
//Txt控件名称.ResignFirstResponder();
|
UIView v = View.FindFirstResponder ();
|
if (v != null) {
|
v.ResignFirstResponder ();
|
}
|
}
|
|
public override void DidReceiveMemoryWarning ()
|
{
|
base.DidReceiveMemoryWarning ();
|
// Release any cached data, images, etc that aren't in use.
|
}
|
|
NetworkStatus internetStatus;
|
void UpdateStatus (object sender, EventArgs e)
|
{
|
internetStatus = Reachability.InternetConnectionStatus ();
|
Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)internetStatus);
|
if (internetStatus == NetworkStatus.NotReachable)//没有网络连接 0
|
{
|
} else if (internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork)//3,4G的网络连接 1
|
{
|
} else if (internetStatus == NetworkStatus.ReachableViaWiFiNetwork) { //wifi的网络连接 2
|
}
|
}
|
}
|
}
|