/// <summary> /// Draw the gridlines. /// </summary> /// <param name="graphics">Reference to the GDI+ drawing surface.</param> public void Draw(System.Drawing.Graphics graphics) { using (Pen graphAreaPen = new Pen(m_ParentGraph.GridlineColor)) { graphAreaPen.DashStyle = DashStyle.Dash; using (Brush graphAreaBrush = new SolidBrush(m_ParentGraph.GraphAreaColor)) { graphics.FillRectangle(graphAreaBrush, m_ParentGraph.GraphArea); graphics.DrawRectangle(graphAreaPen, m_ParentGraph.GraphArea); if ((m_ParentGraph.Gridlines & GridStyles.Horizontal) == GridStyles.Horizontal) { graphics.SetClip(m_ParentGraph.GraphArea); int gridSize = m_ParentGraph.GraphArea.Height / m_ParentGraph.GraduationsY; for (int i = 0; i < m_ParentGraph.GraphArea.Height; i += gridSize) { graphics.DrawLine(graphAreaPen, m_ParentGraph.GraphArea.Left, m_ParentGraph.GraphArea.Top + i, m_ParentGraph.GraphArea.Right, m_ParentGraph.GraphArea.Top + i); } } if ((m_ParentGraph.Gridlines & GridStyles.Vertical) == GridStyles.Vertical) { graphics.SetClip(m_ParentGraph.GraphArea); int gridSize = m_ParentGraph.GraphArea.Width / m_ParentGraph.GraduationsX; for (int i = 0; i < m_ParentGraph.GraphArea.Width; i += gridSize) { graphics.DrawLine(graphAreaPen, m_ParentGraph.GraphArea.Left + i, m_ParentGraph.GraphArea.Bottom, m_ParentGraph.GraphArea.Left + i, m_ParentGraph.GraphArea.Top); } } } } }
public override void DrawArrowForces(System.Drawing.Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods) { if (m_visibleThickPath != null) { GraphicsState o = gc.Save(); gc.SetClip(m_visibleThickPath); if ((m_traceLines != null) && (m_traceLines.Length > 0) && (m_traceLines[0].Count > 1)) { for (int k = 0; k < m_traceLines.Length; k++) { gc.DrawLines(r.RegionGuides, m_traceLines[k].ToArray()); } } gc.Restore(o); } }
protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); if (this.Icon != null) { System.Drawing.Drawing2D.GraphicsContainer container = graphics.BeginContainer(); graphics.SetClip(cellBounds); // Point p = new Point(); p = cellBounds.Location; p.Offset(iconLeftPad, iconTopPad); graphics.DrawImageUnscaled(this.Icon, p); graphics.EndContainer(container); } }
/// <include file='doc\GridEntry.uex' path='docs/doc[@for="GridEntry.PaintLabel"]/*' /> /// <devdoc> /// Paints the label portion of this GridEntry into the given Graphics object. This /// is called by the GridEntry host (the PropertyGridView) when this GridEntry is /// to be painted. /// </devdoc> public virtual void PaintLabel(System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { PropertyGridView gridHost = this.GridEntryHost; Debug.Assert(gridHost != null, "No propEntryHost"); string strLabel = this.PropertyLabel; int borderWidth = gridHost.GetOutlineIconSize()+OUTLINE_ICON_PADDING; // fill the background if necessary Brush bkBrush = selected ? gridHost.GetSelectedItemWithFocusBackBrush(g) : this.GetBackgroundBrush(g); // if we don't have focus, paint with the line color if (selected && !hasFocus) { bkBrush = gridHost.GetLineBrush(g); } bool fBold = ((this.Flags & GridEntry.FLAG_LABEL_BOLD) != 0); Font font = GetFont(fBold); int labelWidth = GetLabelTextWidth(strLabel, g, font); int neededWidth = paintFullLabel ? labelWidth : 0; int stringX = rect.X + this.PropertyLabelIndent; Brush blank = bkBrush; if (paintFullLabel && (neededWidth >= (rect.Width-(stringX+2)))) { int totalWidth = stringX + neededWidth + PropertyGridView.GDIPLUS_SPACE; // 5 = extra needed to ensure text draws completely and isn't clipped. #if PBRS_PAINT_DEBUG blank = Brushes.Green; #endif // blank out the space we're going to use g.FillRectangle(blank, borderWidth-1, rect.Y, totalWidth-borderWidth+3, rect.Height); // draw an end line Pen linePen = new Pen(gridHost.GetLineColor()); g.DrawLine(linePen, totalWidth, rect.Y, totalWidth, rect.Height); linePen.Dispose(); // set the new width that we can draw into rect.Width = totalWidth - rect.X; } else { // Normal case -- no pseudo-tooltip for the label #if PBRS_PAINT_DEBUG blank = Brushes.Red; #endif // Debug.WriteLine(rect.X.ToString() +" "+ rect.Y.ToString() +" "+ rect.Width.ToString() +" "+ rect.Height.ToString()); g.FillRectangle(blank, rect.X, rect.Y, rect.Width, rect.Height); } // draw the border stripe on the left Brush stripeBrush = gridHost.GetLineBrush(g); g.FillRectangle(stripeBrush, rect.X, rect.Y, borderWidth, rect.Height); if (selected && hasFocus) { g.FillRectangle(gridHost.GetSelectedItemWithFocusBackBrush(g), stringX, rect.Y, rect.Width - stringX - 1, rect.Height); } int maxSpace = Math.Min(rect.Width-stringX-1, labelWidth + PropertyGridView.GDIPLUS_SPACE); Rectangle textRect = new Rectangle(stringX, rect.Y + 1, maxSpace, rect.Height - 1); if (!Rectangle.Intersect(textRect, clipRect).IsEmpty) { Region oldClip = g.Clip; g.SetClip(textRect); // Do actual drawing // A brush is needed if using GDI+ only (UseCompatibleTextRendering); if using GDI, only the color is needed. Color textColor = (selected && hasFocus) ? gridHost.GetSelectedItemWithFocusForeColor() : g.GetNearestColor(this.LabelTextColor); if( this.ownerGrid.UseCompatibleTextRendering ) { using( Brush textBrush = new SolidBrush(textColor)){ StringFormat stringFormat = new StringFormat(StringFormatFlags.NoWrap); stringFormat.Trimming = StringTrimming.None; g.DrawString(strLabel, font, textBrush, textRect, stringFormat); } } else{ TextRenderer.DrawText( g, strLabel, font, textRect, textColor, PropertyGrid.MeasureTextHelper.GetTextRendererFlags() ); } #if PBRS_PAINT_DEBUG textRect.Width --; textRect.Height--; g.DrawRectangle(new Pen(Color.Blue), textRect); #endif g.SetClip(oldClip, CombineMode.Replace); oldClip.Dispose(); // clip is actually copied out. if (maxSpace <= labelWidth) { this.labelTipPoint = new Point(stringX+2, rect.Y+1); } else { this.labelTipPoint = InvalidPoint; } } rect.Y -= 1; rect.Height += 2; PaintOutline(g, rect); }
/// <summary> /// Paints the entity using the given graphics object /// </summary> /// <param name="g"></param> public override void Paint(System.Drawing.Graphics g) { if (!Visible) return; //g.DrawRectangle(Pens.OrangeRed, Rectangle); GraphicsContainer cto = g.BeginContainer(); g.SetClip(Shape.Rectangle); plusminus.Paint(g); header.Paint(g); if (!mCollapsed && mShowLines) { g.DrawLine( ArtPalette.FolderLinesPen, Rectangle.X + 7, plusminus.Rectangle.Bottom, Rectangle.X + 7, plusminus.Rectangle.Bottom + mEntries.Count * (ItemHeight + ItemSpacing)); } int k = 1; foreach (IShapeMaterial material in mEntries) { material.Paint(g); if (!mCollapsed && mShowLines) { g.DrawLine( ArtPalette.FolderLinesPen, Rectangle.X + 7, plusminus.Rectangle.Bottom + k * (ItemHeight + ItemSpacing), Rectangle.X + 16, plusminus.Rectangle.Bottom + k * (ItemHeight + ItemSpacing)); k++; } } g.EndContainer(cto); }
protected override void OnPaint(System.Drawing.Graphics g) { var actualText = this.checked_ ? this.CheckedText : this.Text; var strSize = g.MeasureString(actualText, this.Font); var contentBox = new RectangleF(0, 0, this.Size.Width, this.Size.Height); var patch = this.pressed ? this.checked_ ? backgroundCheckedPressed9P : backgroundPressed9P : this.over ? this.checked_ ? backgroundCheckedOver9P : backgroundOver9P : this.checked_ ? backgroundCheckedNormal9P : backgroundNormal9P; if (patch != null) { patch = anim != null && anim.IsRunning() ? anim.GetCurrentFrame() : patch; lastDrawnPatch = patch; contentBox = patch.GetContentBox(this.Size); patch.Paint(g, this.Size); } else drawDefaultToggleButton(g); g.SetClip(contentBox, System.Drawing.Drawing2D.CombineMode.Intersect); g.DrawString(actualText, this.Font, new SolidBrush(this.ForeColor), contentBox.Width / 2 - strSize.Width / 2 + contentBox.Left, contentBox.Height / 2 - strSize.Height / 2 + contentBox.Top); }
private void PaintTile(int x, int y, System.Drawing.Graphics g) { System.Drawing.Rectangle dest = new System.Drawing.Rectangle(); dest.Size = size; dest.X = x * size.Width - this.ScrollOffsetX; dest.Y = y * size.Height - this.ScrollOffsetY; g.SetClip(dest); g.Clear(System.Drawing.Color.SteelBlue); if (this.justLayer == -1) { int id = 0; foreach (var item in this.layers) { if (this.layersVisible[id]) PaintTileInternal(item, dest, x, y, g); id += 1; } } else { int id = 0; foreach (var item in this.layers) { if (this.layersVisible[id] && id != this.justLayer) PaintTileInternal(item, dest, x, y, g); id += 1; } g.FillRectangle(shadowBrush, dest); if (this.layersVisible[this.justLayer]) PaintTileInternal(this.layers[this.justLayer], dest, x, y, g); } }
void DrawTabStrip_Document(System.Drawing.Graphics g) { var count = Tabs.Count; if (count == 0) return; var rectTabStrip = TabStripRectangle; // Draw the tabs var rectTabOnly = TabsRectangle; Rectangle rectTab; TabVS2005 tabActive = null; g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly)); for (var i = 0; i < count; i++) { rectTab = GetTabRectangle(i); if (Tabs[i].Content == DockPane.ActiveContent) { tabActive = Tabs[i] as TabVS2005; continue; } if (rectTab.IntersectsWith(rectTabOnly)) DrawTab(g, Tabs[i] as TabVS2005, rectTab); } g.SetClip(rectTabStrip); if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom) g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Top + 1, rectTabStrip.Right, rectTabStrip.Top + 1); else g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Bottom - 1, rectTabStrip.Right, rectTabStrip.Bottom - 1); g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly)); if (tabActive != null) { rectTab = GetTabRectangle(Tabs.IndexOf(tabActive)); if (rectTab.IntersectsWith(rectTabOnly)) DrawTab(g, tabActive, rectTab); } }
private void Render(System.Drawing.Graphics g) { if (!Visible) return; using (var b = new SolidBrush(BackColor)) { g.FillRectangle(b, ClientRectangle); } var display = new Rectangle(DisplayRectangle.Location, DisplayRectangle.Size); if (TabPages.Count == 0) display.Y += 21; var border = SystemInformation.Border3DSize.Width; display.Inflate(border, border); g.DrawLine(SystemPens.ControlDark, display.X, display.Y, display.X + display.Width, display.Y); var clip = g.Clip; g.SetClip(new Rectangle(display.Left, ClientRectangle.Top, display.Width, ClientRectangle.Height)); for (var i = 0; i < TabPages.Count; i++) { RenderTab(g, i); } g.Clip = clip; }