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

📄 toolbartextbox.cs

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 CS
📖 第 1 页 / 共 3 页
字号:
            {
                // If the AutoPostBack property has been set,
                // then retrieve it.
                if (ViewState["AutoPostBack"] != null)
                {
                    return _TextBox.AutoPostBack;
                }

                // The AutoPostBack property has not been set,
                // so look to the parent
                Toolbar tbParent = ParentToolbar;
                if (tbParent != null)
                {
                    return tbParent.AutoPostBack;
                }

                return false;
            }

            set
            {
                ViewState["AutoPostBack"] = value;
                _TextBox.AutoPostBack = value;
            }
        }

        /// <summary>
        /// Gets or sets the display width of the text box in characters.
        /// </summary>
        [
        Category("Appearance"),
        DefaultValue(0),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("TextBoxColumns"),
        ]
        public virtual int Columns
        {
            get { return _TextBox.Columns; }
            set { _TextBox.Columns = value; }
        }

        /// <summary>
        /// Gets or sets the maximum number of characters allowed in the text box.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(0),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("TextBoxMaxLength"),
        ]
        public virtual int MaxLength
        {
            get { return _TextBox.MaxLength; }
            set { _TextBox.MaxLength = value; }
        }

        /// <summary>
        /// Gets or sets the behavior mode of the text box.
        /// Valid values: TextBoxMode.SingleLine and TextBoxMode.Password
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(ToolbarTextBoxMode.SingleLine),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("TextBoxTextMode"),
        ]
        public virtual ToolbarTextBoxMode TextMode
        {
            get { return (_TextBox.TextMode == TextBoxMode.Password) ? ToolbarTextBoxMode.Password : ToolbarTextBoxMode.SingleLine; }
            set { _TextBox.TextMode = (value == ToolbarTextBoxMode.Password) ? TextBoxMode.Password : TextBoxMode.SingleLine; }
        }

        /// <summary>
        /// Gets or sets the text content of the text box.
        /// </summary>
        [
        Category("Appearance"),
        DefaultValue(""),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("TextBoxText"),
        ]
        public virtual string Text
        {
            get { return _TextBox.Text; }
            set { _TextBox.Text = value; }
        }

        /// <summary>
        /// Gets or sets the read-only status of the text box.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(false),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("TextBoxReadOnly"),
        ]
        public virtual bool ReadOnly
        {
            get { return _TextBox.ReadOnly; }
            set { _TextBox.ReadOnly = value; }
        }

        /// <summary>
        /// Gets or sets the keyboard shortcut key (AccessKey) for setting focus to the item.
        /// </summary>
        public override string AccessKey
        {
            get { return _TextBox.AccessKey; }
            set { base.AccessKey = _TextBox.AccessKey = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the textbox is enabled.
        /// </summary>
        public override bool Enabled
        {
            get { return _TextBox.Enabled; }
            set { base.Enabled = _TextBox.Enabled = value; }
        }

        /// <summary>
        /// Gets or sets the tab index of the item.
        /// </summary>
        public override short TabIndex
        {
            get { return _TextBox.TabIndex; }
            set { base.TabIndex = _TextBox.TabIndex = value; }
        }

        /// <summary>
        /// Gets or sets the tool tip for the item to be displayed when the mouse cursor is over the control.
        /// </summary>
        public override string ToolTip
        {
            get { return _TextBox.ToolTip; }
            set { base.ToolTip = _TextBox.ToolTip = value; }
        }

        /// <summary>
        /// The ID of the hidden helper.
        /// </summary>
        internal string HelperID
        {
            get
            {
                if (_HelperID == null)
                {
                    Toolbar parent = ParentToolbar;
                    if (parent == null)
                    {
                        return String.Empty;
                    }

                    _HelperID = "__" + parent.ClientID + "_" + Index.ToString() + "__";
                }

                return _HelperID;
            }
        }

        /// <summary>
        /// Processes the new text data.
        /// </summary>
        /// <param name="newText">The new text for the Text property.</param>
        /// <returns>Returns true if there was a change.</returns>
        private bool ProcessData(string newText)
        {
            if (Text != newText)
            {
                Text = newText;
                return true;
            }

            return false;
        }

        /// <summary>
        /// Loads postback data into the control.
        /// </summary>
        /// <param name="postDataKey">The key identifier for the control.</param>
        /// <param name="postCollection">The collection of all incoming name values.</param>
        /// <returns>true if the server control's state changes as a result of the post back; otherwise false.</returns>
        bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            string szData = postCollection[HelperID];
            if (szData != null)
            {
                return ProcessData(szData);
            }

            return false;
        }

        /// <summary>
        /// Signals the server control object to notify the ASP.NET application that the state of the control has changed.
        /// </summary>
        void IPostBackDataHandler.RaisePostDataChangedEvent()
        {
            OnTextChanged(this, EventArgs.Empty);
        }

        /// <summary>
        /// Initializes postback data fields. Should be called from OnPreRender.
        /// </summary>
        /// <param name="isUpLevel"></param>
        internal void SetupHiddenHelper(bool isUpLevel)
        {
            _TextBox.ID = HelperID;

            Toolbar parent = ParentToolbar;
            if (isUpLevel && (parent != null) && (parent.Page != null))
            {
                parent.Page.RegisterHiddenField(HelperID, (TextMode != ToolbarTextBoxMode.Password) ? _TextBox.Text : String.Empty);
            }
        }

        /// <summary>
        /// The product of merging local and global styles.
        /// </summary>
        protected override CssCollection CurrentStyle
        {
            get
            {
                CssCollection style = base.CurrentStyle;

                // Due to the order in which we want to inherit fonts,
                // we need to make DefaultStyle override Style override Parent.DefaultStyle
                if (style["font-family"] != null)
                {
                    if ((DefaultStyle["font-family"] == null) && (Font.Names.Length > 0))
                    {
                        style.Remove("font-family");
                    }
                }

                if (style["font-size"] != null)
                {
                    if ((DefaultStyle["font-size"] == null) && (!Font.Size.IsEmpty))
                    {
                        style.Remove("font-size");
                    }
                }

                if (style["font-weight"] != null)
                {
                    if ((DefaultStyle["font-weight"] == null) && Font.Bold)
                    {
                        style.Remove("font-weight");
                    }
                }

                if (style["font-style"] != null)
                {
                    if ((DefaultStyle["font-style"] == null) && Font.Italic)
                    {
                        style.Remove("font-style");
                    }
                }

                return style;
            }
        }

        /// <summary>
        /// The uplevel ToolbarTag ID for the toolbar item.
        /// </summary>
        protected override string UpLevelTag
        {
            get { return Toolbar.TextBoxTagName; }
        }

        /// <summary>
        /// Renders ToolbarItem attributes.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter to receive markup.</param>
        protected override void WriteItemAttributes(HtmlTextWriter writer)
        {
            base.WriteItemAttributes(writer);

            string css = CssClass;
            if (css.Length > 0)
            {
                writer.WriteAttribute("class", css);
            }

            string style = String.Empty;

            Color color = ForeColor;
            if (!color.IsEmpty)
            {
                style += "color:" + ColorTranslator.ToHtml(color) + ";";
            }

            color = BackColor;
            if (!color.IsEmpty)
            {
                style += "background-color:" + ColorTranslator.ToHtml(color) + ";";
            }

            color = BorderColor;
            if (!color.IsEmpty)
            {
                style += "border-color:" + ColorTranslator.ToHtml(color) + ";";
            }

            BorderStyle bs = BorderStyle;
            Unit unit = BorderWidth;

            if (bs != BorderStyle.NotSet)
            {
                style += "border-style:" + Enum.Format(typeof(BorderStyle), bs, "G") + ";";
            }

            if (!unit.IsEmpty) 
            {
                style += "border-width:" + unit.ToString(CultureInfo.InvariantCulture) + ";";

                if ((bs == BorderStyle.NotSet) && (unit.Value != 0.0))
                {
                    style += "border-style:solid;";
                }
            }

            FontInfo font = Font;

            string[] names = font.Names;
            if (names.Length > 0)
            {
                style += "font-family:";
                for (int i = 0; i < names.Length; i++)
                {
                    if (i > 0)
                    {
                        style += ",";

⌨️ 快捷键说明

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