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

📄 toolbartextbox.cs

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 CS
📖 第 1 页 / 共 3 页
字号:
//------------------------------------------------------------------------------
// Copyright (c) 2000-2003 Microsoft Corporation. All Rights Reserved.
//------------------------------------------------------------------------------

namespace Microsoft.Web.UI.WebControls
{
    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    using System.Drawing;
    using System.Globalization;
    using System.Reflection;

    /// <summary>
    /// Represents a text box within a toolbar.
    /// </summary>
    public class ToolbarTextBox : ToolbarItem, IPostBackDataHandler
    {
        /// <summary>
        /// Occurs when the Text property value has changed.
        /// </summary>
        public event EventHandler TextChanged;

        private InternalTextBox _TextBox;
        private CssWrapper _CssWrapper;
        private bool _IsTrackingVS;
        private string _HelperID;

        /// <summary>
        /// Initializes a new ToolbarTextBox instance.
        /// </summary>
        public ToolbarTextBox() : base()
        {
            _TextBox = new InternalTextBox();
            _TextBox.TextChanged += new EventHandler(this.OnTextChanged);
            _IsTrackingVS = false;
            _HelperID = null;
        }

        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a copy of this instance.</returns>
        public override object Clone()
        {
            ToolbarTextBox copy = (ToolbarTextBox)base.Clone();

            copy.TextChanged = this.TextChanged;
            copy._CssWrapper = this._CssWrapper;

            copy._TextBox = new InternalTextBox();
            if (this._IsTrackingVS)
            {
                ((IStateManager)copy).TrackViewState();
            }

            foreach (string key in this._TextBox.Attributes.Keys)
            {
                copy._TextBox.Attributes.Add(key, this._TextBox.Attributes[key]);
            }

            foreach (string key in this._TextBox.VS.Keys)
            {
                PropertyInfo pinfo = copy._TextBox.GetType().GetProperty(key);
                if ((pinfo != null) && pinfo.CanRead && pinfo.CanWrite)
                {
                    // Try to be more gentle
                    object obj = pinfo.GetValue(this._TextBox, null);
                    if (obj != null)
                    {
                        pinfo.SetValue(copy._TextBox, obj, null);
                    }
                }
                else
                {
                    // Brute force copy the ViewState
                    object obj = this._TextBox.VS[key];
                    if (obj is ICloneable)
                    {
                        obj = ((ICloneable)obj).Clone();
                    }
                    copy._TextBox.VS[key] = obj;
                }
            }

            copy._TextBox.Font.CopyFrom(this._TextBox.Font);

            return copy;
        }

        /// <summary>
        /// Sets all items within the StateBag to be dirty
        /// </summary>
        protected internal override void SetViewStateDirty()
        {
            base.SetViewStateDirty();

            Hashtable table = new Hashtable();
            foreach (string key in _TextBox.Attributes.Keys)
            {
                table[key] = _TextBox.Attributes[key];
            }
            _TextBox.Attributes.Clear();
            foreach (string key in table.Keys)
            {
                _TextBox.Attributes[key] = (string)table[key];
            }

            foreach (string key in _TextBox.VS.Keys)
            {
                PropertyInfo pinfo = _TextBox.GetType().GetProperty(key);
                if ((pinfo != null) && pinfo.CanRead && pinfo.CanWrite)
                {
                    object obj = pinfo.GetValue(_TextBox, null);
                    pinfo.SetValue(_TextBox, obj, null);
                }
            }

            _TextBox.Font.CopyFrom(_TextBox.Font);

            foreach (StateItem item in _TextBox.VS.Values)
            {
                item.IsDirty = true;
            }
        }

        /// <summary>
        /// Raises the TextChanged event.
        /// </summary>
        /// <param name="sender">Event argument.</param>
        /// <param name="e">The source control.</param>
        protected virtual void OnTextChanged(Object sender, EventArgs e)
        {
            if (TextChanged != null)
            {
                TextChanged(this, e);   // call the delegate
            }
        }

        //DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),

        /// <summary>
        /// Gets a collection of text attributes that will be rendered as a style attribute on the outer tag.
        /// </summary>
        [
        Browsable(false),
        DefaultValue(typeof(CssCollection), ""),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("InnerControlStyle"),
        ]
        public CssCollection Style 
        {
            get
            {
                if (_CssWrapper == null)
                {
                    _CssWrapper = new CssWrapper(_TextBox);
                }

                return _CssWrapper;
            }
            set
            {
                CssCollection style = this.Style;
                style.Clear();
                style.Merge(value, true);
            }
        }

        /// <summary>
        /// Gets the style of the control
        /// </summary>
        [
        Browsable(false),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
        ]
        public Style ControlStyle
        {
            get { return _TextBox.ControlStyle; }
        }

        /// <summary>
        /// Gets or sets the background color of the Web control.
        /// </summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(typeof(Color), ""),
        TypeConverterAttribute(typeof(WebColorConverter)),
        ResDescription("InnerControlBackColor"),
        ]
        public virtual Color BackColor 
        {
            get { return _TextBox.BackColor; }
            set { _TextBox.BackColor = value; }
        }

        /// <summary>
        /// Gets or sets the border color of the Web control.
        /// </summary>summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(typeof(Color), ""),
        TypeConverterAttribute(typeof(WebColorConverter)),
        ResDescription("InnerControlBorderColor"),
        ]
        public virtual Color BorderColor 
        {
            get { return _TextBox.BorderColor; }
            set { _TextBox.BorderColor = value; }
        }

        /// <summary>
        /// Gets or sets the border width of the Web control.
        /// </summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(typeof(Unit), ""),
        ResDescription("InnerControlBorderWidth"),
        ]
        public virtual Unit BorderWidth 
        {
            get { return _TextBox.BorderWidth; }
            set { _TextBox.BorderWidth = value; }
        }

        /// <summary>
        /// Gets or sets the border style of the Web control.
        /// </summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(BorderStyle.NotSet),
        ResDescription("InnerControlBorderStyle"),
        ]
        public virtual BorderStyle BorderStyle 
        {
            get { return _TextBox.BorderStyle; }
            set { _TextBox.BorderStyle = value; }
        }

        /// <summary>
        /// Gets or sets the CssClass
        /// </summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(""),
        ResDescription("InnerControlCssClass"),
        ]
        public virtual string CssClass 
        {
            get { return _TextBox.CssClass; }
            set { _TextBox.CssClass = value; }
        }

        /// <summary>
        /// Gets font information
        /// </summary>
        [
        Category("Appearance"),
        DefaultValue(null),
        DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true),
        ResDescription("InnerControlFont"),
        ]
        public virtual FontInfo Font 
        {
            get { return _TextBox.Font; }
        }

        /// <summary>
        /// Gets or sets the foreground color (typically the color of the text) of the control
        /// </summary>
        [
        Bindable(true),
        Category("Appearance"),
        DefaultValue(typeof(Color), ""),
        TypeConverterAttribute(typeof(WebColorConverter)),
        ResDescription("InnerControlForeColor"),
        ]
        public virtual Color ForeColor 
        {
            get { return _TextBox.ForeColor; }
            set { _TextBox.ForeColor = value; }
        }

        /// <summary>
        /// The height of the control
        /// </summary>
        [
        Bindable(true),
        Category("Layout"),
        DefaultValue(typeof(Unit), ""),
        ResDescription("InnerControlHeight"),
        ]
        public virtual Unit Height 
        {
            get { return _TextBox.Height; }
            set { _TextBox.Height = value; }
        }

        /// <summary>
        /// The Width of the control
        /// </summary>
        [
        Bindable(true),
        Category("Layout"),
        DefaultValue(typeof(Unit), ""),
        ResDescription("InnerControlWidth"),
        ]
        public virtual Unit Width
        {
            get { return _TextBox.Width; }
            set { _TextBox.Width = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the state automatically posts back to the server when clicked.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(false),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("AutoPostBack"),
        ]
        public virtual bool AutoPostBack
        {
            get

⌨️ 快捷键说明

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