Beispiel #1
0
        private void Desktop1_Load(object sender, EventArgs e)
        {
            ImageListEntry[] imageList = new ImageListEntry[3];
            imageList[0]       = new ImageListEntry();
            imageList[0].Name  = "blue";
            imageList[0].Image = Image.FromFile(Application.StartupPath + "/Wallpapers/" + "blue.png");

            imageList[1]       = new ImageListEntry();
            imageList[1].Name  = "purple";
            imageList[1].Image = Image.FromFile(Application.StartupPath + "/Wallpapers/" + "purple.png");

            imageList[2]       = new ImageListEntry();
            imageList[2].Name  = "orange";
            imageList[2].Image = Image.FromFile(Application.StartupPath + "/Wallpapers/" + "orange.png");


            this.customWallpaper.Images = imageList;
        }
Beispiel #2
0
        /// <summary>
        /// Process the http request.
        /// </summary>
        /// <param name="context">The current <see cref="T:System.Web.HttpContext"/>.</param>
        void IWisejHandler.ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            int index = -1;

            if (!int.TryParse(request["ix"], out index))
            {
                return;
            }

            if (this._images == null || index < 0 || index >= this._images.Length)
            {
                return;
            }

            ImageListEntry entry = this._images[index];

            if (entry.Image != null)
            {
                try
                {
                    Image image = entry.Image;
                    lock (image)
                    {
                        var format    = GetImageFormat(image);
                        var mediaType = GetImageMediaType(image);

                        response.ContentType = mediaType;
                        response.Cache.SetSlidingExpiration(true);
                        response.Cache.SetMaxAge(TimeSpan.FromDays(1));
                        response.Cache.SetCacheability(HttpCacheability.Private);

                        image.Save(response.OutputStream, format);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Log(ex);
                }
                response.Flush();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Process the http request.
        /// </summary>
        /// <param name="context">The current <see cref="T:System.Web.HttpContext"/>.</param>
        void IWisejHandler.ProcessRequest(HttpContext context)
        {
            var request  = context.Request;
            var response = context.Response;

            int index = -1;

            if (!int.TryParse(request["ix"], out index))
            {
                return;
            }

            if (this._images == null || index < 0 || index >= this._images.Length)
            {
                return;
            }

            ImageListEntry entry = this._images[index];

            if (entry.Image != null)
            {
                try
                {
                    Image image = entry.Image;
                    lock (image)
                    {
                        var format    = GetImageFormat(image);
                        var mediaType = GetImageMediaType(image);

                        response.ContentType = mediaType;
                        response.AppendHeader("Cache-Control", "private, max-age=86400");

                        image.Save(response.OutputStream, format);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Log(ex);
                }
                response.Flush();
            }
        }