本文整理汇总了C#中IGraphics.FillRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.FillRectangle方法的具体用法?C# IGraphics.FillRectangle怎么用?C# IGraphics.FillRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphics
的用法示例。
在下文中一共展示了IGraphics.FillRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintImp
/// <summary>
/// Paints the fragment
/// </summary>
/// <param name="g">the device to draw to</param>
protected override void PaintImp(IGraphics g)
{
var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty;
var rect = new RectangleF(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height);
if (rect.Height > 2 && RenderUtils.IsColorVisible(ActualBackgroundColor))
{
g.FillRectangle(RenderUtils.GetSolidBrush(ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height);
}
var b1 = RenderUtils.GetSolidBrush(ActualBorderTopColor);
BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect);
if (rect.Height > 1)
{
var b2 = RenderUtils.GetSolidBrush(ActualBorderLeftColor);
BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect);
var b3 = RenderUtils.GetSolidBrush(ActualBorderRightColor);
BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect);
var b4 = RenderUtils.GetSolidBrush(ActualBorderBottomColor);
BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect);
}
}
示例2: OnRender
protected override void OnRender(IGraphics g, Map map)
{
Brush brush = new SolidBrush(OpacityColor(Color.Red));
RectangleF rect = g.Clip;
g.FillRectangle(brush,
(int) rect.X, (int) rect.Y,
(int) rect.Width, (int) rect.Height);
}
示例3: DrawBulletTarget
/// <summary>
/// Method to draw half-transparent bullet-line & targeting-box (the size of a robot) on the battlefield.
/// The idea is to use this for visual debugging: Set start point to own robot's position, and end point
/// to where you mean the bullet to go. Then see if this really is where the bullet is heading:
/// 1) If the targeting-box is off the spot you wanted it, you got a bug in your target prediction code.
/// 2) If the targeting-box is on the spot, but the bullet is off the line (and center of the box), you
/// got a bug in your "gun turning and firing" code.
/// </summary>
public static void DrawBulletTarget(IGraphics graphics, Color drawColor, Point2D start, Point2D end)
{
// Set color to a semi-transparent one.
Color halfTransparent = Color.FromArgb(128, drawColor);
// Draw line and rectangle.
graphics.DrawLine(new Pen(halfTransparent), (int)start.X, (int)start.Y, (int)end.X, (int)end.Y);
graphics.FillRectangle(new SolidBrush(halfTransparent), (int)end.X - 18, (int)end.Y - 18, 36, 36);
}
示例4: OnPaintBackground
protected internal override void OnPaintBackground(IGraphics g, int width, int height)
{
Brush b = new SolidBrush(Color.FromArgb(236, 233, 216));
g.FillRectangle(b, 0, 0, width, height);
Pen p = new Pen(Color.FromArgb(172, 168, 153));
g.DrawLine(p, 0, height - 1, width, height - 1);
g.DrawLine(p, width - 1, 0, width - 1, height);
}
示例5: DoPaintBackground
public static void DoPaintBackground(IGraphics g, Control control)
{
if (g is CGraphics && (!control.BackColor.IsEmpty && control.BackColor != Color.Transparent)){
g.FillRectangle(new Brush2(GraphUtils.ToColor2(control.BackColor)), control.Location.X, control.Location.Y, control.Width,
control.Height);
}
(control as BasicControl)?.view.Print(g, control.Width, control.Height);
if (control is Panel && ((Panel) control).BorderStyle == BorderStyle.FixedSingle){
g.DrawRectangle(new Pen2(GraphUtils.ToColor2(control.ForeColor)), control.Location.X, control.Location.Y, control.Width, control.Height);
}
}
示例6: OnPaintBackground
protected internal override sealed void OnPaintBackground(IGraphics g, int width, int height)
{
if (main == null){
return;
}
if (main.BackColor.IsEmpty || main.BackColor == Color.Transparent){
return;
}
Brush b = new SolidBrush(main.BackColor);
g.FillRectangle(b, 0, 0, width, height);
}
示例7: DrawMillimeterGridInPixels
public static void DrawMillimeterGridInPixels(IGraphics g, Rectangle rectPx)
{
Dpi dpi = new Dpi(g.DpiX, g.DpiY);
if (_millimeterGridBitmap == null)
CreateMillimiterGridBrush(dpi);
g.CompositingMode = CompositingMode.SourceCopy;
_millimeterGridBrush.ResetTransform();
_millimeterGridBrush.TranslateTransform(rectPx.Left, rectPx.Top);
g.FillRectangle(_millimeterGridBrush, rectPx);
g.CompositingMode = CompositingMode.SourceOver;
}
示例8: DoPaint
private static void DoPaint(IGraphics g, Label label)
{
Rectangle2 rect = new Rectangle2(GraphUtils.ToPointF2(label.Location) , GraphUtils.ToSizeF2(label.Size) );
g.FillRectangle(new Brush2(GraphUtils.ToColor2(label.BackColor)), rect.X, rect.Y, label.Width - label.Margin.Left - label.Margin.Right,
label.Height - label.Margin.Top - label.Margin.Bottom);
StringFormat2 format = new StringFormat2{Alignment = StringAlignment2.Near, LineAlignment = StringAlignment2.Near};
g.DrawString(label.Text, GraphUtils.ToFont2(label.Font), new Brush2(GraphUtils.ToColor2(label.ForeColor)), rect, format);
}
示例9: Draw
void Draw(IGraphics g)
{
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
g.SmoothingMode = SmoothingMode.HighQuality;
//g.SetClip(new Rectangle(50, 50, 200, 400));
if (gridBrush == null)
{
gridBrush = new TextureBrush(Images.Grid_37px);
}
//gridBrush.ResetTransform();
//gridBrush.TranslateTransform(100, 100);
g.CompositingMode = CompositingMode.SourceCopy;
gridBrush.ResetTransform();
g.FillRectangle(gridBrush, glView1.ClientRectangle);
g.CompositingMode = CompositingMode.SourceOver;
g.HintTextBackgroundAction(HintBackground);
//g.PageUnit = GraphicsUnit.Millimeter;
//g.SmoothingMode = SmoothingMode.AntiAlias;
string text = "12.5% 2/5 (1) + ms test...";
g.DrawString(g.DpiX.ToString(), font1, Brushes.Black, new PointF(2, 2));
StringFormat sf = new StringFormat();
Rectangle rect = new Rectangle(100, 50, 400, 150);
g.DrawRectangle(Pens.Black, rect);
g.DrawString(text, font2, Brushes.Red, rect, sf);
sf.Alignment = StringAlignment.Center;
g.FillRectangle(Brushes.Black, new Rectangle(230, 50, 140, 40));
g.DrawString(text, font1, Brushes.Yellow, rect, sf);
sf.Alignment = StringAlignment.Far;
g.DrawString(text, font2, Brushes.Green, rect, sf);
sf.Alignment = StringAlignment.Near;
sf.LineAlignment = StringAlignment.Center;
g.DrawString(text, font1, Brushes.Blue, rect, sf);
sf = new StringFormat();
sf.Alignment = StringAlignment.Far;
sf.LineAlignment = StringAlignment.Far;
g.DrawString("Far, Far, PointF", font2, Brushes.Green, new PointF(100.0f, 150.0f), sf);
sf = new StringFormat();
sf.LineAlignment = StringAlignment.Far;
g.DrawString(text, font1, Brushes.DarkCyan, rect, sf);
List<PointF> points = new List<PointF>();
for (float x = 0.0f; x < (float)Math.PI * 6.0f; x += 0.01f)
{
points.Add(new PointF(x * (float)Math.Cos(x), x * (float)Math.Sin(x)));
}
Matrix m = new Matrix();
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 5; x++)
{
m.Reset();
m.Translate(x * 50.0f + 200.0f, y * 50.0f + 300.0f);
g.Transform = m;
g.DrawLines(new Pen(Color.Blue, 0.0f), points.ToArray());
}
}
g.ResetTransform();
g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(50, 150, 24, 24));
g.DrawImage(Images.NavigateDown_48px, new Rectangle(50, 150, 24, 24));
if (transparentBitmap == null)
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = 0.4f; //opacity 0 = completely transparent, 1 = completely opaque
transparentBitmap = GraphicsHelpers.BitmapFromImageAndColorMatrix(Images.NavigateDown_48px, matrix);
}
g.DrawRectangle(new Pen(Color.Red, 0), new Rectangle(100, 150, 24, 24));
g.DrawImage(transparentBitmap, new Rectangle(100, 150, 24, 24));
using (HatchBrush hatchBrush = new HatchBrush(HatchStyle.LightUpwardDiagonal, Color.Black, Color.Transparent))
{
g.FillRectangle(hatchBrush, new Rectangle(10, 10, 100, 20));
}
//.........这里部分代码省略.........
示例10: OnPaintRowHeaderView
protected internal virtual void OnPaintRowHeaderView(IGraphics g, int y, int height)
{
g.FillRectangle(Brushes.White, 0, 0, RowHeaderWidth, VisibleHeight);
}
示例11: OnPaintMainView
protected internal virtual void OnPaintMainView(IGraphics g, int x, int y, int width, int height)
{
g.FillRectangle(Brushes.White, 0, 0, VisibleWidth, VisibleHeight);
}
示例12: RenderTextBox
protected void RenderTextBox(IGraphics g, float x, float y, float textHeight, string teamName, string score)
{
var size = this.MeasureTextBox(g, textHeight, teamName, score);
g.FillRectangle(
UserboxBrush,
new RectangleF(
new PointF(x, y),
new SizeF(size.Width, size.Height)));
if (!string.IsNullOrEmpty(teamName))
{
float minWidth = TextXOffset * 2;
if (!string.IsNullOrEmpty(score))
{
minWidth += g.MeasureString(score, UserboxFont).Width + TextXOffset;
}
int nameLength = teamName.Length;
string shortName = teamName;
if (!string.IsNullOrEmpty(teamName))
{
while (nameLength > 1 && g.MeasureString(shortName, UserboxFont).Width + minWidth > MinBracketWidth)
{
nameLength--;
shortName = teamName.Substring(0, nameLength) + "...";
}
minWidth += g.MeasureString(shortName, UserboxFont).Width;
}
g.DrawString(
shortName,
UserboxFont,
UserboxFontBrush,
new PointF(
x + TextXOffset,
y + TextYOffset));
}
if (!string.IsNullOrEmpty(score))
{
var scoreWidth = g.MeasureString(score, UserboxFont).Width;
g.DrawString(
score,
UserboxFont,
UserboxFontBrush,
new PointF(
x + size.Width - scoreWidth - TextXOffset,
y + TextYOffset));
}
}
示例13: DrawZoomBox
private void DrawZoomBox(IGraphics g, WorldTransform transform, Coordinates start, Coordinates end)
{
float x, y;
float width, height;
if (start.X < end.X) {
x = (float)start.X;
width = (float)(end.X - start.X);
}
else {
x = (float)end.X;
width = (float)(start.X - end.X);
}
if (start.Y < end.Y) {
y = (float)start.Y;
height = (float)(end.Y - start.Y);
}
else {
y = (float)end.Y;
height = (float)(start.Y - end.Y);
}
// create the rectangle
RectangleF rect = new RectangleF(x, y, width, height);
// draw the transparent background
g.FillRectangle(Color.FromArgb(50, Color.Purple), rect);
IPen pen = g.CreatePen();
pen.Width = 1.0f/transform.Scale;
pen.Color = Color.Purple;
g.DrawRectangle(pen, rect);
pen.Dispose();
}
示例14: PaintOnGraphicsVector
protected void PaintOnGraphicsVector(IGraphics g, int width, int height)
{
if (scatterPlot == null) {
return;
}
if (!area.IsEmpty){
g.FillRectangle(Brushes.LightGray, 0, 0, width, height);
g.FillRectangle(Brushes.White, area.X, area.Y, area.Width, area.Height);
} else{
g.FillRectangle(new SolidBrush(BackColor), 0, 0, width, height);
}
PaintGridVector(g, width, height);
SymbolProperties[] gg = ArrayUtils.GetKeys(values);
int[] counts = new int[gg.Length];
for (int i = 0; i < counts.Length; i++){
counts[i] = values[gg[i]].Count;
}
int[] o = ArrayUtils.Order(counts);
Array.Reverse(o);
gg = ArrayUtils.SubArray(gg, o);
foreach (SymbolProperties g1 in gg){
bool[,] vals = values[g1].Data;
double[,] zvals = null;
if (zValues != null){
zvals = zValues[g1];
}
for (int i = 0; i < width; i++){
for (int j = 0; j < height; j++){
if (vals[i, j]){
Color color;
if (zvals != null && !double.IsNaN(zvals[i, j]) && colorScale != null){
color = colorScale.GetColor(zvals[i, j]);
} else{
color = g1.Color;
}
Pen p = new Pen(color);
Brush b = new SolidBrush(color);
SymbolType symbolType = SymbolType.allSymbols[g1.Type];
int symbolSize = g1.Size;
if (symbolSize == 0){
continue;
}
int[] pathX;
int[] pathY;
symbolType.GetPath(symbolSize, out pathX, out pathY);
symbolType.Draw(symbolSize, i, j, g, p, b);
}
}
}
}
// selected data points
Brush selectionBrush = new SolidBrush(SelectionColor);
Pen selectionPen = new Pen(SelectionColor);
foreach (int s in scatterPlot.Selection){
double[] w = scatterPlot.GetDataAt(s);
if (w.Length > 0){
double x = w[0];
double y = w[1];
SymbolProperties gx = GetPointProperties != null ? GetPointProperties(s) : defaultSymbol;
SymbolType symbolType = SymbolType.allSymbols[gx.Type];
int symbolSize = gx.Size;
if (symbolSize > 0){
symbolType.Draw(symbolSize, ModelToViewX(x, width), ModelToViewY(y, height), g, selectionPen, selectionBrush);
}
}
}
// labels
ScatterPlotLabelMode labelMode = scatterPlot.GetLabelMode();
bool cutLabels = scatterPlot.CutLabels;
if (labelMode == ScatterPlotLabelMode.All && scatterPlot.HasLabels) {
Font font = new Font("Arial", scatterPlot.FontSize, scatterPlot.FontStyle);
for (;;){
double[] x;
double[] y;
double[] z;
string[] labels;
int index;
scatterPlot.GetData(out x, out y, out z, out labels, out index);
if (x == null){
break;
}
SymbolProperties gx = GetPointProperties != null ? GetPointProperties(index) : defaultSymbol;
for (int i = 0; i < x.Length; i++){
if (labelMode == ScatterPlotLabelMode.All || scatterPlot.IsSelected(i)) {
int ix = ModelToViewX(x[i], width);
int iy = ModelToViewY(y[i], height);
Color c;
if (z != null && colorScale != null){
c = colorScale.GetColor(z[i]);
} else{
c = gx.Color;
}
Brush b = new SolidBrush(c);
if (ix >= 0 && iy >= 0 && ix < width && iy < height){
if (labels[i] != null){
string s = labels[i];
if (cutLabels){
if (s.Contains(";")){
s = s.Substring(0, s.IndexOf(';'));
}
//.........这里部分代码省略.........
示例15: PaintIndicator
private void PaintIndicator(IGraphics g, int width, int height)
{
Brush2 indicatorBrush = new Brush2(IndicatorColor);
Pen2 indicatorPen = new Pen2(ForeColor);
float len = GetDeltaIndicator(GetLength(width, height));
if (IsHorizontal()){
if (len >= 1){
g.FillRectangle(indicatorBrush, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
g.DrawRectangle(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
} else{
g.DrawLine(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, GetMinIndicator(GetLength(width, height)),
height - 1);
}
} else{
if (len >= 1){
g.FillRectangle(indicatorBrush, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
g.DrawRectangle(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
} else{
g.DrawLine(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1,
GetMinIndicator(GetLength(width, height)));
}
}
}