Пример #1
0
        void c_TreeViewSelectionChanged(object sender, KmlTreeViewControllerSelectionChangedEventArgs e)
        {
            selectedKMLFeatureTreeViewItem = e.kmlFeatureTreeViewItem;
            Feature feature = selectedKMLFeatureTreeViewItem.Feature;

            NameTextBox.Text        = feature.Name;
            DescriptionTextBox.Text = feature.Description != null ? feature.Description.Text : "";
            kmlFeatureSchemaListViewController.SetFeature(feature);
        }
Пример #2
0
        void c_TreeViewSelectionChanged(object sender, KmlTreeViewControllerSelectionChangedEventArgs e)
        {
            selectedKMLFeatureTreeViewItem = e.kmlFeatureTreeViewItem;
            Feature feature = selectedKMLFeatureTreeViewItem.Feature;

            NameTextBox.Text = feature.Name;
            DescriptionTextBox.Text = feature.Description != null ? feature.Description.Text : "";
            kmlFeatureSchemaListViewController.SetFeature(feature);
        }
        TreeViewItem ProcessPlacemark(Placemark placemark)
        {
            string name = placemark.Name;
            StackPanel pan = new StackPanel();
            pan.Orientation = System.Windows.Controls.Orientation.Horizontal;

            Style style = FindStyleByStyleURL(placemark.StyleUrl.OriginalString);

            if (placemark.Geometry is 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 = 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;
        }
        TreeViewItem ProcessFolder(Folder folder)
        {
            string name = folder.Name;
            KMLFeatureTreeViewItem item = new KMLFeatureTreeViewItem()
            {
                Header = name,
                Feature = folder
            };

            IEnumerable<Feature> features = folder.Features;
            features.ToList().ForEach(feature =>
            {
                TreeViewItem node = ProcessFeature(feature);
                if (node != null)
                {
                    item.Items.Add(node);
                }
            });

            return item;
        }
        TreeViewItem ProcessDocument(Document document)
        {
            string name = document.Name;
            KMLFeatureTreeViewItem item = new KMLFeatureTreeViewItem()
            {
                Header = name,
                Feature = document
            };

            IEnumerable<Feature> features = document.Features;
            features.ToList().ForEach(feature => {
                TreeViewItem node = ProcessFeature(feature);
                if (node != null)
                {
                    item.Items.Add(node);
                }
            });

            return item;
        }