CSDN博客

img z329175905

最新写的toolbar

发表于2008/9/28 18:04:00  178人阅读

using System;
using System.Collections.Generic;
using System.Text;
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.Text;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;

namespace SysControl
{
    [DefaultEvent("Click")]
    [ToolboxData("<{0}:form1 runat=server></{0}:form1>")]
    public class sysToolbar1 : Panel, IPostBackEventHandler
    {
         public sysToolbar1()
         {
             AddToolbar(this);
            
         }
         protected string getToolbartitles="";
         protected string getToolbarItems="";
        public virtual string Toolbartitles
         {
             get { return getToolbartitles; }
             set { getToolbartitles = value; }
         }
         public string getItemName="";
        public virtual string ToolbarItems
         {
             get { return getToolbarItems; }
             set { getToolbarItems = value; }
         }
        public virtual string ToolItemName
         {
             get { return getItemName; }
             set { getItemName = value; }
         }
         protected string getTitle="";
        public virtual string Titlestr
         {
             get { return getTitle; }
             set { getTitle = value; }
         }
         private void AddToolbar(Panel divs)
         {
             sysdiv div = new sysdiv();
             div.classstr = "top_banner";
             sysdiv div1 = new sysdiv();
             div1.onclickstr = "sysf_ShowMenuSetting("+divs.ClientID+")";
             div1.classstr = "NavigatorBannerTitle";
             div1.stylestr = "float:left;";
             div1.texts = "卡片信息";
             div.Controls.Add(div1);
             sysdiv div2 = new sysdiv();
             div2.stylestr = "float:right;margin-top:5px;";
             sysTable tab = new sysTable();
             tab.stylestr = "border-width:0px;height:16px;border-collapse:collapse;";
             tab.CellSpacing=0;
             tab.CellPadding=0;
             tab.BorderWidth=0;
             sysTabRow row = new sysTabRow();
             row.classstr = "banner_bt_table";
          
             string[] Toolbartitlesstr = Toolbartitles.Split(',');
             string[] ToolbarItemsstr = ToolbarItems.Split(',');
             string[] ItemNamestr = ToolItemName.Split(',');
             for (int i = 0; i < Toolbartitlesstr.Length; i++)
             {
                 row.Controls.Add(addCel(Toolbartitlesstr[i], ToolbarItemsstr[i],ItemNamestr[i]));
                 sysTabcel cel2 = new sysTabcel();
                 cel2.stylestr = "width:16px;";
                 cel2.Text = "|";
                 row.Controls.Add(cel2);
             }
           
       
             tab.Controls.Add(row);
             div2.Controls.Add(tab);
             div.Controls.Add(div2);
             divs.Controls.Add(div);
    
            
         }

         private Control addCel(string Toolbartitlesstr, string ToolbarItemsstr, string ItemNamestr)
         {
             sysTabcel cel = new sysTabcel();
             cel.stylestr = "white-space:nowrap;";
             syslable labe1 = new syslable();
             labe1.stylestr = "cursor:hand;";
             labe1.classstr = "STYLE10";
             labe1.onclickstr = "f_add()";
             labe1.ID ="add";
             labe1.texts = "增加";
             cel.Controls.Add(labe1);
             return cel;
         }
         protected override void AddAttributesToRender(HtmlTextWriter writer)
         {
             base.AddAttributesToRender(writer);
             writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%");
             writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
             writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
             writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            
         }
         //
         // 摘要:
         //     将 System.Web.UI.WebControls.Panel 控件的 HTML 开始标记呈现到指定的编写器中。
         //
         // 参数:
         //   writer:
         //     System.Web.UI.HtmlTextWriter,表示要在客户端呈现 HTML 内容的输出流。
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
           
        }
         // 定义一个Click事件委托对象
         private static readonly object EventClick = new object();
         //实现Click事件属性
         [Description("Click事件属性"), Category("Action")]
         public event EventHandler Click
         {
             add
             {
                 Events.AddHandler(EventClick, value);
             }
             remove
             {
                 Events.RemoveHandler(EventClick, value);
             }
         }
         void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
         {
             OnClick(EventArgs.Empty, eventArgument);
             //if (eventArgument == "Previous")
             //    PreviousText = "你点击了PreviousText按钮";
             //else if (eventArgument == "Next")
             //    NextText = "你点击了NextText按钮";
         }      //实现事件方法
         protected virtual void OnClick(EventArgs e, string eventArgument)
         {

             EventHandler clickHandler = (EventHandler)Events[EventClick];
             if (clickHandler != null)
             {
                 clickHandler(this, e);
             }

         }
     }
     #region 自定义自控件
     class sysdiv : Panel
    {
        public sysdiv()
        {
        
        }
        private string getonclick;
        private string getclassstr;
        private string getstylestr;
        private string getAlignstr="";
        private string gettexts="";
        public string onclickstr
        {
            get { return getonclick; }
            set { getonclick = value; }
        }
        public string Alignstr
        {
            get { return getAlignstr; }
            set { getAlignstr = value; }
        }
        public string classstr
        {
            get { return getclassstr; }
            set { getclassstr = value; }
        }
        public string stylestr
        {
            get { return getstylestr; }
            set { getstylestr = value; }
        }
        public string texts
        {
            get { return gettexts; }
            set { gettexts = value; }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickstr);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, getclassstr);
            writer.AddStyleAttribute("", stylestr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, Alignstr);
            AddText(this);
        }
        void AddText(Panel div)
        {
            systext tex = new systext();
            tex.Text = texts;
            div.Controls.Add(tex);
        }
   
    }
     class sysTable : Table
    {
         private string getonclick;
        private string getclassstr;
        private string getstylestr;
        private string gettexts;
         public string onclickstr
        {
            get { return getonclick; }
            set { getonclick = value; }
        }
        public string classstr
        {
            get { return getclassstr; }
            set { getclassstr = value; }
        }
        public string stylestr
        {
            get { return getstylestr; }
            set { getstylestr = value; }
        }
        public string texts
        {
            get { return gettexts; }
            set { gettexts = value; }
        }
         private string getAlignstr = "";
         public string Alignstr
         {
             get { return getAlignstr; }
             set { getAlignstr = value; }
         }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickstr);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, getclassstr);
            writer.AddStyleAttribute("", stylestr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, Alignstr);
        
        }
        //protected override void RenderContents(HtmlTextWriter writer)
        //{

        //}
    }
    class sysTabcel : TableCell
    {
        public sysTabcel()
        {
       
        }
        private string getonclick;
        private string getclassstr;
        private string getstylestr;
        public string onclickstr
        {
            get { return getonclick; }
            set { getonclick = value; }
        }
        public string classstr
        {
            get { return getclassstr; }
            set { getclassstr = value; }
        }
        public string stylestr
        {
            get { return getstylestr; }
            set { getstylestr = value; }
        }
        private string getAlignstr = "";
        public string Alignstr
        {
            get { return getAlignstr; }
            set { getAlignstr = value; }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickstr);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, getclassstr);
            writer.AddStyleAttribute("", stylestr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, Alignstr);

        }
    
    }
    class sysTabRow : TableRow
    {
        public sysTabRow()
        {
       
        }
        private string getonclick;
        private string getclassstr;
        private string getstylestr;
        public string onclickstr
        {
            get { return getonclick; }
            set { getonclick = value; }
        }
        public string classstr
        {
            get { return getclassstr; }
            set { getclassstr = value; }
        }
        public string stylestr
        {
            get { return getstylestr; }
            set { getstylestr = value; }
        }
        private string getAlignstr = "";
        public string Alignstr
        {
            get { return getAlignstr; }
            set { getAlignstr = value; }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickstr);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, getclassstr);
            writer.AddStyleAttribute("", stylestr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, Alignstr);

        }
     
    }
    class syslable : Label
    {
        public syslable() { }
        private string getonclick;
        private string getclassstr;
        private string getstylestr;
        private string gettexts="";
        public string onclickstr
        {
            get { return getonclick; }
            set { getonclick = value; }
        }
        public string classstr
        {
            get { return getclassstr; }
            set { getclassstr = value; }
        }
        public string stylestr
        {
            get { return getstylestr; }
            set { getstylestr = value; }
        }
        public string texts
        {
            get { return gettexts; }
            set { gettexts = value; }
        }
        private string getAlignstr = "";
        public string Alignstr
        {
            get { return getAlignstr; }
            set { getAlignstr = value; }
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onclickstr);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, getclassstr);
            writer.AddStyleAttribute("", stylestr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, Alignstr);
            AddText(this);
        }
        void AddText(Label la)
        {
            systext tex = new systext();
            tex.Text = texts;
            la.Controls.Add(tex);
        }
    }
   class systext : System.Web.UI.Control
    {
       public systext()
        {
       
        }
        string gettext="";
        public string Text
        {

            get
            {

 

                return gettext;

            }

            set
            {

                this.gettext= value;

            }

        }

        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(Text);

        }

    }
     #endregion


}

235168650

0 0

相关博文

我的热门文章

img
取 消
img