private void ApplyShapeLabel(D2DShape shape, MapShapeStyleContext selectorContext) { if (shape.Label == null) { return; } D2DTextStyle labelStyle = this.labelStyleCache; if (selectorContext != null && selectorContext.LabelStyle != null) { labelStyle = selectorContext.LabelStyle; } if (labelStyle != null) { shape.Label.Style = labelStyle; } this.ApplyShapeLabelStrategy(shape); }
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); }