📄 webcontrol.cs
字号:
/*===========================================*/
//* 此类已经翻译基本完毕,除了部分属性的Atrributes外!
/*===========================================*/
using System;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for WebControl.
/// </summary>
[System.Web.UI.PersistChildren(false)]
[System.Web.UI.ParseChildren(false)]
public class WebControl : System.Web.UI.Control, System.Web.UI.IAttributeAccessor
{
private const int accessKeySet = 8;
private System.Web.UI.AttributeCollection attrColl;
private System.Web.UI.StateBag attrState;
private System.Web.UI.WebControls.Style controlStyle;
private const int deferStyleLoadViewState = 1;
private const int disabled = 2;
private const int disabledDirty = 4;
private System.Web.Util.SimpleBitVector32 flags;
private const int tabIndexSet = 32;
private System.Web.UI.HtmlTextWriterTag tagKey;
private string tagName;
private const int toolTipSet = 16;
/// <summary>
/// 缺省构造函数会调用另一个构造函数来产生一个Span。
/// </summary>
public WebControl() : this(System.Web.UI.HtmlTextWriterTag.Span)
{
}
public WebControl(System.Web.UI.HtmlTextWriterTag tag) : base()
{
this.tagKey = tag;
}
public WebControl(string tag) : base()
{
this.tagKey = System.Web.UI.HtmlTextWriterTag.Unknown;
this.tagName = tag;
}
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
protected virtual void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
string V_0;
int V_1;
System.Web.UI.AttributeCollection V_2;
System.Collections.IEnumerator V_3;
string V_4;
if(this.ID != null)
{
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Id, this.ClientID);
if(this.flags[8])
{
V_0 = this.AccessKey;
if(V_0.Length != 0)
{
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Accesskey,V_0);
}
}
}
if(!(this.Enabled))
{
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Disabled,"disabled");
}
if(this.flags[32])
{
V_1 = this.TabIndex;
if(V_1 != 0)
{
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Tabindex,V_1.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
}
if(this.flags[16])
{
V_0 = this.ToolTip;
if(V_0.Length != 0)
{
writer.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Title,V_0);
}
}
if(this.ControlStyleCreated)
{
if(!(this.ControlStyle.IsEmpty))
{
this.ControlStyle.AddAttributesToRender(writer, this);
}
}
if(this.attrState != null)
{
V_2 = this.Attributes;
V_3 = V_2.Keys.GetEnumerator();
while(V_3.MoveNext())
{
V_4 = (string)V_3.Current;
writer.AddAttribute(V_2[V_4],V_4);
}
}
}
public void ApplyStyle(System.Web.UI.WebControls.Style s)
{
if(s != null)
{
if(!(s.IsEmpty))
{
this.ControlStyle.CopyFrom(s);
}
}
}
public void CopyBaseAttributes(System.Web.UI.WebControls.WebControl controlSrc)
{
string V_0;
System.Collections.IEnumerator V_1;
System.IDisposable V_2;
if(controlSrc.flags[8])
{
this.AccessKey = controlSrc.AccessKey;
}
if(!(controlSrc.Enabled))
{
this.Enabled = false;
}
if(controlSrc.flags[16])
{
this.ToolTip = controlSrc.ToolTip;
}
if(controlSrc.flags[32])
{
this.TabIndex = controlSrc.TabIndex;
}
V_1 = controlSrc.Attributes.Keys.GetEnumerator();
try
{
while(V_1.MoveNext())
{
V_0 = (string)V_1.Current;
this.Attributes[V_0] = controlSrc.Attributes[V_0];
}
}
finally
{
V_2 = V_1 as System.IDisposable;
if(V_2 != null)
{
V_2.Dispose();
}
}
}
protected virtual System.Web.UI.WebControls.Style CreateControlStyle()
{
return(new System.Web.UI.WebControls.Style(this.ViewState));
}
protected override void LoadViewState(object savedState)
{
System.Web.UI.Pair V_0;
object V_1;
if(savedState != null)
{
V_0 = (System.Web.UI.Pair)savedState;
base.LoadViewState(V_0.First);
if(!(this.ChildControlsCreated))
{
if(this.ViewState["_!SB"] != null)
{
this.ControlStyle.LoadViewState(null);
}
}
else
{
this.flags[1] = true;
}
if(V_0.Second != null)
{
if(this.attrState == null)
{
this.attrState = new System.Web.UI.StateBag(true);
}
((System.Web.UI.IStateManager)this.attrState).TrackViewState();
((System.Web.UI.IStateManager)this.attrState).LoadViewState(V_0.Second);
}
V_1 = this.ViewState["Enabled"];
if(V_1 != null)
{
this.flags[2] = (!((bool)V_1));
this.flags[4] = true;
}
if(((System.Collections.IDictionary)this.ViewState).Contains("AccessKey"))
{
this.flags[8] = true;
}
if(((System.Collections.IDictionary)this.ViewState).Contains("TabIndex"))
{
this.flags[32] = true;
}
if(((System.Collections.IDictionary)this.ViewState).Contains("ToolTip"))
{
this.flags[16] = true;
}
}
}
public void MergeStyle(System.Web.UI.WebControls.Style s)
{
if(s != null)
{
if(!(s.IsEmpty))
{
this.ControlStyle.MergeWith(s);
}
}
}
protected virtual void Render(System.Web.UI.HtmlTextWriter writer)
{
this.RenderBeginTag(writer);
this.RenderContents(writer);
this.RenderEndTag(writer);
}
public virtual void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
{
System.Web.UI.HtmlTextWriterTag V_0;
this.AddAttributesToRender(writer);
V_0 = this.TagKey;
if(V_0 != System.Web.UI.HtmlTextWriterTag.Unknown)
{
writer.RenderBeginTag(V_0);
}
else
{
writer.RenderBeginTag(this.TagName);
}
}
protected virtual void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
base.Render(writer);
}
public virtual void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
{
writer.RenderEndTag();
}
protected override object SaveViewState()
{
System.Web.UI.Pair V_0;
object V_1;
object V_2;
V_0 = null;
if(this.flags[4])
{
this.ViewState["Enabled"] = (!(this.flags[2]));
}
if(this.ControlStyleCreated)
{
this.ControlStyle.SaveViewState();
}
V_1 = this.SaveViewState();
V_2 = null;
if(this.attrState != null)
{
V_2 = ((System.Web.UI.IStateManager)this.attrState).SaveViewState();
}
if(V_1 ==null || V_2== null)
{
V_0 = new System.Web.UI.Pair(V_1, V_2);
}
return(V_0);
}
string System.Web.UI.IAttributeAccessor.GetAttribute(string name)
{
if(this.attrState == null)
{
return(null);
}
return (string)this.attrState[name];
}
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value)
{
this.Attributes[name] = value;
}
protected override void TrackViewState()
{
base.TrackViewState();
if(this.ControlStyleCreated)
{
this.ControlStyle.TrackViewState();
}
if(this.attrState != null)
{
((System.Web.UI.IStateManager)this.attrState).TrackViewState();
}
}
//[System.Web.WebCategory("Behavior")]
[System.ComponentModel.Bindable(true)]
//[System.Web.WebSysDescription("WebControl_AccessKey")]
[System.ComponentModel.DefaultValue("")]
public virtual string AccessKey
{
get
{
string V_0;
if(this.flags[8])
{
V_0 = (string)base.ViewState["AccessKey"];
if(V_0 != null)
{
return(V_0);
}
}
return(string.Empty);
}
set
{
if(value != null)
{
if(value.Length > 1)
{
throw new ArgumentOutOfRangeException("value");
}
base.ViewState["AccessKey"] = value;
this.flags[8] = true;
}
}
}
protected virtual System.Web.UI.HtmlTextWriterTag TagKey
{
get
{
return(this.tagKey);
}
set
{
//TODO:GetAttribute
throw new Exception("TODO");
}
}
public virtual string TagName
{
get
{
if(this.tagName == null)
{
if(this.tagKey != System.Web.UI.HtmlTextWriterTag.Unknown)
{
this.tagName = Enum.Format(typeof(System.Web.UI.HtmlTextWriterTag),this.tagKey, "G").ToLower();
}
}
return(this.tagName);
}
}
public virtual string ToolTip
{
get
{
string V_0;
if(this.flags[16])
{
V_0 = (string)base.ViewState["ToolTip"];
return(V_0);
}
return(string.Empty);
}
set
{
this.ViewState["TabIndex"] = value;
this.flags[16] = true;
}
}
public virtual System.Drawing.Color ForeColor
{
get
{
if(this.ControlStyleCreated)
{
return System.Drawing.Color.Empty;
}
return(this.ControlStyle.ForeColor);
}
set
{
this.ControlStyle.ForeColor = value;
}
}
public virtual System.Web.UI.WebControls.FontInfo Font
{
get
{
return(this.ControlStyle.Font);
}
}
public virtual bool Enabled
{
get
{
return(!(this.flags[2]));
}
set
{
bool V_0;
V_0 = (!(this.flags[2]));
if(V_0 != value)
{
this.flags[2] = !(value);
if(this.IsTrackingViewState)
{
this.flags[4] = true;
}
}
}
}
public bool ControlStyleCreated
{
get
{
return (this.controlStyle != null);
}
}
public virtual string CssClass
{
get
{
if(!(ControlStyleCreated))
{
return(string.Empty);
}
return(this.controlStyle.CssClass);
}
set
{
this.ControlStyle.CssClass = value;
}
}
public virtual short TabIndex
{
get
{
object V_0;
if(this.flags[32])
{
V_0 = this.ViewState["TabIndex"];
if(V_0 != null)
{
return(short)V_0;
}
}
return(0);
}
set
{
this.ViewState["TabIndex"] = value;
this.flags[32] = true;
}
}
public System.Web.UI.WebControls.Style ControlStyle
{
get
{
if(this.controlStyle == null)
{
this.controlStyle = this.CreateControlStyle();
if(this.IsTrackingViewState)
{
this.controlStyle.TrackViewState();
}
if(this.flags[1])
{
this.flags[1] = false;
this.controlStyle.LoadViewState(null);
}
}
return(controlStyle);
}
set
{
//TODO:GetAttribute
throw new Exception("TODO");
}
}
//[System.Web.WebSysDescription("WebControl_Attributes")]
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
public System.Web.UI.AttributeCollection Attributes
{
get
{
if(this.attrColl == null)
{
if(this.attrState == null)
{
this.attrState = new System.Web.UI.StateBag(true);
if(this.IsTrackingViewState)
{
((System.Web.UI.IStateManager)this.attrState).TrackViewState();
}
}
this.attrColl = new System.Web.UI.AttributeCollection(attrState);
}
return(this.attrColl);
}
}
public System.Web.UI.CssStyleCollection Style
{
get
{
return this.Attributes.CssStyle;
}
}
public virtual System.Drawing.Color BackColor
{
get
{
if(!(this.ControlStyleCreated))
{
return(System.Drawing.Color.Empty);
}
return(this.ControlStyle.BackColor);
}
set
{
this.ControlStyle.BackColor = value;
}
}
public virtual System.Drawing.Color BorderColor
{
get
{
if(!(this.ControlStyleCreated))
{
return(System.Drawing.Color.Empty);
}
return(this.ControlStyle.BorderColor);
}
set
{
this.ControlStyle.BorderColor = value;
}
}
public virtual System.Web.UI.WebControls.BorderStyle BorderStyle
{
get
{
if(!(this.ControlStyleCreated))
{
// return System.Web.UI.WebControls.BorderStyle.NotSet;
throw new Exception("");
}
return(this.ControlStyle.BorderStyle);
}
set
{
this.ControlStyle.BorderStyle = value;
}
}
public virtual System.Web.UI.WebControls.Unit BorderWidth
{
get
{
if(!(this.ControlStyleCreated))
{
return System.Web.UI.WebControls.Unit.Empty;
}
return(this.ControlStyle.BorderWidth);
}
set
{
if(value.Value < 0.0)
{
throw new ArgumentOutOfRangeException("value");
}
this.ControlStyle.BorderWidth = value;
}
}
public virtual System.Web.UI.WebControls.Unit Height
{
get
{
if(!(this.ControlStyleCreated))
{
return System.Web.UI.WebControls.Unit.Empty;
}
return(this.ControlStyle.Height);
}
set
{
if(value.Value < 0.0)
{
throw new ArgumentOutOfRangeException("value");
}
this.ControlStyle.Height = value;
}
}
public virtual System.Web.UI.WebControls.Unit Width
{
get
{
if(!(this.ControlStyleCreated))
{
return System.Web.UI.WebControls.Unit.Empty;
}
return(this.ControlStyle.Width);
}
set
{
if(value.Value < 0.0)
{
throw new ArgumentOutOfRangeException("value");
}
this.ControlStyle.Width = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -