Пример #1
0
        private void UpdateStyleField(ref D2DShapeStyle field, D2DShapeStyle newValue)
        {
            field = newValue;
            if (field != null)
            {
                // TODO: This is not optimal. Instead of cloning, keep all D2DFactory-dependent resources on a per D2DCanvas instance basis.
                field = field.Clone();
            }

            this.EvaluateShapeStyles();
        }
Пример #2
0
        protected override D2DShapeStyle GetShapeStyle(IMapShape shape)
        {
            var populationDensity = GetPopulationDensity(shape);
            var color             = GetColor(populationDensity);
            var style             = new D2DShapeStyle
            {
                Fill = new D2DSolidColorBrush {
                    Color = color
                },
                StrokeThickness = 0
            };

            return(style);
        }
Пример #3
0
        private void ApplyShapeStyle(D2DShape shape)
        {
            (shape.Model as IMapShape).AttributeChanged -= this.MapShapeLayer_AttributeChanged;
            (shape.Model as IMapShape).AttributeChanged += this.MapShapeLayer_AttributeChanged;

            D2DShapeStyle normalStyle      = this.normalStyleCache;
            D2DShapeStyle pointerOverStyle = this.pointerOverStyleCache;
            D2DShapeStyle selectedStyle    = this.selectedStyleCache;

            if (this.colorizerCache != null && this.colorizerCache.IsProperlyInitialized)
            {
                var style = this.colorizerCache.GetShapeStyle(shape.Model as IMapShape);
                if (style != null)
                {
                    if (normalStyle != null)
                    {
                        if (style.Stroke == null)
                        {
                            style.Stroke = normalStyle.Stroke;
                        }
                        if (style.Foreground == null)
                        {
                            style.Foreground = normalStyle.Foreground;
                        }
                        if (style.StrokeThickness == 1)
                        {
                            style.StrokeThickness = normalStyle.StrokeThickness;
                        }
                    }

                    normalStyle = style;
                }
            }

            MapShapeStyleContext selectorContext = null;

            if (this.shapeStyleSelectorCache != null)
            {
                selectorContext = new MapShapeStyleContext()
                {
                    Shape   = shape.Model as IMapShape,
                    UIState = shape.UIState
                };
                this.shapeStyleSelectorCache.SelectStyle(selectorContext, this);
                if (selectorContext.NormalStyle != null)
                {
                    normalStyle = selectorContext.NormalStyle;
                }
                if (selectorContext.PointerOverStyle != null)
                {
                    pointerOverStyle = selectorContext.PointerOverStyle;
                }
                if (selectorContext.SelectedStyle != null)
                {
                    selectedStyle = selectorContext.SelectedStyle;
                }
            }

            // TODO: We may run into a D2DFactory exception if the resources provided by the user are shared across different Map instances
            // TODO: This requires some refactoring, which will be handled after the Q3 release
            shape.NormalStyle      = normalStyle;
            shape.PointerOverStyle = pointerOverStyle;
            shape.SelectedStyle    = selectedStyle;

            this.ApplyShapeLabel(shape, selectorContext);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorRange"/> class.
 /// </summary>
 public ColorRange()
 {
     this.style = new D2DShapeStyle();
 }