Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / HtmlObjectListAdapter.cs / 1305376 / HtmlObjectListAdapter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.Globalization; using System.Drawing; using System.IO; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.MobileControls; using System.Diagnostics; using System.Security.Permissions; using SR=System.Web.UI.MobileControls.Adapters.SR; #if COMPILING_FOR_SHIPPED_SOURCE namespace System.Web.UI.MobileControls.ShippedAdapterSource #else namespace System.Web.UI.MobileControls.Adapters #endif { /* * HtmlObjectListAdapter provides HTML rendering of Object List control. * * 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 class HtmlObjectListAdapter : HtmlControlAdapter { /// internal protected static readonly String BackToList = "__back"; /// internal protected static readonly String ShowMoreFormat = "__more{0}"; /// internal protected static readonly String ShowMore = "__more"; private const int _modeDetails = 1; /// protected new ObjectList Control { get { return (ObjectList)base.Control; } } /// public override void OnInit(EventArgs e) { } /// public override void OnPreRender(EventArgs e) { base.OnPreRender(e); if(Control.MobilePage.ActiveForm == Control.Form && Control.Visible && (Control.ViewMode == ObjectListViewMode.Commands || Control.ViewMode == ObjectListViewMode.Details)) { SecondaryUIMode = _modeDetails; if (Control.Items.Count > 0) { int itemIndex = Control.SelectedIndex; Debug.Assert(itemIndex >= 0, "itemIndex is negative"); Control.PreShowItemCommands(itemIndex); } } else { SecondaryUIMode = NotSecondaryUI; } } /// public override void Render(HtmlMobileTextWriter writer) { if (Control.ViewMode == ObjectListViewMode.List) { if (Control.HasControls()) { RenderChildren(writer); } else { RenderItemsList(writer); } } else { if (Control.Selection.HasControls()) { Control.Selection.RenderChildren(writer); } else { RenderItemDetails(writer, Control.Selection); } FormAdapter.DisablePager(); } } /// public override void CreateTemplatedUI(bool doDataBind) { if (Control.ViewMode == ObjectListViewMode.List) { Control.CreateTemplatedItemsList(doDataBind); } else { Control.CreateTemplatedItemDetails(doDataBind); } } /// protected virtual void RenderItemsList(HtmlMobileTextWriter writer) { Debug.Assert (Control.VisibleItemCount <= Control.Items.Count); if (Control.VisibleItemCount == 0) { return; } Debug.Assert (Control.AllFields != null && Control.AllFields.Count > 0, "Should never have items but no fields."); if (Device.Tables) { RenderItemsListWithTableTags(writer); } else { RenderItemsListWithoutTableTags(writer); } } private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer) { int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; // Determine how to render. bool shouldRenderAsTable = ShouldRenderAsTable(); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands()); bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; int fieldCount; int[] fieldIndices = new int[]{}; if (shouldRenderAsTable) { fieldIndices = Control.TableFieldIndices; } Debug.Assert(fieldIndices != null, "fieldIndices is null"); fieldCount = fieldIndices.Length; if(fieldCount == 0) { fieldIndices = new int[1]; fieldIndices[0] = Control.LabelFieldIndex; fieldCount = 1; } Style style = this.Style; Style subCommandStyle = Control.CommandStyle; Style labelStyle = Control.LabelStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.BeginStyleContext(); writer.WriteLine("
"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write(" | "); } if (itemRequiresMoreButton) { writer.WriteLine(""); } writer.WriteLine("\r\n |
"); if (field == 0 && itemRequiresHyperlink) { writer.BeginStyleContext(); writer.EnterStyle(style); String eventArgument = hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]]); writer.ExitStyle(style); writer.EndStyleContext(); } else { writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndices[field]], true); writer.ExitStyle(style); writer.EndStyleContext(); } writer.WriteLine(" | "); } if (itemRequiresMoreButton) { writer.Write(""); writer.BeginStyleContext(); writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, subCommandStyle); writer.ExitFormat(subCommandStyle); writer.EndStyleContext(); writer.Write(" | \r\n"); } writer.WriteLine("
"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write(" | |
"); writer.BeginStyleContext(); writer.EnterStyle(Style); writer.WriteText(field.Title, true); writer.ExitStyle(Style); writer.EndStyleContext(); writer.Write(" | "); writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndex], true); writer.ExitStyle(style); writer.EndStyleContext(); writer.Write(" |
"); writer.BeginStyleContext(); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EndStyleContext(); writer.Write(" |
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- _LocalDataStoreMgr.cs
- WindowsGraphics.cs
- Identifier.cs
- HtmlTernaryTree.cs
- PolyQuadraticBezierSegment.cs
- MDIWindowDialog.cs
- StorageComplexPropertyMapping.cs
- WebContentFormatHelper.cs
- XmlSerializerSection.cs
- CanonicalFontFamilyReference.cs
- VersionedStreamOwner.cs
- SelectionEditingBehavior.cs
- QilNode.cs
- SafeLibraryHandle.cs
- SecurityDocument.cs
- __ConsoleStream.cs
- SamlDelegatingWriter.cs
- CodeAccessSecurityEngine.cs
- LineBreakRecord.cs
- EndOfStreamException.cs
- IpcChannel.cs
- Rect.cs
- MinimizableAttributeTypeConverter.cs
- WindowsAuthenticationEventArgs.cs
- PrintingPermissionAttribute.cs
- Message.cs
- Token.cs
- XPathChildIterator.cs
- DrawListViewSubItemEventArgs.cs
- Matrix3DStack.cs
- Error.cs
- ConfigXmlAttribute.cs
- KeyedCollection.cs
- ScriptResourceAttribute.cs
- BaseUriHelper.cs
- XmlDataSourceView.cs
- ScriptMethodAttribute.cs
- ArrayWithOffset.cs
- ScrollViewerAutomationPeer.cs
- errorpatternmatcher.cs
- XmlMtomWriter.cs
- CancellationHandler.cs
- SmtpException.cs
- SafeNativeMethodsOther.cs
- webclient.cs
- ListSourceHelper.cs
- XmlEntity.cs
- WebScriptServiceHost.cs
- QueryInterceptorAttribute.cs
- Point.cs
- BaseProcessor.cs
- PrintDialogDesigner.cs
- GenericPrincipal.cs
- WizardForm.cs
- AsymmetricSecurityProtocol.cs
- StateMachineExecutionState.cs
- VoiceSynthesis.cs
- FormatterServices.cs
- CompilationUtil.cs
- COM2FontConverter.cs
- OracleConnectionString.cs
- DataObjectPastingEventArgs.cs
- ComponentChangedEvent.cs
- DesignerAttribute.cs
- ParameterBuilder.cs
- SHA512.cs
- SchemaImporterExtensionElementCollection.cs
- PhysicalFontFamily.cs
- LoggedException.cs
- MethodMessage.cs
- ClusterRegistryConfigurationProvider.cs
- Aes.cs
- AsymmetricAlgorithm.cs
- sqlser.cs
- ImageButton.cs
- FontUnit.cs
- CharEnumerator.cs
- RelatedView.cs
- ImageSource.cs
- ProviderMetadataCachedInformation.cs
- TextBox.cs
- EntityClassGenerator.cs
- EventItfInfo.cs
- ApplicationBuildProvider.cs
- PointCollectionValueSerializer.cs
- controlskin.cs
- CertificateManager.cs
- ActivityTrace.cs
- MessageQueuePermission.cs
- HtmlToClrEventProxy.cs
- PagerSettings.cs
- WarningException.cs
- DeadCharTextComposition.cs
- TimeSpan.cs
- UriParserTemplates.cs
- MasterPageCodeDomTreeGenerator.cs
- DockPatternIdentifiers.cs
- HwndHostAutomationPeer.cs
- StaticDataManager.cs
- CodeTypeDelegate.cs