/// <summary>
		/// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
		/// </summary>
		/// <param name="legendItemInfo">The legend item info.</param>
		/// <param name="geometryType">Type of the geometry.</param>
		internal LegendItemViewModel(LegendItemInfo legendItemInfo, GeometryType geometryType)
			: this()
		{
			Label = legendItemInfo.Label;
			Symbol = legendItemInfo.Symbol;
			GeometryType = geometryType;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
 /// </summary>
 /// <param name="legendItemInfo">The legend item info.</param>
 /// <param name="geometryType">Type of the geometry.</param>
 internal LegendItemViewModel(LegendItemInfo legendItemInfo, GeometryType geometryType)
     : this()
 {
     Label        = legendItemInfo.Label;
     Symbol       = legendItemInfo.Symbol;
     GeometryType = geometryType;
 }
Ejemplo n.º 3
0
 public void Init(LegendItemInfo item, Drawing.Resources resources, IViewEvents events)
 {
     this.item                = item;
     this.resources           = resources;
     this.events              = events;
     previewView.NeedsDisplay = true;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Queries for the legend infos of a layer.
        /// </summary>
        /// <remarks>
        /// The returned result is encapsulated in a <see cref="LayerLegendInfo" /> object containing one legend item showing the heat map gradient.
        /// </remarks>
        /// <param name="callback">The method to call on completion.</param>
        /// <param name="errorCallback">The method to call in the event of an error.</param>
        public void QueryLegendInfos(Action <LayerLegendInfo> callback, Action <Exception> errorCallback)
        {
            // Create one legend item with a radial brush using the heat map gradient (reversed)

            // Create the UI element
            RadialGradientBrush brush = new RadialGradientBrush()
            {
                Center         = new Point(0.5, 0.5),
                RadiusX        = 0.5,
                RadiusY        = 0.5,
                GradientOrigin = new Point(0.5, 0.5),
                GradientStops  = new GradientStopCollection()
            };

            if (Gradient != null)
            {
                foreach (GradientStop stop in Gradient)
                {
                    brush.GradientStops.Add(new GradientStop()
                    {
                        Color = stop.Color, Offset = 1 - stop.Offset
                    });
                }
            }
            Rectangle rect = new Rectangle()
            {
                Height = 20, Width = 20, Fill = brush
            };

            // Create the imagesource
            ImageSource imageSource;

#if SILVERLIGHT
            imageSource = new WriteableBitmap(rect, null);
#else
            RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(20, 20, 96, 96, PixelFormats.Pbgra32);
            renderTargetBitmap.Render(rect);
            imageSource = renderTargetBitmap;
#endif
            // Create a layerItemInfo array (so enumerable) with one item
            LegendItemInfo legendItemInfo = new LegendItemInfo()
            {
                Label       = ID,
                ImageSource = imageSource
            };
            LegendItemInfo[] legendItemInfos = new LegendItemInfo[] { legendItemInfo };

            // Create the returned layerLegendInfo
            LayerLegendInfo layerLegendInfo = new LayerLegendInfo()
            {
                LegendItemInfos = legendItemInfos
            };

            if (callback != null)
            {
                callback(layerLegendInfo);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
 /// </summary>
 /// <param name="legendItemInfo">The legend item info.</param>
 internal LegendItemViewModel(LegendItemInfo legendItemInfo) : this()
 {
     Label       = legendItemInfo.Label;
     ImageSource = legendItemInfo.ImageSource;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
 /// </summary>
 /// <param name="legendItemInfo">The legend item info.</param>
 internal LegendItemViewModel(LegendItemInfo legendItemInfo)
     : this()
 {
     Label = legendItemInfo.Label;
     ImageSource = legendItemInfo.ImageSource;
 }
Ejemplo n.º 7
0
		/// <summary>
		/// Queries for the legend infos of a layer.
		/// </summary>
		/// <remarks>
		/// The returned result is encapsulated in a <see cref="LayerLegendInfo" /> object containing one legend item showing the heat map gradient.
		/// </remarks>
		/// <param name="callback">The method to call on completion.</param>
		/// <param name="errorCallback">The method to call in the event of an error.</param>
		public void QueryLegendInfos(Action<LayerLegendInfo> callback, Action<Exception> errorCallback)
		{
			// Create one legend item with a radial brush using the heat map gradient (reversed)

			// Create the UI element
			RadialGradientBrush brush = new RadialGradientBrush()
			{
				Center = new Point(0.5, 0.5),
				RadiusX = 0.5,
				RadiusY = 0.5,
				GradientOrigin = new Point(0.5, 0.5),
				GradientStops = new GradientStopCollection()
			};

			if (Gradient != null)
			{
				foreach (GradientStop stop in Gradient)
					brush.GradientStops.Add(new GradientStop() { Color = stop.Color, Offset = 1 - stop.Offset });
			}
			Rectangle rect = new Rectangle() { Height = 20, Width = 20, Fill = brush };

			// Create the imagesource
			ImageSource imageSource;
#if SILVERLIGHT
			imageSource = new WriteableBitmap(rect, null);
#else
			RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(20, 20, 96, 96, PixelFormats.Pbgra32);
			renderTargetBitmap.Render(rect);
			imageSource = renderTargetBitmap;
#endif
			// Create a layerItemInfo array (so enumerable) with one item
			LegendItemInfo legendItemInfo = new LegendItemInfo() {
				Label = ID,
				ImageSource = imageSource
			};
			LegendItemInfo[] legendItemInfos = new LegendItemInfo[] { legendItemInfo };

			// Create the returned layerLegendInfo
			LayerLegendInfo layerLegendInfo = new LayerLegendInfo() { LegendItemInfos = legendItemInfos };

			if (callback != null)
				callback(layerLegendInfo);
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="LegendItemViewModel"/> class from a <see cref="LegendItemInfo"/>.
 /// </summary>
 /// <param name="legendItemInfo">The legend item info.</param>
 internal LegendItemViewModel(LegendItemInfo legendItemInfo)
     : this()
 {
     Label = legendItemInfo.Label;
     Symbol = legendItemInfo.Symbol;
 }