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

📄 toolbar.cs

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

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

    /// <summary>
    /// Represents a toolbar.
    /// </summary>
    [
    ParseChildren(true, "Items"),
    Designer(typeof(Microsoft.Web.UI.WebControls.Design.ToolbarDesigner)),
    ToolboxBitmap(typeof(Microsoft.Web.UI.WebControls.Toolbar)),
    ]
    public class Toolbar : BasePostBackControl
    {
        /// <summary>
        /// The namespace for the Toolbar and its children.
        /// </summary>
        public const string TagNamespace = "TBNS";

        /// <summary>
        /// The Toolbar tag name.
        /// </summary>
        public const string ToolbarTagName = "Toolbar";

        /// <summary>
        /// The ToolbarButton's tag name.
        /// </summary>
        public const string ButtonTagName = "ToolbarButton";

        /// <summary>
        /// The ToolbarCheckButton's tag name.
        /// </summary>
        public const string CheckButtonTagName = "ToolbarCheckButton";

        /// <summary>
        /// The ToolbarCheckGroup's tag name.
        /// </summary>
        public const string CheckGroupTagName = "ToolbarCheckGroup";

        /// <summary>
        /// The ToolbarSeparator's tag name.
        /// </summary>
        public const string SeparatorTagName = "ToolbarSeparator";

        /// <summary>
        /// The ToolbarLabel's tag name.
        /// </summary>
        public const string LabelTagName = "ToolbarLabel";

        /// <summary>
        /// The ToolbarDropDownList's tag name.
        /// </summary>
        public const string DropDownListTagName = "ToolbarDropDownList";

        /// <summary>
        /// The ToolbarTextBox's tag name.
        /// </summary>
        public const string TextBoxTagName = "ToolbarTextBox";

        /// <summary>
        /// Fired when a button is clicked.
        /// </summary>
        [ResDescription("ToolbarButtonClick")]
        public event EventHandler ButtonClick;

        /// <summary>
        /// Fired when a checkbutton's state changes.
        /// </summary>
        [ResDescription("ToolbarCheckChange")]
        public event EventHandler CheckChange;

        private ToolbarItemCollection _Items;
        private CssCollection _DefaultStyle;
        private CssCollection _HoverStyle;
        private CssCollection _SelectedStyle;

#if false
        // Databinding
        private IEnumerable _DataSource;
        private bool _ClearChildViewState;
#endif

        private ArrayList _Changed;
        private ArrayList _DataChanged;

        /// <summary>
        /// Initializes a new instance of a Toolbar control.
        /// </summary>
        public Toolbar() : base()
        {
            _Items = new ToolbarItemCollection(this);
            _DefaultStyle = new CssCollection();
            _HoverStyle = new CssCollection();
            _SelectedStyle = new CssCollection();

            _Changed = new ArrayList();
            _DataChanged = new ArrayList();
#if false
            // Databinding
            _ClearChildViewState = false;
#endif
        }

        /// <summary>
        /// Gets the collection of items in the control.
        /// </summary>
        [
        Category("Data"),
        DefaultValue(null),
        MergableProperty(false),
        PersistenceMode(PersistenceMode.InnerDefaultProperty),
        ResDescription("ToolbarItems"),
        ]
        public virtual ToolbarItemCollection Items
        {
            get { return _Items; }
        }

        /// <summary>
        /// Overridden. Creates an EmptyControlCollection to prevent controls from
        /// being added to the ControlCollection.
        /// </summary>
        /// <returns>An EmptyControlCollection object.</returns>
        protected override ControlCollection CreateControlCollection()
        {
            return new EmptyControlCollection(this);
        }

        /// <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 bool AutoPostBack
        {
            get
            {
                Object obj = ViewState["AutoPostBack"];
                return ((obj == null) ? false : (bool)obj);
            }

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

        /// <summary>
        /// Gets or sets the horizontal or vertical orientation of the Toolbar.
        /// </summary>
        [
        Category("Appearance"),
        DefaultValue(Orientation.Horizontal),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("ToolbarOrientation"),
        ]
        public Orientation Orientation
        {
            get
            {
                object obj = ViewState["Orientation"];
                return (obj == null) ? Orientation.Horizontal : (Orientation)obj;
            }

            set { ViewState["Orientation"] = value; }
        }

        /// <summary>
        /// Global style for items.
        /// </summary>
        [
        Category("Styles"),
        DefaultValue(typeof(CssCollection), ""),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("ParentDefaultStyle"),
        ]
        public CssCollection DefaultStyle
        {
            get { return _DefaultStyle; }
            set
            {
                _DefaultStyle = value;
                if (IsTrackingViewState)
                {
                    ((IStateManager)_DefaultStyle).TrackViewState();
                    _DefaultStyle.Dirty = true;
                }
            }
        }

        /// <summary>
        /// Global style for items in the hover state.
        /// </summary>
        [
        Category("Styles"),
        DefaultValue(typeof(CssCollection), ""),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("ParentHoverStyle"),
        ]
        public CssCollection HoverStyle
        {
            get { return _HoverStyle; }
            set
            {
                _HoverStyle = value;
                if (IsTrackingViewState)
                {
                    ((IStateManager)_HoverStyle).TrackViewState();
                    _HoverStyle.Dirty = true;
                }
            }
        }

        /// <summary>
        /// Global style for items in the selected state.
        /// </summary>
        [
        Category("Styles"),
        DefaultValue(typeof(CssCollection), ""),
        PersistenceMode(PersistenceMode.Attribute),
        ResDescription("ParentSelectedStyle"),
        ]
        public CssCollection SelectedStyle
        {
            get { return _SelectedStyle; }
            set
            {
                _SelectedStyle = value;
                if (IsTrackingViewState)
                {
                    ((IStateManager)_SelectedStyle).TrackViewState();
                    _SelectedStyle.Dirty = true;
                }
            }
        }

#if false
        // Databinding
        /// <summary>
        /// Gets or sets the data source that populates the items of the control.
        /// </summary>
        public virtual IEnumerable DataSource
        {
            get { return _DataSource; }
            set { _DataSource = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the type content.
        /// </summary>
        public string DataTypeField
        {
            get
            {
                Object obj = ViewState["DataTypeField"];
                return((obj == null) ? String.Empty : (string)obj);
            }

            set { ViewState["DataTypeField"] = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the text content.
        /// </summary>
        public string DataTextField
        {
            get
            {
                Object obj = ViewState["DataTextField"];
                return((obj == null) ? String.Empty : (string)obj);
            }

            set { ViewState["DataTextField"] = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the image url content.
        /// </summary>
        public string DataImageUrlField
        {
            get
            {
                Object obj = ViewState["DataImageUrlField"];
                return((obj == null) ? String.Empty : (string)obj);
            }

            set { ViewState["DataImageUrlField"] = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the selected content.
        /// </summary>
        public string DataSelectedField
        {
            get
            {
                Object obj = ViewState["DataSelectedField"];
                return((obj == null) ? String.Empty : (string)obj);
            }

            set { ViewState["DataSelectedField"] = value; }
        }

        /// <summary>
        /// Gets or sets the field of the data source that provides the groupname content.
        /// </summary>
        public string DataGroupnameField
        {
            get
            {
                Object obj = ViewState["DataGroupnameField"];
                return((obj == null) ? String.Empty : (string)obj);
            }

            set { ViewState["DataGroupnameField"] = value; }
        }
#endif

        /// <summary>
        /// Fired when a button is clicked.
        /// </summary>
        /// <param name="sender">The source item.</param>
        /// <param name="e">Event parameters.</param>
        protected virtual void OnButtonClick(object sender, EventArgs e)
        {
            if (ButtonClick != null)
            {
                ButtonClick(sender, e);   // call the delegate if non-null
            }
        }

        /// <summary>
        /// Fired when a checkbutton's state changes.
        /// </summary>
        /// <param name="sender">The source item.</param>
        /// <param name="e">The event parameters.</param>
        protected virtual void OnCheckChange(object sender, EventArgs e)
        {
            if (CheckChange != null)
            {
                CheckChange(sender, e);   // call the delegate if non-null
            }
        }

        /// <summary>
        /// Returns a true value to indicate that a hidden helper is needed by this control.
        /// </summary>
        protected override bool NeedHelper
        {
            get { return true; }
        }

        /// <summary>
        /// Perform the bubbling necessary in firing the ButtonClick event.
        /// </summary>
        /// <param name="item">The source ToolbarItem.</param>
        private void PostButtonClickEvent(ToolbarItem item)
        {
            bool bBubble = true;
            EventArgs eventArgs = new EventArgs();

            if (item is ToolbarButton)
            {
                bBubble = ((ToolbarButton)item).OnButtonClick(eventArgs);
            }

⌨️ 快捷键说明

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