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

📄 toolbaritem.cs

📁 浏览器端看到树型目录结构,用户可以完整地看到像windows资源管理器一样的效果
💻 CS
📖 第 1 页 / 共 2 页
字号:

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

        /// <summary>
        /// Returns true if the child has uplevel content.
        /// </summary>
        protected virtual bool HasUpLevelContent
        {
            get { return false; }
        }

        /// <summary>
        /// Adds attributes to the HtmlTextWriter.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);

            if (AccessKey != String.Empty)
            {
                writer.AddAttribute("accesskey", AccessKey);
            }

            if (!Enabled)
            {
                writer.AddAttribute("disabled", "true");
            }

            if (TabIndex != 0)
            {
                writer.AddAttribute("tabindex", TabIndex.ToString());
            }

            if (ToolTip != String.Empty)
            {
                writer.AddAttribute("title", ToolTip);
            }
        }

        /// <summary>
        /// Writes attributes to the HtmlTextWriter.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected override void WriteAttributes(HtmlTextWriter writer)
        {
            base.WriteAttributes(writer);

            if (AccessKey != String.Empty)
            {
                writer.WriteAttribute("accesskey", AccessKey);
            }

            if (!Enabled)
            {
                writer.WriteAttribute("disabled", "true");
            }

            if (TabIndex != 0)
            {
                writer.WriteAttribute("tabindex", TabIndex.ToString());
            }

            if (ToolTip != String.Empty)
            {
                writer.WriteAttribute("title", ToolTip);
            }
        }

        /// <summary>
        /// Renders ToolbarItem attributes.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter to receive markup.</param>
        protected virtual void WriteItemAttributes(HtmlTextWriter writer)
        {
            string style = DefaultStyle.CssText;
            if (style != String.Empty)
            {
                writer.WriteAttribute("defaultStyle", style);
            }
        }

        /// <summary>
        /// Renders the item for uplevel browsers.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected override void RenderUpLevelPath(HtmlTextWriter writer)
        {
            writer.WriteBeginTag(Toolbar.TagNamespace + ":" + UpLevelTag);

            WriteAttributes(writer);
            WriteItemAttributes(writer);

            if (HasUpLevelContent)
            {
                // Finish the begin tag
                writer.Write(HtmlTextWriter.TagRightChar);

                // Render content
                UpLevelContent(writer);

                // Render the close tag
                writer.WriteEndTag(Toolbar.TagNamespace + ":" + UpLevelTag);
            }
            else
            {
                // Finish and close the tag
                writer.Write(HtmlTextWriter.SelfClosingChars + HtmlTextWriter.TagRightChar);
            }

            writer.WriteLine();
        }

        /// <summary>
        /// Render the item's content.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected virtual void UpLevelContent(HtmlTextWriter writer)
        {
        }

        /// <summary>
        /// Renders the item for downlevel browsers.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected override void RenderDownLevelPath(HtmlTextWriter writer)
        {
            if (Orientation == Orientation.Vertical)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            }

            HtmlInlineWriter inlineWriter = (writer is HtmlInlineWriter) ? (HtmlInlineWriter)writer : new HtmlInlineWriter(writer);
            CurrentStyle.AddAttributesToRender(inlineWriter);
            inlineWriter.AddAttribute(HtmlTextWriterAttribute.Nowrap, null);
            inlineWriter.RenderBeginTag(HtmlTextWriterTag.Td);

            DownLevelContent(inlineWriter);

            inlineWriter.RenderEndTag();

            if (Orientation == Orientation.Vertical)
            {
                writer.RenderEndTag();
            }
            // If the inline writer was passed in, then the WriteLine won't happen
            writer.WriteLine();
        }

        /// <summary>
        /// Renders the item's contents.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected virtual void DownLevelContent(HtmlTextWriter writer)
        {
        }

        /// <summary>
        /// Renders the item for visual designers.
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected override void RenderDesignerPath(HtmlTextWriter writer)
        {
            CurrentStyle.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, null);
            if (Orientation == Orientation.Vertical)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            DesignerContent(writer);

            writer.RenderEndTag();  // TD
            if (Orientation == Orientation.Vertical)
            {
                writer.RenderEndTag();
            }
            writer.WriteLine();
        }

        /// <summary>
        /// Renders the item's contents
        /// </summary>
        /// <param name="writer">The HtmlTextWriter object that receives the content.</param>
        protected virtual void DesignerContent(HtmlTextWriter writer)
        {
        }

        /// <summary>
        /// Loads the item's previously saved view state.
        /// </summary>
        /// <param name="savedState">An Object that contains the saved view state values for the item.</param>
        protected override void LoadViewState(object savedState)
        {
            if (savedState != null)
            {
                object[] state = (object[])savedState;

                base.LoadViewState(state[0]);

                if (state.Length > 1)
                {
                    ((IStateManager)DefaultStyle).LoadViewState(state[1]);
                }
            }
        }

        /// <summary>
        /// Saves the changes to the item's view state to an object.
        /// </summary>
        /// <returns>The object that contains the view state changes.</returns>
        protected override object SaveViewState()
        {
            object state = base.SaveViewState();
            object defaultStyle = ((IStateManager)DefaultStyle).SaveViewState();

            if (defaultStyle != null)
            {
                return new object[] { state, defaultStyle };
            }
            else if (state != null)
            {
                return new object[] { state };
            }

            return null;
        }

        /// <summary>
        /// Instructs the control to track changes to its view state.
        /// </summary>
        protected override void TrackViewState()
        {
            base.TrackViewState();

            ((IStateManager)DefaultStyle).TrackViewState();
        }
    }
}

⌨️ 快捷键说明

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