private void OpenMenu_Click(object sender, RoutedEventArgs e) { // Create an instance of the open file dialog box. OpenFileDialog openFileDialog = new OpenFileDialog(); // Set filter options and filter index. openFileDialog.Filter = "Google Earth (.kml .kmz)|*.kml;*.kmz"; openFileDialog.FilterIndex = 1; openFileDialog.Multiselect = true; // Call the ShowDialog method to show the dialog box. bool?userClickedOK = openFileDialog.ShowDialog(); // Process input if the user clicked OK. if (userClickedOK == true) { KmlFile kmlFile = KmlFileHelper.OpenFile(openFileDialog.FileName); FerromapasKmlHelper.AddFerromapasSchemaIfNotExists(kmlFile); String fileName = ((kmlFile.Root as Kml).Feature as Document).Name; this.Title = fileName; this.kmlFile = kmlFile; kmlTreeView.kmlFile = kmlFile; this.fileName = openFileDialog.FileName; } }
private void SaveAsMenu_Click(object sender, RoutedEventArgs e) { // Create an instance of the open file dialog box. SaveFileDialog saveFileDialog = new SaveFileDialog(); // Set filter options and filter index. saveFileDialog.Filter = "Google Earth (.kml .kmz)|*.kml;*.kmz"; saveFileDialog.FilterIndex = 1; // Call the ShowDialog method to show the dialog box. bool?userClickedOK = saveFileDialog.ShowDialog(); // Process input if the user clicked OK. if (userClickedOK == true) { KmlFileHelper.SaveFile(kmlFile, saveFileDialog.FileName); fileName = saveFileDialog.FileName; } }
private void SaveMenu_Click(object sender, RoutedEventArgs e) { KmlFileHelper.SaveFile(kmlFile, fileName); }
TreeViewItem ProcessPlacemark(Placemark placemark) { string name = placemark.Name; StackPanel pan = new StackPanel(); pan.Orientation = System.Windows.Controls.Orientation.Horizontal; SharpKml.Dom.Style style = KmlFileHelper.FindStyleByStyleURL(_kmlFile, placemark.StyleUrl.OriginalString); if (placemark.Geometry is SharpKml.Dom.Point) { Uri uri = null; if (style != null && style.Icon != null && style.Icon.Icon != null && style.Icon.Icon.Href != null) { uri = style.Icon.Icon.Href; } Image image = new Image(); image.Height = 16; image.Source = _imagesFromUri.FindImageByUri(uri); pan.Children.Add(image); } else if (placemark.Geometry is LineString) { GeometryGroup Lines = new GeometryGroup(); Color32 styleColor = new Color32(); if (style != null && style.Line != null && style.Line.Color != null) { styleColor = (Color32)style.Line.Color; } // Line LineGeometry line = new LineGeometry(); line.StartPoint = new System.Windows.Point(0, 5); line.EndPoint = new System.Windows.Point(10, 5); Lines.Children.Add(line); GeometryDrawing MyGeometryDrawing = new GeometryDrawing(); MyGeometryDrawing.Geometry = Lines; MyGeometryDrawing.Brush = new SolidColorBrush(Color.FromArgb(styleColor.Alpha, styleColor.Red, styleColor.Green, styleColor.Blue)); MyGeometryDrawing.Pen = new Pen(MyGeometryDrawing.Brush, 1); DrawingImage drawingImage = new DrawingImage(MyGeometryDrawing); drawingImage.Freeze(); Image image = new Image(); image.Height = 16; image.Width = 16; image.Source = drawingImage; pan.Children.Add(image); } TextBlock textBlock = new TextBlock(); textBlock.Text = name; textBlock.Margin = new System.Windows.Thickness(4, 0, 0, 0); pan.Children.Add(textBlock); KMLFeatureTreeViewItem item = new KMLFeatureTreeViewItem() { Header = pan, Feature = placemark }; return(item); }