public ImageExporter(Document document, SessionCollection sessions, Stream outputStream) { this.document = document; this.sessions = sessions; OutputStream = outputStream; // set default values for non-mandatory fields Properties = new ImageExporterProperties {SessionSettings = new SessionSettings()}; }
public ImageExporter(Document document, SessionCollection sessions, Stream outputStream) { this.document = document; this.sessions = sessions; OutputStream = outputStream; // set default values for non-mandatory fields Properties = new ImageExporterProperties { SessionSettings = new SessionSettings() }; }
private void CreateKmz(IEnumerable<string> documentFileNames, Stream stream, KmlProperties kmlProperties) { var imageExporterProperties = new ImageExporterProperties() { ColorCodingAttribute = SelectedColorCodingAttribute, SecondaryColorCodingAttribute = SelectedSecondaryColorCodingAttribute, ColorRangeProperties = GetCurrentColorRangeProperties(), SessionSettings = new SessionSettings() }; var kmlExporter = new KmlExporter( documentFileNames, imageExporterProperties, stream) { KmlProperties = kmlProperties }; kmlExporter.ExportKmz(CommonUtil.GetTempFileName() + @"\"); }
private void CreateKmz(Document document, Stream stream, KmlProperties kmlProperties, WaypointAttribute colorCodingAttribute, WaypointAttribute? secondaryColorCodingAttribute, ColorRangeProperties colorRangeProperties) { var imageExporterProperties = new ImageExporterProperties() { ColorCodingAttribute = colorCodingAttribute, SecondaryColorCodingAttribute = secondaryColorCodingAttribute, ColorRangeProperties = colorRangeProperties }; var imageExporter = new ImageExporter(document) { Properties = imageExporterProperties }; var kmlExporter = new KmlExporter(document, imageExporter, stream) { KmlProperties = kmlProperties }; kmlExporter.ExportKmz(CommonUtil.GetTempFileName() + @"\"); }
private void ExportImage() { using (var sfd = new SaveFileDialog { Title = Strings.ExportImageTitle, Filter = (Strings.FileFilter_JpegFiles + "|" + Strings.FileFilter_PngFiles + "|" + Strings.FileFilter_TiffFiles), FileName = (canvas.Document != null && canvas.Document.FileName != null ? Path.GetFileNameWithoutExtension(canvas.Document.FileName) : Path.GetFileNameWithoutExtension(untitledDocumentFileNameProposal)), FilterIndex = 1, AddExtension = true, OverwritePrompt = true }) { if (ApplicationSettings.InitialFolders.ContainsKey(ApplicationSettings.FileDialogType.ExportFile)) { sfd.InitialDirectory = ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportFile]; } if (sfd.ShowDialog() == DialogResult.OK) { try { // TODO: change to saved PercentualImageSize and Quality when dialog is working IMapImageFileExporterDialog selector = null; switch (sfd.FilterIndex) { case 1: // jpeg selector = new JpegPropertySelector { SizeCalculator = canvas.Document.CalculateImageForExportSize, PercentualImageSize = 1, //ApplicationSettings.ExportImagePercentualImageSize, Quality = 0.8 //ApplicationSettings.ExportImageQuality, }; break; case 2: // png selector = new PngPropertySelector { SizeCalculator = canvas.Document.CalculateImageForExportSize, PercentualImageSize = 1, //ApplicationSettings.ExportImagePercentualImageSize }; break; default: // tiff selector = new TiffPropertySelector { SizeCalculator = canvas.Document.CalculateImageForExportSize, PercentualImageSize = 1, //ApplicationSettings.ExportImagePercentualImageSize }; break; } if (selector.ShowPropertyDialog() == DialogResult.OK) { BeginWork(); using (var fs = new FileStream(sfd.FileName, FileMode.Create)) { var imageExporterProperties = new ImageExporterProperties() { EncodingInfo = selector.EncodingInfo, RouteDrawingMode = Document.RouteDrawingMode.Extended, ColorCodingAttribute = SelectedColorCodingAttribute, SecondaryColorCodingAttribute = SelectedSecondaryColorCodingAttribute, PercentualSize = selector.PercentualImageSize, ColorRangeProperties = GetCurrentColorRangeProperties() }; var imageExporter = new ImageExporter(canvas.Document, canvas.SelectedSessions, fs) { Properties = imageExporterProperties }; imageExporter.Export(); fs.Close(); } ApplicationSettings.ExportImagePercentualImageSize = selector.PercentualImageSize; if (selector is JpegPropertySelector) ApplicationSettings.ExportImageQuality = ((JpegPropertySelector)selector).Quality; // ugly! ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportImage] = Path.GetDirectoryName(sfd.FileName); EndWork(); } } catch (Exception ex) { Util.ShowExceptionMessageBox(ex, Strings.Error_ExportImage); } } } }
public KmlExportDocument(string fileName, ImageExporterProperties imageExporterProperties) { this.fileName = fileName; this.imageExporterProperties = imageExporterProperties; this.type = KmlExportDocumentType.File; }
/// <summary> /// Creates an exporter from the specified QuickRoute files. /// </summary> /// <param name="documentFileNames">The file names of the QuickRoute files to export. The map image of the first file in the collection will be used as the map image.</param> /// <param name="imageExporterProperties">The proerties of the exporter used to create the map image</param> /// <param name="outputStream">The stream to export to</param> public KmlExporter(IEnumerable<string> documentFileNames, ImageExporterProperties imageExporterProperties, Stream outputStream) : this() { kmlExportDocuments = new List<KmlExportDocument>(); foreach (var fileName in documentFileNames) { kmlExportDocuments.Add(new KmlExportDocument(fileName, imageExporterProperties)); } this.outputStream = outputStream; }
private MapInfo CreateMapInfoFromControls() { MapInfo mapInfo = new MapInfo(); var selectedMap = map.SelectedValue as MapInfo; if (selectedMap != null) mapInfo.ID = selectedMap.ID; mapInfo.Date = date.Value.ToUniversalTime(); var selectedCategory = category.SelectedItem as Category; if (selectedCategory != null) mapInfo.CategoryID = selectedCategory.ID; mapInfo.Name = name.Text; mapInfo.MapName = mapName.Text; mapInfo.Organiser = organiser.Text; mapInfo.Country = country.Text; mapInfo.Discipline = type.Text; mapInfo.RelayLeg = relayLeg.Text; mapInfo.ResultListUrl = resultListUrl.Text; mapInfo.Comment = comment.Text; mapInfo.MapImageFileExtension = imageFormat.Text; IMapImageFileExporterDialog selector = null; switch (imageFormat.Text) { case "jpg": selector = new JpegPropertySelector { SizeCalculator = document.CalculateImageForExportSize }; break; case "png": default: selector = new PngPropertySelector { SizeCalculator = document.CalculateImageForExportSize }; break; //case "tiff": // selector = new TiffPropertySelector // { // SizeCalculator = document.CalculateImageForExportSize // }; // break; } if (selector.ShowPropertyDialog() == DialogResult.OK) { Application.DoEvents(); // map image using (var ms = new MemoryStream()) { var imageExporterProperties = new ImageExporterProperties() { EncodingInfo = selector.EncodingInfo, RouteDrawingMode = Document.RouteDrawingMode.Extended, ColorCodingAttribute = colorCodingAttribute, SecondaryColorCodingAttribute = secondaryColorCodingAttribute, PercentualSize = selector.PercentualImageSize, ColorRangeProperties = colorRangeProperties }; var imageExporter = new ImageExporter(document, document.Sessions, ms) { Properties = imageExporterProperties }; imageExporter.Export(); mapInfo.MapImageData = ms.ToArray(); } // blank map image using (var ms = new MemoryStream()) { var imageExporterProperties = new ImageExporterProperties() { EncodingInfo = selector.EncodingInfo, RouteDrawingMode = Document.RouteDrawingMode.None, PercentualSize = selector.PercentualImageSize }; var blankImageExporter = new ImageExporter(document, document.Sessions, ms) { Properties = imageExporterProperties }; blankImageExporter.Export(); mapInfo.BlankMapImageData = ms.ToArray(); } return mapInfo; } return null; }