JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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
            }
        }
    }
}