本文整理汇总了C#中ISurface.SendMessageEvent方法的典型用法代码示例。如果您正苦于以下问题:C# ISurface.SendMessageEvent方法的具体用法?C# ISurface.SendMessageEvent怎么用?C# ISurface.SendMessageEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISurface
的用法示例。
在下文中一共展示了ISurface.SendMessageEvent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportCapture
public override bool ExportCapture(ISurface surface, ICaptureDetails captureDetails)
{
using (Image image = surface.GetImageForExport()) {
bool uploaded = plugin.Upload(captureDetails, image);
if (uploaded) {
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to Dropbox");
surface.Modified = false;
}
return uploaded;
}
}
示例2: ExportCapture
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;
}
示例3: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
bool outputMade = false;
string pattern = "${title}";
if (string.IsNullOrEmpty(pattern))
{
pattern = "greenshot ${capturetime}";
}
string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
string fullPath = Path.Combine(filepath, filename);
// 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
using (Image image = surface.GetImageForExport())
{
try
{
// TODO: For now we overwrite, but this should be fixed some time
ImageOutput.Save(image, fullPath, true);
outputMade = true;
}
catch (Exception e)
{
LOG.Error("Error saving screenshot!", e);
// Show the problem
MessageBox.Show(Language.GetString(LangKey.error_save), Language.GetString(LangKey.error));
// when save failed we present a SaveWithDialog
fullPath = ImageOutput.SaveWithDialog(image, captureDetails);
outputMade = (fullPath != null);
}
}
// Don't overwite filename if no output is made
if (outputMade)
{
surface.LastSaveFullPath = fullPath;
surface.Modified = false;
captureDetails.Filename = fullPath;
surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, Language.GetFormattedString(LangKey.editor_imagesaved, surface.LastSaveFullPath));
}
else
{
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "");
}
return outputMade;
}
示例4: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
try {
using (Image image = surface.GetImageForExport()) {
ClipboardHelper.SetClipboardData(image);
surface.Modified = false;
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetString(LangKey.editor_storedtoclipboard));
return true;
} catch (Exception) {
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString(LangKey.editor_clipboardfailed));
}
return false;
}
示例5: ProcessExport
/// <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);
}
}
示例6: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
string savedTo = null;
using (Image image = surface.GetImageForExport()) {
// Bug #2918756 don't overwrite path if SaveWithDialog returns null!
savedTo = ImageOutput.SaveWithDialog(image, captureDetails);
if (savedTo != null) {
surface.Modified = false;
surface.LastSaveFullPath = savedTo;
captureDetails.Filename = savedTo;
surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, Language.GetFormattedString(LangKey.editor_imagesaved, surface.LastSaveFullPath));
}
}
return savedTo != null;
}
示例7: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
using (Image image = surface.GetImageForExport()) {
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
}
}
if (documentCaption != null) {
WordExporter.InsertIntoExistingDocument(documentCaption, tmpFile);
} 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));
}
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
PickerDestination.ShowMenuAtCursor(menu);
return false;
}
}
WordExporter.InsertIntoNewDocument(tmpFile);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false;
return true;
}
示例8: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
string tmpFile = captureDetails.Filename;
Size imageSize = Size.Empty;
if (tmpFile == null || surface.Modified) {
using (Image image = surface.GetImageForExport()) {
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
imageSize = image.Size;
}
}
if (presentationName != null) {
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));
}
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
PickerDestination.ShowMenuAtCursor(menu);
return false;
}
}
PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false;
return true;
}
示例9: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
if (editor == null) {
// Make sure we collect the garbage before opening the screenshot
GC.Collect();
GC.WaitForPendingFinalizers();
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");
return true;
} catch (Exception e) {
LOG.Error(e);
}
} else {
using (Bitmap image = (Bitmap)surface.GetImageForExport()) {
editor.Surface.AddBitmapContainer(image, 10, 10);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
}
return false;
}
示例10: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
if (!isOutlookUsed) {
using (Image image = surface.GetImageForExport()) {
MapiMailMessage.SendImage(image, captureDetails);
surface.Modified = false;
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, "Exported to " + mapiClient);
}
return true;
}
// Outlook logic
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
using (Image image = surface.GetImageForExport()) {
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
}
} 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);
} else {
if (!manuallyInitiated) {
Dictionary<string, OlObjectClass> inspectorCaptions = OutlookEmailExporter.RetrievePossibleTargets(conf.OutlookAllowExportInMeetings);
if (inspectorCaptions != null && inspectorCaptions.Count > 0) {
List<IDestination> destinations = new List<IDestination>();
destinations.Add(new EmailDestination());
foreach (string inspectorCaption in inspectorCaptions.Keys) {
destinations.Add(new EmailDestination(inspectorCaption, inspectorCaptions[inspectorCaption]));
}
ContextMenuStrip menu = PickerDestination.CreatePickerMenu(false, surface, captureDetails, destinations);
PickerDestination.ShowMenuAtCursor(menu);
return false;
}
}
OutlookEmailExporter.ExportToOutlook(conf.OutlookEmailFormat, tmpFile, captureDetails.Title, attachmentName);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false;
// Don't know how to handle a cancel in the email
return true;
}
示例11: ExportCapture
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;
}
示例12: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
PrinterSettings printerSettings = null;
using (Image image = surface.GetImageForExport()) {
if (!string.IsNullOrEmpty(printerName)) {
printerSettings = new PrintHelper(image, captureDetails).PrintTo(printerName);
} else if (!manuallyInitiated) {
PrinterSettings settings = new PrinterSettings();
printerSettings = new PrintHelper(image, captureDetails).PrintTo(settings.PrinterName);
} else {
printerSettings = new PrintHelper(image, captureDetails).PrintWithDialog();
}
if (printerSettings != null) {
surface.Modified = false;
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.editor_senttoprinter, printerSettings.PrinterName));
}
}
return printerSettings != null;
}
示例13: ExportCapture
public override bool ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
{
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified) {
using (Image image = surface.GetImageForExport()) {
tmpFile = ImageOutput.SaveNamedTmpFile(image, captureDetails, conf.OutputFileFormat, conf.OutputFileJpegQuality, conf.OutputFileReduceColors);
}
}
if (workbookName != null) {
ExcelExporter.InsertIntoExistingWorkbook(workbookName, tmpFile);
} else {
ExcelExporter.InsertIntoNewWorkbook(tmpFile);
}
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString(LangKey.exported_to, Description));
surface.Modified = false;
return true;
}