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
- DataGridViewTopLeftHeaderCell.cs
- WebServiceResponse.cs
- Helpers.cs
- SqlRemoveConstantOrderBy.cs
- FlatButtonAppearance.cs
- DynamicDataRouteHandler.cs
- PhysicalOps.cs
- RemoteWebConfigurationHostServer.cs
- DetailsView.cs
- cache.cs
- SHA512Managed.cs
- RefType.cs
- XmlAutoDetectWriter.cs
- FrameDimension.cs
- LocalizableAttribute.cs
- PenThreadPool.cs
- CngKeyCreationParameters.cs
- NextPreviousPagerField.cs
- HwndStylusInputProvider.cs
- OpenFileDialog.cs
- CompilerResults.cs
- SelectionHighlightInfo.cs
- XmlDataSource.cs
- LicenseManager.cs
- Rijndael.cs
- ArrayWithOffset.cs
- Vector3DAnimationBase.cs
- PopOutPanel.cs
- TimeSpanValidator.cs
- SymbolType.cs
- LookupNode.cs
- XamlRtfConverter.cs
- PropertyInformation.cs
- RequestTimeoutManager.cs
- DialogWindow.cs
- ImageConverter.cs
- DataPointer.cs
- UnsafeNativeMethodsMilCoreApi.cs
- DBCommandBuilder.cs
- ObjectItemCollection.cs
- GradientStopCollection.cs
- TreeViewBindingsEditorForm.cs
- Set.cs
- ContextMenuService.cs
- ZipArchive.cs
- SharedUtils.cs
- AnnotationComponentManager.cs
- HtmlTable.cs
- ByteStreamGeometryContext.cs
- DocumentViewerConstants.cs
- DateTimeStorage.cs
- SystemSounds.cs
- GenericTypeParameterBuilder.cs
- FormsAuthentication.cs
- ListBindingHelper.cs
- IDQuery.cs
- MethodToken.cs
- ResizeGrip.cs
- DataContractJsonSerializer.cs
- PageCatalogPart.cs
- MemoryFailPoint.cs
- Semaphore.cs
- PartDesigner.cs
- ImageCodecInfo.cs
- ScrollBarAutomationPeer.cs
- DebugView.cs
- RadioButton.cs
- OdbcConnectionFactory.cs
- PointHitTestResult.cs
- EntityReference.cs
- ExtentCqlBlock.cs
- PointAnimationClockResource.cs
- DocumentViewer.cs
- DependencyPropertyDescriptor.cs
- InputScopeAttribute.cs
- TemplateManager.cs
- OrderingExpression.cs
- ResizeGrip.cs
- ForeignConstraint.cs
- MetadataCache.cs
- Line.cs
- NamespaceList.cs
- NamespaceQuery.cs
- DateTimeConverter.cs
- ListViewGroupItemCollection.cs
- FactoryMaker.cs
- TextServicesCompartmentContext.cs
- shaperfactory.cs
- EventListenerClientSide.cs
- AutoCompleteStringCollection.cs
- ParserHooks.cs
- Span.cs
- VerificationAttribute.cs
- ListItemViewControl.cs
- CheckedListBox.cs
- EmbeddedMailObjectsCollection.cs
- Propagator.Evaluator.cs
- ExpressionBuilderCollection.cs
- TextContainerChangeEventArgs.cs
- DecimalStorage.cs