⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thumbviewer.cs

📁 一个基于asp.net实现缩略图显示放大的功能
💻 CS
📖 第 1 页 / 共 2 页
字号:
/* --------------------------------------------------------------------------

Copyright (c) 2007 Declan Bright

This software is provided 'as-is', without any express or implied warranty. 
In no event will the authors be held liable for any damages arising from 
the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely, 
subject to the following restrictions:

    1. The origin of this software must not be misrepresented; you must not 
    claim that you wrote the original software. If you use this software in
    a product, an acknowledgment in the product documentation would be 
    appreciated but is not required.

    2. Altered source versions must be plainly marked as such, and must not 
    be misrepresented as being the original software.

    3. This notice may not be removed or altered from any source distribution.
 
--------------------------------------------------------------------------- */

#region Directives

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Design;
using System.ComponentModel;
using System.IO;
using System.Text;

#endregion

namespace Bright.WebControls
{
    /// <summary>
    /// Thumbnail Image Viewer Control
    /// </summary>
    [ToolboxData("<{0}:ThumbViewer runat=\"server\" ImageUrl=\"\" Title=\"\" Width=\"100\" Height=\"100\" />")]
    [ToolboxBitmap(typeof(System.Web.UI.WebControls.Image))]
    public class ThumbViewer : System.Web.UI.WebControls.Image
    {        
        #region Properties & Fields

        #region Urls

        private string _srcImageUrl;

        [        
        Category("Appearance"),
        Description("The URL of the image."),
        DefaultValue(""),        
        Bindable(true)
        ]
        public override string ImageUrl
        {
            get
            {
                return ViewState["ImageUrl"] == null ?
                    string.Empty : ViewState["ImageUrl"].ToString();
            }
            set
            {
                ViewState["ImageUrl"] = value;
            }
        }

        [        
        Category("Appearance"),        
        Description("The URL of the thumb image."),
        DefaultValue(""),
        Bindable(true),         
        Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))
        ]
        public virtual string ThumbUrl
        {
            get
            {
                return ViewState["ThumbUrl"] == null ?
                    string.Empty : ViewState["ThumbUrl"].ToString();
            }
            set
            {
                ViewState["ThumbUrl"] = value;
            }
        }

        #endregion       

        #region Image

        [
        Category("Layout"),
        DefaultValue("100"),
        Bindable(true)        
        ]
        public override Unit Width
        {
            get
            {
                return base.Width.IsEmpty ?
                    Unit.Parse("100") : base.Width;
            }
            set
            {
                if (value.Value < 0)
                    throw new ArgumentOutOfRangeException("Width");
                base.Width = value;
            }
        }

        [
        Category("Layout"),
        DefaultValue("100"),
        Bindable(true)
        ]
        public override Unit Height
        {
            get
            {
                return base.Height.IsEmpty ? 
                    Unit.Parse("100") : base.Height;
            }
            set
            {
                if (value.Value < 0)
                    throw new ArgumentOutOfRangeException("Height");
                base.Height = value;
            }
        }

        #endregion

        #region Modal

        [        
        Category("Appearance"),
        Description("The Title of Image."),
        DefaultValue(""),
        Bindable(true)
        ]
        public virtual string Title
        {
            get
            {
                return ViewState["ImageTitle"] == null ?
                    String.Empty : ViewState["ImageTitle"].ToString();
            }
            set
            {
                ViewState["ImageTitle"] = value;
            }
        }
        
        ModalDisplayModeOptions _modalDisplayModeOption;     
        /// <summary>
        /// ModalDisplayModeOptions enum
        /// </summary>
        public enum ModalDisplayModeOptions
        {
            Stretch,
            Fixed,
            Disabled
        }

        [
        Category("Appearance"),
        Description("The display mode of the Modal Image.\nIf Stretch is selected then ModalImagePadding is applied.\nIf Fixed is selected then ModalFixedWidth and ModalFixedHeight are applied.")
        ]
        public ModalDisplayModeOptions ModalDisplayMode
        {
            get 
            { 
                return _modalDisplayModeOption; 
            }
            set 
            { 
                _modalDisplayModeOption = value; 
            }
        }            

        [
        Category("Layout"),        
        Description("The padding of the Modal Image if ModalDisplayMode is set to Stretch."),
        DefaultValue("50"),
        Bindable(true)
        ]
        public virtual Unit ModalImagePadding
        {
            get
            {
                return ViewState["ModalImagePadding"] == null ? 
                    Unit.Parse("50") : Unit.Parse(ViewState["ModalImagePadding"].ToString());
            }
            set
            {
                if (value.Value < 0) 
                    throw new ArgumentOutOfRangeException("ModalImagePadding");
                ViewState["ModalImagePadding"] = value;
            }
        }

        [
        Category("Layout"),        
        Description("The width of the Modal Image if ModalDisplayMode is set to Fixed."),
        DefaultValue("200"),
        Bindable(true)
        ]
        public virtual Unit ModalFixedWidth
        {
            get
            {
                return ViewState["ModalFixedWidth"] == null ? 
                    Unit.Parse("200") : Unit.Parse(ViewState["ModalFixedWidth"].ToString());
            }
            set
            {
                if (value.Value < 0) 
                    throw new ArgumentOutOfRangeException("ModalFixedWidth");
                ViewState["ModalFixedWidth"] = value;
            }
        }

        [
        Category("Layout"),        
        Description("The height of the Modal Image if ModalDisplayMode is set to Fixed."),
        DefaultValue("200"),
        Bindable(true)
        ]
        public virtual Unit ModalFixedHeight
        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -