Esempio n. 1
0
        public bool Upload(ICaptureDetails captureDetails, Image image)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));

                host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality);
                byte[] buffer = stream.GetBuffer();

                try
                {
                    string     filename    = Path.GetFileName(host.GetFilename(config.UploadFormat, captureDetails));
                    string     contentType = "image/" + config.UploadFormat.ToString();
                    PicasaInfo picasaInfo  = PicasaUtils.UploadToPicasa(buffer, captureDetails.DateTime.ToString(), filename, contentType);
                    if (config.PicasaUploadHistory == null)
                    {
                        config.PicasaUploadHistory = new Dictionary <string, string>();
                    }

                    if (picasaInfo.ID != null)
                    {
                        LOG.InfoFormat("Storing Picasa upload for id {0}", picasaInfo.ID);

                        config.PicasaUploadHistory.Add(picasaInfo.ID, picasaInfo.ID);
                        config.runtimePicasaHistory.Add(picasaInfo.ID, picasaInfo);
                    }

                    picasaInfo.Image = PicasaUtils.CreateThumbnail(image, 90, 90);
                    // Make sure the configuration is save, so we don't lose the deleteHash
                    IniConfig.Save();
                    // Make sure the history is loaded, will be done only once
                    PicasaUtils.LoadHistory();

                    // Show
                    if (config.AfterUploadOpenHistory)
                    {
                        PicasaHistory.ShowHistory();
                    }

                    if (config.AfterUploadLinkToClipBoard)
                    {
                        Clipboard.SetText(picasaInfo.LinkUrl(config.PictureDisplaySize));
                    }
                    return(true);
                }
                catch (Google.GData.Client.InvalidCredentialsException eLo)
                {
                    MessageBox.Show(lang.GetString(LangKey.InvalidCredentials));
                }
                catch (Exception e)
                {
                    MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.ToString());
                }
                finally
                {
                    backgroundForm.CloseDialog();
                }
            }
            return(false);
        }
        public SettingsForm(PicasaConfiguration config)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            InitializeTexts();

            combobox_uploadimageformat.Items.Clear();
            foreach (OutputFormat format in Enum.GetValues(typeof(OutputFormat)))
            {
                combobox_uploadimageformat.Items.Add(format.ToString());
            }

            comboBox_DefaultSize.Items.Clear();
            foreach (PictureDisplaySize displaySize in Enum.GetValues(typeof(PictureDisplaySize)))
            {
                comboBox_DefaultSize.Items.Add(displaySize.ToString());
            }

            PicasaUtils.LoadHistory();

            if (config.runtimePicasaHistory.Count > 0)
            {
                historyButton.Enabled = true;
            }
            else
            {
                historyButton.Enabled = false;
            }
        }
Esempio n. 3
0
 public void HistoryMenuClick(object sender, EventArgs eventArgs)
 {
     PicasaUtils.LoadHistory();
     PicasaHistory.ShowHistory();
 }