Пример #1
0
        /// <summary>
        /// Initiates a hit test on the specified <see cref="Windows.Foundation.Point(double, double)" /> location.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <remarks>
        /// The default <see cref="MapBehavior" /> logic returns only the top-most <see cref="D2DShape" /> from the <see cref="MapShapeLayer" /> that matches the specific behavior requirements;
        /// you can override the default logic and return multiple <see cref="D2DShape" /> instances (e.g. from layers that overlay one another) and the specific <see cref="MapBehavior" /> will
        /// manipulate all of them.
        /// </remarks>
        protected internal override IEnumerable <IMapShape> HitTest(Point location)
        {
            if (this.map == null)
            {
                yield break;
            }

            IMapShape shape = null;

            int layerCount = this.map.Layers.Count;

            for (int i = layerCount - 1; i >= 0; i--)
            {
                var layer = this.map.Layers[i] as MapShapeLayer;
                if (layer == null || !layer.IsToolTipEnabled)
                {
                    continue;
                }

                shape = this.map.HitTest(location, layer);
                if (shape != null)
                {
                    break;
                }
            }

            yield return(shape);
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IMapShape ValueAsMapShape = (IMapShape)value;
            //get individual simple feature from WKT
            string shapeType = ValueAsMapShape.GetType().ToString();

            shapeType = shapeType.Substring(shapeType.LastIndexOf('.') + 1).ToUpper();
            // render according to simple feature type
            switch (shapeType)
            {
            case "MAPPOINT":
            {
                return(GetPosition(ValueAsMapShape as MapPoint));

                break;
            }

            case "MAPLINE":
            {
                return(GetLine(ValueAsMapShape as MapLine));

                break;
            }

            case "MAPPOLYGON":
            {
                return(GetPolygon(ValueAsMapShape as UcbManagementInformation.Models.MapPolygon));

                break;
            }

            default:
                return(null);
            }
        }
Пример #3
0
        internal D2DShape FindShapeForModel(IMapShape model)
        {
            var layer = this.GetLayerForShape(model);

            if (layer != null)
            {
                return(layer.GetShapeForModel(model));
            }

            return(null);
        }
Пример #4
0
        /// <summary>
        /// Gets the <see cref="D2DShapeStyle" /> instance that defines the appearance of the specified <see cref="IMapShape" /> instance.
        /// </summary>
        /// <param name="shape">The <see cref="IMapShape" /> instance for which the style is to be retrieved.</param>
        protected internal override D2DShapeStyle GetShapeStyle(IMapShape shape)
        {
            var range = this.GetRangeForShape(shape);

            if (range != null)
            {
                return(range.Style);
            }

            return(null);
        }
Пример #5
0
        internal D2DShape GetShapeForModel(IMapShape model)
        {
            D2DShape shape;

            if (this.modelToVisualTable.TryGetValue(model, out shape))
            {
                return(shape);
            }

            return(null);
        }
Пример #6
0
        private double GetPopulationDensity(IMapShape shape)
        {
            var population = int.Parse(shape.GetAttribute("POP_CNTRY").ToString());

            if (population < 0)
            {
                return(0);
            }
            var area    = double.Parse(shape.GetAttribute("SQKM").ToString());
            var density = population / area;

            return(density);
        }
Пример #7
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);
        }
Пример #8
0
        /// <summary>
        /// Gets the <see cref="ColorRange"/> instance where the specified shape falls.
        /// </summary>
        public ColorRange GetRangeForShape(IMapShape shape)
        {
            if (shape == null)
            {
                throw new ArgumentNullException();
            }

            ColorRange range;

            if (this.colorRangesByColorShape.TryGetValue((shape as MapShapeModel).UniqueId, out range))
            {
                return(range);
            }

            return(null);
        }
Пример #9
0
        /// <summary>
        /// Gets the <see cref="MapShapeLayer"/> that the <see cref="IMapShape"/> instance specified as parameter belongs to.
        /// </summary>
        /// <param name="shape">The <see cref="IMapShape"/> instance.</param>
        public MapShapeLayer GetLayerForShape(IMapShape shape)
        {
            if (!this.IsTemplateApplied)
            {
                return(null);
            }

            foreach (var layer in this.layers)
            {
                var shapeLayer = layer as MapShapeLayer;
                if (shapeLayer != null && shapeLayer.ContainsShape(shape))
                {
                    return(shapeLayer);
                }
            }

            return(null);
        }
Пример #10
0
 /// <summary>
 /// Provides an extension point for inheritors to perform additional logic when a <see cref="IMapShape"/> is associated with a valid <see cref="ColorRange"/>.
 /// </summary>
 protected virtual void OnShapeAssociated(IMapShape shape, ColorRange range)
 {
 }
Пример #11
0
 internal bool ContainsShape(IMapShape model)
 {
     return(this.modelToVisualTable.ContainsKey(model));
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapShapeAutomationPeer"/> class.
 /// </summary>
 /// <param name="layerPeer">The parent shape layer.</param>
 /// <param name="shapeModel">The underlying shape model.</param>
 public MapShapeAutomationPeer(MapShapeLayerAutomationPeer layerPeer, IMapShape shapeModel) : base()
 {
     this.LayerPeer  = layerPeer;
     this.ShapeModel = shapeModel;
 }
Пример #13
0
 /// <summary>
 /// Gets the <see cref="D2DShapeStyle"/> instance that defines the appearance of the specified <see cref="IMapShape"/> instance.
 /// </summary>
 /// <param name="shape">The <see cref="IMapShape"/> instance for which the style is to be retrieved.</param>
 protected internal abstract D2DShapeStyle GetShapeStyle(IMapShape shape);
        protected override void OnShapeAssociated(IMapShape shape, ColorRange range)
        {
            base.OnShapeAssociated(shape, range);

            shape.SetAttribute("RANGE", range);
        }