资源简介
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
相关资源
- 自己动手改造TabControl--从山寨Safari开
- OA人员选择模块Js+JSON
- 航空管理系统
- 资源管理器
- 学生健康管理系统 软件工程大作业
- LitJson源码--cs文件
- redupload多文件上传控件 dll
- 喜马拉雅音频修改器有源码
- trainingDigits/testDigits
- 有意思的应用程序《用名字打架》
- DNS协议解析源码程序
- .net财务管理系统完整源码值得
- C#Textbox获得扫描枪条码内容
- CSharpModBusExample
- 进程调度 优先权和轮转法
- 在RichTextBox中实现项目符号功能
- 基于SOCKET编写的QQ模拟程序
- RFID读写程序
- 简易水准网平差程序
- 用GDI+绘制的一个强大可移动坐标,已
- 手写签名采集识别系统
- NotifyIcon
- ScreenCaptor组件
- GPS NMEA协议解析.NET库
- GPS广播星历计算卫星概略位置
- DevExpressCrack-master.zip
- 打包管理工具 Asset Bundle Manager
- Loic源码-DDOS/DOS测试
- 空间后方交会求外方位元素
- 手写签名图片,可保存为图片或到数
评论
共有 条评论