资源简介
by conmajia
这是一个简单的GDI+的例子。讲的是怎么从无到有绘制一个极坐标系,以及在此基础上绘制数据图。按照类似的思路,你可以画出直角坐标系、对数直角系、外太空银河系……
没有版权,但仍希望使用者能够反馈
conmajia@gmail.com

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace GetPhysical
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public class PolarValue
{
float ang = 0;
float val = 0;
// 角度
public float Angle
{
get { return ang; }
set { ang = value; }
}
// 数值
public float Value
{
get { return val; }
set { val = value; }
}
public PolarValue(float angle float value)
{
this.ang = angle;
this.val = value;
}
}
// 数据列表
public List values = new List();
float min = 0;
float max = 100;
// 合并后的映射方法
private PointF getMappedPoint(float angle float value)
{
// 计算映射在坐标图中的半径
float r = radius * (value - min) / (max - min);
// 计算GDI+坐标
PointF pt = new PointF();
pt.X = (float)(r * Math.Cos(angle * Math.PI / 180) + center.X);
pt.Y = (float)(r * Math.Sin(angle * Math.PI / 180) + center.Y);
return pt;
}
private void Form1_Paint(object sender PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
//drawDiagramCircles(e.Graphics this.ClientRectangle);
// 缩小点画圆的区域
Rectangle rect = this.ClientRectangle;
rect.Inflate(0 -20);
drawDiagramCircles(e.Graphics rect);
drawDiagramCrosshair(e.Graphics);
drawPoints(e.Graphics values);
}
// 画圆
float diameter radius;
PointF center;
private void drawDiagramCircles(Graphics g Rectangle rect)
{
// 圆的直径等于绘图区域最短边
diameter = Math.Min(rect.Width rect.Height);
// 半径
radius = diameter / 2;
// 圆心
center = new PointF(
rect.X + rect.Width / 2
rect.Y + rect.Height / 2
);
// 画几个圆
int count = 1;
float diameterStep = diameter / count;
float radiusStep = radius / count;
// 生成圆的范围
RectangleF cirleRect = new RectangleF();
cirleRect.X = center.X - radius;
cirleRect.Y = center.Y - radius;
cirleRect.Width = cirleRect.Height = diameter;
// 画同心圆
for (int i = 0; i < count; i++
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-05-21 22:40 PolarDiagram\
文件 1685 2012-05-21 21:54 PolarDiagram\Form1.Designer.cs
文件 6094 2012-05-21 22:05 PolarDiagram\Form1.cs
文件 5814 2012-05-21 21:54 PolarDiagram\Form1.resx
文件 3304 2012-05-21 22:05 PolarDiagram\GetPhysical.csproj
文件 910 2012-05-20 20:54 PolarDiagram\GetPhysical.sln
文件 13824 2012-05-21 22:05 PolarDiagram\GetPhysical.suo
文件 470 2012-05-20 20:54 PolarDiagram\Program.cs
目录 0 2012-05-21 22:40 PolarDiagram\Properties\
文件 1186 2012-05-21 22:41 PolarDiagram\Properties\AssemblyInfo.cs
文件 2878 2012-05-20 20:54 PolarDiagram\Properties\Resources.Designer.cs
文件 5612 2012-05-20 20:54 PolarDiagram\Properties\Resources.resx
文件 1096 2012-05-20 20:54 PolarDiagram\Properties\Settings.Designer.cs
文件 249 2012-05-20 20:54 PolarDiagram\Properties\Settings.settings
目录 0 2012-05-21 22:40 PolarDiagram\bin\
目录 0 2012-05-21 22:40 PolarDiagram\bin\Debug\
文件 24576 2012-05-21 22:05 PolarDiagram\bin\Debug\GetPhysical.exe
文件 36352 2012-05-21 22:05 PolarDiagram\bin\Debug\GetPhysical.pdb
文件 5632 2005-11-11 22:25 PolarDiagram\bin\Debug\GetPhysical.vshost.exe
目录 0 2012-05-21 22:40 PolarDiagram\obj\
目录 0 2012-05-21 22:40 PolarDiagram\obj\Debug\
文件 180 2012-05-21 21:54 PolarDiagram\obj\Debug\GetPhysical.Form1.resources
文件 180 2012-05-20 21:12 PolarDiagram\obj\Debug\GetPhysical.Properties.Resources.resources
文件 842 2012-05-21 21:54 PolarDiagram\obj\Debug\GetPhysical.csproj.GenerateResource.Cache
文件 24576 2012-05-21 22:05 PolarDiagram\obj\Debug\GetPhysical.exe
文件 36352 2012-05-21 22:05 PolarDiagram\obj\Debug\GetPhysical.pdb
目录 0 2012-05-21 22:41 PolarDiagram\obj\Debug\Refactor\
文件 2613 2012-05-21 21:43 PolarDiagram\obj\Debug\ResolveAssemblyReference.cache
目录 0 2012-05-21 22:41 PolarDiagram\obj\Debug\TempPE\
文件 664 2012-05-21 22:05 PolarDiagram\obj\GetPhysical.csproj.FileListAbsolute.txt
相关资源
- WPF USB 网络 串口 通信软件
- B/S 网上订餐系统
- 教室管理系统.rar
- 小鸡快跑游戏.
- GDI自绘滚动条
-
分别适用于.NET fr
amework 2.0和4.0的E - 汽车租赁系统............................
- 德卡D8读写器关于读写感应卡的一些代
- halcon 测量助手
- 图片存储到数据库保存二进制文件并
- 用Socket写的简易FTP服务器和客户端
- 企业销售管理信息系统(全套)
- VC 使用GDI 矢量绘图软件源代码
- 串口操作类(justinio)
- 基于Petri网的工作流(完整的原创源代
- 选择题自动考试系统
- 多线程实例:桌面智能弹球小游戏
- 易语言矩阵的旋转源码易语言GDI矩阵
- 易语言认识矩阵源码易语言GDI矩阵源
- 易语言矩阵应用到指定坐标源码易语
- halcon极坐标变换傅里叶变换
- 土地信息管理系统
- ServiceStack V3.9 全部dll
- PDF pdfview.ocx 无水印
- delphi基于gdi+的图片旋转任意角度
- 全站仪极坐标法在相似材料模拟试验
- 易语言图像编码、解码器源码易语言
- 易语言GDI三角板源码
- 易语言GDI设置输出前景色源码
-
易语言GDI自绘电梯st
yle源码
评论
共有 条评论