本文整理汇总了C#中System.Drawing.Pen.GetBrush方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.GetBrush方法的具体用法?C# Pen.GetBrush怎么用?C# Pen.GetBrush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.GetBrush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// Draw on to the supplied graphics surface against the supplied axes.
/// </summary>
/// <param name="g">The graphics surface on which to draw.</param>
/// <param name="xAxis">The X-Axis to draw against.</param>
/// <param name="yAxis">The Y-Axis to draw against.</param>
/// <remarks>TODO: block positions may be off by a pixel or so. maybe. Re-think calculations</remarks>
public void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
{
if ( data_==null || data_.GetLength(0) == 0 || data_.GetLength(1) == 0 )
{
return;
}
double worldWidth = xAxis.Axis.WorldMax - xAxis.Axis.WorldMin;
double numBlocksHorizontal = worldWidth / this.xStep_;
double worldHeight = yAxis.Axis.WorldMax - yAxis.Axis.WorldMin;
double numBlocksVertical = worldHeight / this.yStep_;
double physicalWidth = xAxis.PhysicalMax.X - xAxis.PhysicalMin.X;
double blockWidth = physicalWidth / numBlocksHorizontal;
bool wPositive = true;
if (blockWidth < 0.0)
{
wPositive = false;
}
blockWidth = Math.Abs(blockWidth)+1;
double physicalHeight = yAxis.PhysicalMax.Y - yAxis.PhysicalMin.Y;
double blockHeight = physicalHeight / numBlocksVertical;
bool hPositive = true;
if (blockHeight < 0.0)
{
hPositive = false;
}
blockHeight = Math.Abs(blockHeight)+1;
for (int i=0; i<data_.GetLength(0); ++i)
{
for (int j=0; j<data_.GetLength(1); ++j)
{
double wX = (double)j*this.xStep_ + xStart_;
double wY = (double)i*this.yStep_ + yStart_;
if ( !hPositive )
{
wY += yStep_;
}
if (!wPositive )
{
wX += xStep_;
}
if (this.center_)
{
wX -= this.xStep_/2.0;
wY -= this.yStep_/2.0;
}
Pen p = new Pen( this.Gradient.GetColor( (data_[i,j]-this.dataMin_)/(this.dataMax_-this.dataMin_) ) );
int x = (int)xAxis.WorldToPhysical(wX,false).X;
int y = (int)yAxis.WorldToPhysical(wY,false).Y;
g.FillRectangle(p.GetBrush(),
x,
y,
(int)blockWidth,
(int)blockHeight);
//g.DrawRectangle(Pens.White,x,y,(int)blockWidth,(int)blockHeight);
}
}
}