Пример #1
0
        private void InsertPictureFromFile()
        {
            if (!uploadingPicture)
            {
                String pictureUrl = string.Empty;
                using (Microsoft.WindowsMobile.Forms.SelectPictureDialog s = new Microsoft.WindowsMobile.Forms.SelectPictureDialog())
                {
                    if (s.ShowDialog() == DialogResult.OK)
                    {
                        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PostUpdate));
                        this.pictureFromCamers.Image = PockeTwit.Themes.FormColors.GetThemeIcon("takepicture.png");
                        if (DetectDevice.DeviceType == DeviceType.Standard)
                        {
                            this.pictureFromCamers.Visible = false;
                        }
                        uploadedPictureOrigin = "file";

                        pictureService = GetMediaService();
                        if (pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService)
                        {
                            AddPictureToForm(s.FileName, pictureFromStorage);
                            picturePath = s.FileName;
                            //Reduce length of message 140-pictureService.UrlLength
                            pictureUsed = true;
                        }
                        else
                        {
                            uploadingPicture = true;
                            AddPictureToForm(ClientSettings.IconsFolder() + "wait.png", pictureFromStorage);
                            using (PicturePostObject ppo = new PicturePostObject())
                            {
                                ppo.Filename = s.FileName;
                                ppo.Username = AccountToSet.UserName;
                                ppo.Password = AccountToSet.Password;
                                ppo.UseAsync = false;
                                Cursor.Current = Cursors.WaitCursor;
                                pictureService.PostPicture(ppo);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Uploading picture...");
            }
        }
Пример #2
0
 private void InsertPictureFromFile()
 {
     if (!uploadingPicture)
     {
         String pictureUrl = string.Empty;
         String filename = string.Empty;
         //using (Microsoft.WindowsMobile.Forms.SelectPictureDialog s = new Microsoft.WindowsMobile.Forms.SelectPictureDialog())
         try
         {
             pictureService = GetMediaService();
             using (Microsoft.WindowsMobile.Forms.SelectPictureDialog s = new Microsoft.WindowsMobile.Forms.SelectPictureDialog())
             {
                 //s.Filter = string.Empty; //all files //pictureService.FileFilter;
                 s.Filter = pictureService.FileFilter;
                 
                 if (s.ShowDialog() == DialogResult.OK)
                 {
                     filename = s.FileName;
                     ComponentResourceManager resources = new ComponentResourceManager(typeof(PostUpdate));
                     pictureFromCamers.Image = FormColors.GetThemeIcon("takepicture.png");
                     if (DetectDevice.DeviceType == DeviceType.Standard)
                     {
                         pictureFromCamers.Visible = false;
                     }
                     uploadedPictureOrigin = "file";
                 }
                 else //cancelled
                 {
                     pictureUsed = true;
                 }
             }
         }
         catch
         {
             MessageBox.Show("Unable to select picture.", "PockeTwit");
         }
         if  (string.IsNullOrEmpty(filename))
         {
             return;
         }
         try
         {
             if (pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService)
             {
                 AddPictureToForm(filename, pictureFromStorage);
                 picturePath = filename;
                 //Reduce length of message 140-pictureService.UrlLength
                 pictureUsed = true;
             }
             else
             {
                 uploadingPicture = true;
                 AddPictureToForm(FormColors.GetThemeIconPath("wait.png"), pictureFromStorage);
                 using (PicturePostObject ppo = new PicturePostObject())
                 {
                     ppo.Filename = filename;
                     ppo.Username = AccountToSet.UserName;
                     ppo.Password = AccountToSet.Password;
                     ppo.UseAsync = false;
                     Cursor.Current = Cursors.WaitCursor;
                     pictureService.PostPicture(ppo);
                 }
             }
         }
         catch
         {
             MessageBox.Show("Unable to upload picture.", "PockeTwit");
         } 
     }
     else
     {
         MessageBox.Show("Uploading picture...");
     }
 }
Пример #3
0
        private bool DoUpload(IPictureService Service, UploadAttachment a)
        {
            PicturePostObject ppo = new PicturePostObject();
            if(a.MediaType != null)
                ppo.ContentType = a.MediaType.ContentType;
            if (a.Position != null)
            {
                ppo.Lat = a.Position.Lat.ToString(System.Globalization.CultureInfo.InvariantCulture);
                ppo.Lon = a.Position.Lat.ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
            ppo.Message = a.Caption;
            //ppo.PictureStream = a.Contents;
            ppo.Filename = a.Name;
            ppo.UseAsync = false;

            // This is only temporary -> PostUpdate form has event handlers reg'd
            a.Status = UploadAttachment.AttachmentStatus.Uploading;
            Service.PostPicture(ppo, Account);
            if (!string.IsNullOrEmpty(ppo.URL))
            {
                a.UploadedUri = new Uri(ppo.URL);
                a.Status = UploadAttachment.AttachmentStatus.Complete;
            }
            else
            {
                a.Status = UploadAttachment.AttachmentStatus.Error;
            }
            return true;
        }
Пример #4
0
 private void InsertPictureFromCamera()
 {
     if (!uploadingPicture)
     {
         String pictureUrl = string.Empty;
         String filename = string.Empty;
         try
         {
             using (Microsoft.WindowsMobile.Forms.CameraCaptureDialog c = new Microsoft.WindowsMobile.Forms.CameraCaptureDialog())
             {
                 if (c.ShowDialog() == DialogResult.OK)
                 {
                     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PostUpdate));
                     pictureFromStorage.Image = PockeTwit.Themes.FormColors.GetThemeIcon("existingimage.png");
                     if (DetectDevice.DeviceType == DeviceType.Standard)
                     {
                         pictureFromStorage.Visible = false;
                     }
                     uploadedPictureOrigin = "camera";
                     filename = c.FileName;                            
                 }
                 else //cancelled
                 {
                     pictureUsed = true;
                 }
             }
         }
         catch
         {
             MessageBox.Show("The camera is not available.", "PockeTwit");
             return;
         }
         if (string.IsNullOrEmpty(filename))
         {
             return; //no file selected, so don't upload
         }
         try
         {
             pictureService = GetMediaService();
             if (pictureService.CanUploadMessage && ClientSettings.SendMessageToMediaService)
             {
                 AddPictureToForm(filename, pictureFromCamers);
                 picturePath = filename;
                 //Reduce length of message 140-pictureService.UrlLength
                 pictureUsed = true;
             }
             else
             {
                 AddPictureToForm(FormColors.GetThemeIconPath("wait.png"), pictureFromCamers);
                 uploadingPicture = true;
                 using (PicturePostObject ppo = new PicturePostObject())
                 {
                     ppo.Filename = filename;
                     ppo.Username = AccountToSet.UserName;
                     ppo.Password = AccountToSet.Password;
                     ppo.UseAsync = false;
                     Cursor.Current = Cursors.WaitCursor;
                     pictureService.PostPicture(ppo);
                 }
             }
         }
         catch
         {
             MessageBox.Show("Unable to upload picture.", "PockeTwit");
         }
     }
     else
     {
         MessageBox.Show("Uploading picture...");
     }
 }
Пример #5
0
 private void StartUpload(IPictureService mediaService, String fileName)
 {
     if (mediaService.CanUploadMessage && ClientSettings.SendMessageToMediaService)
     {
         AddPictureToForm(fileName, pictureFromStorage);
         picturePath = fileName;
         //Reduce length of message 140-pictureService.UrlLength
         pictureUsed = true;
     }
     else
     {
         uploadingPicture = true;
         AddPictureToForm(FormColors.GetThemeIconPath("wait.png"), pictureFromStorage);
         using (PicturePostObject ppo = new PicturePostObject())
         {
             ppo.Filename = fileName;
             ppo.Username = AccountToSet.UserName;
             ppo.Password = AccountToSet.Password;
             ppo.UseAsync = false;
             Cursor.Current = Cursors.WaitCursor;
             mediaService.PostPicture(ppo);
         }
     }
 }