Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / ControlAdapter.cs / 1305376 / ControlAdapter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Globalization; using System.IO; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.Mobile; using RootMobile = System.Web.Mobile; using System.Web.UI.MobileControls; using System.Collections; using System.Collections.Specialized; using System.Text; using System.Security.Permissions; // We don't recompile this base class in the shipped source samples, as it // accesses some internal functionality and is a core utility (rather than an // extension itself). #if !COMPILING_FOR_SHIPPED_SOURCE namespace System.Web.UI.MobileControls.Adapters { /* * ControlAdapter base class. * * Copyright (c) 2000 Microsoft Corporation */ ///[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public abstract class ControlAdapter : IControlAdapter { private static readonly String[] LabelIDs = new String[] { RootMobile.SR.ControlAdapter_BackLabel, RootMobile.SR.ControlAdapter_GoLabel, RootMobile.SR.ControlAdapter_OKLabel, RootMobile.SR.ControlAdapter_MoreLabel, RootMobile.SR.ControlAdapter_OptionsLabel, RootMobile.SR.ControlAdapter_NextLabel, RootMobile.SR.ControlAdapter_PreviousLabel, RootMobile.SR.ControlAdapter_LinkLabel, RootMobile.SR.ControlAdapter_PhoneCallLabel }; /// protected static readonly int BackLabel = 0; /// protected static readonly int GoLabel = 1; /// protected static readonly int OKLabel = 2; /// protected static readonly int MoreLabel = 3; /// protected static readonly int OptionsLabel = 4; /// protected static readonly int NextLabel = 5; /// protected static readonly int PreviousLabel = 6; /// protected static readonly int LinkLabel = 7; /// protected static readonly int CallLabel = 8; private MobileControl _control; /// public MobileControl Control { get { return _control; } set { _control = value; } } /// public virtual MobilePage Page { get { return Control.MobilePage; } set { // Do not expect to be called directly. Subclasses should // override this when needed. throw new Exception( SR.GetString( SR.ControlAdapterBasePagePropertyShouldNotBeSet)); } } /// public virtual MobileCapabilities Device { get { return (MobileCapabilities)Page.Request.Browser; } } /// public virtual void OnInit(EventArgs e){} /// public virtual void OnLoad(EventArgs e){} /// public virtual void OnPreRender(EventArgs e){} /// public virtual void Render(HtmlTextWriter writer) { RenderChildren(writer); } /// public virtual void OnUnload(EventArgs e){} /// public virtual bool HandlePostBackEvent(String eventArgument) { return false; } // By default, always return false, so the control itself will handle // it. /// public virtual bool LoadPostData(String key, NameValueCollection data, Object controlPrivateData, out bool dataChanged) { dataChanged = false; return false; } /// public virtual void LoadAdapterState(Object state) { } /// public virtual Object SaveAdapterState() { return null; } /// public virtual void CreateTemplatedUI(bool doDataBind) { // No device specific templated UI to create. Control.CreateDefaultTemplatedUI(doDataBind); } // convenience methods here /// public Style Style { get { return Control.Style; } } /// protected void RenderChildren(HtmlTextWriter writer) { if (Control.HasControls()) { foreach (Control child in Control.Controls) { child.RenderControl(writer); } } } /// public virtual int VisibleWeight { get { return ControlPager.UseDefaultWeight; } } /// public virtual int ItemWeight { get { return ControlPager.UseDefaultWeight; } } // The following method is used by PageAdapter subclasses of // ControlAdapter for determining the optimum page weight for // a given device. Algorithm is as follows: // 1) First look for the "optimumPageWeight" parameter set // for the device. If it exists, and can be converted // to an integer, use it. // 2) Otherwise, look for the "screenCharactersHeight" parameter. // If it exists, and can be converted to an integer, multiply // it by 100 and use the result. // 3) As a last resort, use the default provided by the calling // PageAdapter. /// protected virtual int CalculateOptimumPageWeight(int defaultPageWeight) { int optimumPageWeight = 0; // Pull OptimumPageWeight from the web.config parameter of the same // name, when present. String pageWeight = Device[Constants.OptimumPageWeightParameter]; if (pageWeight != null) { try { optimumPageWeight = Convert.ToInt32(pageWeight, CultureInfo.InvariantCulture); } catch { optimumPageWeight = 0; } } if (optimumPageWeight <= 0) { // If OptimumPageWeight isn't established explicitly, attempt to // construct it as 100 * number of lines of characters. String numLinesStr = Device[Constants.ScreenCharactersHeightParameter]; if (numLinesStr != null) { try { int numLines = Convert.ToInt32(numLinesStr, CultureInfo.InvariantCulture); optimumPageWeight = 100 * numLines; } catch { optimumPageWeight = 0; } } } if (optimumPageWeight <= 0) { optimumPageWeight = defaultPageWeight; } return optimumPageWeight; } private String[] _defaultLabels = null; /// protected String GetDefaultLabel(int labelID) { if ((labelID < 0) || (labelID >= LabelIDs.Length)) { throw new ArgumentException(System.Web.Mobile.SR.GetString( System.Web.Mobile.SR.ControlAdapter_InvalidDefaultLabel)); } MobilePage page = Page; if (page != null) { ControlAdapter pageAdapter = (ControlAdapter)page.Adapter; if (pageAdapter._defaultLabels == null) { pageAdapter._defaultLabels = new String[LabelIDs.Length]; } String labelValue = pageAdapter._defaultLabels[labelID]; if (labelValue == null) { labelValue = System.Web.Mobile.SR.GetString(LabelIDs[labelID]); pageAdapter._defaultLabels[labelID] = labelValue; } return labelValue; } else { return System.Web.Mobile.SR.GetString(LabelIDs[labelID]); } } } [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] internal class EmptyControlAdapter : ControlAdapter { internal EmptyControlAdapter() {} } } #endif // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Globalization; using System.IO; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.Mobile; using RootMobile = System.Web.Mobile; using System.Web.UI.MobileControls; using System.Collections; using System.Collections.Specialized; using System.Text; using System.Security.Permissions; // We don't recompile this base class in the shipped source samples, as it // accesses some internal functionality and is a core utility (rather than an // extension itself). #if !COMPILING_FOR_SHIPPED_SOURCE namespace System.Web.UI.MobileControls.Adapters { /* * ControlAdapter base class. * * Copyright (c) 2000 Microsoft Corporation */ ///[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public abstract class ControlAdapter : IControlAdapter { private static readonly String[] LabelIDs = new String[] { RootMobile.SR.ControlAdapter_BackLabel, RootMobile.SR.ControlAdapter_GoLabel, RootMobile.SR.ControlAdapter_OKLabel, RootMobile.SR.ControlAdapter_MoreLabel, RootMobile.SR.ControlAdapter_OptionsLabel, RootMobile.SR.ControlAdapter_NextLabel, RootMobile.SR.ControlAdapter_PreviousLabel, RootMobile.SR.ControlAdapter_LinkLabel, RootMobile.SR.ControlAdapter_PhoneCallLabel }; /// protected static readonly int BackLabel = 0; /// protected static readonly int GoLabel = 1; /// protected static readonly int OKLabel = 2; /// protected static readonly int MoreLabel = 3; /// protected static readonly int OptionsLabel = 4; /// protected static readonly int NextLabel = 5; /// protected static readonly int PreviousLabel = 6; /// protected static readonly int LinkLabel = 7; /// protected static readonly int CallLabel = 8; private MobileControl _control; /// public MobileControl Control { get { return _control; } set { _control = value; } } /// public virtual MobilePage Page { get { return Control.MobilePage; } set { // Do not expect to be called directly. Subclasses should // override this when needed. throw new Exception( SR.GetString( SR.ControlAdapterBasePagePropertyShouldNotBeSet)); } } /// public virtual MobileCapabilities Device { get { return (MobileCapabilities)Page.Request.Browser; } } /// public virtual void OnInit(EventArgs e){} /// public virtual void OnLoad(EventArgs e){} /// public virtual void OnPreRender(EventArgs e){} /// public virtual void Render(HtmlTextWriter writer) { RenderChildren(writer); } /// public virtual void OnUnload(EventArgs e){} /// public virtual bool HandlePostBackEvent(String eventArgument) { return false; } // By default, always return false, so the control itself will handle // it. /// public virtual bool LoadPostData(String key, NameValueCollection data, Object controlPrivateData, out bool dataChanged) { dataChanged = false; return false; } /// public virtual void LoadAdapterState(Object state) { } /// public virtual Object SaveAdapterState() { return null; } /// public virtual void CreateTemplatedUI(bool doDataBind) { // No device specific templated UI to create. Control.CreateDefaultTemplatedUI(doDataBind); } // convenience methods here /// public Style Style { get { return Control.Style; } } /// protected void RenderChildren(HtmlTextWriter writer) { if (Control.HasControls()) { foreach (Control child in Control.Controls) { child.RenderControl(writer); } } } /// public virtual int VisibleWeight { get { return ControlPager.UseDefaultWeight; } } /// public virtual int ItemWeight { get { return ControlPager.UseDefaultWeight; } } // The following method is used by PageAdapter subclasses of // ControlAdapter for determining the optimum page weight for // a given device. Algorithm is as follows: // 1) First look for the "optimumPageWeight" parameter set // for the device. If it exists, and can be converted // to an integer, use it. // 2) Otherwise, look for the "screenCharactersHeight" parameter. // If it exists, and can be converted to an integer, multiply // it by 100 and use the result. // 3) As a last resort, use the default provided by the calling // PageAdapter. /// protected virtual int CalculateOptimumPageWeight(int defaultPageWeight) { int optimumPageWeight = 0; // Pull OptimumPageWeight from the web.config parameter of the same // name, when present. String pageWeight = Device[Constants.OptimumPageWeightParameter]; if (pageWeight != null) { try { optimumPageWeight = Convert.ToInt32(pageWeight, CultureInfo.InvariantCulture); } catch { optimumPageWeight = 0; } } if (optimumPageWeight <= 0) { // If OptimumPageWeight isn't established explicitly, attempt to // construct it as 100 * number of lines of characters. String numLinesStr = Device[Constants.ScreenCharactersHeightParameter]; if (numLinesStr != null) { try { int numLines = Convert.ToInt32(numLinesStr, CultureInfo.InvariantCulture); optimumPageWeight = 100 * numLines; } catch { optimumPageWeight = 0; } } } if (optimumPageWeight <= 0) { optimumPageWeight = defaultPageWeight; } return optimumPageWeight; } private String[] _defaultLabels = null; /// protected String GetDefaultLabel(int labelID) { if ((labelID < 0) || (labelID >= LabelIDs.Length)) { throw new ArgumentException(System.Web.Mobile.SR.GetString( System.Web.Mobile.SR.ControlAdapter_InvalidDefaultLabel)); } MobilePage page = Page; if (page != null) { ControlAdapter pageAdapter = (ControlAdapter)page.Adapter; if (pageAdapter._defaultLabels == null) { pageAdapter._defaultLabels = new String[LabelIDs.Length]; } String labelValue = pageAdapter._defaultLabels[labelID]; if (labelValue == null) { labelValue = System.Web.Mobile.SR.GetString(LabelIDs[labelID]); pageAdapter._defaultLabels[labelID] = labelValue; } return labelValue; } else { return System.Web.Mobile.SR.GetString(LabelIDs[labelID]); } } } [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] internal class EmptyControlAdapter : ControlAdapter { internal EmptyControlAdapter() {} } } #endif // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LineVisual.cs
- SafeRegistryHandle.cs
- BitmapEffectInput.cs
- FontInfo.cs
- Cursors.cs
- COM2ICategorizePropertiesHandler.cs
- SimpleTypeResolver.cs
- EditingMode.cs
- BaseDataBoundControl.cs
- PeerResolverMode.cs
- QilGeneratorEnv.cs
- ProtectedConfigurationProviderCollection.cs
- EventPropertyMap.cs
- Predicate.cs
- PermissionSetTriple.cs
- securitycriticaldataformultiplegetandset.cs
- wgx_exports.cs
- EmptyReadOnlyDictionaryInternal.cs
- SimpleLine.cs
- PropertyInfoSet.cs
- SemanticAnalyzer.cs
- ImpersonateTokenRef.cs
- CreateUserWizard.cs
- WebControlAdapter.cs
- ObjectDisposedException.cs
- EncodingTable.cs
- BaseTemplateCodeDomTreeGenerator.cs
- ContractType.cs
- LinqDataSource.cs
- PropertyGridCommands.cs
- DataGridViewRow.cs
- UnionExpr.cs
- _HeaderInfoTable.cs
- TrustSection.cs
- MailDefinition.cs
- ModelUIElement3D.cs
- StatusBarPanel.cs
- EntityCollection.cs
- TreeWalker.cs
- XmlDeclaration.cs
- SerialStream.cs
- RegionInfo.cs
- FaultConverter.cs
- Bits.cs
- DrawingContextWalker.cs
- AdvancedBindingPropertyDescriptor.cs
- PrintPreviewGraphics.cs
- Transform3D.cs
- QuerySettings.cs
- TextReader.cs
- SynchronizedKeyedCollection.cs
- FactoryMaker.cs
- NoPersistHandle.cs
- MenuItem.cs
- PersistenceTypeAttribute.cs
- CatalogZone.cs
- ColumnHeaderConverter.cs
- ContentType.cs
- URLIdentityPermission.cs
- Int64Converter.cs
- ConvertersCollection.cs
- Geometry3D.cs
- HttpListenerPrefixCollection.cs
- ObjectListField.cs
- ColumnReorderedEventArgs.cs
- DecimalAnimationUsingKeyFrames.cs
- ExpandSegmentCollection.cs
- ProcessThreadCollection.cs
- ContentElementCollection.cs
- ReflectionServiceProvider.cs
- SQLStringStorage.cs
- LicFileLicenseProvider.cs
- oledbmetadatacolumnnames.cs
- handlecollector.cs
- MenuItemBindingCollection.cs
- MimeFormatter.cs
- SerTrace.cs
- LinkUtilities.cs
- TimerTable.cs
- DotExpr.cs
- TemplatedMailWebEventProvider.cs
- DataBindingValueUIHandler.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SecurityResources.cs
- UTF8Encoding.cs
- InvalidEnumArgumentException.cs
- PrintController.cs
- ConstNode.cs
- AuthenticationSection.cs
- ContextBase.cs
- BitmapVisualManager.cs
- BindingValueChangedEventArgs.cs
- ResourceType.cs
- ExecutionEngineException.cs
- CryptoApi.cs
- AsymmetricKeyExchangeFormatter.cs
- ElementProxy.cs
- Int16AnimationUsingKeyFrames.cs
- SubclassTypeValidator.cs
- SplitterPanel.cs