Esempio n. 1
0
        public MainPage()
        {
            InitializeComponent();

            MapView mapView = new MapView();

            Content = mapView;

            mapView.MapUnit = GeographyUnit.DecimalDegree;
            GeoImage        textureSource = new GeoImage(typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("TextureDemo.Images.texture.png"));
            GeoTextureBrush textureBrush  = new GeoTextureBrush(textureSource);

            InMemoryFeatureLayer layer = new InMemoryFeatureLayer();

            layer.InternalFeatures.Add(new Feature(new EllipseShape(new PointShape(0, 0), 60)));
            layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County2;
            layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.Advanced.FillCustomBrush = textureBrush;
            layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(layer);
            mapView.Overlays.Add(layerOverlay);

            mapView.CurrentExtent = new RectangleShape(-180, 90, 180, -90);
        }
Esempio n. 2
0
        private void ChangeColorFromColorPicker(Control colorPicker, EventArgs e)
        {
            if (colorPicker is SolidColorPicker)
            {
                SolidColorPicker solidColorPicker = (SolidColorPicker)colorPicker;
                Color            newColor         = solidColorPicker.SelectedColor;
                GeoColor         newGeoColor      = GeoColor2MediaColorConverter.ConvertBack(newColor);

                hatchColorPicker.SyncBaseColor(DrawingColorToMediaColorConverter.ConvertBack(newColor));
                gradientPicker.SyncBaseColor(DrawingColorToMediaColorConverter.ConvertBack(newColor));

                SelectedBrush = new GeoSolidBrush(newGeoColor);
            }
            else if (colorPicker is HatchPicker)
            {
                HatchPicker hatchPicker = (HatchPicker)colorPicker;
                System.Drawing.Drawing2D.HatchStyle drawingHatchStyle = hatchPicker.SelectedHatchStyle;
                GeoHatchStyle geoHatchStyle = GeoHatchStyle2DrawingHatchStyle.ConvertBack(drawingHatchStyle);

                //solidColorPicker.SyncBaseColor(hatchPicker.ForegroundColor);
                gradientPicker.SyncBaseColor(hatchPicker.ForegroundColor);

                SelectedBrush = new GeoHatchBrush(geoHatchStyle, GeoColor2DrawingColorConverter.ConvertBack(hatchPicker.ForegroundColor)
                                                  , GeoColor2DrawingColorConverter.ConvertBack(hatchColorPicker.BackgroundColor));
            }
            else if (colorPicker is TexturePicker)
            {
                PropertyChangedEventArgs args          = (PropertyChangedEventArgs)e;
                TexturePicker            texturePicker = (TexturePicker)colorPicker;
                if (args.PropertyName == "SelectedBrush")
                {
                    ImageBrush mediaBrush = texturePicker.SelectedBrush as ImageBrush;
                    if (mediaBrush != null)
                    {
                        BitmapImage imageSource = (BitmapImage)mediaBrush.ImageSource;
                        if (imageSource != null)
                        {
                            SelectedBrush = new GeoTextureBrush(new GeoImage(imageSource.UriSource.LocalPath));
                        }
                    }
                }
            }
            else if (colorPicker is DrawingLinearGradientBrushPicker)
            {
                DrawingLinearGradientBrushPicker linearPicker = (DrawingLinearGradientBrushPicker)colorPicker;
                LinearGradientBrushEntity        brushEntity  = linearPicker.SelectedBrush;

                solidColorPicker.SyncBaseColor(brushEntity.StartColor);
                hatchColorPicker.SyncBaseColor(brushEntity.StartColor);

                SelectedBrush = new GeoLinearGradientBrush(GeoColor2DrawingColorConverter.ConvertBack(brushEntity.StartColor),
                                                           GeoColor2DrawingColorConverter.ConvertBack(brushEntity.EndColor),
                                                           brushEntity.Angle);
            }
        }
        public static ImageBrush Convert(GeoTextureBrush geoTextureBrush)
        {
            string fileName = geoTextureBrush.GeoImage.GetPathFilename();

            ImageBrush imageBrush = new ImageBrush();

            if (File.Exists(fileName))
            {
                imageBrush.ImageSource = new BitmapImage(new Uri("file://" + fileName));
                imageBrush.SetValue(Canvas.TagProperty, fileName);
                return(imageBrush);
            }
            else
            {
                return(imageBrush);
            }
        }
Esempio n. 4
0
        private void SetSelectedBrush(GeoBrush geoBrush)
        {
            if (!isTemplateApplied)
            {
                return;
            }

            if (geoBrush is GeoSolidBrush)
            {
                SelectTabItem(solidColorBrushTabItem);
                Color selectedMediaColor = GeoColor2MediaColorConverter.Convert(((GeoSolidBrush)geoBrush).Color);
                if (solidColorPicker.SelectedColor != selectedMediaColor)
                {
                    solidColorPicker.SelectedColor = selectedMediaColor;
                }
            }
            else if (geoBrush is GeoLinearGradientBrush)
            {
                SelectTabItem(gradientTabItem);
                GeoLinearGradientBrush geoGradientBrush  = (GeoLinearGradientBrush)geoBrush;
                System.Drawing.Color   drawingStartColor = GeoColor2DrawingColorConverter.Convert(geoGradientBrush.StartColor);
                System.Drawing.Color   drawingEndColor   = GeoColor2DrawingColorConverter.Convert(geoGradientBrush.EndColor);

                if (gradientPicker.SelectedBrush.StartColor != drawingStartColor ||
                    gradientPicker.SelectedBrush.EndColor != drawingEndColor ||
                    gradientPicker.SelectedBrush.Angle - geoGradientBrush.DirectionAngle > 1)
                {
                    gradientPicker.SelectedBrush = new LinearGradientBrushEntity
                    {
                        StartColor = drawingStartColor,
                        EndColor   = drawingEndColor,
                        Angle      = (int)geoGradientBrush.DirectionAngle
                    }
                }
                ;
            }
            else if (geoBrush is GeoHatchBrush)
            {
                GeoHatchBrush geoHatchBrush = (GeoHatchBrush)geoBrush;
                SelectTabItem(hatchBrushTabItem);
                System.Drawing.Drawing2D.HatchStyle drawingHatchStyle = GeoHatchStyle2DrawingHatchStyle.Convert(geoHatchBrush.HatchStyle);
                System.Drawing.Color drawingBackgroundColor           = GeoColor2DrawingColorConverter.Convert(geoHatchBrush.BackgroundColor);
                System.Drawing.Color drawingForegroundColor           = GeoColor2DrawingColorConverter.Convert(geoHatchBrush.ForegroundColor);

                if (hatchColorPicker.SelectedHatchStyle != drawingHatchStyle ||
                    drawingBackgroundColor != hatchColorPicker.BackgroundColor ||
                    drawingForegroundColor != hatchColorPicker.ForegroundColor)
                {
                    hatchColorPicker.BackgroundColor    = drawingBackgroundColor;
                    hatchColorPicker.ForegroundColor    = drawingForegroundColor;
                    hatchColorPicker.SelectedHatchStyle = drawingHatchStyle;
                }
            }
            else if (geoBrush is GeoTextureBrush)
            {
                SelectTabItem(textureTabItem);
                textureTabItem.IsSelected = true;
                GeoTextureBrush geoTextureBrush = (GeoTextureBrush)geoBrush;
                if (textureColorPicker.SelectedBrush == null || !textureColorPicker.SelectedBrush.GetValue(Canvas.TagProperty).Equals(geoTextureBrush.GeoImage.GetPathFilename()))
                {
                    textureColorPicker.SelectedBrush = GeoTextureBrushToImageBrushConverter.Convert(geoTextureBrush);
                }
            }
        }