// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. // // Purpose: Design-time classes for the image maps. // #if DESIGNER using System.ComponentModel; using System.Drawing.Design; using FastReport.DataVisualization.Charting; using FastReport.DataVisualization.Charting.Utilities; namespace FastReport.Design.DataVisualization.Charting { /// /// Image string editor class. /// internal class ImageValueEditor : FileNameEditor { #region Editor method and properties /// /// Override this function to support palette colors drawing /// /// Descriptor context. /// Can paint values. public override bool GetPaintValueSupported(ITypeDescriptorContext context) { return true; } /// /// Override this function to support palette colors drawing /// /// Paint value event arguments. public override void PaintValue(PaintValueEventArgs e) { try { if (e.Value is string) { // Get image loader ImageLoader imageLoader = null; if (e.Context != null && e.Context.Instance != null) { if (e.Context.Instance is Chart) { Chart chart = (Chart)e.Context.Instance; imageLoader = (ImageLoader)chart.GetService(typeof(ImageLoader)); } else if (e.Context.Instance is IChartElement) { IChartElement chartElement = (IChartElement)e.Context.Instance; imageLoader = (ImageLoader)chartElement.Common.ImageLoader; } } if (imageLoader != null && !string.IsNullOrEmpty((string)e.Value)) { // Load a image System.Drawing.Image image = imageLoader.LoadImage((string)e.Value); // Draw Image e.Graphics.DrawImage(image, e.Bounds); } } } catch (ArgumentException) { } } #endregion } } #endif