示例#1
0
        void PostCallback(object sender, EventArgs a)
        {
            sendItem.Enabled = false;

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

            var    jpeg = Picture.AsJPEG();
            Stream stream;

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

            progressHud = new ProgressHud(Locale.GetText("Uploading Image"), Locale.GetText("Stop"));
            var uploader = TwitterAccount.CurrentAccount.UploadPicture(stream, PicUploadComplete, progressHud);

            progressHud.ButtonPressed += delegate {
                uploader.Cancel();
                DestroyProgressHud();
            };
            View.AddSubview(progressHud);
            ThreadPool.QueueUserWorkItem(delegate {
                uploader.Upload();

                // This captures the variable and handle of jpeg, and then we clear it
                // to release it
                jpeg = null;
            });
        }
示例#2
0
 void RunDebugUi2()
 {
     var b = new ProgressHud ("Uploading image ", "Stop");
     b.Progress = .5f;
     window.BringSubviewToFront (b);
     window.AddSubview (b);
 }
示例#3
0
                void Save()
                {
                    userElement.FetchValue();
                    passwordElement.FetchValue();

                    hud = new ProgressHud(Locale.GetText("Authenticating"), Locale.GetText("Cancel"));
                    hud.ButtonPressed += delegate { DestroyHud(); };
                    dvc.View.AddSubview(hud);

                    // Send an incomplete request with login/password, if this returns 403, we got the wrong password
                    ThreadPool.QueueUserWorkItem((x) => {
                        bool ok = false;
                        try {
                            ok = ValidateCredentials();
                        } catch (Exception e) {
                            Util.ReportError(this, e, Locale.GetText("While validating credentials"));
                        }
                        BeginInvokeOnMainThread(delegate {
                            DestroyHud();
                            if (ok)
                            {
                                Close(true);
                            }
                        });
                    });
                }
示例#4
0
        void RunDebugUi2()
        {
            var b = new ProgressHud("Uploading image ", "Stop");

            b.Progress = .5f;
            window.BringSubviewToFront(b);
            window.AddSubview(b);
        }
示例#5
0
 public Uploader UploadPicture(Stream source, Action <string> completed, ProgressHud progressHud)
 {
     return(new Uploader(this)
     {
         SourceStream = source,
         UploadCompletedCallback = completed,
         ProgressHudView = progressHud
     });
 }
示例#6
0
 void DestroyProgressHud()
 {
     progressHud.RemoveFromSuperview();
     progressHud = null;
 }
示例#7
0
 void DestroyHud()
 {
     hud.RemoveFromSuperview();
     hud = null;
 }
示例#8
0
 public Uploader UploadPicture(Stream source, Action<string> completed, ProgressHud progressHud)
 {
     return new Uploader (this) {
         SourceStream = source,
         UploadCompletedCallback = completed,
         ProgressHudView = progressHud
     };
 }
示例#9
0
                void Save()
                {
                    userElement.FetchValue ();
                    passwordElement.FetchValue ();

                    hud = new ProgressHud (Locale.GetText ("Authenticating"), Locale.GetText ("Cancel"));
                    hud.ButtonPressed += delegate { DestroyHud (); };
                    dvc.View.AddSubview (hud);

                    // Send an incomplete request with login/password, if this returns 403, we got the wrong password
                    ThreadPool.QueueUserWorkItem ((x) => {
                        bool ok = false;
                        try {
                            ok = ValidateCredentials ();
                        } catch (Exception e){
                            Util.ReportError (this, e, "While validating credentials");
                        }
                        BeginInvokeOnMainThread (delegate {
                            DestroyHud ();
                            if (ok)
                                Close (true);
                        });
                    });
                }
示例#10
0
 void DestroyHud()
 {
     hud.RemoveFromSuperview ();
     hud = null;
 }
示例#11
0
        void PostCallback(object sender, EventArgs a)
        {
            sendItem.Enabled = false;

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

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

            progressHud = new ProgressHud (Locale.GetText ("Uploading Image"), Locale.GetText ("Stop"));
            var uploader = TwitterAccount.CurrentAccount.UploadPicture (stream, PicUploadComplete, progressHud);

            progressHud.ButtonPressed += delegate {
                uploader.Cancel ();
                DestroyProgressHud ();
            };
            View.AddSubview (progressHud);
            ThreadPool.QueueUserWorkItem (delegate {
                uploader.Upload ();

                // This captures the variable and handle of jpeg, and then we clear it
                // to release it
                jpeg = null;
            });
        }
示例#12
0
 void DestroyProgressHud()
 {
     progressHud.RemoveFromSuperview ();
     progressHud = null;
 }