C#中怎样设置绘图模式

ustcair 2003-02-21 04:16:03
象vc++6.0中那样设置绘图模式,比如下面的程序C#中怎样实现?

CClientDC ClientDC(this);
CRect rect;
GetClientRect(&rect)
ClientDC.SetMapMode(MM_ANISOTROPIC);
ClientDC.SetViewportOrg(40,rect.bottom/2);
ClientDC.SetViewportExt(rect.right,rect.bottom);
ClientDC.SetWindowOrg(0,0);
ClientDC.SetWindowExt(3000,-3000);
...全文
96 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bob 2003-02-23
  • 打赏
  • 举报
回复
// 画一个圆
using System;
using System.Drawing;
using System.Windows.Forms;

class PrintableForm: Form
{
public static void Main()
{
Application.Run(new PrintableForm());
}
public PrintableForm()
{
Text = "Printable Form";
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
ResizeRedraw = true;
}
protected override void OnPaint(PaintEventArgs pea)
{
DoPage(pea.Graphics, ForeColor,
ClientSize.Width, ClientSize.Height);
}
protected override void OnClick(EventArgs ea)
{
PrintDocument prndoc = new PrintDocument();

prndoc.DocumentName = Text;
prndoc.PrintPage +=
new PrintPageEventHandler(PrintDocumentOnPrintPage);
prndoc.Print();
}
void PrintDocumentOnPrintPage(object obj, PrintPageEventArgs ppea)
{
Graphics grfx = ppea.Graphics;
SizeF sizef = grfx.VisibleClipBounds.Size;

DoPage(grfx, Color.Black, (int)sizef.Width, (int)sizef.Height);
}
protected virtual void DoPage(Graphics grfx, Color clr, int cx, int cy)
{
Pen pen = new Pen(clr);

grfx.DrawLine(pen, 0, 0, cx - 1, cy - 1);
grfx.DrawLine(pen, cx - 1, 0, 0, cy - 1);
}
}
ustcair 2003-02-22
  • 打赏
  • 举报
回复
比如有类似点A的110个点的坐标,如何将它们连成一条曲线?
点A(1.46386302,0.0194725022) 。不知道怎样用C#实现绘图功能。
以前在vc中设置了映射模式,将逻辑坐标映射到物理坐标。
然后对每个点坐标值乘以1000放大。这样可以用VC绘出图形。
cxx1997 2003-02-21
  • 打赏
  • 举报
回复
具体你的要求,我不是太懂,你还是自己看看C#的帮助吧
cxx1997 2003-02-21
  • 打赏
  • 举报
回复
C#提供Graphics对象,它

封装 GDI+ 绘图面

备注
Graphics 类提供将对象绘制到显示设备的方法。Graphics 对象与特定的设备上下文关联。

下面代码写在一个控件的PAINT事件中,你就可以看到一条线

Pen p=new Pen(Color.Blue,5);
Point p1=new Point(2,2);
Point p2=new Point(20,20);


e.Graphics.DrawLine(p,p1,p2);

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧