/// <summary> /// Constructor /// </summary> /// <param name="group">The group the row is associated to.</param> public OutlookGridRow(IOutlookGridGroup group) : this(group, false) { //nodeCollection = new OutlookGridRowNodeCollection(this); //NodeLevel = 0; //Collapsed = true; }
/// <summary> /// Gets if the row has one parent that is collapsed /// </summary> /// <param name="gr">The group to look at.</param> /// <param name="i">Fill 0 to first this method (used for recursive).</param> /// <returns>True or false.</returns> public bool IsAParentCollapsed(IOutlookGridGroup gr, int i) { i++; if (gr.ParentGroup != null) { //if it is not the original group but it is one parent and if it is collapsed just stop here //no need to look further to the parents (one of the parents can be expanded...) //if (i > 1 && gr.Collapsed) if (gr.ParentGroup.Collapsed) { return(true); } else { return(IsAParentCollapsed(gr.ParentGroup, i)); } } else { //if 1 that means there is no parent if (i == 1) { return(false); } else { return(gr.Collapsed); } } }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parent group if any.</param> public OutlookGridDefaultGroup(IOutlookGridGroup parentGroup) : this() { if (parentGroup != null) { children.ParentGroup = parentGroup; } }
/// <summary> /// Constructor /// </summary> /// <param name="columnName">The name.</param> /// <param name="col">The DataGridViewColumn.</param> /// <param name="group">The group chosen for the column.</param> /// <param name="sort">The sort.</param> /// <param name="grouped">true if grouped, false otherwise.</param> public OutlookGridColumn(string columnName, DataGridViewColumn col, IOutlookGridGroup group, SortOrder sort, bool grouped) { this.name = columnName; this.column = col; this.groupingType = group; sortDirection = sort; isGrouped = grouped; }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parent group if any.</param> public OutlookgGridDefaultGroup(IOutlookGridGroup parentGroup) { val = null; this.column = null; height = 34; // default height rows = new List <OutlookGridRow>(); children = new OutlookGridGroupCollection(parentGroup); formatStyle = ""; }
/// <summary> /// Constructor /// </summary> /// <param name="group">The group the row is associated to.</param> /// <param name="isGroupRow">Determines if it a group row.</param> public OutlookGridRow(IOutlookGridGroup group, bool isGroupRow) : base() { this.group = group; this.isGroupRow = isGroupRow; nodeCollection = new OutlookGridRowNodeCollection(this); NodeLevel = 0; Collapsed = true; }
/// <summary> /// Constructor /// </summary> /// <param name="columnName">The name.</param> /// <param name="col">The DataGridViewColumn.</param> /// <param name="group">The group type for the column.</param> /// <param name="sortDirection">The sort direction.</param> /// <param name="groupIndex">The column's position in grouping and at which level.</param> /// <param name="sortIndex">the column's position among sorted columns.</param> public OutlookGridColumn(string columnName, DataGridViewColumn col, IOutlookGridGroup group, SortOrder sortDirection, int groupIndex, int sortIndex) { this.column = col; this.name = columnName; this.groupingType = group; this.sortDirection = sortDirection; this.groupIndex = groupIndex; this.sortIndex = sortIndex; }
public OutlookGrid() { InitializeComponent(); // very important, this indicates that a new default row class is going to be used to fill the grid // in this case our custom OutlookGridRow class base.RowTemplate = new OutlookGridRow(); this._groupTemplate = new OutlookgGridDefaultGroup(); }
internal void Clear() { parentGroup = null; //If a group is collapsed the rows will not appear. Then if we clear the group the rows should not remain "collapsed" for (int i = 0; i < groupList.Count; i++) { groupList[i].Collapsed = false; } groupList.Clear(); }
public OutlookGridYearGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridGroupCollection"/> class. /// </summary> /// <param name="parentGroup">The parent group, if any.</param> public OutlookGridGroupCollection(IOutlookGridGroup parentGroup) { groupList = new List<IOutlookGridGroup>(); this.parentGroup = parentGroup; }
/// <summary> /// Adds a new group /// </summary> /// <param name="group">The IOutlookGridGroup.</param> public void Add(IOutlookGridGroup group) { groupList.Add(group); }
public OutlookGridRow(IOutlookGridGroup group, bool isGroupRow) : base() { this.group = group; this.isGroupRow = isGroupRow; }
/// <summary> /// Gets all the subrows of a grouprow (recursive) /// </summary> /// <param name="list">The result list of OutlookGridRows</param> /// <param name="grouprow">The IOutlookGridGroup that contains rows to inspect.</param> /// <returns>A list of OutlookGridRows</returns> public List<OutlookGridRow> GetSubRows(ref List<OutlookGridRow> list, IOutlookGridGroup grouprow) { list.AddRange(grouprow.Rows); for (int i = 0; i < grouprow.Children.Count; i++) { if (grouprow.Children.Count > 0) GetSubRows(ref list, grouprow.Children[i]); } return list; }
/// <summary> /// Constructor. /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridAlphabeticGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { }
/// <summary> /// Constructor. /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridPriceGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { AllowHiddenWhenGrouped = false; _currency = CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridDateTimeGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { allowHiddenWhenGrouped = true; Interval = DateInterval.SMART; }
/// <summary> /// Update all the parents counters of a group /// </summary> /// <param name="l">The group whic</param> private void RecursiveIncrementParentGroupCounters(IOutlookGridGroup l) { //Add +1 to the counter l.ItemCount++; if (l.ParentGroup != null) { //Recursive call for parent RecursiveIncrementParentGroupCounters(l.ParentGroup); } }
// this event is called when the user clicks on a cell // in this particular case we check to see if one of the column headers // was clicked. If so, the grid will be sorted based on the clicked column. // Note: this handler is not implemented optimally. It is merely used for demonstration purposes private void outlookGrid1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 && e.ColumnIndex >= 0) { ListSortDirection direction = ListSortDirection.Ascending; if (e.ColumnIndex == prevColIndex) // reverse sort order { direction = prevSortDirection == ListSortDirection.Descending ? ListSortDirection.Ascending : ListSortDirection.Descending; } // remember the column that was clicked and in which direction is ordered prevColIndex = e.ColumnIndex; prevSortDirection = direction; // set the column to be grouped outlookGrid1.GroupTemplate.Column = outlookGrid1.Columns[e.ColumnIndex]; //sort the grid (based on the selected view) switch (View) { case "BoundContactInfo": outlookGrid1.Sort(new ContactInfoComparer(e.ColumnIndex, direction)); break; case "BoundCategory": outlookGrid1.Sort(new DataRowComparer(e.ColumnIndex, direction)); break; case "BoundInvoices": outlookGrid1.Sort(new DataRowComparer(e.ColumnIndex, direction)); break; case "BoundQuarterly": // this is an example of overriding the default behaviour of the // Group object. Instead of using the DefaultGroup behavious, we // use the AlphabeticGroup, so items are grouped together based on // their first character: // all items starting with A or a will be put in the same group. IOutlookGridGroup prevGroup = outlookGrid1.GroupTemplate; if (e.ColumnIndex == 0) // execption when user pressed the customer name column { // simply override the GroupTemplate to use before sorting outlookGrid1.GroupTemplate = new OutlookGridAlphabeticGroup(); outlookGrid1.GroupTemplate.Collapsed = prevGroup.Collapsed; } // set the column to be grouped // this must always be done before sorting outlookGrid1.GroupTemplate.Column = outlookGrid1.Columns[e.ColumnIndex]; // execute the sort, arrange and group function outlookGrid1.Sort(new DataRowComparer(e.ColumnIndex, direction)); //after sorting, reset the GroupTemplate back to its default (if it was changed) // this is needed just for this demo. We do not want the other // columns to be grouped alphabetically. outlookGrid1.GroupTemplate = prevGroup; break; default: //UnboundContactInfo outlookGrid1.Sort(outlookGrid1.Columns[e.ColumnIndex], direction); break; } } }
/// <summary> /// Group a column /// </summary> /// <param name="col">The name of the column.</param> /// <param name="sortDirection">The sort direction of the group./</param> /// <param name="gr">The IOutlookGridGroup object.</param> public void GroupColumn(OutlookGridColumn col, SortOrder sortDirection, IOutlookGridGroup gr) { if (!col.IsGrouped) { col.GroupIndex = ++internalColumns.MaxGroupIndex; if (col.SortIndex > -1) internalColumns.RemoveSortIndex(col); col.SortDirection = sortDirection; col.DataGridViewColumn.HeaderCell.SortGlyphDirection = sortDirection; if (gr != null) col.GroupingType = gr; if (_hideColumnOnGrouping && col.GroupingType.AllowHiddenWhenGrouped) col.DataGridViewColumn.Visible = false; } #if DEBUG internalColumns.DebugOutput(); #endif }
/// <summary> /// Group a column /// </summary> /// <param name="columnName">The name of the column.</param> /// <param name="sortDirection">The sort direction of the group./</param> /// <param name="gr">The IOutlookGridGroup object.</param> public void GroupColumn(string columnName, SortOrder sortDirection, IOutlookGridGroup gr) { GroupColumn(internalColumns[columnName], sortDirection, gr); }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridDateTimeGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { }
public OutlookGridRow(IOutlookGridGroup group) : this(group, false) { }
/// <summary> /// the fill grid method fills the grid with the data from the DataSourceManager /// It takes the grouping style into account, if it is set. /// </summary> private void FillGrid(IOutlookGridGroup groupingStyle) { ArrayList list; OutlookGridRow row; this.Rows.Clear(); // start filling the grid if (_dataSource == null) return; else list = _dataSource.Rows; if (list.Count <= 0) return; // this block is used of grouping is turned off // this will simply list all attributes of each object in the list if (groupingStyle == null) { foreach (DataSourceRow r in list) { row = (OutlookGridRow) this.RowTemplate.Clone(); foreach (var val in r) { DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Value = val.ToString(); row.Cells.Add(cell); } Rows.Add(row); } } // this block is used when grouping is used // items in the list must be sorted, and then they will automatically be grouped else { IOutlookGridGroup groupCur = null; object result = null; var counter = 0; // counts number of items in the group foreach (DataSourceRow r in list) { row = (OutlookGridRow)this.RowTemplate.Clone(); result = r[groupingStyle.Column.Index]; if (groupCur != null && groupCur.CompareTo(result) == 0) // item is part of the group { row.Group = groupCur; counter++; } else // item is not part of the group, so create new group { if (groupCur != null) groupCur.ItemCount = counter; groupCur = (IOutlookGridGroup)groupingStyle.Clone(); // init groupCur.Value = result; row.Group = groupCur; row.IsGroupRow = true; row.Height = groupCur.Height; row.CreateCells(this, groupCur.Value); Rows.Add(row); // add content row after this row = (OutlookGridRow)this.RowTemplate.Clone(); row.Group = groupCur; counter = 1; // reset counter for next group } foreach (var obj in r) { DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Value = obj.ToString(); row.Cells.Add(cell); } Rows.Add(row); groupCur.ItemCount = counter; } } }
/// <summary> /// Add a column for internal uses of the OutlookGrid. The column must already exists in the datagridview. Do this *BEFORE* using the grid (sorting and grouping, filling,...) /// </summary> /// <param name="col">The DataGridViewColumn.</param> /// <param name="group">The group type for the column.</param> /// <param name="sortDirection">The sort direction.</param> /// <param name="groupIndex">The column's position in grouping and at which level.</param> /// <param name="sortIndex">the column's position among sorted columns.</param> public void AddInternalColumn(DataGridViewColumn col, IOutlookGridGroup group, SortOrder sortDirection, int groupIndex, int sortIndex) { AddInternalColumn(new OutlookGridColumn(col, group, sortDirection, groupIndex, sortIndex)); //internalColumns.Add(new OutlookGridColumn(col, group, sortDirection, groupIndex, sortIndex)); ////Already reflect the SortOrder on the column //col.HeaderCell.SortGlyphDirection = sortDirection; //if (this._hideColumnOnGrouping && groupIndex > -1 && group.AllowHiddenWhenGrouped) // col.Visible = false; }
/// <summary> /// Constructor. /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridAlphabeticGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { allowHiddenWhenGrouped = false; }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parentGroup if any.</param> public OutlookGridDateTimeGroup(IOutlookGridGroup parentGroup) : base(parentGroup) { allowHiddenWhenGrouped = true; Interval = DateInterval.Smart; }
/// <summary> /// Constructor /// </summary> /// <param name="parentGroup">The parent group if any.</param> public OutlookGridDefaultGroup(IOutlookGridGroup parentGroup) : this() { if (parentGroup != null) children.ParentGroup = parentGroup; }
/// <summary> /// Initializes a new instance of the <see cref="OutlookGridGroupCollection"/> class. /// </summary> /// <param name="parentGroup">The parent group, if any.</param> public OutlookGridGroupCollection(IOutlookGridGroup parentGroup) { groupList = new List <IOutlookGridGroup>(); this.parentGroup = parentGroup; }
/// <summary> /// the fill grid method fills the grid with the data from the DataSourceManager /// It takes the grouping style into account, if it is set. /// </summary> private void FillGrid(IOutlookGridGroup groupingStyle) { ArrayList list; OutlookGridRow row; this.Rows.Clear(); // start filling the grid if (dataSource == null) { return; } else { list = dataSource.Rows; } if (list.Count <= 0) { return; } // this block is used of grouping is turned off // this will simply list all attributes of each object in the list if (groupingStyle == null) { foreach (DataSourceRow r in list) { row = (OutlookGridRow)this.RowTemplate.Clone(); foreach (object val in r) { DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Value = val.ToString(); row.Cells.Add(cell); } Rows.Add(row); } } // this block is used when grouping is used // items in the list must be sorted, and then they will automatically be grouped else { IOutlookGridGroup groupCur = null; object result = null; int counter = 0; // counts number of items in the group foreach (DataSourceRow r in list) { row = (OutlookGridRow)this.RowTemplate.Clone(); result = r[groupingStyle.Column.Index]; if (groupCur != null && groupCur.CompareTo(result) == 0) // item is part of the group { row.Group = groupCur; counter++; } else // item is not part of the group, so create new group { if (groupCur != null) { groupCur.ItemCount = counter; } groupCur = (IOutlookGridGroup)groupingStyle.Clone(); // init groupCur.Value = result; row.Group = groupCur; row.IsGroupRow = true; row.Height = groupCur.Height; row.CreateCells(this, groupCur.Value); Rows.Add(row); // add content row after this row = (OutlookGridRow)this.RowTemplate.Clone(); row.Group = groupCur; counter = 1; // reset counter for next group } foreach (object obj in r) { DataGridViewCell cell = new DataGridViewTextBoxCell(); cell.Value = obj.ToString(); row.Cells.Add(cell); } Rows.Add(row); groupCur.ItemCount = counter; } } }
/// <summary> /// Gets if the row has one parent that is collapsed /// </summary> /// <param name="gr">The group to look at.</param> /// <param name="i">Fill 0 to first this method (used for recursive).</param> /// <returns>True or false.</returns> public bool IsAParentCollapsed(IOutlookGridGroup gr, int i) { i++; if (gr.ParentGroup != null) { //if it is not the original group but it is one parent and if it is collapsed just stop here //no need to look further to the parents (one of the parents can be expanded...) //if (i > 1 && gr.Collapsed) if (gr.ParentGroup.Collapsed) return true; else return IsAParentCollapsed(gr.ParentGroup, i); } else { //if 1 that means there is no parent if (i == 1) return false; else return gr.Collapsed; } }