示例#1
0
        partial void Button1_Activated() => this.PresentTextInputController(new[] { "Yes", "No", "Maybe" }, WKTextInputMode.Plain, delegate(NSArray results) {
            if (results?.Count > 0)
            {
                WKInterfaceController.OpenParentApplication(new NSDictionary("input", results.GetItem <NSObject>(0).ToString()), (replyInfo, error) =>
                {
                    if (error != null)
                    {
                        this.label1.SetText(error.ToString());
                        return;
                    }

                    var result = ((NSString)replyInfo["result"]).ToString();
                    this.label1.SetText(result);
                });
            }
        });
示例#2
0
		partial void ReplyWithTextInputController (NSObject obj)
		{
			// Using the WKTextInputMode enum, you can specify which aspects of the Text Input Controller are shown when presented.
			PresentTextInputController (new [] { "Yes", "No", "Maybe" }, WKTextInputMode.AllowAnimatedEmoji, delegate(NSArray results) {
				Console.WriteLine ("Text Input Results: {0}", results);

				if (results.GetItem<NSString> (0) != null) {
					// Sends a non-nil result to the parent iOS application.
					bool didOpenParent = WKInterfaceController.OpenParentApplication (new NSDictionary (new NSString ("TextInput"), results.GetItem<NSString> (0)), delegate(NSDictionary replyInfo, NSError error) {
						Console.WriteLine ("Reply Info: {0}", replyInfo);
						Console.WriteLine ("Error: {0}", error != null ? error.LocalizedDescription : "null");
					});

					Console.WriteLine ("Did open parent application? {0}", didOpenParent);
				}
			});
		}
示例#3
0
        void UpdateUserInterface()
        {
            WKInterfaceController.OpenParentApplication(new NSDictionary(), (replyInfo, error) =>
            {
                if (error != null)
                {
                    Console.WriteLine(error);
                    return;
                }

                var events = (NSArray)replyInfo["SessionTitle"];

                MyTable.SetNumberOfRows((nint)events.Count, "default");

                for (int i = 0; i < (int)events.Count; i++)
                {
                    var elementRow = (RowController)MyTable.GetRowController(i);
                    elementRow.MyLabel.SetText(events.GetItem <NSString>((nuint)i));
                }
            });
        }
示例#4
0
        void UpdateUserInterface(NSTimer t)
        {
            WKInterfaceController.OpenParentApplication(new NSDictionary(), (replyInfo, error) => {
                if (error != null)
                {
                    Console.WriteLine(error);
                    return;
                }

                var status    = (CLAuthorizationStatus)((NSNumber)replyInfo["status"]).UInt32Value;
                var longitude = ((NSNumber)replyInfo["lon"]).DoubleValue;
                var latitude  = ((NSNumber)replyInfo["lat"]).DoubleValue;

                Console.WriteLine("authorization status {0}", status);
                switch (status)
                {
                case CLAuthorizationStatus.AuthorizedAlways:
                    SetCooridinate(longitude, latitude);
                    HideWarning();
                    break;

                case CLAuthorizationStatus.NotDetermined:
                    SetNotAvailable();
                    ShowWarning("Launch the iOS app first");
                    break;

                case CLAuthorizationStatus.Denied:
                    SetNotAvailable();
                    ShowWarning("Enable Location Service on iPhone");
                    break;

                default:
                    throw new NotImplementedException();
                }
            });
        }