private void OpenInGoogleEarth(Document document, WaypointAttribute? colorCodingAttribute, WaypointAttribute? secondaryColorCodingAttribute, ColorRangeProperties colorRangeProperties) { if (document == null) throw new ArgumentNullException("document"); // set default values if (!colorCodingAttribute.HasValue) colorCodingAttribute = SelectedColorCodingAttribute; if (colorRangeProperties == null) colorRangeProperties = GetCurrentColorRangeProperties(); using (var kmlPropertySelector = new KmlPropertySelectorDialog(ApplicationSettings.ExportKmlProperties) { DialogTitle = Strings.OpenInGoogleEarth }) { var result = kmlPropertySelector.ShowDialog(); if (result == DialogResult.OK) { BeginWork(); try { ApplicationSettings.ExportKmlProperties = kmlPropertySelector.Properties; using (var stream = new MemoryStream()) { CreateKmz(document, stream, kmlPropertySelector.Properties, colorCodingAttribute.Value, secondaryColorCodingAttribute, colorRangeProperties); GoogleEarthUtil.OpenInGoogleEarth(stream); stream.Close(); } EndWork(); } catch (Exception ex) { EndWork(); Util.ShowExceptionMessageBox(Strings.Error_GoogleEarthNotInstalledMessage, ex, Strings.Error_GoogleEarthNotInstalledTitle); } } } }
private void ExportKmz() { using (var kmlPropertySelector = new KmlPropertySelectorDialog(ApplicationSettings.ExportKmlProperties)) { var result = kmlPropertySelector.ShowDialog(); if (result == DialogResult.OK) { var sfd = new SaveFileDialog { Title = Strings.ExportKMZTitle, Filter = Strings.FileFilter_KmzFiles, FileName = ((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 { BeginWork(); ApplicationSettings.ExportKmlProperties = kmlPropertySelector.Properties; using (var stream = new FileStream(sfd.FileName, FileMode.Create)) { CreateKmz(canvas.Document, stream, kmlPropertySelector.Properties, SelectedColorCodingAttribute, SelectedSecondaryColorCodingAttribute, GetCurrentColorRangeProperties()); stream.Close(); } ApplicationSettings.InitialFolders[ApplicationSettings.FileDialogType.ExportFile] = Path.GetDirectoryName(sfd.FileName); EndWork(); } catch (Exception ex) { EndWork(); Util.ShowExceptionMessageBox(ex, Strings.Error_ExportRoute); } } sfd.Dispose(); } } }