Example #1
0
 internal GaugePaintEventArgs(GaugeContainer gauge, GaugeGraphics graphics)
 {
     this.gauge    = gauge;
     this.graphics = graphics;
 }
        public Image LoadImage(string imageURL, bool saveImage)
        {
            Image image = null;

            if (serviceContainer != null)
            {
                GaugeCore gaugeCore = (GaugeCore)serviceContainer.GetService(typeof(GaugeCore));
                if (gaugeCore != null)
                {
                    foreach (NamedImage namedImage in gaugeCore.NamedImages)
                    {
                        if (namedImage.Name == imageURL)
                        {
                            if (namedImage.Image == null)
                            {
                                throw new ArgumentException(Utils.SRGetStr("ExceptionImageLoaderInvalidUrl", imageURL));
                            }
                            return(namedImage.Image);
                        }
                    }
                }
            }
            if (imageData == null)
            {
                imageData = new Hashtable(new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture), StringComparer.OrdinalIgnoreCase);
            }
            if (imageData.Contains(imageURL))
            {
                image = (Image)imageData[imageURL];
            }
            if (image == null)
            {
                Uri uri = null;
                try
                {
                    uri = new Uri(imageURL);
                }
                catch (Exception)
                {
                }
                if (uri == null)
                {
                    GaugeContainer gaugeContainer = (GaugeContainer)serviceContainer.GetService(typeof(GaugeContainer));
                    if (gaugeContainer != null)
                    {
                        if (imageURL.StartsWith("~", StringComparison.Ordinal) && gaugeContainer.applicationDocumentURL.Length > 0)
                        {
                            try
                            {
                                uri = new Uri(gaugeContainer.applicationDocumentURL + imageURL.Substring(1));
                            }
                            catch (Exception)
                            {
                            }
                        }
                        else
                        {
                            string text = gaugeContainer.webFormDocumentURL;
                            int    num  = text.LastIndexOf('/');
                            if (num != -1)
                            {
                                text = text.Substring(0, num + 1);
                            }
                            try
                            {
                                uri = new Uri(new Uri(text), imageURL);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
                if (uri != null)
                {
                    try
                    {
                        image = Image.FromStream(WebRequest.Create(uri).GetResponse().GetResponseStream());
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (image == null)
            {
                image = LoadFromFile(imageURL);
            }
            if (image == null)
            {
                throw new ArgumentException(Utils.SRGetStr("ExceptionImageLoaderInvalidUrl", imageURL));
            }
            if (saveImage)
            {
                imageData[imageURL] = image;
            }
            return(image);
        }
 internal void InvokePostPaint(object sender)
 {
     GaugeContainer.OnPostPaint(sender, new GaugePaintEventArgs(GaugeContainer, graph));
 }