/// <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); }
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(); }
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(); } } } }
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); }
/// <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); } }
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); }
/// <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); }
/// <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(); } } } }
/// <summary> /// Here the logic for capturing the IE Content is located /// </summary> /// <param name="capture">ICapture where the capture needs to be stored</param> /// <param name="windowToCapture">window to use</param> /// <returns>ICapture with the content (if any)</returns> public static ICapture CaptureIE(ICapture capture, WindowDetails windowToCapture) { if (windowToCapture == null) { windowToCapture = WindowDetails.GetActiveWindow(); } // Show backgroundform after retrieving the active window.. BackgroundForm backgroundForm = new BackgroundForm(Language.GetString(LangKey.contextmenu_captureie), Language.GetString(LangKey.wait_ie_capture)); backgroundForm.Show(); //BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(language.GetString(LangKey.contextmenu_captureie), language.GetString(LangKey.wait_ie_capture)); try { //Get IHTMLDocument2 for the current active window DocumentContainer documentContainer = CreateDocumentContainer(windowToCapture); // Nothing found if (documentContainer == null) { LOG.Debug("Nothing to capture found"); return(null); } try { LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName); LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location); } catch (Exception ex) { LOG.Warn("Error while logging information.", ex); } // bitmap to return Bitmap returnBitmap = null; Size pageSize = Size.Empty; try { pageSize = PrepareCapture(documentContainer, capture); returnBitmap = capturePage(documentContainer, capture, pageSize); } catch (Exception captureException) { LOG.Error("Exception found, ignoring and returning nothing! Error was: ", captureException); } // TODO: Enable when the elements are usable again. // Capture the element on the page //try { // if (configuration.IEFieldCapture && capture.CaptureDetails.HasDestination("Editor")) { // // clear the current elements, as they are for the window itself // capture.Elements.Clear(); // CaptureElement documentCaptureElement = documentContainer.CreateCaptureElements(pageSize); // foreach(DocumentContainer frameDocument in documentContainer.Frames) { // try { // CaptureElement frameCaptureElement = frameDocument.CreateCaptureElements(Size.Empty); // if (frameCaptureElement != null) { // documentCaptureElement.Children.Add(frameCaptureElement); // } // } catch (Exception ex) { // LOG.Warn("An error occurred while creating the capture elements: ", ex); // } // } // capture.AddElement(documentCaptureElement); // // Offset the elements, as they are "back offseted" later... // Point windowLocation = documentContainer.ContentWindow.WindowRectangle.Location; // capture.MoveElements(-(capture.ScreenBounds.Location.X-windowLocation.X), -(capture.ScreenBounds.Location.Y-windowLocation.Y)); // } //} catch (Exception elementsException) { // LOG.Warn("An error occurred while creating the capture elements: ", elementsException); //} if (returnBitmap == null) { return(null); } // Store the bitmap for further processing capture.Image = returnBitmap; try { // Store the location of the window capture.Location = documentContainer.ContentWindow.Location; // The URL is available unter "document2.url" and can be used to enhance the meta-data etc. capture.CaptureDetails.AddMetaData("url", documentContainer.Url); // Store the title of the page if (documentContainer.Name != null) { capture.CaptureDetails.Title = documentContainer.Name; } else { capture.CaptureDetails.Title = windowToCapture.Text; } } catch (Exception ex) { LOG.Warn("Problems getting some attributes...", ex); } // Store the URL of the page if (documentContainer.Url != null) { try { Uri uri = new Uri(documentContainer.Url); capture.CaptureDetails.AddMetaData("URL", uri.OriginalString); // As the URL can hardly be used in a filename, the following can be used if (!string.IsNullOrEmpty(uri.Scheme)) { capture.CaptureDetails.AddMetaData("URL_SCHEME", uri.Scheme); } if (!string.IsNullOrEmpty(uri.DnsSafeHost)) { capture.CaptureDetails.AddMetaData("URL_HOSTNAME", uri.DnsSafeHost); } if (!string.IsNullOrEmpty(uri.AbsolutePath)) { capture.CaptureDetails.AddMetaData("URL_PATH", uri.AbsolutePath); } if (!string.IsNullOrEmpty(uri.Query)) { capture.CaptureDetails.AddMetaData("URL_QUERY", uri.Query); } if (!string.IsNullOrEmpty(uri.UserInfo)) { capture.CaptureDetails.AddMetaData("URL_USER", uri.UserInfo); } capture.CaptureDetails.AddMetaData("URL_PORT", uri.Port.ToString()); } catch (Exception e) { LOG.Warn("Exception when trying to use url in metadata " + documentContainer.Url, e); } } try { // Only move the mouse to correct for the capture offset capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y); // Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y)); } catch (Exception ex) { LOG.Warn("Error while correcting the mouse offset.", ex); } } finally { // Always close the background form backgroundForm.CloseDialog(); } return(capture); }
/// <summary> /// Here the logic for capturing the IE Content is located /// </summary> /// <param name="capture">ICapture where the capture needs to be stored</param> /// <returns>ICapture with the content (if any)</returns> public static ICapture CaptureIE(ICapture capture) { WindowDetails activeWindow = WindowDetails.GetActiveWindow(); // Show backgroundform after retrieving the active window.. BackgroundForm backgroundForm = new BackgroundForm(language.GetString(LangKey.contextmenu_captureie), language.GetString(LangKey.wait_ie_capture)); backgroundForm.Show(); //BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(language.GetString(LangKey.contextmenu_captureie), language.GetString(LangKey.wait_ie_capture)); try { //Get IHTMLDocument2 for the current active window DocumentContainer documentContainer = GetDocument(activeWindow); // Nothing found if (documentContainer == null) { LOG.Debug("Nothing to capture found"); return(null); } LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName); LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location); // The URL is available unter "document2.url" and can be used to enhance the meta-data etc. capture.CaptureDetails.AddMetaData("url", documentContainer.Url); // bitmap to return Bitmap returnBitmap = null; try { returnBitmap = capturePage(documentContainer, capture); } catch (Exception e) { LOG.Error("Exception found, ignoring and returning nothing! Error was: ", e); } if (returnBitmap == null) { return(null); } // Store the bitmap for further processing capture.Image = returnBitmap; // Store the location of the window capture.Location = documentContainer.ContentWindow.Location; // Store the title of the Page if (documentContainer.Name != null) { capture.CaptureDetails.Title = documentContainer.Name; } else { capture.CaptureDetails.Title = activeWindow.Text; } // Only move the mouse to correct for the capture offset capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y); // Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y)); } finally { // Always close the background form backgroundForm.CloseDialog(); } return(capture); }