예제 #1
0
        private void deletePicture()
        {
            if (listview_TFS_uploads.SelectedItems != null && listview_TFS_uploads.SelectedItems.Count > 0)
            {
                for (int i = 0; i < listview_TFS_uploads.SelectedItems.Count; i++)
                {
                    TFSInfo      imgurInfo = (TFSInfo)listview_TFS_uploads.SelectedItems[i].Tag;
                    DialogResult result    = MessageBox.Show(Language.GetFormattedString(LangKey.delete_question, imgurInfo.Title), Language.GetFormattedString(LangKey.delete_title, imgurInfo.ID), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs", LangKey.communication_wait));
                        try
                        {
                            TFSUtils.DeleteTfsWorkItem(imgurInfo);
                        }
                        catch (Exception ex)
                        {
                            LOG.Warn("Problem communicating with TFS: ", ex);
                        }
                        finally
                        {
                            backgroundForm.CloseDialog();
                        }

                        imgurInfo.Dispose();
                    }
                }
            }
            redraw();
        }
예제 #2
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            button_save.Enabled = false;
            using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false))
            {
                DialogResult result = tpp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    textbox_tfsUrl.Text = tpp.SelectedTeamProjectCollection.Uri.ToString();
                    textbox_defaultProject.Text = tpp.SelectedProjects[0].Name;
                    button_save.Enabled = true;

                    BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs",LangKey.communication_wait));

                    try
                    {
                        this.BindScreen();
                    }
                    finally
                    {
                        backgroundForm.CloseDialog();
                    }
                }
            }
        }
        /// <summary>
        /// A form for token
        /// </summary>
        /// <returns>bool true if OK was pressed, false if cancel</returns>
        public bool ShowConfigDialog()
        {
            SettingsForm settingsForm;
            ILanguage    lang = Language.GetInstance();

            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(DropboxPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));

            try {
                settingsForm = new SettingsForm(this);
            } finally {
                backgroundForm.CloseDialog();
            }
            settingsForm.AuthToken                  = this.DropboxAccessToken;
            settingsForm.UploadFormat               = this.UploadFormat.ToString();
            settingsForm.AfterUploadOpenHistory     = this.AfterUploadOpenHistory;
            settingsForm.AfterUploadLinkToClipBoard = this.AfterUploadLinkToClipBoard;
            DialogResult result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.DropboxAccessToken = settingsForm.AuthToken;
                this.UploadFormat       = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());

                this.AfterUploadOpenHistory     = settingsForm.AfterUploadOpenHistory;
                this.AfterUploadLinkToClipBoard = settingsForm.AfterUploadLinkToClipBoard;
                IniConfig.Save();

                // Save DropboxAccessToken from file
                DropboxUtils.SaveAccessToken();

                return(true);
            }
            return(false);
        }
예제 #4
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);
        }
예제 #5
0
        /// <summary>
        /// Do the actual upload to TFS
        /// </summary>
        /// <param name="imageData">byte[] with image data</param>
        /// <returns>TFSResponse</returns>
        public static TFSInfo UploadToTFS(byte[] imageData, string title, string filename, string contentType)
        {
            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs", LangKey.communication_wait));
            AddForm        addForm        = null;

            try
            {
                addForm = new AddForm();
            }
            finally
            {
                backgroundForm.CloseDialog();
            }
            addForm.ImageData   = imageData;
            addForm.Title       = title;
            addForm.Filename    = filename;
            addForm.ContentType = contentType;
            if (addForm.ShowDialog() == DialogResult.OK)
            {
                return(addForm.TFSInfo);
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        private void combobox_workItemType_SelectedIndexChanged(object sender, EventArgs e)
        {
            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs", LangKey.communication_wait));

            try
            {
                this.BindScreenByItemType();
            }
            finally
            {
                backgroundForm.CloseDialog();
            }
        }
        void SendToButtonClick(object sender, EventArgs e)
        {
            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Language.GetString("fogbugz", LangKey.fogbugz), Language.GetString("fogbugz", LangKey.communication_wait));

            bool success = false;
            int  caseId  = 0;

            if (ResultsListBox.SelectedIndex == 0)
            {
                // TODO: Open new case dialog
                FogBugz fb = new FogBugz(new Uri(m_cfg.FogBugzServerUrl), m_cfg.FogBugzLoginToken);
                caseId  = fb.CreateNewCase(CaptionTextBox.Text, m_filename, m_captureStream.GetBuffer());
                success = true;
            }
            else
            {
                string item = ResultsListBox.SelectedItem.ToString();
                caseId = Convert.ToInt32(item.Substring(0, item.IndexOf(" ")));

                FogBugz fb = new FogBugz(new Uri(m_cfg.FogBugzServerUrl), m_cfg.FogBugzLoginToken);
                fb.AttachImageToExistingCase(caseId, CaptionTextBox.Text, m_filename, m_captureStream.GetBuffer());
                success = true;
            }

            // Set the configuration for next time
            if (success)
            {
                m_cfg.LastCaseId = caseId;
                try {
                    string caseUrl = string.Concat(m_cfg.FogBugzServerUrl, "?", caseId);
                    if (m_cfg.CopyCaseUrlToClipboardAfterSend)
                    {
                        System.Windows.Forms.Clipboard.SetText(caseUrl);
                    }
                    if (m_cfg.OpenBrowserAfterSend)
                    {
                        Process.Start(caseUrl);
                    }
                } catch {
                    // Throw away "after-upload" exceptions
                }
            }
            backgroundForm.CloseDialog();
        }
        /// <summary>
        /// A form for token
        /// </summary>
        /// <returns>bool true if OK was pressed, false if cancel</returns>
        public bool ShowConfigDialog()
        {
            SettingsForm settingsForm;
            ILanguage    lang = Language.GetInstance();

            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(FlickrPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));

            try {
                settingsForm = new SettingsForm(this);
            } finally {
                backgroundForm.CloseDialog();
            }
            settingsForm.AuthToken                  = this.flickrToken;
            settingsForm.IsFamily                   = this.IsFamily;
            settingsForm.IsPublic                   = this.IsPublic;
            settingsForm.IsFriend                   = this.IsFriend;
            settingsForm.UploadFormat               = this.UploadFormat.ToString();
            settingsForm.SafetyLevel                = this.SafetyLevel.ToString();
            settingsForm.HiddenFromSearch           = this.HiddenFromSearch.ToString();
            settingsForm.PictureDefaultSize         = this.PictureDisplaySize.ToString();
            settingsForm.AfterUploadOpenHistory     = this.AfterUploadOpenHistory;
            settingsForm.AfterUploadLinkToClipBoard = this.AfterUploadLinkToClipBoard;
            DialogResult result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.flickrToken        = settingsForm.AuthToken;
                this.IsFamily           = settingsForm.IsFamily;
                this.IsPublic           = settingsForm.IsPublic;
                this.IsFriend           = settingsForm.IsFriend;
                this.SafetyLevel        = (FlickrNet.SafetyLevel)Enum.Parse(typeof(FlickrNet.SafetyLevel), settingsForm.SafetyLevel);
                this.HiddenFromSearch   = (FlickrNet.HiddenFromSearch)Enum.Parse(typeof(FlickrNet.HiddenFromSearch), settingsForm.HiddenFromSearch);
                this.UploadFormat       = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());
                this.PictureDisplaySize = (PictureDisplaySize)Enum.Parse(typeof(PictureDisplaySize), settingsForm.PictureDefaultSize);

                this.AfterUploadOpenHistory     = settingsForm.AfterUploadOpenHistory;
                this.AfterUploadLinkToClipBoard = settingsForm.AfterUploadLinkToClipBoard;
                IniConfig.Save();
                return(true);
            }
            return(false);
        }
예제 #9
0
        /// <summary>
        /// A form for token
        /// </summary>
        /// <returns>bool true if OK was pressed, false if cancel</returns>
        public bool ShowConfigDialog()
        {
            SettingsForm settingsForm;

            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(TFSPlugin.Attributes.Name, Language.GetString("tfs", LangKey.communication_wait));

            try
            {
                settingsForm = new SettingsForm(this);
            }
            finally
            {
                backgroundForm.CloseDialog();
            }
            settingsForm.UploadFormat               = this.UploadFormat.ToString();
            settingsForm.AfterUploadOpenHistory     = this.AfterUploadOpenHistory;
            settingsForm.AfterUploadLinkToClipBoard = this.AfterUploadLinkToClipBoard;
            settingsForm.AfterUploadOpenWorkItem    = this.AfterUploadOpenWorkItem;
            settingsForm.ServerUrl      = this.TfsServerUrl;
            settingsForm.DefaultProject = this.TfsDefaultProject;
            DialogResult result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.UploadFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());

                this.AfterUploadOpenHistory     = settingsForm.AfterUploadOpenHistory;
                this.AfterUploadLinkToClipBoard = settingsForm.AfterUploadLinkToClipBoard;
                this.AfterUploadOpenWorkItem    = settingsForm.AfterUploadOpenWorkItem;

                this.TfsServerUrl      = settingsForm.ServerUrl;
                this.TfsDefaultProject = settingsForm.DefaultProject;

                IniConfig.Save();
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// A form for token
        /// </summary>
        /// <returns>bool true if OK was pressed, false if cancel</returns>
        public bool ShowConfigDialog()
        {
            SettingsForm settingsForm;
            ILanguage    lang = Language.GetInstance();

            BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(PicasaPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));

            try {
                settingsForm = new SettingsForm(this);
            } finally {
                backgroundForm.CloseDialog();
            }
            settingsForm.UploadFormat               = this.UploadFormat.ToString();
            settingsForm.AfterUploadOpenHistory     = this.AfterUploadOpenHistory;
            settingsForm.AfterUploadLinkToClipBoard = this.AfterUploadLinkToClipBoard;
            settingsForm.Username           = this.Username;
            settingsForm.Password           = this.Password;
            settingsForm.PictureDefaultSize = this.PictureDisplaySize.ToString();
            DialogResult result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.UploadFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());

                this.AfterUploadOpenHistory     = settingsForm.AfterUploadOpenHistory;
                this.AfterUploadLinkToClipBoard = settingsForm.AfterUploadLinkToClipBoard;

                this.Username           = settingsForm.Username;
                this.Password           = settingsForm.Password;
                this.PictureDisplaySize = (PictureDisplaySize)Enum.Parse(typeof(PictureDisplaySize), settingsForm.PictureDefaultSize);

                IniConfig.Save();
                return(true);
            }
            return(false);
        }
예제 #11
0
        /// <summary>
        /// This will be called when the menu item in the Editor is clicked
        /// </summary>
        public bool Upload(ICaptureDetails captureDetails, Image image)
        {
            if (config.DropboxAccessToken == null)
            {
                MessageBox.Show(lang.GetString(LangKey.TokenNotSet), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            else
            {
                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));
                        DropboxInfo DropboxInfo = DropboxUtils.UploadToDropbox(buffer, captureDetails.Title, filename);

                        if (config.DropboxUploadHistory == null)
                        {
                            config.DropboxUploadHistory = new Dictionary <string, string>();
                        }

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

                            config.DropboxUploadHistory.Add(DropboxInfo.ID, DropboxInfo.ID);
                            config.runtimeDropboxHistory.Add(DropboxInfo.ID, DropboxInfo);
                        }

                        DropboxInfo.Image = DropboxUtils.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
                        DropboxUtils.LoadHistory();

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

                        if (config.AfterUploadLinkToClipBoard)
                        {
                            Clipboard.SetText(DropboxInfo.WebUrl);
                        }
                        return(true);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.ToString());
                        return(false);
                    }
                    finally
                    {
                        backgroundForm.CloseDialog();
                    }
                }
            }
        }