internal void Add(ObjectListItem item) { Items.Add (item); if (_marked) { _dirty = true; item.Dirty = true; } }
/// <include file='doc\ObjectListItemCollection.uex' path='docs/doc[@for="ObjectListItemCollection.GetAll"]/*' /> public ObjectListItem[] GetAll() { int n = Count; ObjectListItem[] result = new ObjectListItem[n]; if (n > 0) { Items.CopyTo (0, result, 0, n); } return result; }
/// <include file='doc\ObjectListItemCollection.uex' path='docs/doc[@for="ObjectListItemCollection.IndexOf"]/*' /> public int IndexOf(ObjectListItem item) { return Items.IndexOf(item); }
/// <include file='doc\ObjectListShowCommandsEventArgs.uex' path='docs/doc[@for="ObjectListShowCommandsEventArgs.ObjectListShowCommandsEventArgs"]/*' /> public ObjectListShowCommandsEventArgs(ObjectListItem item, ObjectListCommandCollection commands) { _item = item; _commands = commands; }
// Called from RenderItemDetails. (Extracted for intelligibility.) private void RenderItemFieldsInDetailsView (XhtmlMobileTextWriter writer, ObjectListItem item) { Style style = Style; IObjectListFieldCollection fields = Control.AllFields; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); ConditionalEnterStyle(writer, Style); writer.WriteEncodedText (field.Title); ConditionalExitStyle(writer, Style); writer.Write("</td><td>"); ConditionalEnterStyle(writer, style); writer.WriteEncodedText (item [fields.IndexOf (field)]); ConditionalExitStyle(writer, style); writer.WriteLine("</td></tr>"); } } }
// Render the details view /// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.RenderItemDetails"]/*' /> protected virtual void RenderItemDetails(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.AllFields.Count == 0) { return; } if (!Device.Tables) { RenderItemDetailsWithoutTableTags(writer, item); return; } Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; writer.ClearPendingBreak(); // we are writing a block level element in all cases. ConditionalEnterLayout(writer, Style); writer.WriteBeginTag ("table"); ConditionalRenderClassAttribute(writer); writer.Write(">"); writer.Write("<tr><td colspan=\"2\">"); ConditionalEnterStyle(writer, labelStyle); writer.WriteEncodedText (item[Control.LabelFieldIndex]); ConditionalExitStyle(writer, labelStyle); writer.WriteLine("</td></tr>"); Color foreColor = (Color)Style[Style.ForeColorKey, true]; RenderRule (writer, foreColor, 2); RenderItemFieldsInDetailsView (writer, item); RenderRule (writer, foreColor, 2); ConditionalPopPhysicalCssClass(writer); writer.WriteEndTag("table"); ConditionalExitLayout(writer, Style); ConditionalEnterStyle(writer, subCommandStyleNoItalic); writer.Write("[ "); ObjectListCommandCollection commands = Control.Commands; String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); if (subCommandClass == null || subCommandClass.Length == 0) { subCommandClass = cssClass; } foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, null /* accessKey */, subCommandStyle, subCommandClass); writer.Write(" | "); } String controlBCT = Control.BackCommandText; String backCommandText = (controlBCT == null || controlBCT.Length == 0) ? GetDefaultLabel(BackLabel) : controlBCT; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, null /* accessKey */, subCommandStyle, subCommandClass); writer.Write(" ]"); ConditionalExitStyle(writer, subCommandStyleNoItalic); }
/// <include file='doc\ObjectListSelectEventArgs.uex' path='docs/doc[@for="ObjectListSelectEventArgs.ObjectListSelectEventArgs"]/*' /> public ObjectListSelectEventArgs(ObjectListItem item, bool selectMore) { _item = item; _selectMore = selectMore; }
public ObjectListCommandEventArgs(ObjectListItem item, Object commandSource, CommandEventArgs originalArgs) : base(originalArgs) { _item = item; _commandSource = commandSource; }
/// <include file='doc\ObjectListField.uex' path='docs/doc[@for="ObjectListField.DataBindItem"]/*' /> public void DataBindItem(int fieldIndex, ObjectListItem item) { Object dataItem = item.DataItem; if (dataItem == null) { return; } if (!SelfReference) { String dataField = DataField; if (dataField.Length == 0) { return; } _dataFieldDescriptor = TypeDescriptor.GetProperties(dataItem).Find(dataField, true); if (_dataFieldDescriptor == null && !_owner.MobilePage.DesignMode) { throw new Exception( SR.GetString(SR.ObjectListField_DataFieldNotFound, dataField)); } } Object data; if (_dataFieldDescriptor != null) { data = _dataFieldDescriptor.GetValue(dataItem); } // Use fake databound text if the datasource is not accessible at designtime. else if (_owner.MobilePage.DesignMode) { data = SR.GetString(SR.ObjectListField_DataBoundText); } else { Debug.Assert(SelfReference, "Shouldn't get this far if !SelfReference"); data = dataItem; } String dataText; if ((data != null) && (data != System.DBNull.Value)) { String dataFormatString = DataFormatString; if (dataFormatString.Length > 0) { dataText = String.Format(CultureInfo.InvariantCulture, dataFormatString, data); } else { dataText = data.ToString(); } } else { dataText = String.Empty; } item[fieldIndex] = dataText; }
/// <include file='doc\WmlObjectListAdapter.uex' path='docs/doc[@for="WmlObjectListAdapter.RenderItemDetails"]/*' /> protected virtual void RenderItemDetails(WmlMobileTextWriter writer, ObjectListItem item) { String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; String softkeyLabel = backCommandText.Length <= Device.MaximumSoftkeyLabelLength ? backCommandText : null; Style labelStyle = Control.LabelStyle; writer.EnterStyle(labelStyle); writer.RenderText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EnterStyle(Style); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; foreach (ObjectListField field in fields) { if (field.Visible) { String displayText = String.Format(CultureInfo.InvariantCulture, "{0}: {1}", field.Title, item[fieldIndex]); writer.RenderText(displayText, true); } fieldIndex++; } RenderPostBackEvent(writer, _backToList, softkeyLabel, true, backCommandText, true); writer.ExitStyle(Style); }
/// <include file='doc\WmlObjectListAdapter.uex' path='docs/doc[@for="WmlObjectListAdapter.RenderItemMenu"]/*' /> protected virtual void RenderItemMenu(WmlMobileTextWriter writer, ObjectListItem item) { bool requiresDetails = HasItemDetails(); String detailsCommandText = Control.DetailsCommandText.Length == 0 ? SR.GetString(SR.WmlObjectListAdapterDetails) : Control.DetailsCommandText; String softkeyLabel = detailsCommandText.Length <= Device.MaximumSoftkeyLabelLength ? detailsCommandText : null; Style commandStyle = Control.CommandStyle; if (commandStyle.Alignment == Alignment.NotSet) { commandStyle.Alignment = Alignment.Left; } writer.EnterStyle(commandStyle); if (requiresDetails) { RenderPostBackEvent(writer, _showDetails, softkeyLabel, true, detailsCommandText, true, WmlPostFieldType.Raw); } ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEvent(writer, command.Name, GetDefaultLabel(GoLabel), false, command.Text, true, WmlPostFieldType.Raw); } writer.ExitStyle(commandStyle); }
/// <include file='doc\ObjectListItemCollection.uex' path='docs/doc[@for="ObjectListItemCollection.Contains"]/*' /> public bool Contains(ObjectListItem item) { return Items.Contains (item); }
private void EnsureCount(int count) { int diff = Count - count; if (diff > 0) { Items.RemoveRange (count, diff); if (_marked) { _dirty = true; } } else { for (int i = Count; i < count; i++) { ObjectListItem item = new ObjectListItem(_owner); item.SetIndex(i + BaseIndex); Add (item); } } }
private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td></tr>\r\n<tr>"); RenderRule(writer, foreColor, 2); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); writer.BeginStyleContext(); writer.EnterStyle(Style); writer.WriteText(field.Title, true); writer.ExitStyle(Style); writer.EndStyleContext(); writer.Write("</td><td>"); writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndex], true); writer.ExitStyle(style); writer.EndStyleContext(); writer.Write("</td></tr>\r\n"); } fieldIndex++; } RenderRule(writer, foreColor, 2); writer.Write("<tr><td colspan=2>"); 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("</td></tr></table>"); }
/// <include file='doc\ObjectListCommandEventArgs.uex' path='docs/doc[@for="ObjectListCommandEventArgs.ObjectListCommandEventArgs"]/*' /> public ObjectListCommandEventArgs(ObjectListItem item, Object commandSource, CommandEventArgs originalArgs) : base(originalArgs) { _item = item; _commandSource = commandSource; }
private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle, true); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; bool boldInStyle = (style.Font.Bold == BooleanOption.True) ? true : false; writer.EnterStyle(style); foreach (ObjectListField field in fields) { if (field.Visible) { if (!boldInStyle) { writer.Write("<b>"); } writer.WriteText(field.Title + ":", true); if (!boldInStyle) { writer.Write("</b>"); } writer.Write(" "); writer.WriteText(item[fieldIndex], true); writer.WriteBreak(); } fieldIndex++; } writer.ExitStyle(style); 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, Control.BreakAfter); subCommandStyle.Font.Italic = cachedItalic; }
/// <include file='doc\ObjectListCommandEventArgs.uex' path='docs/doc[@for="ObjectListCommandEventArgs.ObjectListCommandEventArgs1"]/*' /> public ObjectListCommandEventArgs(ObjectListItem item, String commandName) : base(commandName, item) { _item = item; _commandSource = null; }
/// <include file='doc\ObjectListDataBindEventArgs.uex' path='docs/doc[@for="ObjectListDataBindEventArgs.ObjectListDataBindEventArgs"]/*' /> public ObjectListDataBindEventArgs(ObjectListItem item, Object dataItem) { _item = item; _dataItem = dataItem; }
public ObjectListCommandEventArgs(ObjectListItem item, String commandName) : base(commandName, item) { _item = item; _commandSource = null; }
public bool Contains(ObjectListItem item) { return(Items.Contains(item)); }
public int IndexOf(ObjectListItem item) { return(Items.IndexOf(item)); }
private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.VisibleItemCount == 0) { return; } Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; ConditionalRenderOpeningDivElement(writer); String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(item[Control.LabelFieldIndex]); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; ConditionalEnterStyle(writer, style); foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write(field.Title + ":"); writer.Write(" "); writer.Write(item[fieldIndex]); writer.WriteBreak(); } fieldIndex++; } ConditionalExitStyle(writer, style); String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); ConditionalEnterStyle(writer, subCommandStyleNoItalic); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("[ "); } ConditionalEnterStyle(writer, subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" | "); } } String controlBCT = Control.BackCommandText; String backCommandText = controlBCT == null || controlBCT.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText); ConditionalExitStyle(writer, subCommandStyle); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ]"); } ConditionalExitStyle(writer, subCommandStyleNoItalic); ConditionalRenderClosingDivElement(writer); }
// Render a single ObjectListItem in list view. private void RenderListViewItem (XhtmlMobileTextWriter writer, ObjectListItem item, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton, bool itemRequiresHyperlink) { Style style = Style; Style subCommandStyle = Control.CommandStyle; String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); if (subCommandClass == null || subCommandClass.Length == 0) { subCommandClass = cssClass; } writer.WriteLine("<tr>"); // Render fields. for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { String eventArgument = HasDefaultCommand() ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]], accessKey, Style, cssClass); } else { writer.WriteEncodedText (item[fieldIndices[field]]); } writer.WriteLine("</td>"); } if (itemRequiresMoreButton) { writer.Write("<td>"); String controlMT = Control.MoreText; String moreText = (controlMT == null || controlMT.Length == 0) ? GetDefaultLabel(MoreLabel) : controlMT; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, null /*accessKey*/, subCommandStyle, subCommandClass); writer.WriteLine("</td>"); } writer.WriteLine("</tr>"); }
/// <include file='doc\HtmlObjectListAdapter.uex' path='docs/doc[@for="HtmlObjectListAdapter.RenderItemDetails"]/*' /> protected virtual void RenderItemDetails(HtmlMobileTextWriter writer, ObjectListItem item) { if (Control.AllFields.Count == 0) { return; } if(Device.Tables) { RenderItemDetailsWithTableTags(writer, item); } else { RenderItemDetailsWithoutTableTags(writer, item); } }
/// <include file='doc\ObjectList.uex' path='docs/doc[@for="ObjectList.CreateItem"]/*' /> protected virtual ObjectListItem CreateItem(Object dataItem) { ObjectListItem item = new ObjectListItem(this, dataItem); // Set fields. IObjectListFieldCollection allFields = AllFields; int fieldIndex = 0; foreach (ObjectListField field in AllFields) { field.DataBindItem(fieldIndex, item); fieldIndex++; } // Use delegated data binding, if specified. if (dataItem != null) { OnItemDataBind(new ObjectListDataBindEventArgs(item, dataItem)); } return item; }