实现在pictureBox控件中绘制了一系列的矢量图,然后实现部分的选择打印。
1. 记录下选择区域的开始点和结束点的坐标;
Point startPoint = Point.empty;
Point EndPoint = Point.empyt;
int zoom = 2;//图片的放大系数
int xtrans = 0;//图片的x轴偏移
int ytrans = 0;//图片的y轴偏移
2.在Printdocument _PrintPages()中绘制选择区域的图
private PrintDocument_PrintPages( object sender, PrintPageEventArgs e )
{
PrintF p = new PointF( startPoint.x , startPoint.Y );
p.x = ( startPoint.x / zoom ) - xtrans;
p.y = ( startPoint.y / zoom ) - ytrans;
Draw( p , e.Graphics );
}
private void Draw( PointF org , Graphics g )
{
Matrix orgM = g.Transform.Clone();
Matrix c = orgM.Clone();
Matrix X = new Matrix();
X.Scale( e.VisibleClipBounds.Width / Math.abs(endPoint.x - startPoint.x ) * zoom , e.VisibleClipBounds.Height / Math.abs( endPoint.y - startPoint.y ) * zoom );
Matrix y = new Matrix();
y.Translate( -org.x , -org.y , MatrixOrder.Append);
c.Multiply( x );
c.Multiply( y );
g.Transform = c;
//
绘制代理......
//
}
1. 记录下选择区域的开始点和结束点的坐标;
Point startPoint = Point.empty;
Point EndPoint = Point.empyt;
int zoom = 2;//图片的放大系数
int xtrans = 0;//图片的x轴偏移
int ytrans = 0;//图片的y轴偏移
2.在Printdocument _PrintPages()中绘制选择区域的图
private PrintDocument_PrintPages( object sender, PrintPageEventArgs e )
{
PrintF p = new PointF( startPoint.x , startPoint.Y );
p.x = ( startPoint.x / zoom ) - xtrans;
p.y = ( startPoint.y / zoom ) - ytrans;
Draw( p , e.Graphics );
}
private void Draw( PointF org , Graphics g )
{
Matrix orgM = g.Transform.Clone();
Matrix c = orgM.Clone();
Matrix X = new Matrix();
X.Scale( e.VisibleClipBounds.Width / Math.abs(endPoint.x - startPoint.x ) * zoom , e.VisibleClipBounds.Height / Math.abs( endPoint.y - startPoint.y ) * zoom );
Matrix y = new Matrix();
y.Translate( -org.x , -org.y , MatrixOrder.Append);
c.Multiply( x );
c.Multiply( y );
g.Transform = c;
//
绘制代理......
//
}