void DBChooserComplete(DBChooserResult[] results)
 {
     if (results != null && results.Length > 0) {
         var result = results [0];
         Console.WriteLine ("\n Link: {0} \n Name: {1} \n Icon: {2}", result.Link, result.Name, result.IconURL);
     } else {
         UIAlertView error = new UIAlertView ("Error", "No values", null, "OK", null);
         error.Show ();
     }
 }
        public void openDropboxChooser(DropboxChooserLinkType linkType, onDBChooserResult chooserResult)
        {
            this.chooserResult = chooserResult;
            var window = UIApplication.SharedApplication.KeyWindow;
            var vc     = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }
            DBChooserLinkType linkTypeIOs = DBChooserLinkType.Direct;

            if (linkType == DropboxChooserLinkType.Preview)
            {
                linkTypeIOs = DBChooserLinkType.Preview;
            }
            Dropins.Chooser.iOS.DBChooser.DefaultChooser.OpenChooser(linkTypeIOs, vc, new DBChooserCompletionHandler(
                                                                         (DBChooserResult[] results) =>
            {
                System.Diagnostics.Debug.WriteLine("Results . . . . . ");
                if (results != null)
                {
                    if (results.Length > 0)
                    {
                        DBChooserResult result0             = results[0];
                        Dictionary <string, Uri> thumbnails = new Dictionary <string, Uri>();
                        if (result0.Thumbnails != null)
                        {
                            foreach (NSObject curKey in result0.Thumbnails.Keys)
                            {
                                NSString strKey = (NSString)curKey;
                                thumbnails.Add((string)strKey, new Uri(((NSUrl)result0.Thumbnails[strKey]).Path));
                            }
                        }
                        string link = null;
                        if (result0.Link != null)
                        {
                            link = result0.Link.Path;
                        }
                        string icon = null;
                        if (result0.IconUrl != null)
                        {
                            icon = result0.IconUrl.Path;
                        }
                        DropboxChooserResult droboxChooserResult = new DropboxChooserResult(link, result0.Name, icon, result0.Size, thumbnails);
                        this.chooserResult(droboxChooserResult);
                    }
                }
            }
                                                                         ));
        }
예제 #3
0
        void DBChooserComplete(DBChooserResult[] results)
        {
            if (results != null && results.Length > 0) {
                var result = results [0];

                var metadata = root [1];
                metadata.Clear ();

                var values = new Element[] {
                    new StringElement("Name",result.Name),
                    new StringElement("Size in bytes: ",result.Size.ToString()),
                    new ImageStringElement("Icon", UIImage.LoadFromData(NSData.FromUrl(result.IconURL)))
                };

                foreach (var item in values) {
                    metadata.Add (item);
                }

                var linkSection = root [2];
                linkSection.Clear ();

                linkSection.Add (
                    new StringElement (result.Link.ToString (), delegate {
                    OpenLink (result.Link);
                }));

                foreach (var thumb in result.Thumbnails) {
                    string key = thumb.Key.ToString ();
                    string value = thumb.Value.ToString ();
                    linkSection.Add (new StringElement (key, delegate {
                        OpenLink (NSUrl.FromString (value));
                    }));
                }

            } else {
                UIAlertView error = new UIAlertView ("Error", "No values", null, "OK", null);
                error.Show ();
            }
        }