// will return the count of the table with the largest number of columns private int ColsCount() { int colNum = 0; for (int row = 0; row < parentsCount; row++) { DataGridState dgs = (DataGridState)parents[row]; colNum = Math.Max(colNum, dgs.GridColumnStyles.Count); } return(colNum); }
internal void Clear() { for (int i = 0; i < parents.Count; i++) { DataGridState dgs = parents[i] as DataGridState; dgs.RemoveChangeNotification(); } parents.Clear(); rowHeights.Clear(); totalHeight = 0; SetParentCount(0); }
private int PaintRow(Graphics g, Rectangle bounds, int row, Font font, bool alignToRight, int tableNameBoxWidth, int[] colsNameWidths, int[] colsDataWidths) { DataGridState dgs = (DataGridState)parents[row]; Rectangle paintBounds = bounds; Rectangle rowBounds = bounds; paintBounds.Height = (int)rowHeights[row]; rowBounds.Height = (int)rowHeights[row]; int paintedWidth = 0; // used for scrolling: when paiting, we will skip horizOffset cells in the dataGrid ParentRows int skippedCells = 0; // paint the table name if (dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.TableName || dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both) { if (skippedCells < horizOffset) { // skip this skippedCells++; } else { paintBounds.Width = Math.Min(paintBounds.Width, tableNameBoxWidth); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); string displayTableName = dgs.ListManager.GetListName() + ": "; PaintText(g, paintBounds, displayTableName, font, true, alignToRight); // true is for painting bold paintedWidth += paintBounds.Width; } } if (paintedWidth >= bounds.Width) { return(bounds.Width); // we painted everything } rowBounds.Width -= paintedWidth; rowBounds.X += alignToRight ? 0 : paintedWidth; paintedWidth += PaintColumns(g, rowBounds, dgs, font, alignToRight, colsNameWidths, colsDataWidths, skippedCells); // paint the possible space left after columns if (paintedWidth < bounds.Width) { paintBounds.X = bounds.X + paintedWidth; paintBounds.Width = bounds.Width - paintedWidth; paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); g.FillRectangle(BackBrush, paintBounds); } return(paintedWidth); }
internal DataGridState PopTop() { if (this.parentsCount < 1) { return(null); } this.SetParentCount(this.parentsCount - 1); DataGridState state = (DataGridState)this.parents[this.parentsCount]; state.RemoveChangeNotification(); this.parents.RemoveAt(this.parentsCount); return(state); }
private int PaintColumns(Graphics g, Rectangle bounds, DataGridState dgs, Font font, bool alignToRight, int[] colsNameWidths, int[] colsDataWidths, int skippedCells) { Rectangle containedRect = bounds; GridColumnStylesCollection gridColumnStyles = dgs.GridColumnStyles; int num = 0; for (int i = 0; i < gridColumnStyles.Count; i++) { if (num >= bounds.Width) { return(num); } if (((this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.ColumnName) || (this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both)) && (skippedCells >= this.horizOffset)) { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, colsNameWidths[i]); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); string text = gridColumnStyles[i].HeaderText + ": "; this.PaintText(g, containedRect, text, font, false, alignToRight); num += containedRect.Width; } if (num >= bounds.Width) { return(num); } if (skippedCells < this.horizOffset) { skippedCells++; } else { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, colsDataWidths[i]); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); gridColumnStyles[i].Paint(g, containedRect, (CurrencyManager)this.dataGrid.BindingContext[dgs.DataSource, dgs.DataMember], this.dataGrid.BindingContext[dgs.DataSource, dgs.DataMember].Position, this.BackBrush, this.ForeBrush, alignToRight); num += containedRect.Width; g.DrawLine(new Pen(SystemColors.ControlDark), alignToRight ? containedRect.X : containedRect.Right, containedRect.Y, alignToRight ? containedRect.X : containedRect.Right, containedRect.Bottom); num++; if (i < (gridColumnStyles.Count - 1)) { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, 3); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); g.FillRectangle(this.BackBrush, containedRect); num += 3; } } } return(num); }
// methods // public object Clone() { DataGridState dgs = new DataGridState(); dgs.DataGridRows = DataGridRows; dgs.DataSource = DataSource; dgs.DataMember = DataMember; dgs.FirstVisibleRow = FirstVisibleRow; dgs.FirstVisibleCol = FirstVisibleCol; dgs.CurrentRow = CurrentRow; dgs.CurrentCol = CurrentCol; dgs.GridColumnStyles = GridColumnStyles; dgs.ListManager = ListManager; dgs.DataGrid = DataGrid; return dgs; }
/// <include file='doc\DataGridParentRows.uex' path='docs/doc[@for="DataGridParentRows.PopTop"]/*' /> /// <devdoc> /// Similar to GetTopParent() but also removes it. /// </devdoc> internal DataGridState PopTop() { if (parentsCount < 1) { return(null); } SetParentCount(parentsCount - 1); DataGridState ret = (DataGridState)parents[parentsCount]; ret.RemoveChangeNotification(); parents.RemoveAt(parentsCount); return(ret); }
// methods // public object Clone() { DataGridState dgs = new DataGridState(); dgs.DataGridRows = DataGridRows; dgs.DataSource = DataSource; dgs.DataMember = DataMember; dgs.FirstVisibleRow = FirstVisibleRow; dgs.FirstVisibleCol = FirstVisibleCol; dgs.CurrentRow = CurrentRow; dgs.CurrentCol = CurrentCol; dgs.GridColumnStyles = GridColumnStyles; dgs.ListManager = ListManager; dgs.DataGrid = DataGrid; return(dgs); }
private int GetColDataBoxWidth(Graphics g, int colNum) { int num = 0; for (int i = 0; i < this.parentsCount; i++) { DataGridState state = (DataGridState)this.parents[i]; GridColumnStylesCollection gridColumnStyles = state.GridColumnStyles; if (colNum < gridColumnStyles.Count) { object columnValueAtRow = gridColumnStyles[colNum].GetColumnValueAtRow((CurrencyManager)this.dataGrid.BindingContext[state.DataSource, state.DataMember], state.LinkingRow.RowNumber); num = Math.Max(gridColumnStyles[colNum].GetPreferredSize(g, columnValueAtRow).Width, num); } } return(num); }
private int GetColBoxWidth(Graphics g, Font font, int colNum) { int num = 0; for (int i = 0; i < this.parentsCount; i++) { DataGridState state = (DataGridState)this.parents[i]; GridColumnStylesCollection gridColumnStyles = state.GridColumnStyles; if (colNum < gridColumnStyles.Count) { string text = gridColumnStyles[colNum].HeaderText + " :"; int width = (int)g.MeasureString(text, font).Width; num = Math.Max(width, num); } } return(num); }
// methods // public object Clone() { DataGridState dgs = new DataGridState { DataGridRows = DataGridRows, DataSource = DataSource, DataMember = DataMember, FirstVisibleRow = FirstVisibleRow, FirstVisibleCol = FirstVisibleCol, CurrentRow = CurrentRow, CurrentCol = CurrentCol, GridColumnStyles = GridColumnStyles, ListManager = ListManager, DataGrid = DataGrid }; return(dgs); }
// will return the width of the best fit for the column // private int GetColDataBoxWidth(Graphics g, int colNum) { int width = 0; for (int row = 0; row < parentsCount; row++) { DataGridState dgs = (DataGridState)parents[row]; GridColumnStylesCollection columns = dgs.GridColumnStyles; if (colNum < columns.Count) { object value = columns[colNum].GetColumnValueAtRow((CurrencyManager)dataGrid.BindingContext[dgs.DataSource, dgs.DataMember], dgs.LinkingRow.RowNumber); int size = columns[colNum].GetPreferredSize(g, value).Width; width = Math.Max(size, width); } } return(width); }
private int PaintRow(Graphics g, Rectangle bounds, int row, Font font, bool alignToRight, int tableNameBoxWidth, int[] colsNameWidths, int[] colsDataWidths) { DataGridState dgs = (DataGridState)this.parents[row]; Rectangle containedRect = bounds; Rectangle rectangle2 = bounds; containedRect.Height = (int)this.rowHeights[row]; rectangle2.Height = (int)this.rowHeights[row]; int num = 0; int skippedCells = 0; if ((this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.TableName) || (this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both)) { if (skippedCells < this.horizOffset) { skippedCells++; } else { containedRect.Width = Math.Min(containedRect.Width, tableNameBoxWidth); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); string text = dgs.ListManager.GetListName() + ": "; this.PaintText(g, containedRect, text, font, true, alignToRight); num += containedRect.Width; } } if (num >= bounds.Width) { return(bounds.Width); } rectangle2.Width -= num; rectangle2.X += alignToRight ? 0 : num; num += this.PaintColumns(g, rectangle2, dgs, font, alignToRight, colsNameWidths, colsDataWidths, skippedCells); if (num < bounds.Width) { containedRect.X = bounds.X + num; containedRect.Width = bounds.Width - num; containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); g.FillRectangle(this.BackBrush, containedRect); } return(num); }
// since the layout of the parentRows is computed on every paint message, // we can actually return true ClientRectangle coordinates internal Rectangle GetBoundsForDataGridStateAccesibility(DataGridState dgs) { Rectangle ret = Rectangle.Empty; int rectY = 0; for (int i = 0; i < parentsCount; i++) { int height = (int)rowHeights[i]; if (parents[i] == dgs) { ret.X = layout.leftArrow.IsEmpty ? layout.data.X : layout.leftArrow.Right; ret.Height = height; ret.Y = rectY; ret.Width = layout.data.Width; return(ret); } rectY += height; } return(ret); }
// will return the width of the text box that will // fit all the column names private int GetColBoxWidth(Graphics g, Font font, int colNum) { int width = 0; for (int row = 0; row < parentsCount; row++) { DataGridState dgs = (DataGridState)parents[row]; GridColumnStylesCollection columns = dgs.GridColumnStyles; if (colNum < columns.Count) { // Graphics.MeasureString(...) returns different results for ": " than for " :" // string colName = columns[colNum].HeaderText + " :"; int size = (int)g.MeasureString(colName, font).Width; width = Math.Max(size, width); } } return(width); }
internal Rectangle GetBoundsForDataGridStateAccesibility(DataGridState dgs) { Rectangle empty = Rectangle.Empty; int num = 0; for (int i = 0; i < this.parentsCount; i++) { int num3 = (int)this.rowHeights[i]; if (this.parents[i] == dgs) { empty.X = this.layout.leftArrow.IsEmpty ? this.layout.data.X : this.layout.leftArrow.Right; empty.Height = num3; empty.Y = num; empty.Width = this.layout.data.Width; return(empty); } num += num3; } return(empty); }
internal void OnLayout() { if (this.parentsCount != this.rowHeights.Count) { int num = 0; if (this.totalHeight == 0) { this.totalHeight += 2 * this.borderWidth; } this.textRegionHeight = this.dataGrid.Font.Height + 2; if (this.parentsCount > this.rowHeights.Count) { for (int i = this.rowHeights.Count; i < this.parentsCount; i++) { DataGridState state = (DataGridState)this.parents[i]; GridColumnStylesCollection gridColumnStyles = state.GridColumnStyles; int num4 = 0; for (int j = 0; j < gridColumnStyles.Count; j++) { num4 = Math.Max(num4, gridColumnStyles[j].GetMinimumHeight()); } num = Math.Max(num4, this.textRegionHeight) + 1; this.rowHeights.Add(num); this.totalHeight += num; } } else { if (this.parentsCount == 0) { this.totalHeight = 0; } else { this.totalHeight -= (int)this.rowHeights[this.rowHeights.Count - 1]; } this.rowHeights.RemoveAt(this.rowHeights.Count - 1); } } }
private int GetTableBoxWidth(Graphics g, Font font) { Font font2 = font; try { font2 = new Font(font, FontStyle.Bold); } catch { } int num = 0; for (int i = 0; i < this.parentsCount; i++) { DataGridState state = (DataGridState)this.parents[i]; string text = state.ListManager.GetListName() + " :"; int width = (int)g.MeasureString(text, font2).Width; num = Math.Max(width, num); } return(num); }
// will return the width of the text box that will fit all the // tables names private int GetTableBoxWidth(Graphics g, Font font) { // try to make the font BOLD Font textFont = font; try { textFont = new Font(font, FontStyle.Bold); } catch (Exception) { } int width = 0; for (int row = 0; row < parentsCount; row++) { DataGridState dgs = (DataGridState)parents[row]; // Graphics.MeasureString(...) returns different results for ": " than for " :" // string displayTableName = dgs.ListManager.GetListName() + " :"; int size = (int)g.MeasureString(displayTableName, textFont).Width; width = Math.Max(size, width); } return(width); }
private int PaintColumns(Graphics g, Rectangle bounds, DataGridState dgs, Font font, bool alignToRight, int[] colsNameWidths, int[] colsDataWidths, int skippedCells) { Rectangle paintBounds = bounds; Rectangle rowBounds = bounds; GridColumnStylesCollection cols = dgs.GridColumnStyles; int cx = 0; for (int i = 0; i < cols.Count; i ++) { if (cx >= bounds.Width) break; // paint the column name, if we have to if (dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.ColumnName || dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both) { if (skippedCells < horizOffset) { // skip this column } else { paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, colsNameWidths[i]); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); string colName = cols[i].HeaderText + ": "; PaintText(g, paintBounds, colName, font, false, alignToRight); // false is for not painting bold cx += paintBounds.Width; } } if (cx >= bounds.Width) break; if (skippedCells < horizOffset) { // skip this cell skippedCells ++; } else { // paint the cell contents paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, colsDataWidths[i]); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); // when we paint the data grid parent rows, we want to paint the data at the position // stored in the currency manager. cols[i].Paint(g, paintBounds, (CurrencyManager) dataGrid.BindingContext[dgs.DataSource, dgs.DataMember], dataGrid.BindingContext[dgs.DataSource, dgs.DataMember].Position, BackBrush, ForeBrush, alignToRight); cx += paintBounds.Width; // draw the line to the right (or left, according to alignRight) // g.DrawLine(new Pen(SystemColors.ControlDark), alignToRight ? paintBounds.X : paintBounds.Right, paintBounds.Y, alignToRight ? paintBounds.X : paintBounds.Right, paintBounds.Bottom); // this is how wide the line is.... cx++; // put 3 pixels in between columns // see DonnaWa // if ( i < cols.Count - 1) { paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, 3); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); g.FillRectangle(BackBrush, paintBounds); cx += 3; } } } return cx; }
internal void NavigateTo(string relationName, DataGridRow source, bool fromRow) { if (this.AllowNavigation && this.CommitEdit()) { DataGridState state; try { state = this.CreateChildState(relationName, source); } catch { this.NavigateBack(); return; } try { this.listManager.EndCurrentEdit(); } catch { return; } DataGridState dgs = new DataGridState(this) { LinkingRow = source }; if (source.RowNumber != this.CurrentRow) { this.listManager.Position = source.RowNumber; } if (this.parentRows.GetTopParent() == null) { this.originalState = dgs; } this.parentRows.AddParent(dgs); this.NavigateTo(state); this.OnNavigate(new NavigateEventArgs(true)); } }
private void NavigateTo(DataGridState childState) { this.EndEdit(); this.gridState[0x4000] = false; this.ResetMouseState(); childState.PullState(this, true); if (this.listManager.Position != this.currentRow) { this.currentRow = (this.listManager.Position == -1) ? 0 : this.listManager.Position; } if (this.parentRows.GetTopParent() != null) { this.caption.BackButtonActive = this.AllowNavigation; this.caption.BackButtonVisible = this.caption.BackButtonActive; this.caption.DownButtonActive = true; } this.HorizontalOffset = 0; base.PerformLayout(); base.Invalidate(); }
private void ResetParentRows() { this.parentRows.Clear(); this.originalState = null; this.caption.BackButtonActive = this.caption.DownButtonActive = this.caption.BackButtonVisible = false; this.caption.SetDownButtonDirection(!this.layout.ParentRowsVisible); }
internal void ParentRowsDataChanged() { this.parentRows.Clear(); this.caption.BackButtonActive = this.caption.DownButtonActive = this.caption.BackButtonVisible = false; this.caption.SetDownButtonDirection(!this.layout.ParentRowsVisible); object dataSource = this.originalState.DataSource; string dataMember = this.originalState.DataMember; this.originalState = null; this.Set_ListManager(dataSource, dataMember, true); }
public void SetDataBinding(object dataSource, string dataMember) { this.parentRows.Clear(); this.originalState = null; this.caption.BackButtonActive = this.caption.DownButtonActive = this.caption.BackButtonVisible = false; this.caption.SetDownButtonDirection(!this.layout.ParentRowsVisible); this.Set_ListManager(dataSource, dataMember, false); }
public DataGridStateParentRowAccessibleObject(DataGridState owner) : base() { Debug.Assert(owner != null, "DataGridRowAccessibleObject must have a valid owner DataGridRow"); this.owner = owner; }
// called from DataGrid::OnLayout internal void OnLayout() { if (parentsCount == rowHeights.Count) { return; } int height = 0; if (totalHeight == 0) { totalHeight += 2 * borderWidth; } // figure out how tall each row's text will be // textRegionHeight = (int)dataGrid.Font.Height + 2; // make the height of the Column.Font count for the height // of the parentRows; // // if the user wants to programatically // navigate to a relation in the constructor of the form // ( ie, when the form does not process PerformLayout ) // the grid will receive an OnLayout message when there is more // than one parent in the grid if (parentsCount > rowHeights.Count) { Debug.Assert(parentsCount == rowHeights.Count + 1 || rowHeights.Count == 0, "see comment above for more info"); int rowHeightsCount = this.rowHeights.Count; for (int i = rowHeightsCount; i < parentsCount; i++) { DataGridState dgs = (DataGridState)parents[i]; GridColumnStylesCollection cols = dgs.GridColumnStyles; int colsHeight = 0; for (int j = 0; j < cols.Count; j++) { colsHeight = Math.Max(colsHeight, cols[j].GetMinimumHeight()); } height = Math.Max(colsHeight, textRegionHeight); // the height of the bottom border height++; rowHeights.Add(height); totalHeight += height; } } else { Debug.Assert(parentsCount == rowHeights.Count - 1, "we do layout only for push/popTop"); if (parentsCount == 0) { totalHeight = 0; } else { totalHeight -= (int)rowHeights[rowHeights.Count - 1]; } rowHeights.RemoveAt(rowHeights.Count - 1); } }
public DataGridStateParentRowAccessibleObject(DataGridState owner) { this.owner = owner; }
private int PaintColumns(Graphics g, Rectangle bounds, DataGridState dgs, Font font, bool alignToRight, int[] colsNameWidths, int[] colsDataWidths, int skippedCells) { Rectangle containedRect = bounds; GridColumnStylesCollection gridColumnStyles = dgs.GridColumnStyles; int num = 0; for (int i = 0; i < gridColumnStyles.Count; i++) { if (num >= bounds.Width) { return num; } if (((this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.ColumnName) || (this.dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both)) && (skippedCells >= this.horizOffset)) { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, colsNameWidths[i]); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); string text = gridColumnStyles[i].HeaderText + ": "; this.PaintText(g, containedRect, text, font, false, alignToRight); num += containedRect.Width; } if (num >= bounds.Width) { return num; } if (skippedCells < this.horizOffset) { skippedCells++; } else { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, colsDataWidths[i]); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); gridColumnStyles[i].Paint(g, containedRect, (CurrencyManager) this.dataGrid.BindingContext[dgs.DataSource, dgs.DataMember], this.dataGrid.BindingContext[dgs.DataSource, dgs.DataMember].Position, this.BackBrush, this.ForeBrush, alignToRight); num += containedRect.Width; g.DrawLine(new Pen(SystemColors.ControlDark), alignToRight ? containedRect.X : containedRect.Right, containedRect.Y, alignToRight ? containedRect.X : containedRect.Right, containedRect.Bottom); num++; if (i < (gridColumnStyles.Count - 1)) { containedRect.X = bounds.X + num; containedRect.Width = Math.Min(bounds.Width - num, 3); containedRect.X = this.MirrorRect(bounds, containedRect, alignToRight); g.FillRectangle(this.BackBrush, containedRect); num += 3; } } } return num; }
private int PaintColumns(Graphics g, Rectangle bounds, DataGridState dgs, Font font, bool alignToRight, int[] colsNameWidths, int[] colsDataWidths, int skippedCells) { Rectangle paintBounds = bounds; Rectangle rowBounds = bounds; GridColumnStylesCollection cols = dgs.GridColumnStyles; int cx = 0; for (int i = 0; i < cols.Count; i++) { if (cx >= bounds.Width) { break; } // paint the column name, if we have to if (dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.ColumnName || dataGrid.ParentRowsLabelStyle == DataGridParentRowsLabelStyle.Both) { if (skippedCells < horizOffset) { // skip this column } else { paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, colsNameWidths[i]); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); string colName = cols[i].HeaderText + ": "; PaintText(g, paintBounds, colName, font, false, alignToRight); // false is for not painting bold cx += paintBounds.Width; } } if (cx >= bounds.Width) { break; } if (skippedCells < horizOffset) { // skip this cell skippedCells++; } else { // paint the cell contents paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, colsDataWidths[i]); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); // when we paint the data grid parent rows, we want to paint the data at the position // stored in the currency manager. cols[i].Paint(g, paintBounds, (CurrencyManager)dataGrid.BindingContext[dgs.DataSource, dgs.DataMember], dataGrid.BindingContext[dgs.DataSource, dgs.DataMember].Position, BackBrush, ForeBrush, alignToRight); cx += paintBounds.Width; // draw the line to the right (or left, according to alignRight) // g.DrawLine(new Pen(SystemColors.ControlDark), alignToRight ? paintBounds.X : paintBounds.Right, paintBounds.Y, alignToRight ? paintBounds.X : paintBounds.Right, paintBounds.Bottom); // this is how wide the line is.... cx++; // put 3 pixels in between columns // see DonnaWa // if (i < cols.Count - 1) { paintBounds.X = bounds.X + cx; paintBounds.Width = Math.Min(bounds.Width - cx, 3); paintBounds.X = MirrorRect(bounds, paintBounds, alignToRight); g.FillRectangle(BackBrush, paintBounds); cx += 3; } } } return(cx); }
public void NavigateBack() { if (this.CommitEdit() && !this.parentRows.IsEmpty()) { if (this.gridState[0x100000]) { this.gridState[0x100000] = false; try { this.listManager.CancelCurrentEdit(); } catch { } } else { this.UpdateListManager(); } DataGridState state = this.parentRows.PopTop(); this.ResetMouseState(); state.PullState(this, false); if (this.parentRows.GetTopParent() == null) { this.originalState = null; } DataGridRow[] dataGridRows = this.DataGridRows; if ((this.ReadOnly || !this.policy.AllowAdd) == (dataGridRows[this.DataGridRowsLength - 1] is DataGridAddNewRow)) { int num = (this.ReadOnly || !this.policy.AllowAdd) ? (this.DataGridRowsLength - 1) : (this.DataGridRowsLength + 1); DataGridRow[] newRows = new DataGridRow[num]; for (int i = 0; i < Math.Min(num, this.DataGridRowsLength); i++) { newRows[i] = this.DataGridRows[i]; } if (!this.ReadOnly && this.policy.AllowAdd) { newRows[num - 1] = new DataGridAddNewRow(this, this.myGridTable, num - 1); } this.SetDataGridRows(newRows, num); } dataGridRows = this.DataGridRows; if (((dataGridRows != null) && (dataGridRows.Length != 0)) && (dataGridRows[0].DataGridTableStyle != this.myGridTable)) { for (int j = 0; j < dataGridRows.Length; j++) { dataGridRows[j].DataGridTableStyle = this.myGridTable; } } if ((this.myGridTable.GridColumnStyles.Count > 0) && (this.myGridTable.GridColumnStyles[0].Width == -1)) { this.InitializeColumnWidths(); } this.currentRow = (this.ListManager.Position == -1) ? 0 : this.ListManager.Position; if (!this.AllowNavigation) { this.RecreateDataGridRows(); } this.caption.BackButtonActive = (this.parentRows.GetTopParent() != null) && this.AllowNavigation; this.caption.BackButtonVisible = this.caption.BackButtonActive; this.caption.DownButtonActive = this.parentRows.GetTopParent() != null; base.PerformLayout(); base.Invalidate(); if (this.vertScrollBar.Visible) { this.vertScrollBar.Value = this.firstVisibleRow; } if (this.horizScrollBar.Visible) { this.horizScrollBar.Value = this.HorizontalOffset + this.negOffset; } this.Edit(); this.OnNavigate(new NavigateEventArgs(false)); } }
private DataGridState CreateChildState(string relationName, DataGridRow source) { string str; DataGridState state = new DataGridState(); if (string.IsNullOrEmpty(this.DataMember)) { str = relationName; } else { str = this.DataMember + "." + relationName; } CurrencyManager manager = (CurrencyManager) this.BindingContext[this.DataSource, str]; state.DataSource = this.DataSource; state.DataMember = str; state.ListManager = manager; state.DataGridRows = null; state.DataGridRowsLength = manager.Count + (this.policy.AllowAdd ? 1 : 0); return state; }
internal void AddParent(DataGridState dgs) { CurrencyManager manager1 = (CurrencyManager) this.dataGrid.BindingContext[dgs.DataSource, dgs.DataMember]; this.parents.Add(dgs); this.SetParentCount(this.parentsCount + 1); }
// since the layout of the parentRows is computed on every paint message, // we can actually return true ClientRectangle coordinates internal Rectangle GetBoundsForDataGridStateAccesibility(DataGridState dgs) { Rectangle ret = Rectangle.Empty; int rectY = 0; for (int i = 0; i < parentsCount; i++) { int height = (int) rowHeights[i]; if (parents[i] == dgs) { ret.X = layout.leftArrow.IsEmpty ? layout.data.X : layout.leftArrow.Right; ret.Height = height; ret.Y = rectY; ret.Width = layout.data.Width; return ret; } rectY += height; } return ret; }
private void MetaDataChanged() { this.parentRows.Clear(); this.caption.BackButtonActive = this.caption.DownButtonActive = this.caption.BackButtonVisible = false; this.caption.SetDownButtonDirection(!this.layout.ParentRowsVisible); this.gridState[0x400000] = true; try { if (this.originalState != null) { this.Set_ListManager(this.originalState.DataSource, this.originalState.DataMember, true); this.originalState = null; } else { this.Set_ListManager(this.DataSource, this.DataMember, true); } } finally { this.gridState[0x400000] = false; } }
// =------------------------------------------------------------------ // = Methods // =------------------------------------------------------------------ /// <include file='doc\DataGridParentRows.uex' path='docs/doc[@for="DataGridParentRows.AddParent"]/*' /> /// <devdoc> /// Adds a DataGridState object to the top of the list of parents. /// </devdoc> internal void AddParent(DataGridState dgs) { CurrencyManager childDataSource = (CurrencyManager) dataGrid.BindingContext[dgs.DataSource, dgs.DataMember]; parents.Add(dgs); SetParentCount(parentsCount + 1); Debug.Assert(GetTopParent() != null, "we should have a parent at least"); }
internal Rectangle GetBoundsForDataGridStateAccesibility(DataGridState dgs) { Rectangle empty = Rectangle.Empty; int num = 0; for (int i = 0; i < this.parentsCount; i++) { int num3 = (int) this.rowHeights[i]; if (this.parents[i] == dgs) { empty.X = this.layout.leftArrow.IsEmpty ? this.layout.data.X : this.layout.leftArrow.Right; empty.Height = num3; empty.Y = num; empty.Width = this.layout.data.Width; return empty; } num += num3; } return empty; }