Example #1
0
        public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            base.SetDefaults(surface);
            ExportInformation exportInformation = new ExportInformation(Designation, 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);
        }