private static void EnsureGroupTag(OLVGroup listViewGroup) { if (listViewGroup.Tag == null) { var groupStats = new TransactionAggregates(listViewGroup.Items.Select(i => (Transaction)i.RowObject)); listViewGroup.Tag = groupStats; } }
private void collapseGroup() { for (int i = 0; i < ResultListView.OLVGroups.Count; i++) { OLVGroup grp = ResultListView.OLVGroups[i]; grp.Collapsed = true; } }
private void toggleCollapsed() { collapsed = !collapsed; for (int i = 0; i < listView_Forks.OLVGroups.Count; i++) { OLVGroup grp = listView_Forks.OLVGroups[i]; //LogManager.AddLogMessage(Name, "toggleCollapsed", grp.Header + " | " + grp.Collapsed); grp.Collapsed = collapsed; } foreach (var item in groupStates.ToList()) { groupStates[item.Key] = collapsed; } }
private void toggleCollapsed() { collapsed = !collapsed; //LogManager.AddLogMessage(Name, "toggleCollapsed2", collapsed + " | " + listView.OLVGroups.Count, LogManager.LogMessageType.DEBUG); for (int i = 0; i < listView.OLVGroups.Count; i++) { OLVGroup grp = listView.OLVGroups[i]; grp.Collapsed = collapsed; } foreach (var item in groupStates.ToList()) { groupStates[item.Key] = collapsed; } }
private void toggleCollapsed() { //if (listView.OLVGroups != null) //{ //LogManager.AddLogMessage(Name, "toggleCollapsed", collapsed + " | " + listView.OLVGroups.Count, LogManager.LogMessageType.DEBUG); collapsed = !collapsed; //LogManager.AddLogMessage(Name, "toggleCollapsed2", collapsed + " | " + listView.OLVGroups.Count, LogManager.LogMessageType.DEBUG); for (int i = 0; i < listView.OLVGroups.Count; i++) { OLVGroup grp = listView.OLVGroups[i]; //LogManager.AddLogMessage(Name, "toggleCollapsed", grp.Header + " | " + grp.Collapsed); grp.Collapsed = collapsed; } //UpdateUI(true); //} }
/// <summary> /// Return the index at which the given item is shown in the given group /// </summary> /// <param name="group"></param> /// <param name="itemIndex"></param> /// <returns></returns> public virtual int GetIndexWithinGroup(OLVGroup group, int itemIndex) { return -1; }
/// <summary> /// Return the index of the item that appears at the given position within the given group. /// </summary> /// <param name="group"></param> /// <param name="indexWithinGroup"></param> /// <returns></returns> public virtual int GetGroupMember(OLVGroup group, int indexWithinGroup) { return -1; }
/// <summary> /// /// </summary> /// <param name="group"></param> /// <param name="itemIndex"></param> /// <returns></returns> public override int GetIndexWithinGroup(OLVGroup group, int itemIndex) { return group.Contents.IndexOf(itemIndex); }
/// <summary> /// /// </summary> /// <param name="group"></param> /// <param name="indexWithinGroup"></param> /// <returns></returns> public override int GetGroupMember(OLVGroup group, int indexWithinGroup) { return (int)group.Contents[indexWithinGroup]; }
/// <summary> /// Create groups for FastListView /// </summary> /// <param name="parmameters"></param> /// <returns></returns> public override IList<OLVGroup> GetGroups(GroupingParameters parmameters) { // This strategy can only be used on FastObjectListViews FastObjectListView folv = (FastObjectListView)parmameters.ListView; // Separate the list view items into groups, using the group key as the descrimanent int objectCount = 0; NullableDictionary<object, List<object>> map = new NullableDictionary<object, List<object>>(); foreach (object model in folv.FilteredObjects) { object key = parmameters.GroupByColumn.GetGroupKey(model); if (!map.ContainsKey(key)) map[key] = new List<object>(); map[key].Add(model); objectCount++; } // Sort the items within each group OLVColumn primarySortColumn = parmameters.SortItemsByPrimaryColumn ? parmameters.ListView.GetColumn(0) : parmameters.PrimarySort; ModelObjectComparer sorter = new ModelObjectComparer(primarySortColumn, parmameters.PrimarySortOrder, parmameters.SecondarySort, parmameters.SecondarySortOrder); foreach (object key in map.Keys) { map[key].Sort(sorter); } // Make a list of the required groups List<OLVGroup> groups = new List<OLVGroup>(); foreach (object key in map.Keys) { string title = parmameters.GroupByColumn.ConvertGroupKeyToTitle(key); if (!String.IsNullOrEmpty(parmameters.TitleFormat)) { int count = map[key].Count; title = String.Format((count == 1 ? parmameters.TitleSingularFormat : parmameters.TitleFormat), title, count); } OLVGroup lvg = new OLVGroup(title); lvg.Key = key; lvg.SortValue = key as IComparable; lvg.Contents = map[key].ConvertAll<int>(delegate(object x) { return folv.IndexOf(x); }); lvg.VirtualItemCount = map[key].Count; if (parmameters.GroupByColumn.GroupFormatter != null) parmameters.GroupByColumn.GroupFormatter(lvg, parmameters); groups.Add(lvg); } // Sort the groups groups.Sort(new OLVGroupComparer(parmameters.PrimarySortOrder)); // Build an array that remembers which group each item belongs to. this.indexToGroupMap = new List<int>(objectCount); this.indexToGroupMap.AddRange(new int[objectCount]); for (int i = 0; i < groups.Count; i++) { OLVGroup group = groups[i]; List<int> members = (List<int>)group.Contents; foreach (int j in members) this.indexToGroupMap[j] = i; } return groups; }
private void UpdateGrid(bool bDisplayAll) { /*int nbTot = 0; * int nbOk = 0; * int nbMissing = 0; * int nbNotExpexted = 0; * * if (bDisplayAll) * { * dt.DefaultView.RowFilter = null; * dataGridViewImport.DataSource = null; * dataGridViewImport.DataSource = dt.DefaultView; * } * else * { * dt.DefaultView.RowFilter = "Status <> 'Ok'"; * dataGridViewImport.DataSource = null; * dataGridViewImport.DataSource = dt.DefaultView; * } * * * foreach (DataGridViewRow dgvRow in dataGridViewImport.Rows) * { * * * Object cellValue = dgvRow.Cells["Status"].Value; * if (cellValue != null) * { * nbTot++; * switch (cellValue.ToString()) * { * case "Ok": dgvRow.DefaultCellStyle.ForeColor = Color.Green; nbOk++; break; * case "Missing": dgvRow.DefaultCellStyle.ForeColor = Color.Red; nbMissing++; break; * case "Not Expected": dgvRow.DefaultCellStyle.ForeColor = Color.Blue; nbNotExpexted++; break; * } * } * } * string strInfo = "Info : Nb Total = " + nbTot; * if (bDisplayAll) strInfo += " - Nb Present = " + nbOk; * strInfo += " - Nb Missing = " + nbMissing; * strInfo += " - Nb Not Expected = " + nbNotExpexted; * * toolStripStatusLabel.Text = strInfo; */ int nbTot = 0; int nbOk = 0; int nbMissing = 0; int nbNotExpexted = 0; if (bDisplayAll) { _dt.DefaultView.RowFilter = null; dataListViewImport.DataSource = null; dataListViewImport.DataSource = _dt.DefaultView; } else { _dt.DefaultView.RowFilter = ResStrings.CompareInventoryForm_ProcessData_CompareStatus + " <> '" + ResStrings.str_Ok + "'"; dataListViewImport.DataSource = null; dataListViewImport.DataSource = _dt.DefaultView; } for (int i = 0; i < dataListViewImport.Columns.Count; i++) { OLVColumn ol = dataListViewImport.GetColumn(i); //ol.FillsFreeSpace = true; ol.HeaderFont = new Font("Arial", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0))); ol.HeaderForeColor = Color.AliceBlue; ol.IsTileViewColumn = true; ol.UseInitialLetterForGroup = false; ol.MinimumWidth = 20 + ol.Text.Length * 10; ol.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); if (ol.Index == dataListViewImport.Columns.Count - 1) { ol.FillsFreeSpace = true; } } foreach (ListViewItem lvi in dataListViewImport.Items) { string strCase = lvi.SubItems[0].Text; { if (strCase.Equals(ResStrings.str_Ok)) { lvi.ForeColor = Color.Green; nbOk++; } else if (strCase.Equals(ResStrings.CompareInventoryForm_ProcessData_Missing)) { lvi.ForeColor = Color.Red; nbMissing++; } else if (strCase.Equals(ResStrings.CompareInventoryForm_UpdateGrid_Not_Expected)) { lvi.ForeColor = Color.Blue; nbNotExpexted++; } else { lvi.ForeColor = Color.Black; } } } if (dataListViewImport.OLVGroups != null) { for (int i = 0; i < dataListViewImport.OLVGroups.Count; i++) { OLVGroup grp = dataListViewImport.OLVGroups[i]; grp.Collapsed = true; } } string strInfo = string.Format(ResStrings.CompareInventoryForm_UpdateGrid_, nbTot); if (bDisplayAll) { strInfo += string.Format(ResStrings.CompareInventoryForm_UpdateGrid_NbPresent, nbOk); } strInfo += string.Format(ResStrings.CompareInventoryForm_UpdateGrid_Missing, nbMissing); strInfo += string.Format(ResStrings.CompareInventoryForm_UpdateGrid_Notexpected, nbNotExpexted); toolStripStatusLabel.Text = strInfo; }