/// <summary> /// Default constructor for ResultItemEventArgs /// </summary> /// <param name="item">ResultItem control instance</param> public ResultItemEventArgs(ResultItem item) { this.item = item; }
/// <summary> /// Check for presense of ResultItem control in collection /// </summary> /// <param name="item">ResultItem control</param> /// <returns>bool value result of check</returns> public bool Contains(ResultItem item) { return(List.Contains(item)); }
/// <summary> /// Returns zero based index of ResultItem control in collection /// </summary> /// <param name="item">ResultItem control</param> /// <returns>Zero based index of ResultItem control in collection</returns> public int IndexOf(ResultItem item) { return(List.IndexOf(item)); }
/// <summary> /// Add ResultItem control to collection at specified index /// </summary> /// <param name="index">Zero based index</param> /// <param name="item">ResultItem control</param> public void Insert(int index, ResultItem item) { List.Insert(index, item); }
/// <summary> /// Remove ResultItem from collection /// </summary> /// <param name="item">ResultItem control</param> public void Remove(ResultItem item) { List.Remove(item); }
/// <summary> /// Add ResultItem control to collection /// </summary> /// <param name="item">ResultItem control</param> /// <returns>Zero based index of added ResultItem in colleciton</returns> public int Add(ResultItem item) { return(List.Add(item)); }
private void CreateControlHierarchy(bool dataBind) { Service.GoogleSearchResult result = null; // Result items items = new ArrayList(); int count = 0; if (dataBind == true) { if (DataSource == null) { return; } result = (Service.GoogleSearchResult)DataSource; Query = result.searchQuery; StartIndex = result.startIndex - 1; // set ViewState values for read-only props ViewState["TotalResultsCount"] = result.estimatedTotalResultsCount; ViewState["EndIndex"] = result.endIndex - 1; count = result.resultElements.Length; } else { object temp = ViewState["ResultItemCount"]; if (temp != null) { count = (int)temp; } } if (HeaderTemplate != null) { ResultItem headerItem = CreateResultItem(-1, ResultItemType.Header, false, null); items.Add(headerItem); } ResultItem statusItem = CreateResultItem(-1, ResultItemType.Status, dataBind, result); items.Add(statusItem); // loop through and create ResultItem controls for each of the // result elements from the Google web service result ResultItemType itemType = ResultItemType.Item; for (int i = 0; i < count; i++) { if (separatorTemplate != null) { ResultItem separator = CreateResultItem(-1, ResultItemType.Separator, false, null); items.Add(separator); } Service.ResultElement resultElem = null; if (dataBind == true) { resultElem = result.resultElements[i]; } ResultItem item = CreateResultItem(i, itemType, dataBind, resultElem); items.Add(item); // swap between item and alternatingitem types if (itemType == ResultItemType.Item) { itemType = ResultItemType.AlternatingItem; } else { itemType = ResultItemType.Item; } } // display pager if allowed by user and if results // are greater than a page in length if (DisplayPager == true && TotalResultsCount > PageSize) { ResultItem pager = CreatePagerResultItem(dataBind, result); items.Add(pager); } if (FooterTemplate != null) { ResultItem footer = CreateResultItem(-1, ResultItemType.Footer, false, null); items.Add(footer); } if (dataBind) { ViewState["ResultItemCount"] = count; } }
private ResultItem CreateResultItem(int index, ResultItemType itemType, bool dataBind, object dataItem) { ITemplate selectedTemplate; switch (itemType) { case ResultItemType.Header: selectedTemplate = HeaderTemplate; break; case ResultItemType.Status: if (StatusTemplate == null) { // if no StatusTemplate, pick up the default // template ResultStatusTemplate selectedTemplate = new ResultStatusTemplate(); } else { selectedTemplate = StatusTemplate; } break; case ResultItemType.Item: if (ItemTemplate == null) { // if no ItemTemplate, pick up the default // template ResultItemTemplate selectedTemplate = new ResultItemTemplate(); } else { selectedTemplate = ItemTemplate; } break; case ResultItemType.AlternatingItem: selectedTemplate = AlternatingItemTemplate; if (selectedTemplate == null) { // if no AlternatingItemTemplate, switch to Item type // and pick up ItemTemplate itemType = ResultItemType.Item; selectedTemplate = ItemTemplate; if (selectedTemplate == null) { // if that doesnt work, pick up the default // template ResultItemTemplate selectedTemplate = new ResultItemTemplate(); } } break; case ResultItemType.Separator: selectedTemplate = SeparatorTemplate; break; case ResultItemType.Footer: selectedTemplate = FooterTemplate; break; default: selectedTemplate = null; break; } ResultItem item = new ResultItem(index, itemType, dataItem); if (selectedTemplate != null) { selectedTemplate.InstantiateIn(item); } OnItemCreated(new ResultItemEventArgs(item)); Controls.Add(item); if (dataBind) { item.DataBind(); OnItemDataBound(new ResultItemEventArgs(item)); } return(item); }
private Service.GoogleSearchResult GetResult(Control container) { ResultItem item = (ResultItem)container; return((Service.GoogleSearchResult)item.DataItem); }
private Service.ResultElement GetResultElement(Control container) { ResultItem item = (ResultItem)container; return((Service.ResultElement)item.DataItem); }