private static void SetMediaMetadata(string localId, NSDictionary meta, ref MediaFile media)
		{
			var exif = meta[ImageIO.CGImageProperties.ExifDictionary] as NSDictionary;
			var gps = meta[ImageIO.CGImageProperties.GPSDictionary] as NSDictionary;
			var dateString = exif.ValueForKey(ImageIO.CGImageProperties.ExifDateTimeOriginal).ToString();
			media.MediaTakenAt = DateTime.ParseExact(dateString, "yyyy:MM:dd HH:mm:ss", CultureInfo.InvariantCulture);
			int.TryParse(meta.ValueForKey(ImageIO.CGImageProperties.Orientation).ToString(), out media.Orientation);
			var obj = new NSObject();
			if (gps?.TryGetValue(ImageIO.CGImageProperties.GPSLatitude, out obj) ?? false)
			{
				media.Latitude = ((NSNumber)obj).FloatValue;
			}
			if (gps?.TryGetValue(ImageIO.CGImageProperties.GPSLatitudeRef, out obj) ?? false)
			{
				media.LatitudeRef = obj.ToString();
			}
			if (gps?.TryGetValue(ImageIO.CGImageProperties.GPSLongitude, out obj) ?? false)
			{
				media.Longitude = ((NSNumber)obj).FloatValue;
			}
			if (gps?.TryGetValue(ImageIO.CGImageProperties.GPSLongitudeRef, out obj) ?? false)
			{
				media.LongitudeRef = obj.ToString();
			}
			media.Id = localId;
		}
Esempio n. 2
0
        public override void SetObjectValue(NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, int row)
        {
            var proposedValue = theObject.ToString();

            if (proposedValue.Trim().Length > 0)
            {
                controller.gamerList[row].Gamertag    = theObject.ToString();
                controller.gamerList[row].DisplayName = theObject.ToString();
            }
        }
 //"outlineView:viewForTableColumn:item:"
 public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
 {
     if (SearchManager.IsGroupItem(item))
     {
         var cellView = (NSTableCellView)outlineView.MakeView("GroupItem", this);
         cellView.TextField.StringValue = item.ToString();
         return(cellView);
     }
     else
     {
         var cellView = (NSTableCellView)outlineView.MakeView("GroupItem", this);
         cellView.TextField.StringValue = item.ToString();
         return(cellView);
     }
 }
Esempio n. 4
0
        //"outlineView:viewForTableColumn:item:"
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            if (SearchManager.IsGroupItem(item))
            {
                var cellView = (NSTableCellView)outlineView.MakeView("GroupItem", this);
                cellView.TextField.StringValue = item.ToString();
                return(cellView);
            }
            else
            {
                NSTableCellView cellView  = (NSTableCellView)outlineView.MakeView("SearchItem", this);
                NSView []       viewList  = cellView.Subviews;
                NSTextField     titleTF   = (NSTextField)viewList [0];
                NSTextField     sectionTF = (NSTextField)viewList [1];
                NSTextField     numberTF  = (NSTextField)viewList [2];
                NSDictionary    value     = (NSDictionary)item;
                titleTF.StringValue = value.ObjectForKey(NSObject.FromObject("key2")).ToString();
//				titleTF.Cell.DrawsBackground = true;
//				titleTF.Cell.BackgroundColor = NSColor.Clear;
                titleTF.ToolTip       = value.ObjectForKey(NSObject.FromObject("key2")).ToString();
                sectionTF.StringValue = value.ObjectForKey(NSObject.FromObject("key3")).ToString();
//				sectionTF.Cell.DrawsBackground = true;
//				sectionTF.Cell.BackgroundColor = NSColor.Clear;
                sectionTF.ToolTip = value.ObjectForKey(NSObject.FromObject("key3")).ToString();
//				numberTF.Cell.DrawsBackground = true;
//				numberTF.Cell.BackgroundColor = NSColor.Clear;
                numberTF.StringValue = "";
                numberTF.ToolTip     = "";
                return(cellView);
            }
        }
        //========================================================================

        //========================================================================
        /// <summary>
        /// Writes out the key and value information to the console, useful for debugging,
        /// or understanding how the user preferences are stored.
        /// </summary>
        private static void WriteKeyAndValueToOutput(NSDictionary dict, NSObject key)
        {
            Console.Write(key.ToString() + ":");

            if (dict[key] is NSString)
            {
                Console.WriteLine(dict[key].ToString());
            }
            else
            {
                switch (dict[key].GetType().ToString())
                {
                case "MonoTouch.Foundation.NSNumber":
                    Console.WriteLine((dict[key] as NSNumber).FloatValue.ToString());
                    break;

                case "MonoTouch.Foundation.NSArray":
                    Console.WriteLine("");
                    NSArray items = dict[key] as NSArray;

                    for (uint j = 0; j < items.Count; j++)
                    {
                        Console.WriteLine("\t" + NSString.FromHandle(items.ValueAt(j)).ToString());
                    }
                    break;
                }
            }
        }
 public override void SetObjectValue(NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
 {
     try {
         if (Entries != null && !string.IsNullOrEmpty(editedVal.ToString()))
         {
             if (col.Identifier == "Value")
             {
                 string currKey = this.Entries.Keys.ElementAt((int)row);
                 if (currKey != "objectClass")
                 {
                     VMDirBagItem currVal = this.Entries [currKey];
                     this.Entries [currKey] = new VMDirBagItem {
                         Description = currVal.Description,
                         IsReadOnly  = currVal.IsReadOnly,
                         IsRequired  = currVal.IsRequired,
                         Value       = Utilities.StringToLdapValue((NSString)editedVal)
                     };
                     this.PendingMod.Add(currKey, (NSString)Utilities.LdapValueToString(this.Entries [currKey].Value));
                 }
             }
         }
     } catch (Exception e) {
         System.Diagnostics.Debug.WriteLine("Error in List Operation " + e.Message);
     }
 }
Esempio n. 7
0
        public static PushNotification PushNotificationFromUserInfo(NSDictionary pushNotification)
        {
            NSDictionary apnPayload    = Instance.nativeManager.GetApnPayload(pushNotification);
            bool         alertIsDict   = apnPayload["alert"] is NSDictionary;
            NSObject     messageObject = null;
            NSObject     titleObject   = null;

            if (alertIsDict)
            {
                titleObject   = (apnPayload["alert"] as NSDictionary)["title"];
                messageObject = (apnPayload["alert"] as NSDictionary)["body"];
            }
            else
            {
                messageObject = apnPayload["alert"];
            }
            NSError error             = null;
            string  pushPayloadString = new NSString(NSJsonSerialization.Serialize(pushNotification, 0, out error), NSStringEncoding.UTF8);

            return(new PushNotification
            {
                Message = messageObject != null?messageObject.ToString() : null,
                              Title = titleObject != null?titleObject.ToString() : null,
                                          CustomData = Instance.nativeManager.GetCustomPushData(pushNotification),
                                          Payload = pushPayloadString
            });
        }
Esempio n. 8
0
        public void DidReceiveUserInfo(WCSession session, NSDictionary <NSString, NSObject> userInfo)
        {
            var writer = new BarcodeWriter <UIImage>
            {
                Format  = BarcodeFormat.QR_CODE,
                Options = new EncodingOptions
                {
                    Height = 200,
                    Width  = 200,
                    Margin = 0
                },
                Renderer = new BarcodeRenderer()
            };

            var qrCodeUrl = new NSObject();

            userInfo.TryGetValue(new NSString("qrCode"), out qrCodeUrl);

            var img = writer.Write(qrCodeUrl.ToString());

            myImage.SetImage(img);
            myImage.SetRelativeWidth(0.98f, 0);
            myImage.SetRelativeHeight(0.98f, 0);

            var asdf = WKExtension.SharedExtension.Delegate as ExtensionDelegate;

            HealthStore.EndWorkoutSession(asdf.WorkoutSession);
        }
Esempio n. 9
0
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            var vc = segue.DestinationViewController as ARTCVideoChatViewController;

            vc?.SetRoomName(sender.ToString());
            base.PrepareForSegue(segue, sender);
        }
        public override void Request(FBRequest request, NSObject result)
        {
            NSDictionary dict;

            if (result is NSDictionary)
            {
                dict = result as NSDictionary;
            }
            else if (result is NSArray)
            {
                var arr = (NSArray)result;
                dict = new NSDictionary(arr.ValueAt(0));
            }
            else
            {
                throw new Exception("cannot handle result in FBRequestDelegate callback");
            }

            if (dict.ObjectForKey(new NSString("owner")) != null)
            {
                _vc.SetText("Photo upload Success");
            }
            else
            {
                NSObject name = dict.ObjectForKey(new NSString("name"));
                _vc.SetText(name.ToString());
            }
        }
Esempio n. 11
0
        static void ViewDidAppearCapture(IntPtr block, IntPtr self, bool animated)
        {
            var orig = (OriginalBooleanDelegate)Marshal.GetDelegateForFunctionPointer(original_viewDidAppear_impl, typeof(OriginalBooleanDelegate));

            orig(self, animated);

            NSObject obj      = Runtime.GetNSObject(self);
            string   pageName = GetPageName(obj.ToString());

            _lastViewName = pageName;

            Stopwatch stopwatch;

            _timers.TryGetValue(pageName, out stopwatch);
            long duration = 0;

            if (stopwatch != null)
            {
                stopwatch.Stop();
                duration = stopwatch.ElapsedMilliseconds;
                _timers.Remove(pageName);
            }

            if (IsValidPageName(pageName))
            {
                _raygunClient.SendPulseTimingEvent(RaygunPulseEventType.ViewLoaded, pageName, duration);
                //Console.WriteLine ("did appear " + obj.ToString() + " " + duration);
            }
        }
        private string parseFacebookUserIdFromSettings(ACAccount account)
        {
            SLRequest sl = SLRequest.Create(SLServiceKind.Facebook, SLRequestMethod.Get, new NSUrl("https://graph.facebook.com/me"), null);

            sl.Account = account;

            AutoResetEvent completedEvent = new AutoResetEvent(false);
            var            id             = string.Empty;

            sl.PerformRequest((data, response, error) =>
            {
                if (error == null)
                {
                    NSError parseError;
                    NSDictionary jsonDict = (NSDictionary)NSJsonSerialization.Deserialize(data, 0, out parseError);
                    if (jsonDict != null)
                    {
                        NSObject obj = jsonDict.ValueForKey(new NSString("id"));
                        id           = obj?.ToString();
                    }
                }

                completedEvent.Set();
            });

            completedEvent.WaitOne();
            return(id);
        }
Esempio n. 13
0
 /// <summary>
 /// Checks that ToString does not return null (not helpful for debugging) and that it does not crash.
 /// </summary>
 /// <param name="obj">NSObject instance to validate</param>
 protected virtual void CheckToString(NSObject obj)
 {
     if (obj.ToString() == null)
     {
         ReportError("{0} : ToString", instance_type_name);
     }
 }
        public override void Awake(NSObject context)
        {
            base.Awake(context);

            // Configure interface objects here.
            Console.WriteLine("{0} awake with context", this);

            var stations = Stations.All;

            if (context is NSString)
            {
                var parameter = context.ToString();
                var index     = parameter.IndexOf(",", StringComparison.InvariantCultureIgnoreCase);
                var fromId    = Convert.ToInt32(parameter.Substring(0, index));
                var toId      = Convert.ToInt32(parameter.Substring(index + 1));

                _from = stations.FirstOrDefault(f => f.Id == fromId);
                _to   = stations.FirstOrDefault(t => t.Id == toId);
            }

            if (_from == null)
            {
                _from = stations.First();
            }

            if (_to == null)
            {
                _to = stations.Last();
            }

            FromLabel.SetText(_from.Name);
            ToLabel.SetText(_to.Name);
        }
Esempio n. 15
0
        private void HandleAlphaFadeIn(NSNotification obj)
        {
            NSDictionary parameters = obj.UserInfo;

            NSObject objectFade          = parameters[NSObject.FromObject("fadeIn")];
            string   objectFadeParameter = objectFade.ToString();
            int      fadeNumber          = ConvertUtil.ConvertStringToInt(objectFadeParameter);

            NSObject objectView          = parameters[NSObject.FromObject("view")];
            string   objectViewParameter = objectView.ToString();
            int      view = ConvertUtil.ConvertStringToInt(objectViewParameter);

            nfloat value = 0.0f;

            if (fadeNumber == 1)
            {
                value = 1.0f;
            }

            InvokeOnMainThread(async delegate
            {
                if (value != lastAlpha || view != lastView)
                {
                    lastAlpha = value;
                    lastView  = view;

                    await UIView.AnimateAsync(0.5, () =>
                    {
                        this.View.Subviews[0].Alpha = value;
                    });
                }
            });
        }
        public override bool OpenUrl
        (
            UIApplication application,
            NSUrl url,
            string sourceApplication,
            NSObject annotation
        )
        {
            #if DEBUG
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("OpenURL Called");
            sb.Append("     url         = ").AppendLine(url.AbsoluteUrl.ToString());
            sb.Append("     application = ").AppendLine(sourceApplication);
            sb.Append("     annotation  = ").AppendLine(annotation?.ToString());
            System.Diagnostics.Debug.WriteLine(sb.ToString());
            #endif

            // Convert iOS NSUrl to C#/netxf/BCL System.Uri - common API
            Uri uri_netfx = new Uri(url.AbsoluteString);

            // load redirect_url Page
            AuthenticationState.Authenticator.OnPageLoading(uri_netfx);

            return(true);
        }
 public override void SetObjectValue(NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
 {
     try
     {
         if (data != null)
         {
             if (col.Identifier == "Value")
             {
                 string currKey = this.data[(int)row].Key;
                 if (currKey != "objectClass")
                 {
                     if (!string.IsNullOrEmpty(editedVal.ToString()))
                     {
                         this.data[(int)row] = new KeyValuePair <string, string>(currKey, (NSString)editedVal);
                         this.PendingMod.Add(new KeyValuePair <string, string>(currKey, this.data[(int)row].Value));
                     }
                     else
                     {
                         this.DeleteMod.Add(new KeyValuePair <string, string>(currKey, this.data[(int)row].Value));
                         this.data[(int)row] = new KeyValuePair <string, string>(currKey, (NSString)editedVal);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("Error in List Operation " + e.Message);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Opens the URL.
        ///
        ///
        /// </summary>
        /// <returns><c>true</c>, if URL was opened, <c>false</c> otherwise.</returns>
        /// <param name="app">App.</param>
        /// <param name="url">URL.</param>
        /// <param name="sourceApp">Source app.</param>
        /// <param name="annotation">Annotation.</param>
        /// <example>
        /// <code>
        /// <!--
        ///     Info.plist
        /// -->
        ///     <key>CFBundleURLTypes</key>
        ///    <array>
        ///        <dict>
        ///            <key>CFBundleURLName</key>
        ///            <string>com.example.store</string>
        ///            <key>CFBundleURLTypes</key>
        ///            <string>Viewer</string>
        ///            <key>CFBundleURLSchemes</key>
        ///            <array>
        ///                <string>xamarinauth</string>
        ///                <string>xamarin-auth</string>
        ///                <string>xamarin.auth</string>
        ///             </array>
        ///        </dict>
        ///    </array>
        /// </code>
        /// </example>
        //=================================================================
        // WalkThrough Step 4
        //      Intercepting/Catching/Detecting [redirect] url change
        //      App Linking / Deep linking - custom url schemes
        //
        public override bool OpenUrl
        (
            UIApplication application,
            NSUrl url,
            string sourceApplication,
            NSObject annotation
        )
        {
            #if DEBUG
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine("OpenURL Called");
            sb.Append("     url         = ").AppendLine(url.AbsoluteUrl.ToString());
            sb.Append("     application = ").AppendLine(sourceApplication);
            sb.Append("     annotation  = ").AppendLine(annotation?.ToString());
            System.Diagnostics.Debug.WriteLine(sb.ToString());
            #endif

            //=================================================================
            // Walthrough Step 4.1
            //      Intercepting redirect_url and Loading it

            // Convert iOS NSUrl to C#/netxf/BCL System.Uri - common API
            System.Uri uri_netfx = new System.Uri(url.AbsoluteString);

            WebRedirectAuthenticator wre = null;
            wre = (WebRedirectAuthenticator)
                  global::Xamarin.Auth.XamarinForms.XamarinIOS.
                  AuthenticatorPageRenderer.Authenticator;

            // load redirect_url Page
            wre?.OnPageLoading(uri_netfx);
            //=================================================================

            return(true);
        }
Esempio n. 19
0
 public override void SetValueForKey(NSObject value, NSString key)
 {
     if (key == "bindingText")
     {
         this.BindingText = value.ToString();
     }
 }
Esempio n. 20
0
        public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            switch (userActivity.ActivityType)
            {
            case "com.micjames.beerdrinkin.mybeers":
                break;

            case "com.micjames.beerdrinkin.wishlist":
                break;

            case "com.micjames.beerdrinkin.search":
                break;

            case "com.micjames.beerdrinkin.profile":
                break;

            case "com.micjames.beerdrinkin.beerdetails":
                var info = userActivity.UserInfo;
                if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
                {
                    var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
                    tabController.SelectedIndex = 2;

                    var beerItem = new BeerItem();

                    var id = new NSObject();
                    info.TryGetValue(new NSString("id"), out id);

                    var name = new NSObject();
                    info.TryGetValue(new NSString("name"), out name);

                    var description = new NSObject();
                    info.TryGetValue(new NSString("description"), out description);

                    var imageUrl = new NSObject();
                    info.TryGetValue(new NSString("imageUrl"), out imageUrl);

                    var breweryDbId = new NSObject();
                    info.TryGetValue(new NSString("breweryDbId"), out breweryDbId);

                    beerItem.Name        = name.ToString();
                    beerItem.Description = description.ToString();
                    beerItem.ImageMedium = imageUrl.ToString();
                    beerItem.BreweryDbId = breweryDbId.ToString();

                    if (!string.IsNullOrEmpty(beerItem.BreweryDbId))
                    {
                        var storyboard = UIStoryboard.FromName("Main", null);
                        var vc         = storyboard.InstantiateViewController("beerDescriptionTableView") as BeerDescriptionTableView;
                        vc.SetBeer(beerItem);
                        var navigationControler = tabController.SelectedViewController as UINavigationController;
                        navigationControler.PushViewController(vc, true);
                    }
                }
                break;
            }

            return(true);
        }
        //"outlineView:viewForTableColumn:item:"
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            string identifier = tableColumn == null? "IndexItem":tableColumn.Identifier;

            if (indexDataManager.IsGroupItem(item))
            {
                var cellView = (NSTableCellView)outlineView.MakeView(identifier, this);
                cellView.TextField.StringValue = item.ToString();
                return(cellView);
            }
            else
            {
                var cellView = (NSTableCellView)outlineView.MakeView(identifier, this);
                cellView.TextField.StringValue = item.ToString();
                return(cellView);
            }
        }
        public override void Awake(NSObject context)
        {
            base.Awake(context);

            JObject json = JObject.Parse(context.ToString());

            times = (JArray)json ["times"];
        }
Esempio n. 23
0
 private string NSObjectToString(NSObject value)
 {
     try{
         return(value.ToString());
     } catch {
         return("");
     }
 }
 public override void InsertText(NSObject insertString)
 {
     if (!((TextBoxBase)Host.Host).Multiline && insertString.ToString() == "\n")
     {
         return;
     }
     base.InsertText(insertString);
 }
		// Returns the description for a provided value, taking the characteristic's metadata and possible values into account.
		public static string DescriptionForValue(this HMCharacteristic self, NSObject value)
		{
			if (self.IsWriteOnly ())
				return "Write-Only Characteristic";

			var number = value as NSNumber;
			return number != null ? self.DescriptionForValue (number.Int32Value) : value.ToString ();
		}
Esempio n. 26
0
        void OnInsertText(NSObject theEvent)
        {
            var s = theEvent.ToString();

            if (s == " ")
            {
                owner.ToggleSelected();
            }
        }
Esempio n. 27
0
            public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
            {
                if (owner.OnCreateView != null)
                {
                    return(owner.OnCreateView(tableColumn, ((NSNodeItem)item).ModelNode));
                }
                var view = (NSTextField)outlineView.MakeView("defaultView", this);

                if (view == null)
                {
                    view = NSTextField.CreateLabel(item.ToString());
                }
                else
                {
                    view.StringValue = item.ToString();
                }
                return(view);
            }
Esempio n. 28
0
        void OnInsertText(NSObject theEvent)
        {
            var s = theEvent.ToString();

            if (s == " ")
            {
                owner.OnCheckItemShortcut();
            }
        }
Esempio n. 29
0
        void OnInsertText(NSObject theEvent)
        {
            var s = theEvent.ToString();

            if (s == "b" || s == "B")
            {
                owner.OnKeyEvent(Key.Bookmark);
            }
        }
Esempio n. 30
0
        public override void SetObjectValue(NSTableView tableView, NSObject theObject, NSTableColumn tableColumn, int row)
        {
            NSTableColumn[] cols = tableView.TableColumns();
            int             idx  = cols.ToList().FindIndex(t => t.HeaderCell.StringValue == tableColumn.HeaderCell.StringValue);

            if (idx == (int)TableLocation.Brightness && BrightnessCellEdited != null)
            {
                BrightnessCellEdited(row, theObject.ToString());
            }
        }
        public override void Awake(NSObject context)
        {
            base.Awake (context);
            // Configure interface objects here.
            if (context is NSString) {
                contextFromPreviousScreen = context.ToString ();
            }

            Console.WriteLine ("{0} awake with context", this);
        }
Esempio n. 32
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            NSObject ver = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"];

            LoadApplication(new App(new AuthPlatformSpecific(), ver.ToString(), new UriLauncher()));

            return(base.FinishedLaunching(app, options));
        }
        public override void SetObjectValue (NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
        {
            try {
                if (Entries != null && !string.IsNullOrEmpty (editedVal.ToString ())) {
                    if (col.Identifier == "Value") {
                        string currKey = this.Entries.Keys.ElementAt ((int)row);
                        if (currKey != "objectClass") {
                            VMDirBagItem currVal = this.Entries [currKey];
                            this.Entries [currKey] = new VMDirBagItem {
                                Description = currVal.Description,
                                IsReadOnly = currVal.IsReadOnly,
                                IsRequired = currVal.IsRequired,
                                Value = Utilities.StringToLdapValue ((NSString)editedVal)
                            };
                            this.PendingMod.Add (currKey, (NSString)Utilities.LdapValueToString (this.Entries [currKey].Value));
                        }
                    }
                }
            } catch (Exception e) {
                System.Diagnostics.Debug.WriteLine ("Error in List Operation " + e.Message);
            }

        }
Esempio n. 34
0
        //========================================================================
        //========================================================================
        /// <summary>
        /// Writes out the key and value information to the console, useful for debugging,
        /// or understanding how the user preferences are stored.
        /// </summary>
        private static void WriteKeyAndValueToOutput(NSDictionary dict, NSObject key)
        {
            Console.Write (key.ToString () + ":");

            if (dict[key] is NSString)
            {
                Console.WriteLine (dict[key].ToString ());
            }
            else
            {
                switch (dict[key].GetType ().ToString ())
                {
                    case "MonoTouch.Foundation.NSNumber":
                        Console.WriteLine ((dict[key] as NSNumber).FloatValue.ToString ());
                        break;
                    case "MonoTouch.Foundation.NSArray":
                        Console.WriteLine ("");
                        NSArray items = dict[key] as NSArray;

                        for (uint j = 0; j < items.Count; j++)
                        {
                            Console.WriteLine ("\t" + NSString.FromHandle (items.ValueAt (j)).ToString ());
                        }
                        break;
                }

            }
        }
		public override void InsertText (NSObject insertString)
		{
			if (!((TextBoxBase)Host.Host).Multiline && insertString.ToString () == "\n")
				return ;
			base.InsertText (insertString);
		}
 public override void SetValueForKey(NSObject value, NSString key)
 {
     if (key == "bindingText")
         BindingText = value.ToString();
 }
		/// <summary>
		/// Converts to an object.
		/// </summary>
		/// <returns>The object.</returns>
		/// <param name="nsO">Ns o.</param>
		/// <param name="targetType">Target type.</param>
		public static Object ToObject (NSObject nsO, Type targetType)
		{
			if (nsO is NSString) {
				return nsO.ToString ();
			}

			if (nsO is NSDate) {
				var nsDate = (NSDate)nsO;
				return DateTime.SpecifyKind ((DateTime)nsDate, DateTimeKind.Unspecified);
			}

			if (nsO is NSDecimalNumber) {
				return decimal.Parse (nsO.ToString (), CultureInfo.InvariantCulture);
			}

			if (nsO is NSNumber) {
				var x = (NSNumber)nsO;

				switch (Type.GetTypeCode (targetType)) {
				case TypeCode.Boolean:
					return x.BoolValue;
				case TypeCode.Char:
					return Convert.ToChar (x.ByteValue);
				case TypeCode.SByte:
					return x.SByteValue;
				case TypeCode.Byte:
					return x.ByteValue;
				case TypeCode.Int16:
					return x.Int16Value;
				case TypeCode.UInt16:
					return x.UInt16Value;
				case TypeCode.Int32:
					return x.Int32Value;
				case TypeCode.UInt32:
					return x.UInt32Value;
				case TypeCode.Int64:
					return x.Int64Value;
				case TypeCode.UInt64:
					return x.UInt64Value;
				case TypeCode.Single:
					return x.FloatValue;
				case TypeCode.Double:
					return x.DoubleValue;
				}
			}

			if (nsO is NSValue) {
				var v = (NSValue)nsO;

				if (targetType == typeof(IntPtr)) {
					return v.PointerValue;
				}

				if (targetType == typeof(CGSize)) {
					return v.SizeFValue;
				}

				if (targetType == typeof(CGRect)) {
					return v.RectangleFValue;
				}

				if (targetType == typeof(CGPoint)) {
					return v.PointFValue;
				}           
			}

			return nsO;
		}
Esempio n. 38
0
        public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            switch (userActivity.ActivityType) 
            {
				case "com.micjames.beerdrinkin.mybeers":
                    break;
				case "com.micjames.beerdrinkin.wishlist":
                break;
				case "com.micjames.beerdrinkin.search":
                break;
				case "com.micjames.beerdrinkin.profile":
                break;
				case "com.micjames.beerdrinkin.beerdetails":
                    var info = userActivity.UserInfo;
                if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController) 
                {
					var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
					tabController.SelectedIndex = 2;

						var beerItem = new BeerItem();

						var id = new NSObject();
						info.TryGetValue(new NSString("id"), out id);

						var name = new NSObject();
						info.TryGetValue(new NSString("name"), out name);

						var description = new NSObject();
						info.TryGetValue(new NSString("description"), out description);

						var imageUrl = new NSObject();
						info.TryGetValue(new NSString("imageUrl"), out imageUrl);

						var breweryDbId = new NSObject();
						info.TryGetValue(new NSString("breweryDbId"), out breweryDbId);

						beerItem.Name = name.ToString();
						beerItem.Description = description.ToString();
						beerItem.ImageMedium = imageUrl.ToString();
						beerItem.BreweryDbId = breweryDbId.ToString();

						if (!string.IsNullOrEmpty(beerItem.BreweryDbId))
						{
							var storyboard = UIStoryboard.FromName("Main", null);
							var vc = storyboard.InstantiateViewController ("beerDescriptionTableView") as BeerDescriptionTableView;
							vc.SetBeer (beerItem);
							var navigationControler = tabController.SelectedViewController as UINavigationController;
							navigationControler.PushViewController (vc, true);
						}
                }
                break;
            }

            return true;
        }
        public override void SetObjectValue (NSTableView tableView, NSObject editedVal, NSTableColumn col, nint row)
        {
            try {
                if (data != null && !string.IsNullOrEmpty (editedVal.ToString ())) {
                    if (col.Identifier == "Value") {
                        string currKey = this.data [(int)row].Key;
                        if (currKey != "objectClass") {
                            this.data [(int)row] = new KeyValuePair<string, string> (currKey, (NSString)editedVal);
                            this.PendingMod.Add (currKey, this.data [(int)row].Value);
                        }
                    }
                }
            } catch (Exception e) {
                System.Diagnostics.Debug.WriteLine ("Error in List Operation " + e.Message);
            }

        }