本文整理汇总了C#中Graphics.SetClip方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.SetClip方法的具体用法?C# Graphics.SetClip怎么用?C# Graphics.SetClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graphics
的用法示例。
在下文中一共展示了Graphics.SetClip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the specified HTML source on the specified area clipping if specified
/// </summary>
/// <param name="g">Device to draw</param>
/// <param name="html">HTML source</param>
/// <param name="area">Area where HTML should be drawn</param>
/// <param name="clip">If true, it will only paint on the specified area</param>
public static void Render(Graphics g, string html, RectangleF area, bool clip)
{
InitialContainer container = new InitialContainer(html);
Region prevClip = g.Clip;
if (clip) g.SetClip(area);
container.SetBounds(area);
container.MeasureBounds(g);
container.Paint(g);
if (clip) g.SetClip(prevClip, System.Drawing.Drawing2D.CombineMode.Replace);
}
示例2: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
G = e.Graphics;
G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
G.Clear(BackColor);
G.SmoothingMode = SmoothingMode.AntiAlias;
GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7);
GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7);
GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
G.SetClip(GP1);
G.FillRectangle(GB1, ClientRectangle);
G.ResetClip();
G.DrawPath(P1, GP1);
G.DrawPath(P4, GP2);
SZ1 = G.MeasureString(Text, Font);
PT1 = new PointF(5, Height / 2 - SZ1.Height / 2);
G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1);
G.DrawString(Text, Font, Brushes.White, PT1);
G.DrawLine(P3, Width - 15, 10, Width - 11, 13);
G.DrawLine(P3, Width - 7, 10, Width - 11, 13);
G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14);
G.DrawLine(P2, Width - 16, 9, Width - 12, 12);
G.DrawLine(P2, Width - 8, 9, Width - 12, 12);
G.DrawLine(Pens.White, Width - 12, 12, Width - 12, 13);
G.DrawLine(P1, Width - 22, 0, Width - 22, Height);
G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2);
G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2);
}
示例3: DrawTabStrip_Document
private void DrawTabStrip_Document(Graphics g)
{
int count = Tabs.Count;
if (count == 0)
{
return;
}
g.DrawLine(OutlineOuterPen, ClientRectangle.Left, ClientRectangle.Bottom - 1, ClientRectangle.Right, ClientRectangle.Bottom - 1);
// Draw the tabs
Rectangle rectTabs = TabsRectangle;
Rectangle rectTab = Rectangle.Empty;
g.SetClip(rectTabs, CombineMode.Replace);
int j = 0;
for (int i = 0; i <= count - 1; i++)
{
rectTab = GetTabRectangle(i);
if (rectTab.IntersectsWith(rectTabs))
{
DrawTab(g, Tabs[i].Content, rectTab, j);
j++;
}
}
}
示例4: DrawComboBox
/// <summary>
/// Draws a combo box in the Windows Vista (and newer) style.
/// </summary>
/// <param name="graphics"></param>
/// <param name="bounds"></param>
/// <param name="state"></param>
internal static void DrawComboBox(Graphics graphics, Rectangle bounds, ComboBoxState state) {
Rectangle comboBounds = bounds;
comboBounds.Inflate(1, 1);
ButtonRenderer.DrawButton(graphics, comboBounds, GetPushButtonState(state));
Rectangle buttonBounds = new Rectangle(
bounds.Left + (bounds.Width - 17),
bounds.Top,
17,
bounds.Height - (state != ComboBoxState.Pressed ? 1 : 0)
);
Rectangle buttonClip = buttonBounds;
buttonClip.Inflate(-2, -2);
using (Region oldClip = graphics.Clip.Clone()) {
graphics.SetClip(buttonClip, System.Drawing.Drawing2D.CombineMode.Intersect);
ComboBoxRenderer.DrawDropDownButton(graphics, buttonBounds, state);
graphics.SetClip(oldClip, System.Drawing.Drawing2D.CombineMode.Replace);
}
}
示例5: SetClip
private void SetClip(Graphics g)
{
Rectangle r = this.ClientRectangle;
r.X++; r.Y++; r.Width -= 3; r.Height -= 3;
using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
{
g.SetClip(rr);
}
}