本文整理汇总了C#中System.Drawing.Region.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Region.Dispose方法的具体用法?C# Region.Dispose怎么用?C# Region.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Region
的用法示例。
在下文中一共展示了Region.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawPointerDown
private void DrawPointerDown(Graphics g)
{
Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
GraphicsPath path = new GraphicsPath();
path.AddLines(points);
Region region = new Region(path);
g.Clip = region;
if (ThumbState == 3 || !base.Enabled)
ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
else
g.Clear(SystemColors.Control);
g.ResetClip();
region.Dispose();
path.Dispose();
Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
g.DrawLines(SystemPens.ControlLightLight, pointArray2);
pointArray2 = new Point[] { points[3], points[4], points[5] };
g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
points[0].Offset(0, -1);
points[1].Offset(1, 0);
points[2].Offset(1, 1);
points[3].Offset(-1, 1);
points[4].Offset(-1, 0);
points[5] = points[0];
pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
g.DrawLines(SystemPens.ControlLight, pointArray2);
pointArray2 = new Point[] { points[3], points[4], points[5] };
g.DrawLines(SystemPens.ControlDark, pointArray2);
}
示例2: Form2_Load
private void Form2_Load(object sender, EventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(pic1.ClientRectangle);
Region region = new Region(gp);
pic1.Region = region;
gp.Dispose();
region.Dispose();
}
示例3: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
// Clip to path (with shape).
Rectangle rectangle = new Rectangle(10, 10, 250, 50);
GraphicsPath path = new GraphicsPath();
path.AddEllipse(rectangle);
e.Graphics.DrawPath(Pens.Red, path);
// Set the clipping.
Region clippingRegion = new Region(path);
if (chkClipping.Checked) e.Graphics.Clip = clippingRegion;
// Draw in the clipped region.
e.Graphics.DrawString("Clipped",
new Font("Verdana", 36, FontStyle.Bold), Brushes.Black, 10, 10);
clippingRegion.Dispose();
path.Dispose();
// Rest the clipping region.
e.Graphics.ResetClip();
// Clip to path (which represents text).
path = new GraphicsPath();
path.AddString("Clipped", new FontFamily("Verdana"), 0, 70, new Point(10, 130), new StringFormat());
e.Graphics.DrawPath(Pens.Blue, path);
// Set the clipping.
clippingRegion = new Region(path);
if (chkClipping.Checked) e.Graphics.Clip = clippingRegion;
// Draw a series of ellipsis in the clipped region.
for (int i = 0; i < 40; i++)
{
e.Graphics.DrawEllipse(Pens.Red, 180 - i*3, 180 - i*3, i*6, i*6);
}
clippingRegion.Dispose();
path.Dispose();
}
示例4: DrawIcons
public static Rectangle DrawIcons(Graphics gr, Rectangle aTextRect, CustomAppointment anAppointment, ImageList anAppIcons)
{
if ((anAppIcons != null) && (anAppointment.IconIndexes != null))
{
int length = anAppointment.IconIndexes.Length;
int width = anAppIcons.ImageSize.Width;
int num3 = aTextRect.Width / 3;
if ((aTextRect.Width / 2) > width)
{
int x = (aTextRect.Right - 1) - width;
int y = aTextRect.Y + 1;
Region clip = gr.Clip;
Region region2 = new Region(aTextRect);
region2.Intersect(clip);
gr.Clip = region2;
for (int i = length - 1; i >= 0; i--)
{
using (Image image = anAppIcons.Images[anAppointment.IconIndexes[i]])
{
Rectangle rect = new Rectangle(x, y, width, width);
DrawSingleIcon(gr, rect, image);
}
x -= width;
if (num3 >= (x - aTextRect.X))
{
aTextRect.Width -= width * (length - i);
return aTextRect;
}
}
gr.ResetClip();
region2.Dispose();
region2 = null;
if (clip != null)
{
gr.Clip = clip;
}
aTextRect.Width -= width * length;
}
}
return aTextRect;
}
示例5: ClearInsertionMark
private void ClearInsertionMark(ToolStripItem item)
{
if ((ToolStripDesigner.LastCursorPosition == Point.Empty) || (ToolStripDesigner.LastCursorPosition != Cursor.Position))
{
ToolStripKeyboardHandlingService keyBoardHandlingService = this.GetKeyBoardHandlingService(item);
if ((keyBoardHandlingService == null) || !keyBoardHandlingService.TemplateNodeActive)
{
Rectangle empty = Rectangle.Empty;
if ((item != null) && (item.Site != null))
{
IDesignerHost service = (IDesignerHost) item.Site.GetService(typeof(IDesignerHost));
if (service != null)
{
empty = GetPaintingBounds(service, item);
empty.Inflate(1, 1);
Region r = new Region(empty);
try
{
empty.Inflate(-2, -2);
r.Exclude(empty);
BehaviorService behaviorService = this.GetBehaviorService(item);
if ((behaviorService != null) && (empty != Rectangle.Empty))
{
behaviorService.Invalidate(r);
}
}
finally
{
r.Dispose();
r = null;
}
}
}
}
}
}
示例6: DataGridPaintColumnHeaders
public override void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid)
{
if (!grid.CurrentTableStyle.ColumnHeadersVisible)
return;
Rectangle columns_area = grid.column_headers_area;
// Paint corner shared between row and column header
if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
Rectangle rect_bloc = grid.column_headers_area;
rect_bloc.Width = grid.RowHeaderWidth;
if (clip.IntersectsWith (rect_bloc)) {
if (grid.FlatMode)
g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
else
CPDrawBorder3D (g, rect_bloc, Border3DStyle.RaisedInner,
Border3DSide.Left | Border3DSide.Right |
Border3DSide.Top | Border3DSide.Bottom | Border3DSide.Middle,
grid.CurrentTableStyle.CurrentHeaderBackColor);
}
columns_area.X += grid.RowHeaderWidth;
columns_area.Width -= grid.RowHeaderWidth;
}
// Set column painting
Rectangle rect_columnhdr = new Rectangle ();
int col_pixel;
Region current_clip;
Region prev_clip = g.Clip;
rect_columnhdr.Y = columns_area.Y;
rect_columnhdr.Height = columns_area.Height;
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
continue;
col_pixel = grid.GetColumnStartingPixel (column);
rect_columnhdr.X = columns_area.X + col_pixel - grid.HorizPixelOffset;
rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
if (clip.IntersectsWith (rect_columnhdr) == false)
continue;
current_clip = new Region (rect_columnhdr);
current_clip.Intersect (columns_area);
current_clip.Intersect (prev_clip);
g.Clip = current_clip;
DataGridPaintColumnHeader (g, rect_columnhdr, grid, column);
current_clip.Dispose ();
}
g.Clip = prev_clip;
Rectangle not_usedarea = grid.column_headers_area;
not_usedarea.X = (column_cnt == 0) ? grid.RowHeaderWidth : rect_columnhdr.X + rect_columnhdr.Width;
not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - not_usedarea.X;
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
}
示例7: DataGridPaintParentRows
public override void DataGridPaintParentRows (Graphics g, Rectangle clip, DataGrid grid)
{
Rectangle rect_row = new Rectangle ();
rect_row.X = grid.ParentRowsArea.X;
rect_row.Width = grid.ParentRowsArea.Width;
rect_row.Height = (grid.CaptionFont.Height + 3);
object[] parentRows = grid.data_source_stack.ToArray();
Region current_clip;
Region prev_clip = g.Clip;
for (int row = 0; row < parentRows.Length; row++) {
rect_row.Y = grid.ParentRowsArea.Y + row * rect_row.Height;
if (clip.IntersectsWith (rect_row) == false)
continue;
current_clip = new Region (rect_row);
current_clip.Intersect (prev_clip);
g.Clip = current_clip;
DataGridPaintParentRow (g, rect_row, (DataGridDataSource)parentRows[parentRows.Length - row - 1], grid);
current_clip.Dispose ();
}
g.Clip = prev_clip;
}
示例8: OnMouseLeave
void OnMouseLeave (object sender, EventArgs e)
{
Region region_to_invalidate = new Region ();
region_to_invalidate.MakeEmpty ();
bool dirty = false;
if (ThemeEngine.Current.ScrollBarHasHoverArrowButtonStyle) {
region_to_invalidate.Union (first_arrow_area);
region_to_invalidate.Union (second_arrow_area);
dirty = true;
} else
if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
if (first_button_entered) {
region_to_invalidate.Union (first_arrow_area);
dirty = true;
} else if (second_button_entered) {
region_to_invalidate.Union (second_arrow_area);
dirty = true;
}
if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
if (thumb_entered) {
region_to_invalidate.Union (thumb_pos);
dirty = true;
}
first_button_entered = false;
second_button_entered = false;
thumb_entered = false;
if (dirty)
Invalidate (region_to_invalidate);
region_to_invalidate.Dispose ();
}
示例9: at
/*
Horizontal trackbar
Does not matter the size of the control, Win32 always draws:
- Ticks starting from pixel 13, 8
- Channel starting at pos 8, 19 and ends at Width - 8
- Autosize makes always the control 45 pixels high
- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
*/
private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
float ticks, int value_pos, bool mouse_value) {
Point toptick_startpoint = new Point ();
Point bottomtick_startpoint = new Point ();
Point channel_startpoint = new Point ();
float pixel_len;
float pixels_betweenticks;
Rectangle area = tb.ClientRectangle;
GetTrackBarDrawingInfo (tb , out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);
#region Track
TrackBarDrawHorizontalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
#endregion
#region Thumb
switch (tb.TickStyle) {
case TickStyle.BottomRight:
case TickStyle.None:
thumb_pos.Y = channel_startpoint.Y - 8;
TrackBarDrawHorizontalThumbBottom (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
case TickStyle.TopLeft:
thumb_pos.Y = channel_startpoint.Y - 10;
TrackBarDrawHorizontalThumbTop (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
default:
thumb_pos.Y = area.Y + 10;
TrackBarDrawHorizontalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
break;
}
#endregion
pixel_len = thumb_area.Width - 11;
pixels_betweenticks = pixel_len / ticks;
thumb_area.Y = thumb_pos.Y;
thumb_area.X = channel_startpoint.X;
thumb_area.Height = thumb_pos.Height;
#region Ticks
if (pixels_betweenticks <= 0)
return;
if (tb.TickStyle == TickStyle.None)
return;
Region outside = new Region (area);
outside.Exclude (thumb_area);
if (outside.IsVisible (clip_rectangle)) {
ITrackBarTickPainter tick_painter = TrackBarGetHorizontalTickPainter (dc);
if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
float y = area.Y + bottomtick_startpoint.Y;
for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {
float x = area.X + bottomtick_startpoint.X + inc;
tick_painter.Paint (
x, y,
x, y + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2));
}
}
if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
float y = area.Y + toptick_startpoint.Y;
for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {
float x = area.X + toptick_startpoint.X + inc;
tick_painter.Paint (
x, y - (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1 ? 3 : 2),
x, y);
}
}
}
outside.Dispose ();
#endregion
}
示例10: WndProc
protected override void WndProc(ref Message m)
{
try
{
rangee = ClientRectangle.Width;
inc = (maximum - minimum) / rangee;
dra = (loopend1) / inc;
dra2 = (loopstart1) / inc;
//float fx = BLUE_Thumb.Width * .50f;
// float fy = BLUE_Thumb.Height * .40f;
//Bitmap offScreenBmp;
//offScreenBmp = new Bitmap(this.Width, this.Height);
//Graphics g = Graphics.FromImage(offScreenBmp);
Rectangle destRect1 = new Rectangle(BLUE_Thumb.Left, BLUE_Thumb.Top, BLUE_Thumb.Width, BLUE_Thumb.Height);
GraphicsPath path = new GraphicsPath();
if (tricktype == TrickType.Round)
{
path.AddEllipse(destRect1);
}
else
{
path.AddRectangle(destRect1);
}
Region reg = new Region(path);
LinearGradientBrush lgb = new LinearGradientBrush(destRect1,
color_Trick1, color_Trick2, 90, true);
lgb.SetBlendTriangularShape(0.5f);
//Graphics g = BLUE_Thumb.CreateGraphics())
//g.FillRegion(lgb, reg);
BLUE_Thumb.Region = reg;
switch (m.Msg)
{
case Api.WM_ERASEBKGND:
Bitmap bmp;
Rectangle srceRect;
Rectangle destRect;
// Create a memory bitmap to use as double buffer
Bitmap offScreenBmp;
offScreenBmp = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(offScreenBmp);
//g.SmoothingMode = SmoothingMode.AntiAlias;
if (this.BackgroundImage != null)
{
bmp = new Bitmap(this.BackgroundImage);
srceRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
destRect = new Rectangle(0, 0, this.Width + 100, this.Height);
g.DrawImage(bmp, destRect, srceRect, GraphicsUnit.Pixel);
bmp.Dispose();
}
else
{
SolidBrush myBrush = new SolidBrush(this.BackColor);
g.FillRectangle(myBrush, 0, 0, this.Width, this.Height);
myBrush.Dispose();
}
Pen LEFTorTOPblue = new Pen(color_LEFTorTOPblue);
Pen LEFTorTOPdark = new Pen(color_LEFTorTOPdark);
Pen MIDDLEblue = new Pen(color_MIDDLEblue);
Pen MIDDLEdark = new Pen(color_MIDDLEdark);
Pen RIGHTorBOTTOMblue = new Pen(color_RIGHTorBOTTOMblue);
Pen RIGHTorBOTTOMdark = new Pen(color_RIGHTorBOTTOMdark);
Pen loopred=new Pen(Color.Red);
if (Orientation() == Horz)
{
int y = ClientRectangle.Height / 2;
if (y * 2 < ClientRectangle.Height) y -= 1;
if (Minimum > Maximum)
{
g.DrawLine(LEFTorTOPdark, new Point(0, y - 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y - 1));
g.DrawLine(LEFTorTOPblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y - 1), new Point(ClientRectangle.Width, y - 1));
g.DrawLine(MIDDLEdark, new Point(0, y), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y));
g.DrawLine(MIDDLEblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y), new Point(ClientRectangle.Width, y));
g.DrawLine(RIGHTorBOTTOMdark, new Point(0, y + 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y + 1));
g.DrawLine(RIGHTorBOTTOMblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y + 1), new Point(ClientRectangle.Width, y + 1));
}
else
{
g.DrawLine(LEFTorTOPblue, new Point(0, y - 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y - 1));
g.DrawLine(LEFTorTOPdark, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y - 1), new Point(ClientRectangle.Width, y - 1));
//.........这里部分代码省略.........
示例11: PrepareTouchBackground
private void PrepareTouchBackground(Graphics gr, Rectangle rect, Pen frame, out bool aNeedScrollbar)
{
int num = this.TouchBgrdHeight(rect);
if (this.m_TouchBgrdHeight != num)
{
this.ResetTouchBgrd();
}
this.m_TouchBgrdHeight = num;
if (this.m_Background == null)
{
this.m_ClientRectangle = rect;
this.m_Background = new Bitmap(rect.Width, this.m_TouchBgrdHeight);
this.m_indexChanged = true;
}
Graphics.FromImage(this.m_Background);
Rectangle rectangle = rect;
Region region = new Region(rect);
gr.Clip = region;
rectangle.Location = new Point(rect.X, rect.Y - this.m_VScrollShift);
this.DrawBackground(gr, rectangle, frame, out aNeedScrollbar);
gr.ResetClip();
region.Dispose();
region = null;
this.m_OldNeedScrollbarState = aNeedScrollbar;
}
示例12: MouseMove
internal void MouseMove(Point mouseLocation)
{
Region prevBtnRgn = new Region(m_prevBtnRect);
Region nextBtnRgn = new Region(m_nextBtnRect);
Region prevYearBtnRgn = new Region(m_prevYearBtnRect);
Region nextYearBtnRgn = new Region(m_nextYearBtnRect);
mcButtonState oldPrevMonthState = m_prevBtnState;
mcButtonState oldNextMonthState = m_nextBtnState;
mcButtonState oldPrevYearState = m_prevYearBtnState;
mcButtonState oldNextYearState = m_nextYearBtnState;
if (m_monthSelector)
{
// If not within left scroll button, make sure its not pushed
if (!prevBtnRgn.IsVisible(mouseLocation))
{
if (m_prevBtnState != mcButtonState.Inactive) m_prevBtnState = mcButtonState.Normal;
}
else if (m_prevBtnState != mcButtonState.Inactive)
m_prevBtnState = mcButtonState.Hot;
if (oldPrevMonthState != m_prevBtnState)
DrawButton(m_calendar.CreateGraphics(),m_prevBtnState,mcHeaderButtons.PreviousMonth,m_prevBtnRect);
// If not within right scroll button, make sure its not pushed
if (!nextBtnRgn.IsVisible(mouseLocation))
{
if (m_nextBtnState != mcButtonState.Inactive) m_nextBtnState = mcButtonState.Normal;
}
else if (m_nextBtnState != mcButtonState.Inactive)
m_nextBtnState = mcButtonState.Hot;
if (oldNextMonthState != m_nextBtnState)
DrawButton(m_calendar.CreateGraphics(), m_nextBtnState, mcHeaderButtons.NextMonth, m_nextBtnRect);
}
if (m_yearSelector)
{
// If not within left scroll button, make sure its not pushed
if (!prevYearBtnRgn.IsVisible(mouseLocation))
{
if (m_prevYearBtnState != mcButtonState.Inactive) m_prevYearBtnState = mcButtonState.Normal;
}
else if (m_prevYearBtnState != mcButtonState.Inactive)
m_prevYearBtnState = mcButtonState.Hot;
if (oldPrevYearState != m_prevYearBtnState)
DrawButton(m_calendar.CreateGraphics(), m_prevYearBtnState, mcHeaderButtons.PreviousYear, m_prevYearBtnRect);
// If not within right scroll button, make sure its not pushed
if (!nextYearBtnRgn.IsVisible(mouseLocation))
{
if (m_nextYearBtnState != mcButtonState.Inactive) m_nextYearBtnState = mcButtonState.Normal;
}
else if (m_nextYearBtnState != mcButtonState.Inactive)
m_nextYearBtnState = mcButtonState.Hot;
if (oldNextYearState != m_nextYearBtnState)
DrawButton(m_calendar.CreateGraphics(), m_nextYearBtnState, mcHeaderButtons.NextYear, m_nextYearBtnRect);
}
if (m_region.IsVisible(mouseLocation))
m_calendar.ActiveRegion = mcCalendarRegion.Header;
prevBtnRgn.Dispose();
nextBtnRgn.Dispose();
prevYearBtnRgn.Dispose();
nextYearBtnRgn.Dispose();
}
示例13: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse(pictureBox1.ClientRectangle);
Region re = new System.Drawing.Region(gp);
pictureBox1.Region = re;
gp.Dispose();
re.Dispose();
cmbType.SelectedIndex = 0; //选中返修类型的第一项
// cmbStation.SelectedIndex = 0;
label3.Text = clsCommon.userName + " 您好!";//显示用户名
workID = clsCommon.userName;
if (clsCommon.userPermissions == "超级用户")//设置用户权限
{
员工管理ToolStripMenuItem.Visible = true;
}
else
{
员工管理ToolStripMenuItem.Visible = false;
}
DataReflsh();
}
示例14: DataGridPaintRowContents
public override void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow,
Rectangle clip, DataGrid grid)
{
Rectangle rect_cell = new Rectangle ();
int col_pixel;
Color backcolor, forecolor;
Brush backBrush, foreBrush;
Rectangle not_usedarea = Rectangle.Empty;
rect_cell.Y = row_rect.Y;
rect_cell.Height = row_rect.Height;
if (grid.IsSelected (row)) {
backcolor = grid.SelectionBackColor;
forecolor = grid.SelectionForeColor;
} else {
if (row % 2 == 0) {
backcolor = grid.BackColor;
} else {
backcolor = grid.AlternatingBackColor;
}
forecolor = grid.ForeColor;
}
backBrush = ResPool.GetSolidBrush (backcolor);
foreBrush = ResPool.GetSolidBrush (forecolor);
// PaintCells at row, column
int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
DataGridCell current_cell = grid.CurrentCell;
if (column_cnt > 0) {
Region prev_clip = g.Clip;
Region current_clip;
for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
continue;
col_pixel = grid.GetColumnStartingPixel (column);
rect_cell.X = row_rect.X + col_pixel - grid.HorizPixelOffset;
rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;
if (clip.IntersectsWith (rect_cell)) {
current_clip = new Region (rect_cell);
current_clip.Intersect (row_rect);
current_clip.Intersect (prev_clip);
g.Clip = current_clip;
Brush colBackBrush = backBrush;
Brush colForeBrush = foreBrush;
// If we are in the precise cell we are editing, then use the normal colors
// even if we are selected.
if (grid.is_editing && column == current_cell.ColumnNumber && row == current_cell.RowNumber) {
colBackBrush = ResPool.GetSolidBrush (grid.BackColor);
colForeBrush = ResPool.GetSolidBrush (grid.ForeColor);
}
if (is_newrow) {
grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell,
colBackBrush,
colForeBrush);
} else {
grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
colBackBrush,
colForeBrush,
grid.RightToLeft == RightToLeft.Yes);
}
current_clip.Dispose ();
}
}
g.Clip = prev_clip;
if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
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;
}
}
else {
not_usedarea = row_rect;
}
if (!not_usedarea.IsEmpty && clip.IntersectsWith (not_usedarea))
g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
not_usedarea);
}
示例15: Invalidate
private void Invalidate(int i1, int i2)
{
Rectangle rect;
if (i2 == -1)
{
i2 = i1;
}
rect = rectangles[i2];
Region r = new Region(rect);
if (i1 != -1)
{
try
{
rect = rectangles[i1];
r.Union(rect);
}
catch (IndexOutOfRangeException ex)
{
Console.WriteLine(ex.Message);
}
}
r.Translate(AutoScrollPosition.X, AutoScrollPosition.Y);
Invalidate(r);
r.Dispose();
}