コード例 #1
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);
        }
コード例 #2
0
        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);
        }