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
- RepeaterItemCollection.cs
- IteratorFilter.cs
- DataListItemCollection.cs
- XmlDataSourceView.cs
- SecurityCapabilities.cs
- BulletedListEventArgs.cs
- FrameworkElementFactoryMarkupObject.cs
- SslStreamSecurityUpgradeProvider.cs
- XmlExpressionDumper.cs
- PreservationFileReader.cs
- VarRefManager.cs
- XmlRootAttribute.cs
- TransformFinalBlockRequest.cs
- RemoteWebConfigurationHost.cs
- ProtocolImporter.cs
- PaperSource.cs
- ToolboxBitmapAttribute.cs
- XMLSyntaxException.cs
- BulletedListDesigner.cs
- WebRequestModulesSection.cs
- FixUp.cs
- UriScheme.cs
- RepeatButton.cs
- PriorityBinding.cs
- Model3DGroup.cs
- PartialCachingAttribute.cs
- MultiBindingExpression.cs
- AttachInfo.cs
- PageThemeCodeDomTreeGenerator.cs
- RenderData.cs
- _ConnectOverlappedAsyncResult.cs
- Camera.cs
- DataReceivedEventArgs.cs
- EventProviderWriter.cs
- ObjectPersistData.cs
- CodeLinePragma.cs
- ClientSideProviderDescription.cs
- WebPartDescription.cs
- OutputWindow.cs
- Panel.cs
- DataSourceSelectArguments.cs
- HttpRequest.cs
- TableItemPattern.cs
- CertificateManager.cs
- HtmlImage.cs
- SslStream.cs
- ExtensionWindow.cs
- ResXFileRef.cs
- ParenthesizePropertyNameAttribute.cs
- SqlLiftIndependentRowExpressions.cs
- ToolStripContainerDesigner.cs
- OdbcParameterCollection.cs
- DirectoryInfo.cs
- SimpleType.cs
- ReferencedAssembly.cs
- StateItem.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- TemplateBindingExpression.cs
- IndexerReference.cs
- WebControlsSection.cs
- LabelInfo.cs
- ReferenceCountedObject.cs
- WorkflowDispatchContext.cs
- HotSpotCollection.cs
- HttpDictionary.cs
- Int32Rect.cs
- WindowsAuthenticationEventArgs.cs
- precedingquery.cs
- SqlSelectStatement.cs
- _AcceptOverlappedAsyncResult.cs
- ScriptingWebServicesSectionGroup.cs
- DESCryptoServiceProvider.cs
- Exception.cs
- PointAnimation.cs
- ViewUtilities.cs
- SqlConnectionString.cs
- SelectingProviderEventArgs.cs
- PersonalizationAdministration.cs
- VisualTreeFlattener.cs
- ArraySubsetEnumerator.cs
- GregorianCalendar.cs
- DeclaredTypeElement.cs
- DataBoundControlAdapter.cs
- UrlPath.cs
- FusionWrap.cs
- InternalPermissions.cs
- DefinitionBase.cs
- datacache.cs
- TableCell.cs
- Visual3DCollection.cs
- newinstructionaction.cs
- Cursors.cs
- GraphicsPathIterator.cs
- EntryPointNotFoundException.cs
- PostBackOptions.cs
- OleDbParameter.cs
- CollectionEditor.cs
- MenuItemStyle.cs
- KeyGesture.cs
- CommandBindingCollection.cs