C#Windows窗体界面设计_攻击决策项目_真实轨迹RealTrack
2013-10-29 17:25
483 查看
Author: binzhouweichao@163.com
Date: 2013-10-29
参考:
http://www.cnblogs.com/OpenCoder/archive/2010/02/23/1672043.html
http://developer.51cto.com/art/200909/149829.htm
重新建立项目。命名为AttackDecision_RealTrack
MainForm
Size: 800, 600
pictureBox1
Size: 520, 520
BackColor: White
time1
Enabled: True
Trick
MainForm.cs
GlobalVars.cs
效果:
![](https://img-blog.csdn.net/20131029172232625?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2R1d2VpY2hhbw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
代码:
http://yunpan.cn/Q9QaF2enPvGT9
Date: 2013-10-29
参考:
http://www.cnblogs.com/OpenCoder/archive/2010/02/23/1672043.html
http://developer.51cto.com/art/200909/149829.htm
重新建立项目。命名为AttackDecision_RealTrack
MainForm
Size: 800, 600
pictureBox1
Size: 520, 520
BackColor: White
time1
Enabled: True
Trick
MainForm.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace AttackDecision_RealTrack { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void MainForm_Load(object sender, EventArgs e) { //初始化 GlobalVars.B = new Bitmap(pictureBox1.Width, pictureBox1.Height); this.pictureBox1.Image = GlobalVars.B; //当前速度 GlobalVars.currentVx = 0; GlobalVars.currentVy = 10; //当前位置 /* GlobalVars.currentPoint = new PointF(100F, 0F); * */ //初始位置 GlobalVars.startPoint = new PointF(100F, 0F); GlobalVars.attackPointData = new List<PointF>(); GlobalVars.attackPointData.Add(GlobalVars.startPoint); //时间间隔 GlobalVars.timeInterval = 1000; this.timer1.Interval = GlobalVars.timeInterval; GlobalVars.timeCnt = 0; } private void timer1_Tick(object sender, EventArgs e) { //处理数据 PointF currentPoint = new PointF(GlobalVars.attackPointData[GlobalVars.timeCnt].X, GlobalVars.attackPointData[GlobalVars.timeCnt].Y); currentPoint.X = currentPoint.X + GlobalVars.currentVx * this.timer1.Interval / 1000; currentPoint.Y = currentPoint.Y + GlobalVars.currentVy * this.timer1.Interval / 1000; GlobalVars.attackPointData.Add(currentPoint); GlobalVars.timeCnt++; SolidBrush myBrush = new SolidBrush(Color.Red); Graphics g = Graphics.FromImage(GlobalVars.B); //g.DrawArc(myBrush, GlobalVars.attackPointData[GlobalVars.timeCnt-1].X, GlobalVars.attackPointData[GlobalVars.timeCnt-1].Y,) g.FillEllipse(myBrush, GlobalVars.attackPointData[GlobalVars.timeCnt - 1].X, GlobalVars.attackPointData[GlobalVars.timeCnt - 1].Y, 2F, 2F); //pictureBox1.Image = GlobalVars.B; pictureBox1.Refresh(); } } }
GlobalVars.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; namespace AttackDecision_RealTrack { public static class GlobalVars { //攻击结点数据全局变量 private static List<PointF> attackpointdata; public static List<PointF> attackPointData { set { attackpointdata = value; } get { return attackpointdata; } } //绘图全局变量 private static Bitmap b; public static Bitmap B { set { b = value; } get { return b; } } //当前速度 private static float currentvx; public static float currentVx { set { currentvx = value; } get { return currentvx; } } private static float currentvy; public static float currentVy { set { currentvy = value; } get { return currentvy; } } //当前位置 /* private static PointF currentpoint; public static PointF currentPoint { set { currentpoint = value; } get { return currentpoint; } } * */ //初始位置 private static PointF startpoint; public static PointF startPoint { set { startpoint = value; } get { return startpoint; } } //当前时间间隔 private static int timeinterval; public static int timeInterval { set { timeinterval = value; } get { return timeinterval; } } //时间计时 private static int timecnt; public static int timeCnt { set { timecnt = value; } get { return timecnt; } } } }
效果:
代码:
http://yunpan.cn/Q9QaF2enPvGT9
相关文章推荐
- C#Windows窗体界面设计_攻击决策项目_02_设计窗体_01_主窗体
- C#Windows窗体界面设计_攻击决策项目_03_数据绘图_03_绘制雷点
- C#Windows窗体界面设计_攻击决策项目_01_系统架构
- C#Windows窗体界面设计_攻击决策项目_03_数据绘图_02_修订坐标轴和ParamsForm文本框数据
- C#Windows窗体界面设计_攻击决策项目_02_设计窗体_04_修订主窗体工具栏和状态栏
- C#Windows窗体界面设计_攻击决策项目_02_设计窗体_03_设置窗体弹出退出顺序
- C#Windows窗体界面设计_攻击决策项目_03_数据绘图_01_绘制坐标轴_修订ParamsForm
- C#Windows窗体界面设计_攻击决策项目_02_设计窗体_02_子窗体
- C#Windows窗体界面设计_03_坐标系平移 旋转 镜像
- C#Windows窗体界面设计_02_绘制三角函数_多点作图法
- C#Windows窗体界面设计_06_通过调整坐标系来调整数据
- C#Windows 窗体设计-实现欢迎界面-显示About窗体-在托盘中写入应用程序图标
- C#Windows窗体界面设计_01_绘制三角函数_附强制类型转换
- C#Windows窗体界面设计_05_添加菜单栏 工具栏 状态栏 按钮
- C#Windows窗体界面设计_01_绘制三角函数_五点作图法
- C#Windows窗体界面设计_07_多窗体设计
- C#Windows窗体界面设计_01_绘制三角函数_五点作图法
- C#Windows窗体界面设计_04_添加PictureBox控件绘图
- C#实例:5个.net经典例子(窗体与界面设计)
- C#实例:5个.net经典例子(窗体与界面设计)