System.Windows.Forms.ThemeWin32Classic.DataGridPaintRelationRow C# (CSharp) Method

DataGridPaintRelationRow() public method

public DataGridPaintRelationRow ( Graphics g, int row, Rectangle row_rect, bool is_newrow, Rectangle clip, System.Windows.Forms.DataGrid grid ) : void
g System.Drawing.Graphics
row int
row_rect System.Drawing.Rectangle
is_newrow bool
clip System.Drawing.Rectangle
grid System.Windows.Forms.DataGrid
return void
		public override void DataGridPaintRelationRow (Graphics g, int row, Rectangle row_rect, bool is_newrow,
							       Rectangle clip, DataGrid grid)
		{
			Rectangle rect_header;
			Rectangle icon_bounds = new Rectangle ();
			Pen pen = ThemeEngine.Current.ResPool.GetPen (grid.CurrentTableStyle.ForeColor);

			/* paint the header if it's visible and intersects the clip */
			if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
				rect_header = row_rect;
				rect_header.Width = grid.RowHeaderWidth;
				row_rect.X += grid.RowHeaderWidth;
				if (clip.IntersectsWith (rect_header)) {
					DataGridPaintRowHeader (g, rect_header, row, grid);
				}

				icon_bounds = rect_header;
				icon_bounds.X += icon_bounds.Width / 2;
				icon_bounds.Y += 3;
				icon_bounds.Width = 8;
				icon_bounds.Height = 8;

				g.DrawRectangle (pen, icon_bounds);

				/* the - part of the icon */
				g.DrawLine (pen,
					    icon_bounds.X + 2, icon_bounds.Y + icon_bounds.Height / 2,
					    icon_bounds.X + icon_bounds.Width - 2, icon_bounds.Y + icon_bounds.Height / 2);
					    
				if (!grid.IsExpanded (row)) {
					/* the | part of the icon */
					g.DrawLine (pen,
						    icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + 2,
						    icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + icon_bounds.Height - 2);
				}
			}

			Rectangle nested_rect = row_rect;

			if (grid.DataGridRows[row].IsExpanded)
				nested_rect.Height -= grid.DataGridRows[row].RelationHeight;

			DataGridPaintRowContents (g, row, nested_rect, is_newrow, clip, grid);

			if (grid.DataGridRows[row].IsExpanded) {
				// XXX we should create this in the
				// datagrid and cache it for use by
				// the theme instead of doing it each
				// time through here
				string[] relations = grid.CurrentTableStyle.Relations;
				StringBuilder relation_builder = new StringBuilder ("");

				for (int i = 0; i < relations.Length; i ++) {
					if (i > 0)
						relation_builder.Append ("\n");

					relation_builder.Append (relations[i]);
				}
				string relation_text = relation_builder.ToString ();

				StringFormat string_format = new StringFormat ();
				string_format.FormatFlags |= StringFormatFlags.NoWrap;


				//Region prev_clip = g.Clip;
				//Region current_clip;
				Rectangle rect_cell = row_rect;

				rect_cell.X = nested_rect.X + grid.GetColumnStartingPixel (grid.FirstVisibleColumn) - grid.HorizPixelOffset;
				rect_cell.Y += nested_rect.Height;
				rect_cell.Height = grid.DataGridRows[row].RelationHeight;

				rect_cell.Width = 0;
				int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
				for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
					if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
						continue;
					rect_cell.Width += grid.CurrentTableStyle.GridColumnStyles[column].Width;
				}
				rect_cell.Width = Math.Max (rect_cell.Width, grid.DataGridRows[row].relation_area.Width);

				g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (grid.CurrentTableStyle.BackColor),
						 rect_cell);


				/* draw the line leading from the +/- to the relation area */
				Rectangle outline = grid.DataGridRows[row].relation_area;
				outline.Y = rect_cell.Y;
				outline.Height --;

				g.DrawLine (pen,
					    icon_bounds.X + icon_bounds.Width / 2, icon_bounds.Y + icon_bounds.Height,
					    icon_bounds.X + icon_bounds.Width / 2, outline.Y + outline.Height / 2);

				g.DrawLine (pen,
					    icon_bounds.X + icon_bounds.Width / 2, outline.Y + outline.Height / 2,
					    outline.X, outline.Y + outline.Height / 2);

				g.DrawRectangle (pen, outline);

				g.DrawString (relation_text, grid.LinkFont, ResPool.GetSolidBrush (grid.LinkColor),
					      outline, string_format);

				if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
					Rectangle not_usedarea = new Rectangle ();
					not_usedarea.X = rect_cell.X + rect_cell.Width;
					not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
					not_usedarea.Y = row_rect.Y;
					not_usedarea.Height = row_rect.Height;
					if (clip.IntersectsWith (not_usedarea))
						g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
								 not_usedarea);
				}
			}
		}
ThemeWin32Classic