Пример #1
0
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            _log.Debug("Start capture export to oo.vg");

            try
            {
                string uploadUrl;

                var exportInformation = new ExportInformation(this.Designation, this.Description)
                {
                    ExportMade = UploadImage(captureDetails, surface, out uploadUrl),
                    Uri = uploadUrl
                };

                ProcessExport(exportInformation, surface);

                if (exportInformation.ExportMade)
                {
                    Clipboard.SetText(uploadUrl);
                }

                return exportInformation;
            }
            finally
            {
                _log.Debug("Export to oo.vg complete");
            }
        }
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();

			
			if (presetCommand != null) {
				if (!config.runInbackground.ContainsKey(presetCommand)) {
					config.runInbackground.Add(presetCommand, true);
				}
				bool runInBackground = config.runInbackground[presetCommand];
				string fullPath = captureDetails.Filename;
				if (fullPath == null) {
					fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
				}

				string output;
				string error;
				if (runInBackground) {
					Thread commandThread = new Thread(delegate() {
						CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
						ProcessExport(exportInformation, surface);
					});
					commandThread.Name = "Running " + presetCommand;
					commandThread.IsBackground = true;
					commandThread.SetApartmentState(ApartmentState.STA);
					commandThread.Start();
					exportInformation.ExportMade = true;
				} else {
					CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
					ProcessExport(exportInformation, surface);
				}
			}
			return exportInformation;
		}
Пример #3
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			string uploadURL = null;
			exportInformation.ExportMade = plugin.Upload(captureDetails, surface, out uploadURL);
			exportInformation.Uri = uploadURL;
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #4
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			string uploadUrl = _plugin.Upload(captureDetails, surface);
			if (uploadUrl != null) {
				exportInformation.ExportMade = true;
				exportInformation.Uri = uploadUrl;
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #5
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			bool outputMade;
            bool overwrite;
            string fullPath;
			// Get output settings from the configuration
			SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();

			if (captureDetails != null && captureDetails.Filename != null) {
                // As we save a pre-selected file, allow to overwrite.
                overwrite = true;
                LOG.InfoFormat("Using previous filename");
                fullPath = captureDetails.Filename;
				outputSettings.Format = ImageOutput.FormatForFilename(fullPath);
            } else {
                fullPath = CreateNewFilename(captureDetails);
                // As we generate a file, the configuration tells us if we allow to overwrite
                overwrite = conf.OutputFileAllowOverwrite;
            }
			if (conf.OutputFilePromptQuality) {
				QualityDialog qualityDialog = new QualityDialog(outputSettings);
				qualityDialog.ShowDialog();
			}

			// Catching any exception to prevent that the user can't write in the directory.
			// This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218, #3004642
			try {
				ImageOutput.Save(surface, fullPath, overwrite, outputSettings, conf.OutputFileCopyPathToClipboard);
				outputMade = true;
			} catch (ArgumentException ex1) {
				// Our generated filename exists, display 'save-as'
				LOG.InfoFormat("Not overwriting: {0}", ex1.Message);
				// when we don't allow to overwrite present a new SaveWithDialog
				fullPath = ImageOutput.SaveWithDialog(surface, captureDetails);
				outputMade = (fullPath != null);
			} catch (Exception ex2) {
				LOG.Error("Error saving screenshot!", ex2);
				// Show the problem
				MessageBox.Show(Language.GetString(LangKey.error_save), Language.GetString(LangKey.error));
				// when save failed we present a SaveWithDialog
				fullPath = ImageOutput.SaveWithDialog(surface, captureDetails);
				outputMade = (fullPath != null);
			}
			// Don't overwrite filename if no output is made
			if (outputMade) {
				exportInformation.ExportMade = outputMade;
				exportInformation.Filepath = fullPath;
				captureDetails.Filename = fullPath;
				conf.OutputFileAsFullpath = fullPath;
			}

			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #6
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			try {
				ClipboardHelper.SetClipboardData(surface);
				exportInformation.ExportMade = true;
			} catch (Exception) {
				// TODO: Change to general logic in ProcessExport
				surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString(LangKey.editor_clipboardfailed));
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #7
0
		public override ExportInformation ExportCapture(bool manually, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			string uploadURL = null;
			bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
			if (uploaded) {
				exportInformation.Uri = uploadURL;
				exportInformation.ExportMade = true;
				if (config.AfterUploadLinkToClipBoard) {
					ClipboardHelper.SetClipboardData(uploadURL);
				}
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #8
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			string savedTo = null;
			// Bug #2918756 don't overwrite path if SaveWithDialog returns null!
			savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
			if (savedTo != null) {
				exportInformation.ExportMade = true;
				exportInformation.Filepath = savedTo;
				captureDetails.Filename = savedTo;
				conf.OutputFileAsFullpath = savedTo;
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #9
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			CoreConfiguration config = IniConfig.GetIniSection<CoreConfiguration>();
			OutputSettings outputSettings = new OutputSettings();

			string file = FilenameHelper.GetFilename(OutputFormat.png, null);
			string filePath = Path.Combine(config.OutputFilePath, file);
			using (FileStream stream = new FileStream(filePath, FileMode.Create)) {
				using (Image image = surface.GetImageForExport()) {
					ImageOutput.SaveToStream(image, stream, outputSettings);
				}
			}
			exportInformation.Filepath = filePath;
			exportInformation.ExportMade = true;
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #10
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
			SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
			if (jira != null) {
				try {
					// Run upload in the background
					new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
						delegate() {
							jiraPlugin.JiraConnector.addAttachment(jira.Key, filename, new SurfaceContainer(surfaceToUpload, outputSettings, filename));
						}
					);
					LOG.Debug("Uploaded to Jira.");
					exportInformation.ExportMade = true;
					// TODO: This can't work:
					exportInformation.Uri = surfaceToUpload.UploadURL;
				} catch (Exception e) {
					MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
				}
			} else {
				JiraForm jiraForm = new JiraForm(jiraPlugin.JiraConnector);
				if (jiraPlugin.JiraConnector.isLoggedIn) {
					jiraForm.setFilename(filename);
					DialogResult result = jiraForm.ShowDialog();
					if (result == DialogResult.OK) {
						try {
							// Run upload in the background
							new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
								delegate() {
									jiraForm.upload(new SurfaceContainer(surfaceToUpload, outputSettings, filename));
								}
							);
							LOG.Debug("Uploaded to Jira.");
							exportInformation.ExportMade = true;
							// TODO: This can't work:
							exportInformation.Uri = surfaceToUpload.UploadURL;
						} catch(Exception e) {
							MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
						}
					}
				}
			}
			ProcessExport(exportInformation, surfaceToUpload);
			return exportInformation;
		}
Пример #11
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			// force password check to take place before the pages load
			if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
				return exportInformation;
			}

			Page selectedPage = page;
			bool openPage = (page == null) && config.OpenPageAfterUpload;
			string filename = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConfig.OutputFileFilenamePattern, captureDetails);
			if (selectedPage == null) {
				ConfluenceUpload confluenceUpload = new ConfluenceUpload(filename);
				Nullable<bool> dialogResult = confluenceUpload.ShowDialog();
				if (dialogResult.HasValue && dialogResult.Value) {
					selectedPage = confluenceUpload.SelectedPage;
					if (confluenceUpload.isOpenPageSelected) {
						openPage = false;
					}
					filename = confluenceUpload.Filename;
				}
			}
			string extension = "." + config.UploadFormat;
			if (!filename.ToLower().EndsWith(extension)) {
				filename = filename + extension;
			}
			if (selectedPage != null) {
				string errorMessage;
				bool uploaded = upload(surface, selectedPage, filename, out errorMessage);
				if (uploaded) {
					if (openPage) {
						try {
							Process.Start(selectedPage.Url);
						} catch { }
					}
					exportInformation.ExportMade = true;
					exportInformation.Uri = selectedPage.Url;
				} else {
					exportInformation.ErrorMessage = errorMessage;
				}
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #12
0
		/// <summary>
		/// This method will create and show the destination picker menu
		/// </summary>
		/// <param name="addDynamics">Boolean if the dynamic values also need to be added</param>
		/// <param name="surface">The surface which can be exported</param>
		/// <param name="captureDetails">Details for the surface</param>
		/// <param name="destinations">The list of destinations to show</param>
		/// <returns></returns>
		public ExportInformation ShowPickerMenu(bool addDynamics, ISurface surface, ICaptureDetails captureDetails, IEnumerable<IDestination> destinations) {
			// Generate an empty ExportInformation object, for when nothing was selected.
			ExportInformation exportInformation = new ExportInformation(Designation, Language.GetString("settings_destination_picker"));
			ContextMenuStrip menu = new ContextMenuStrip();
			menu.ImageScalingSize = configuration.IconSize;
			menu.Tag = null;

			menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) {
				LOG.DebugFormat("Close reason: {0}", eventArgs.CloseReason);
				switch (eventArgs.CloseReason) {
					case ToolStripDropDownCloseReason.AppFocusChange:
						if (menu.Tag == null) {
							// Do not allow the close if the tag is not set, this means the user clicked somewhere else.
							eventArgs.Cancel = true;
						} else {
							LOG.DebugFormat("Letting the menu 'close' as the tag is set to '{0}'", menu.Tag);
						}
						break;
					case ToolStripDropDownCloseReason.ItemClicked:
					case ToolStripDropDownCloseReason.CloseCalled:
						// The ContextMenuStrip can be "closed" for these reasons.
						break;
					case ToolStripDropDownCloseReason.Keyboard:
						// Dispose as the close is clicked
						if (!captureDetails.HasDestination("Editor")) {
							surface.Dispose();
							surface = null;
						}
						break;
					default:
						eventArgs.Cancel = true;
						break;
				}
			};
			menu.MouseEnter += delegate(object source, EventArgs eventArgs) {
				// in case the menu has been unfocused, focus again so that dropdown menus will still open on mouseenter
				if(!menu.ContainsFocus) menu.Focus();
			};
			foreach (IDestination destination in destinations) {
				// Fix foreach loop variable for the delegate
				ToolStripMenuItem item = destination.GetMenuItem(addDynamics, menu,
					delegate(object sender, EventArgs e) {
						ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem;
						if (toolStripMenuItem == null) {
							return;
						}
						IDestination clickedDestination = (IDestination)toolStripMenuItem.Tag;
						if (clickedDestination == null) {
							return;
						}
						menu.Tag = clickedDestination.Designation;
						// Export
						exportInformation = clickedDestination.ExportCapture(true, surface, captureDetails);
						if (exportInformation != null && exportInformation.ExportMade) {
							LOG.InfoFormat("Export to {0} success, closing menu", exportInformation.DestinationDescription);
							// close menu if the destination wasn't the editor
							menu.Close();

							// Cleanup surface, only if there is no editor in the destinations and we didn't export to the editor
							if (!captureDetails.HasDestination("Editor") && !"Editor".Equals(clickedDestination.Designation)) {
								surface.Dispose();
								surface = null;
							}
						} else {
							LOG.Info("Export cancelled or failed, showing menu again");

							// Make sure a click besides the menu don't close it.
							menu.Tag = null;

							// This prevents the problem that the context menu shows in the task-bar
							ShowMenuAtCursor(menu);
						}
					}
				);
				if (item != null) {
					menu.Items.Add(item);
				}
			}
			// Close
			menu.Items.Add(new ToolStripSeparator());
			ToolStripMenuItem closeItem = new ToolStripMenuItem(Language.GetString("editor_close"));
			closeItem.Image = GreenshotResources.getImage("Close.Image");
			closeItem.Click += delegate {
				// This menu entry is the close itself, we can dispose the surface
				menu.Close();
				if (!captureDetails.HasDestination("Editor")) {
					surface.Dispose();
					surface = null;
				}
			};
			menu.Items.Add(closeItem);

			ShowMenuAtCursor(menu);
			return exportInformation;
		}
Пример #13
0
		/// <summary>
		/// A small helper method to perform some default destination actions, like inform the surface of the export
		/// </summary>
		/// <param name="exportInformation"></param>
		/// <param name="surface"></param>
		public void ProcessExport(ExportInformation exportInformation, ISurface surface) {
			if (exportInformation != null && exportInformation.ExportMade) {
				if (!string.IsNullOrEmpty(exportInformation.Uri)) {
					surface.UploadURL = exportInformation.Uri;
					surface.SendMessageEvent(this, SurfaceMessageTyp.UploadedUri, Language.GetFormattedString("exported_to", exportInformation.DestinationDescription));
				} else if (!string.IsNullOrEmpty(exportInformation.Filepath)) {
					surface.LastSaveFullPath = exportInformation.Filepath;
					surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, Language.GetFormattedString("exported_to", exportInformation.DestinationDescription));
				} else {
					surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString("exported_to", exportInformation.DestinationDescription));
				}
				surface.Modified = false;
			} else if (exportInformation != null && !string.IsNullOrEmpty(exportInformation.ErrorMessage)) {
				surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetFormattedString("exported_to_error", exportInformation.DestinationDescription) + " " + exportInformation.ErrorMessage);
			}
		}
 /// <summary>
 /// Wrapper method for the background and normal call, this does all the logic:
 /// Call the external command, parse for URI, place to clipboard and set the export information
 /// </summary>
 /// <param name="exportInformation"></param>
 /// <param name="commando"></param>
 /// <param name="fullPath"></param>
 /// <param name="output"></param>
 /// <param name="error"></param>
 private void CallExternalCommand(ExportInformation exportInformation, string commando, string fullPath, out string output, out string error)
 {
     output = null;
     error = null;
     try {
         if (CallExternalCommand(presetCommand, fullPath, out output, out error) == 0) {
             exportInformation.ExportMade = true;
             if (!string.IsNullOrEmpty(output)) {
                 MatchCollection uriMatches = URI_REGEXP.Matches(output);
                 // Place output on the clipboard before the URI, so if one is found this overwrites
                 if (config.OutputToClipboard) {
                     ClipboardHelper.SetClipboardData(output);
                 }
                 if (uriMatches != null && uriMatches.Count >= 0) {
                     exportInformation.Uri = uriMatches[0].Groups[1].Value;
                     LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
                     if (config.UriToClipboard) {
                         ClipboardHelper.SetClipboardData(exportInformation.Uri);
                     }
                 }
             }
         } else {
             LOG.WarnFormat("Error calling external command: {0} ", output);
             exportInformation.ExportMade = false;
             exportInformation.ErrorMessage = error;
         }
     } catch (Exception ex) {
         LOG.WarnFormat("Error calling external command: {0} ", exportInformation.ErrorMessage);
         exportInformation.ExportMade = false;
         exportInformation.ErrorMessage = ex.Message;
     }
 }
Пример #15
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			exportInformation.ExportMade = plugin.DoOCR(surface) != null;
			return exportInformation;
		}
Пример #16
0
		/// <summary>
		/// Export the capture to the printer
		/// </summary>
		/// <param name="manuallyInitiated"></param>
		/// <param name="surface"></param>
		/// <param name="captureDetails"></param>
		/// <returns>ExportInformation</returns>
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			PrinterSettings printerSettings = null;
			if (!string.IsNullOrEmpty(printerName)) {
				using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
					printerSettings = printHelper.PrintTo(printerName);
				}
			} else if (!manuallyInitiated) {
				PrinterSettings settings = new PrinterSettings();
				using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
					printerSettings = printHelper.PrintTo(settings.PrinterName);
				}
			} else {
				using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
					printerSettings = printHelper.PrintWithDialog();
				}
			}
			if (printerSettings != null) {
				exportInformation.ExportMade = true;
			}

			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #17
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			bool createdFile = false;
			string imageFile = captureDetails.Filename;
			if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
				imageFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
				createdFile = true;
			}
			if (workbookName != null) {
				ExcelExporter.InsertIntoExistingWorkbook(workbookName, imageFile, surface.Image.Size);
			} else {
				ExcelExporter.InsertIntoNewWorkbook(imageFile, surface.Image.Size);
			}
			exportInformation.ExportMade = true;
			ProcessExport(exportInformation, surface);
			// Cleanup imageFile if we created it here, so less tmp-files are generated and left
			if (createdFile) {
				ImageOutput.DeleteNamedTmpFile(imageFile);
			}
			return exportInformation;
		}
Пример #18
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			// Make sure we collect the garbage before opening the screenshot
			GC.Collect();
			GC.WaitForPendingFinalizers();

			bool modified = surface.Modified;
			if (editor == null) {
				if (editorConfiguration.ReuseEditor) {
					foreach(IImageEditor openedEditor in ImageEditorForm.Editors) {
						if (!openedEditor.Surface.Modified) {
							openedEditor.Surface = surface;
							exportInformation.ExportMade = true;
							break;
						}
					}
				}
				if (!exportInformation.ExportMade) {
					try {
						ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??

						if (!string.IsNullOrEmpty(captureDetails.Filename)) {
							editorForm.SetImagePath(captureDetails.Filename);
						}
						editorForm.Show();
						editorForm.Activate();
						LOG.Debug("Finished opening Editor");
						exportInformation.ExportMade = true;
					} catch (Exception e) {
						LOG.Error(e);
						exportInformation.ErrorMessage = e.Message;
					}
				}
			} else {
				try {
					using (Image image = surface.GetImageForExport()) {
						editor.Surface.AddImageContainer(image, 10, 10);
					}
					exportInformation.ExportMade = true;
				} catch (Exception e) {
					LOG.Error(e);
					exportInformation.ErrorMessage = e.Message;
				}
			}
			ProcessExport(exportInformation, surface);
			// Workaround for the modified flag when using the editor.
			surface.Modified = modified;
			return exportInformation;
		}
Пример #19
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			string tmpFile = captureDetails.Filename;
			if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
				tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
			}
			if (documentCaption != null) {
				try {
					WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
					exportInformation.ExportMade = true;
				} catch (Exception) {
					try {
						WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
						exportInformation.ExportMade = true;
					} catch (Exception ex) {
						LOG.Error(ex);
						// TODO: Change to general logic in ProcessExport
						surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetFormattedString("destination_exportfailed", Description));
					}
				}
			} else {
				if (!manuallyInitiated) {
					List<string> documents = WordExporter.GetWordDocuments();
					if (documents != null && documents.Count > 0) {
						List<IDestination> destinations = new List<IDestination>();
						destinations.Add(new WordDestination());
						foreach (string document in documents) {
							destinations.Add(new WordDestination(document));
						}
						// Return the ExportInformation from the picker without processing, as this indirectly comes from us self
						return ShowPickerMenu(false, surface, captureDetails, destinations);
					}
				}
				try {
					WordExporter.InsertIntoNewDocument(tmpFile, null, null);
					exportInformation.ExportMade = true;
				} catch(Exception) {
					// Retry once, just in case
					try {
						WordExporter.InsertIntoNewDocument(tmpFile, null, null);
						exportInformation.ExportMade = true;
					} catch (Exception ex) {
						LOG.Error(ex);
						// TODO: Change to general logic in ProcessExport
						surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetFormattedString("destination_exportfailed", Description));
					}
				}
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #20
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);

			if (page == null) {
				try {
					exportInformation.ExportMade = OneNoteExporter.ExportToNewPage(surface);
				} catch(Exception ex) {
					exportInformation.ErrorMessage = ex.Message;
					LOG.Error(ex);
				}
			} else {
				try {
					exportInformation.ExportMade = OneNoteExporter.ExportToPage(surface, page);
				} catch(Exception ex) {
					exportInformation.ErrorMessage = ex.Message;
					LOG.Error(ex);
				}
			}
			return exportInformation;
		}
Пример #21
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			string tmpFile = captureDetails.Filename;
			Size imageSize = Size.Empty;
			if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
				tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
				imageSize = surface.Image.Size;
			}
			if (presentationName != null) {
				exportInformation.ExportMade = PowerpointExporter.ExportToPresentation(presentationName, tmpFile, imageSize, captureDetails.Title);
			} else {
				if (!manuallyInitiated) {
					List<string> presentations = PowerpointExporter.GetPowerpointPresentations();
					if (presentations != null && presentations.Count > 0) {
						List<IDestination> destinations = new List<IDestination>();
						destinations.Add(new PowerpointDestination());
						foreach (string presentation in presentations) {
							destinations.Add(new PowerpointDestination(presentation));
						}
						// Return the ExportInformation from the picker without processing, as this indirectly comes from us self
						return ShowPickerMenu(false, surface, captureDetails, destinations);
					}
				} else if (!exportInformation.ExportMade) {
					exportInformation.ExportMade = PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
				}
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #22
0
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(Designation, Description);
			MapiMailMessage.SendImage(surface, captureDetails);
			exportInformation.ExportMade = true;
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}
Пример #23
0
		/// <summary>
		/// Export the capture to outlook
		/// </summary>
		/// <param name="manuallyInitiated"></param>
		/// <param name="surface"></param>
		/// <param name="captureDetails"></param>
		/// <returns></returns>
		public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
			ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
			// Outlook logic
			string tmpFile = captureDetails.Filename;
			if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
				tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
			} else {
				LOG.InfoFormat("Using already available file: {0}", tmpFile);
			}

			// Create a attachment name for the image
			string attachmentName = captureDetails.Title;
			if (!string.IsNullOrEmpty(attachmentName)) {
				attachmentName = attachmentName.Trim();
			}
			// Set default if non is set
			if (string.IsNullOrEmpty(attachmentName)) {
				attachmentName = "Greenshot Capture";
			}
			// Make sure it's "clean" so it doesn't corrupt the header
			attachmentName = Regex.Replace(attachmentName, @"[^\x20\d\w]", "");

			if (outlookInspectorCaption != null) {
				OutlookEmailExporter.ExportToInspector(outlookInspectorCaption, tmpFile, attachmentName);
				exportInformation.ExportMade = true;
			} else {
				if (!manuallyInitiated) {
					IDictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets();
					if (inspectorCaptions != null && inspectorCaptions.Count > 0) {
						List<IDestination> destinations = new List<IDestination>();
						destinations.Add(new OutlookDestination());
						foreach (string inspectorCaption in inspectorCaptions.Keys) {
							destinations.Add(new OutlookDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
						}
						// Return the ExportInformation from the picker without processing, as this indirectly comes from us self
						return ShowPickerMenu(false, surface, captureDetails, destinations);
					}
				} else {
					exportInformation.ExportMade = OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, FilenameHelper.FillPattern(conf.EmailSubjectPattern, captureDetails, false), attachmentName, conf.EmailTo, conf.EmailCC, conf.EmailBCC, null);
				}
			}
			ProcessExport(exportInformation, surface);
			return exportInformation;
		}