Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <copyright file="DataBoundControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System.Collections;
public class DataBoundControlAdapter : WebControlAdapter {
protected new DataBoundControl Control {
get {
return (DataBoundControl)base.Control;
}
}
protected internal virtual void PerformDataBinding(IEnumerable data) {
Control.PerformDataBinding(data);
}
}
}

View File

@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <copyright file="HideDisabledControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
// Used for controls which use their default rendering, but are hidden when disabled.
public class HideDisabledControlAdapter : WebControlAdapter {
// Returns without doing anything if the control is disabled, otherwise, uses the default rendering.
protected internal override void Render(HtmlTextWriter writer) {
if (Control.Enabled == false) {
return;
}
Control.Render(writer);
}
}
}

View File

@ -0,0 +1,21 @@
//------------------------------------------------------------------------------
// <copyright file="HierarchicalDataBoundControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
public class HierarchicalDataBoundControlAdapter : WebControlAdapter {
protected new HierarchicalDataBoundControl Control {
get {
return (HierarchicalDataBoundControl)base.Control;
}
}
protected internal virtual void PerformDataBinding() {
Control.PerformDataBinding();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// <copyright file="WebControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
// Provides adaptive rendering for a web control.
public class WebControlAdapter : ControlAdapter {
// Returns a strongly typed control instance.
protected new WebControl Control {
get {
return (WebControl)base.Control;
}
}
/// Indicates whether the associated WebControl is enabled
/// taking into account the cascading effect of the enabled property.
protected bool IsEnabled {
get {
return Control.IsEnabled;
}
}
protected virtual void RenderBeginTag(HtmlTextWriter writer) {
Control.RenderBeginTag(writer);
}
protected virtual void RenderEndTag(HtmlTextWriter writer) {
Control.RenderEndTag(writer);
}
protected virtual void RenderContents(HtmlTextWriter writer) {
Control.RenderContents(writer);
}
protected internal override void Render(HtmlTextWriter writer) {
RenderBeginTag(writer);
RenderContents(writer);
RenderEndTag(writer);
}
}
}

View File

@ -0,0 +1,55 @@
//------------------------------------------------------------------------------
// <copyright file="WmlListControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
public class WmlAdRotatorAdapter : AdRotatorAdapter {
private bool _firstTimeRender = true;
private bool _wmlTopOfForm;
protected internal override void Render(HtmlTextWriter writer) {
WmlTextWriter wmlWriter = (WmlTextWriter) writer;
if (wmlWriter.AnalyzeMode) {
return;
}
if (Control.DoPostCacheSubstitutionAsNeeded(writer)) {
return;
}
// This is to work around the issue that WmlTextWriter has its
// state info for rendering block level elements, such as <p> tag.
// We keep the state info for subsequent PostCache Render call below.
//
// e.g. If the ad is at the beginning of the form, we need to
// call the method below to explicitly write out a <p> tag for
// a valid WML output.
if (_wmlTopOfForm) {
wmlWriter.BeginRender();
}
if (_firstTimeRender) {
_wmlTopOfForm = wmlWriter.TopOfForm;
_firstTimeRender = false;
}
RenderHyperLinkAsAd(writer);
}
}
}
#endif

View File

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <copyright file="WmlBaseValidatorAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.WebControls;
public class WmlBaseValidatorAdapter : WmlLabelAdapter {
protected new BaseValidator Control {
get {
return (BaseValidator)base.Control;
}
}
// Renders the control only if the control is evaluated as invalid.
protected internal override void Render(HtmlTextWriter writer) {
if (Control.Enabled &&
!Control.IsValid &&
Control.Display != ValidatorDisplay.None) {
if (Control.Text.Trim().Length == 0 && !Control.HasControls()) {
Control.Text = Control.ErrorMessage;
}
base.Render(writer);
}
}
}
}
#endif

View File

@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// <copyright file="WmlBulletedListAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Globalization;
using System.Web.UI.WebControls;
using System.Web.Util;
public class WmlBulletedListAdapter : BulletedListAdapter {
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
writer.EnterStyle(Control.ControlStyle);
IItemPaginationInfo itemPaginationInfo = (IItemPaginationInfo)Control;
int firstIndex = itemPaginationInfo.FirstVisibleItemIndex;
for (int i = firstIndex; i < firstIndex + itemPaginationInfo.VisibleItemCount; i++) {
RenderBulletText(Control.Items, i, writer);
}
writer.ExitStyle(Control.ControlStyle);
}
// Writes the text of each bullet according to the list's display mode.
protected virtual void RenderBulletText (ListItemCollection items, int index, HtmlTextWriter writer) {
switch (Control.DisplayMode) {
case BulletedListDisplayMode.Text:
writer.WriteEncodedText(items[index].Text);
writer.WriteBreak();
break;
case BulletedListDisplayMode.HyperLink:
// TODO: if index == 0, set accesskey. Needs a new RenderBeginHyperlink method.
string targetURL = Control.ResolveClientUrl(items[index].Value);
if (items[index].Enabled) {
PageAdapter.RenderBeginHyperlink(writer, targetURL, true /* encode */, items[index].Text);
writer.Write(items[index].Text);
PageAdapter.RenderEndHyperlink(writer);
} else {
writer.WriteEncodedText(items[index].Text);
}
writer.WriteBreak();
break;
case BulletedListDisplayMode.LinkButton:
if (items[index].Enabled) {
// TODO: if index == 0, set accesskey. Needs a new RenderPostBackEvent method.
PageAdapter.RenderPostBackEvent(writer, Control.UniqueID, index.ToString(CultureInfo.InvariantCulture),
items[index].Text, items[index].Text);
} else {
writer.WriteEncodedText(items[index].Text);
}
writer.WriteBreak();
break;
default:
Debug.Assert(false, "Invalid BulletedListDisplayMode");
break;
}
}
}
}
#endif

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="WmlButtonAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.WebControls;
public class WmlButtonAdapter : ButtonAdapter {
protected internal override void Render(HtmlTextWriter writer) {
RenderAsPostBackLink(writer);
}
// renders the button as a postback link
protected override void RenderAsPostBackLink(HtmlTextWriter writer) {
String text = Control.Text;
String softkeyLabel = Control.SoftkeyLabel;
string postUrl = Control.PostBackUrl;
if (!String.IsNullOrEmpty(postUrl)) {
postUrl = ((WebControl)Control).ResolveClientUrl(Control.PostBackUrl);
}
writer.EnterStyle(((WebControl)Control).ControlStyle);
// Do not encode LinkButton Text for V1 compatibility.
if (!(Control is LinkButton) ){
text = text.Replace("$", "$$");
text = HttpUtility.HtmlEncode(text);
softkeyLabel = softkeyLabel.Replace("$", "$$");
softkeyLabel = HttpUtility.HtmlEncode(softkeyLabel);
}
PageAdapter.RenderPostBackEvent(writer, ((Control)base.Control).UniqueID, null /* argument */, softkeyLabel, text, postUrl, null /* accesskey */);
writer.ExitStyle(((WebControl)Control).ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <copyright file="WmlChangePasswordAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
public class WmlChangePasswordAdapter : ChangePasswordAdapter {
// Overridden to render the validator *before* the label, to ensure the validator
// is presented on the correct screen.
protected override void RenderInput(HtmlTextWriter writer, Literal label, Control textBox, Control validator) {
validator.RenderControl(writer);
// In the ChangePassword control, many styles are applied to the table cell that contains
// a child control, rather than the child control itself. We must apply the proper
// style from the ChangePassword control to any control we create for adaptive rendering.
// VSWhidbey 81240
Label newLabel = new Label();
newLabel.Text = label.Text;
newLabel.Page = Page;
newLabel.ApplyStyle(Control.LabelStyle);
newLabel.RenderControl(writer);
// TextBoxStyle is applied directly to the TextBox in the ChangePassword control
textBox.RenderControl(writer);
}
}
}
#endif

View File

@ -0,0 +1,108 @@
//------------------------------------------------------------------------------
// <copyright file="WmlCheckBoxAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.Util;
public class WmlCheckBoxAdapter : CheckBoxAdapter, IPostBackDataHandler {
private const String _clientPrefix = "__cb_";
private string _ivalue = null;
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter) markupWriter;
// If control is not enabled, don't render it at
// all for WML.
if (!Control.Enabled) {
RenderDisabled(writer);
return;
}
((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control);
// determine if control is already checked.
// if so, set initial value.
_ivalue = Control.Checked ? "1" : String.Empty;
((WmlPageAdapter)PageAdapter).AddFormVariable (writer, Control.ClientID, _ivalue, false /* randomID */);
// does not render __ivalue if null or form variables written.
writer.WriteBeginSelect(null, null, Control.ClientID, _ivalue, Control.ToolTip, true /* multiselect*/);
if (Control.AutoPostBack) {
((WmlPageAdapter)PageAdapter).RenderSelectOptionAsAutoPostBack(writer, Control.Text, null);
}
else {
((WmlPageAdapter)PageAdapter).RenderSelectOption(writer, Control.Text);
}
writer.WriteEndSelect();
}
/// <internalonly/>
// Parse the WML posted data appropriately.
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
/// <internalonly/>
// Parse the WML posted data appropriately.
protected virtual bool LoadPostData(String key, NameValueCollection data) {
bool dataChanged = false;
String[] selectedItems = data.GetValues(key);
if (String.IsNullOrEmpty(selectedItems)) {
// This shouldn't happen if we're posting back from the form that
// contains the checkbox. It could happen when being called
// as the result of a postback from another form on the page,
// so we just return quietly.
return false;
}
// For a checkbox, our selection list
// has only one item.
Debug.Assert(selectedItems.Length == 1, "Checkbox selection " +
"list has more than one value");
string selectedItem = selectedItems[0];
if (selectedItem != null && selectedItem.Length == 0) {
dataChanged = Control.Checked == true;
Control.Checked = false;
}
else if (StringUtil.EqualsIgnoreCase(selectedItem, "1")) {
dataChanged = Control.Checked == false;
Control.Checked = true;
}
return dataChanged;
}
/// <internalonly/>
// Raises the post data changed event.
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
// Raises the post data changed event.
protected virtual void RaisePostDataChangedEvent() {
((IPostBackDataHandler)Control).RaisePostDataChangedEvent();
}
}
}
#endif

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <copyright file="WmlLiteralControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.Adapters {
using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
public class WmlDataBoundLiteralControlAdapter : DataBoundLiteralControlAdapter {
protected internal override void BeginRender(HtmlTextWriter writer) {
}
protected internal override void EndRender(HtmlTextWriter writer) {
}
// BUGBUG: This override is for compatibility with MMIT.
// MMIT legacy pages also use this adapter -UNDONE: Review once MMIT legacy plan is complete.
protected internal override void Render(HtmlTextWriter writer) {
WmlTextWriter wmlWriter = writer as WmlTextWriter;
if (wmlWriter == null) {
// MMIT legacy case (else pageAdapter would have generated a WmlTextWriter).
Control.Render(writer);
return;
}
Render(wmlWriter);
}
public virtual void Render(WmlTextWriter writer) {
((WmlPageAdapter)PageAdapter).RenderTransformedText(writer, Control.Text);
}
}
}
#endif

View File

@ -0,0 +1,27 @@
//------------------------------------------------------------------------------
// <copyright file="WmlFileUploadAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
public class WmlFileUploadAdapter : FileUploadAdapter {
protected internal override void Render(HtmlTextWriter writer) {
String alternateText = Control.AlternateText;
if (!String.IsNullOrEmpty(alternateText)) {
writer.EnterStyle(Control.ControlStyle);
writer.Write(LiteralControlAdapterUtility.ProcessWmlLiteralText(alternateText));
writer.ExitStyle(Control.ControlStyle);
}
}
}
}
#endif

View File

@ -0,0 +1,28 @@
//------------------------------------------------------------------------------
// <copyright file="WmlHiddenFieldAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
public class WmlHiddenFieldAdapter : HiddenFieldAdapter {
protected internal override void BeginRender(HtmlTextWriter writer) {
}
protected internal override void EndRender(HtmlTextWriter writer) {
}
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control.UniqueID, Control.Value, false, false);
}
}
}
#endif

View File

@ -0,0 +1,69 @@
//------------------------------------------------------------------------------
// <copyright file="WmlHyperLinkAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Util;
public class WmlHyperLinkAdapter : HyperLinkAdapter {
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
String targetUrl = Control.NavigateUrl;
String text = Control.Text;
if (text.Length == 0) {
// Whidbey 18195 UNDONE: This solution is somewhat ad hoc, awaiting spec resolution on IStaticTextControl
// in M2. For now, take text from first IStaticTextControl or DataboundLiteralControl.
foreach(Control child in Control.Controls) {
if (child is IStaticTextControl) {
text = ((IStaticTextControl)child).Text;
break;
}
else if (child is DataBoundLiteralControl) {
text = ((DataBoundLiteralControl)child).Text;
break;
}
}
}
String softkeyLabel = Control.SoftkeyLabel;
if (softkeyLabel.Length == 0) {
softkeyLabel = Control.Text;
}
writer.EnterStyle(Control.ControlStyle);
// AUI 3652
targetUrl = Control.ResolveClientUrl(targetUrl);
targetUrl = Control.GetCountClickUrl(targetUrl);
// If cookieless mode is on, we need to apply the app path modifier for if the request is authenticated
HttpContext context = HttpContext.Current;
Debug.Assert(context != null);
bool cookieless = CookielessHelperClass.UseCookieless(context, false, FormsAuthentication.CookieMode);
if (cookieless && context.Request != null && context.Request.IsAuthenticated && context.Response != null) {
targetUrl = context.Response.ApplyAppPathModifier(targetUrl);
}
PageAdapter.RenderBeginHyperlink(writer, targetUrl, false /* encode, Whidbey 111129 */, softkeyLabel, Control.AccessKey);
String source = Control.ImageUrl;
if (Control.ImageUrl != null && Control.ImageUrl.Length > 0) {
writer.RenderImage(source, null /* localsource */, text /* alternateText */);
}
else {
writer.Write(text);
}
PageAdapter.RenderEndHyperlink(writer);
writer.ExitStyle(Control.ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
// <copyright file="WmlImageAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.WebControls;
using System.Web.Util;
public class WmlImageAdapter : ImageAdapter {
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter)markupWriter;
String source = Control.ImageUrl;
String text = Control.AlternateText;
writer.EnterStyle(Control.ControlStyle);
// writer.EnterLayout(Style);
if (source != null && source.Length == 0) {
// Just write the alternate as text
writer.WriteEncodedText(text);
}
else {
String localSource;
string symbolProtocol = "symbol:";
if (StringUtil.StringStartsWith(source, symbolProtocol)) {
localSource = source.Substring(symbolProtocol.Length);
source = String.Empty;
}
else {
localSource = null;
// AUI 3652
source = Control.ResolveClientUrl(source);
}
writer.RenderImage(source, localSource, text);
}
writer.ExitStyle(Control.ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
// <copyright file="WmlImageButtonAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
// REVIEW: Inheritance. If this inherits from ImageButtonAdapter, there is no way to create a
// WmlImageAdapter and set the Control property to delegate rendering (base.Render, below). Control is read-only.
// Maybe Control should be get/set for this situation.
public class WmlImageButtonAdapter : WmlImageAdapter {
protected new ImageButton Control {
get {
return (ImageButton)base.Control;
}
}
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter) markupWriter;
string postUrl = Control.PostBackUrl;
if (!String.IsNullOrEmpty(postUrl)) {
postUrl = Control.ResolveClientUrl (Control.PostBackUrl);
}
// UNDONE: Replace hard coded string indexer with strongly typed capability.
if (Page != null && Page.Request != null && (String)Page.Request.Browser["supportsImageSubmit"] == "false") {
writer.EnterStyle(Control.ControlStyle);
PageAdapter.RenderPostBackEvent(writer, Control.UniqueID /* target */, "EA" /* argument, placeholder only */, Control.SoftkeyLabel, Control.AlternateText, postUrl, null /* accesskey */);
writer.ExitStyle(Control.ControlStyle);
return;
}
writer.EnterStyle(Control.ControlStyle);
((WmlPageAdapter)PageAdapter).RenderBeginPostBack(writer, Control.SoftkeyLabel /* maps to title attribute, Whidbey 10732 */, Control.AccessKey);
base.Render(writer);
((WmlPageAdapter)PageAdapter).RenderEndPostBack(writer, Control.UniqueID, "EA" /* argument, placeholder only */, postUrl);
writer.ExitStyle(Control.ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,99 @@
//------------------------------------------------------------------------------
// <copyright file="WmlImageMapAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Globalization;
using System.Web.UI.WebControls;
using System.Web.UI.Adapters;
using System.Collections.Specialized;
using System.Web.Util;
// Adapts the ImageMap for wml.
public class WmlImageMapAdapter : ImageMapAdapter, IPostBackDataHandler, IPostBackEventHandler {
protected internal override void OnInit(EventArgs e) {
// NB: this is required because the control names do not match the controlID
Page.RegisterRequiresPostBack(Control);
base.OnInit(e);
}
protected internal override void Render(HtmlTextWriter writer) {
if (Control.HotSpots.Count > 0) {
HotSpotMode mapMode = Control.HotSpotMode;
if (mapMode == HotSpotMode.NotSet) {
mapMode = HotSpotMode.Navigate;
}
HotSpotMode spotMode;
int hotSpotIndex = 0;
string targetURL;
string text;
foreach (HotSpot item in Control.HotSpots) {
text = item.AlternateText;
if (text != null && text.Length == 0) {
text = item.NavigateUrl;
}
spotMode = item.HotSpotMode;
if (spotMode == HotSpotMode.NotSet) {
spotMode = mapMode;
}
if (spotMode == HotSpotMode.PostBack) {
PageAdapter.RenderPostBackEvent(writer, Control.ClientID, hotSpotIndex.ToString(CultureInfo.InvariantCulture),
null, text);
}
else if (spotMode == HotSpotMode.Navigate) {
targetURL = Control.ResolveClientUrl(item.NavigateUrl);
targetURL = Control.GetCountClickUrl(targetURL);
PageAdapter.RenderBeginHyperlink(writer, targetURL, true /* encode */, null, Control.AccessKey);
writer.Write(text);
PageAdapter.RenderEndHyperlink(writer);
}
else { //HotSpotMode.Inactive
writer.Write(LiteralControlAdapterUtility.ProcessWmlLiteralText(text));
}
++hotSpotIndex;
writer.WriteBreak();
}
}
}
/// <internalonly/>
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
/// <internalonly/>
protected virtual bool LoadPostData(String key, NameValueCollection data) {
return false;
}
/// <internalonly/>
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
protected virtual void RaisePostDataChangedEvent() {
}
/// <internalonly/>
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {
RaisePostBackEvent(eventArgument);
}
/// <internalonly/>
protected virtual void RaisePostBackEvent(string eventArgument) {
((IPostBackEventHandler)Control).RaisePostBackEvent(eventArgument);
}
}
}
#endif

View File

@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <copyright file="WmlLabelAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
public class WmlLabelAdapter : LabelAdapter {
protected internal override void Render(HtmlTextWriter markupWriter) {
markupWriter.EnterStyle(Control.ControlStyle);
markupWriter.Write(LiteralControlAdapterUtility.ProcessWmlLiteralText(Control.Text));
markupWriter.ExitStyle(Control.ControlStyle);
}
}
}
#endif

View File

@ -0,0 +1,274 @@
//------------------------------------------------------------------------------
// <copyright file="WmlListControlAdapter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
#if WMLSUPPORT
namespace System.Web.UI.WebControls.Adapters {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
public class WmlListControlAdapter : ListControlAdapter, IPostBackDataHandler {
private const String ClientPrefix = "__slst_";
private string _ivalue = null;
// Called during the PreRender page lifecycle phase.
protected internal override void OnPreRender(EventArgs e) {
int realCounter;
int firstSelectedIndex;
ListItemCollection items = Control.Items;
int count = items.Count;
for (firstSelectedIndex = realCounter = 0; realCounter < count; realCounter++) {
if (items[firstSelectedIndex].Selected) {
break;
}
if (items[realCounter].Enabled) {
firstSelectedIndex++;
}
}
if (firstSelectedIndex < count) {
StringBuilder ivalue= new StringBuilder();
ivalue.Append((firstSelectedIndex + 1).ToString(CultureInfo.InvariantCulture));
if (IsMultiSelect) {
int i = 0;
for (i = realCounter = firstSelectedIndex + 1; realCounter < count; realCounter++) {
if (items[i].Selected) {
ivalue.Append(";");
ivalue.Append((i + 1).ToString(CultureInfo.InvariantCulture));
}
if (items[realCounter].Enabled) {
i++;
}
}
}
_ivalue = ivalue.ToString();
}
else {
String defaultValue = null;
// For single select list, 1st element is initially selected
// if no other selection. 1 is the first index
if (!IsMultiSelect) {
defaultValue = "1";
}
if (defaultValue != null) {
_ivalue = defaultValue;
}
}
base.OnPreRender(e);
}
protected virtual string GetInputElementText(ListItem item) {
return item.Selected ? CheckBoxAdapter.AltSelectedText : CheckBoxAdapter.AltUnselectedText;
}
protected virtual void RenderDisabledItem(HtmlTextWriter writer, ListItem item) {
string selectionText = GetInputElementText(item);
string text = item.Text;
bool renderSpace = text != null && text.Length > 0;
bool leftTextAlign = (Control is CheckBoxList && ((CheckBoxList)Control).TextAlign == TextAlign.Left);
if (leftTextAlign) {
writer.WriteEncodedText(item.Text);
if (renderSpace) {writer.Write(" ");}
writer.WriteEncodedText(selectionText);
}
else {
writer.WriteEncodedText(selectionText);
if (renderSpace) {writer.Write(" ");}
writer.WriteEncodedText(item.Text);
}
writer.WriteBreak();
}
protected internal override void Render(HtmlTextWriter markupWriter) {
WmlTextWriter writer = (WmlTextWriter) markupWriter;
ListItemCollection items = Control.Items;
int count = items.Count;
if (count == 0) {
return;
}
writer.EnterStyle(Control.ControlStyle);
bool selected = false;
if (!Control.Enabled) {
foreach (ListItem item in items) {
// VSWhidbey 115824
if (item.Selected) {
if (selected) {
Control.VerifyMultiSelect();
}
selected = true;
}
RenderDisabledItem(writer, item);
}
}
else {
// Only register post fields if the control is enabled.
((WmlPageAdapter)PageAdapter).RegisterPostField(writer, Control);
if (_ivalue != null) {
((WmlPageAdapter)PageAdapter).AddFormVariable(writer, Control.ClientID, _ivalue, false);
}
// does not render _ivalue if null or form variables written.
writer.WriteBeginSelect(null /*name*/,
null /*value*/,
Control.ClientID /*iname*/,
_ivalue /*ivalue*/,
Control.ToolTip /*title*/,
IsMultiSelect);
foreach (ListItem item in items) {
// If the item is disabled, don't render it.
// WML only allows selectable <options> within <select> elements.
if (!item.Enabled) {
continue;
}
// VSWhidbey 115824
if (item.Selected) {
if (selected && !IsMultiSelect) {
throw new HttpException(SR.GetString(SR.Cant_Multiselect_In_Single_Mode));
}
selected = true;
}
RenderSelectOption(writer, item);
}
writer.WriteEndSelect();
}
writer.ExitStyle(Control.ControlStyle);
}
internal virtual void RenderSelectOption(WmlTextWriter writer, ListItem item) {
if (Control.AutoPostBack) {
((WmlPageAdapter)PageAdapter).RenderSelectOptionAsAutoPostBack(writer, item.Text, null);
}
else {
((WmlPageAdapter)PageAdapter).RenderSelectOption(writer, item.Text);
}
}
/// <internalonly/>
// Implements IPostBackDataHandler.LoadPostData.
bool IPostBackDataHandler.LoadPostData(String key, NameValueCollection data) {
return LoadPostData(key, data);
}
/// <internalonly/>
// Implements IPostBackDataHandler.LoadPostData.
protected virtual bool LoadPostData(String key, NameValueCollection data) {
int[] selectedItemIndices;
bool dataChanged = false;
String[] selectedItems = data.GetValues(key);
if (selectedItems == null || Control.Items.Count == 0) {
return false;
}
ArrayList originalSelection = Control.SelectedIndicesInternal;
if (originalSelection == null) {
originalSelection = new ArrayList();
}
// If singleselect && nothing was selected, select
// first element.
if (!IsMultiSelect &&
originalSelection.Count == 0 &&
Control.Items.Count > 0) {
Control.Items[0].Selected = true;
}
// Case where nothing is selected.
if (selectedItems == null ||
(selectedItems.Length == 1 &&
selectedItems[0] != null &&
((String)selectedItems[0]).Length == 0) ||
(selectedItems.Length == 1 &&
selectedItems[0] == "0")) {
// non-selected MultiSelect case
selectedItems = new String[]{};
}
// WML multiselect case with more than one selection.
if (selectedItems.Length == 1 && selectedItems[0].IndexOf(';') > -1) {
String selected = selectedItems[0];
// Eliminate trailing semicolon, if there is one.
selected = Regex.Replace(selected, ";$", String.Empty);
selectedItems = Regex.Split(selected, ";");
}
selectedItemIndices = new int[selectedItems.Length];
for (int i = 0; i < selectedItems.Length; i++) {
// WML iname gives index + 1, so subtract one back out.
string selItem = selectedItems[i];
selectedItemIndices[i] = Int32.Parse(selItem, CultureInfo.InvariantCulture) - 1;
}
// Do not assume posted selected indices are ascending.
// We do know originalSelectedIndices are ascending.
Array.Sort(selectedItemIndices);
// Check whether selections have changed.
if (selectedItemIndices.Length != originalSelection.Count) {
dataChanged = true;
}
else {
for (int i = 0; i < selectedItemIndices.Length; i++) {
if (selectedItemIndices[i] != (int)originalSelection[i]) {
dataChanged = true;
}
}
}
// Update selections
Control.ClearSelection();
for (int i = 0; i < selectedItemIndices.Length; i++) {
Control.Items[selectedItemIndices[i]].Selected = true;
}
return dataChanged;
}
/// <internalonly/>
// Implements IPostBackDataHandler.RaisePostDataChangedEvent.
void IPostBackDataHandler.RaisePostDataChangedEvent() {
RaisePostDataChangedEvent();
}
/// <internalonly/>
// Implements IPostBackDataHandler.RaisePostDataChangedEvent.
protected virtual void RaisePostDataChangedEvent() {
((IPostBackDataHandler)Control).RaisePostDataChangedEvent();
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More