コード例 #1
0
 public GaugePaintEventArgs(GaugeContainer gauge, GaugeGraphics graphics)
 {
     this.gauge    = gauge;
     this.graphics = graphics;
 }
コード例 #2
0
        public Image LoadImage(string imageURL, bool saveImage)
        {
            Image image = null;

            if (this.serviceContainer != null)
            {
                GaugeCore gaugeCore = (GaugeCore)this.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 (this.imageData == null)
            {
                this.imageData = new Hashtable(new CaseInsensitiveHashCodeProvider(CultureInfo.InvariantCulture), StringComparer.OrdinalIgnoreCase);
            }
            if (this.imageData.Contains(imageURL))
            {
                image = (Image)this.imageData[imageURL];
            }
            if (image == null)
            {
                Uri uri = null;
                try
                {
                    uri = new Uri(imageURL);
                }
                catch (Exception)
                {
                }
                if (uri == (Uri)null)
                {
                    GaugeContainer gaugeContainer = (GaugeContainer)this.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 != (Uri)null)
                {
                    try
                    {
                        WebRequest webRequest = WebRequest.Create(uri);
                        image = Image.FromStream(webRequest.GetResponse().GetResponseStream());
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (image == null)
            {
                image = this.LoadFromFile(imageURL);
            }
            if (image == null)
            {
                throw new ArgumentException(Utils.SRGetStr("ExceptionImageLoaderInvalidUrl", imageURL));
            }
            if (saveImage)
            {
                this.imageData[imageURL] = image;
            }
            return(image);
        }