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
- PhysicalOps.cs
- Matrix.cs
- CharacterBufferReference.cs
- ExpressionWriter.cs
- FixedTextView.cs
- TabControlCancelEvent.cs
- ObjectReferenceStack.cs
- Point3D.cs
- Model3DCollection.cs
- CommandDesigner.cs
- BamlLocalizer.cs
- WebPartVerbCollection.cs
- Rectangle.cs
- Propagator.cs
- FlagPanel.cs
- PerfCounterSection.cs
- DefaultPrintController.cs
- HitTestWithPointDrawingContextWalker.cs
- HttpListenerPrefixCollection.cs
- UrlPath.cs
- SymbolDocumentInfo.cs
- IndicFontClient.cs
- ScriptingRoleServiceSection.cs
- ChildrenQuery.cs
- PrinterSettings.cs
- TcpStreams.cs
- ListViewGroupItemCollection.cs
- ParallelTimeline.cs
- ColumnWidthChangedEvent.cs
- Int32Collection.cs
- FaultBookmark.cs
- CodeSubDirectoriesCollection.cs
- BitmapEffectState.cs
- SafeProcessHandle.cs
- ToolStripScrollButton.cs
- CreateRefExpr.cs
- WebPermission.cs
- BitmapDownload.cs
- MappedMetaModel.cs
- ZipIOExtraField.cs
- ProtocolsSection.cs
- Int32CollectionValueSerializer.cs
- RoleManagerModule.cs
- SecurityState.cs
- SqlSupersetValidator.cs
- StdValidatorsAndConverters.cs
- SchemaElementDecl.cs
- ExpressionBindings.cs
- PointCollection.cs
- XPathNavigator.cs
- DataSourceXmlAttributeAttribute.cs
- WinHttpWebProxyFinder.cs
- WebPermission.cs
- XPathAncestorIterator.cs
- CodeDomConfigurationHandler.cs
- Registry.cs
- FileDataSourceCache.cs
- MetaColumn.cs
- SerializationException.cs
- XsltLoader.cs
- TextSelection.cs
- ValidationSummary.cs
- FieldBuilder.cs
- ListViewUpdateEventArgs.cs
- ContentElement.cs
- ExpressionContext.cs
- UserControlParser.cs
- XPathNode.cs
- SystemTcpStatistics.cs
- XPathNodePointer.cs
- ProtocolsConfigurationHandler.cs
- KeyEventArgs.cs
- bidPrivateBase.cs
- PerformanceCounter.cs
- WithStatement.cs
- ListViewGroupCollectionEditor.cs
- ThemeableAttribute.cs
- DrawingContextDrawingContextWalker.cs
- WebSysDisplayNameAttribute.cs
- WindowsFormsDesignerOptionService.cs
- InternalSendMessage.cs
- ReachFixedPageSerializer.cs
- HMACRIPEMD160.cs
- Exceptions.cs
- EntityViewContainer.cs
- FacetValues.cs
- HttpNamespaceReservationInstallComponent.cs
- HMACSHA1.cs
- RightsManagementErrorHandler.cs
- WindowHideOrCloseTracker.cs
- ResourceSetExpression.cs
- Tokenizer.cs
- DictationGrammar.cs
- ObjectParameterCollection.cs
- PtsContext.cs
- ModulesEntry.cs
- ToolStripDropTargetManager.cs
- TextDecorationUnitValidation.cs
- ConfigurationSectionCollection.cs
- NameSpaceEvent.cs