Ejemplo n.º 1
0
        // Need HUD display here
        void ShrinkUrls(string [] words)
        {
            var hud = new LoadingHUDView(Locale.GetText("Shrinking"));

            this.AddSubview(hud);
            hud.StartAnimating();

            var wc = new WebClient();

            for (int i = 0; i < words.Length; i++)
            {
                if (!words [i].StartsWith("http://"))
                {
                    continue;
                }

                try {
                    words [i] = wc.DownloadString(new Uri("http://is.gd/api.php?longurl=" + HttpUtility.UrlEncode(words [i])));
                } catch {
                }
            }
            hud.StopAnimating();
            hud.RemoveFromSuperview();
            hud = null;
        }
Ejemplo n.º 2
0
        void PictureSelected(NSDictionary pictureDict)
        {
            int level = Util.Defaults.IntForKey("sizeCompression");

            if ((pictureDict [UIImagePickerController.MediaType] as NSString) == "public.image")
            {
                Picture = pictureDict [UIImagePickerController.EditedImage] as UIImage;
                if (Picture == null)
                {
                    Picture = pictureDict [UIImagePickerController.OriginalImage] as UIImage;
                }

                // Save a copy of the original picture
                if (!FromLibrary)
                {
                    Picture.SaveToPhotosAlbum(delegate {
                        // ignore errors
                    });
                }

                var   size = Picture.Size;
                float maxWidth;
                switch (level)
                {
                case 0:
                    maxWidth = 640;
                    break;

                case 1:
                    maxWidth = 1024;
                    break;

                default:
                    maxWidth = size.Width;
                    break;
                }

                var hud = new LoadingHUDView(Locale.GetText("Image"), Locale.GetText("Compressing"));
                View.AddSubview(hud);
                hud.StartAnimating();

                // Show the UI, and on a callback, do the scaling, so the user gets an animation
                NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0), delegate {
                    if (size.Width > maxWidth || size.Height > maxWidth)
                    {
                        Picture = Scale(Picture, new SizeF(maxWidth, maxWidth * size.Height / size.Width));
                    }
                    hud.StopAnimating();
                    hud.RemoveFromSuperview();
                    hud = null;
                });
            }
            else
            {
                //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl;

                // Future use, when we find a video host that does not require your Twitter login/password
            }

            pictureDict.Dispose();
        }
Ejemplo n.º 3
0
        // Need HUD display here
        void ShrinkUrls(string [] words)
        {
            var hud = new LoadingHUDView (Locale.GetText ("Shrinking"));
            this.AddSubview (hud);
            hud.StartAnimating ();

            var wc = new WebClient ();
            for (int i = 0; i < words.Length; i++){
                if (!words [i].StartsWith ("http://"))
                    continue;

                try {
                    words [i] = wc.DownloadString (new Uri ("http://is.gd/api.php?longurl=" + HttpUtility.UrlEncode (words [i])));
                } catch {
                }
            }
            hud.StopAnimating ();
            hud.RemoveFromSuperview ();
            hud = null;
        }
Ejemplo n.º 4
0
        void PictureSelected(NSDictionary pictureDict)
        {
            int level = Util.Defaults.IntForKey ("sizeCompression");

            if ((pictureDict [UIImagePickerController.MediaType] as NSString) == "public.image"){
                Picture = pictureDict [UIImagePickerController.EditedImage] as UIImage;
                if (Picture == null)
                    Picture = pictureDict [UIImagePickerController.OriginalImage] as UIImage;

                // Save a copy of the original picture
                if (!FromLibrary){
                    Picture.SaveToPhotosAlbum (delegate {
                        // ignore errors
                    });
                }

                var size = Picture.Size;
                float maxWidth;
                switch (level){
                case 0:
                    maxWidth = 640;
                    break;
                case 1:
                    maxWidth = 1024;
                    break;
                default:
                    maxWidth = size.Width;
                    break;
                }

                var hud = new LoadingHUDView (Locale.GetText ("Image"), Locale.GetText ("Compressing"));
                View.AddSubview (hud);
                hud.StartAnimating ();

                // Show the UI, and on a callback, do the scaling, so the user gets an animation
                NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0), delegate {
                    if (size.Width > maxWidth || size.Height > maxWidth)
                        Picture = Scale (Picture, new SizeF (maxWidth, maxWidth*size.Height/size.Width));
                    hud.StopAnimating ();
                    hud.RemoveFromSuperview ();
                    hud = null;
                });
            } else {
                //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl;

                // Future use, when we find a video host that does not require your Twitter login/password
            }

            pictureDict.Dispose ();
        }