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 ();
        }
Ejemplo n.º 5
0
        void PostCallback(object sender, EventArgs a)
        {
            sendItem.Enabled = false;

            if (Picture == null){
                Post ();
                return;
            }

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

            var jpeg = Picture.AsJPEG ();
            Stream stream;
            unsafe { stream = new UnmanagedMemoryStream ((byte*) jpeg.Bytes, jpeg.Length); }

            ThreadPool.QueueUserWorkItem (delegate {
                TwitterAccount.CurrentAccount.UploadPicture (stream, PicUploadComplete);

                // This captures the variable and handle of jpeg, and then we clear it
                // to release it
                jpeg = null;
            });
        }
Ejemplo n.º 6
0
        void PostCallback(object sender, EventArgs a)
        {
            sendItem.Enabled = false;

            var pictureDict = composerView.PictureDict;
            if (pictureDict == null){
                Post ();
                return;
            }

            int level = Util.Defaults.IntForKey ("sizeCompression");

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

                // Save a copy of the original picture
                if (!composerView.FromLibrary){
                    img.SaveToPhotosAlbum (delegate {
                        // Ignore
                    });
                }

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

                if (size.Width > maxWidth || size.Height > maxWidth)
                    img = img.Scale (new SizeF (maxWidth, maxWidth*size.Height/size.Width));

                var jpeg = img.AsJPEG ();
                Stream stream;
                unsafe { stream = new UnmanagedMemoryStream ((byte*) jpeg.Bytes, jpeg.Length); }

                hud = new LoadingHUDView (Locale.GetText ("Uploading\nImage"), "");
                View.AddSubview (hud);
                hud.StartAnimating ();

                TwitterAccount.CurrentAccount.UploadPicture (stream, PicUploadComplete);
            } else {
                //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl;

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