| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1196 人关注过本帖
标题:[求助]大家看看我的程序的溢出错误!我调了一天了!就是提示溢出错误!
只看楼主 加入收藏
gongkezhu
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2006-3-21
收藏
 问题点数:0 回复次数:3 
[求助]大家看看我的程序的溢出错误!我调了一天了!就是提示溢出错误!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;

namespace StockChart
{


/// <summary>
/// Form1 的摘要说明。
/// </summary>



public class StockChart : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public class Stock
{
public Color m_Color;
public String m_Ticker;
public float[] m_Price;
}



private float m_MaxY = 100F;
private float m_MinY = 0F;

private float m_MaxX = 1;
private float m_MinX = 10;

private float m_TickX = 1;
private float m_TickY = 10;

private ArrayList m_StockList;
private Rectangle m_PaintRectangle;

public float MaxY
{
set{m_MaxY = value;}
}

public float MinY
{
set{m_MinY = value;}
}

public float MaxX
{
set{m_MaxX = value;}
}

public float MinX
{
set{m_MinX = value;}
}

public void AddStock(Stock aStock)
{
m_StockList.Add(aStock);
}

public float TickX
{
set{m_TickX = value;}
}

public float TickY
{
set{m_TickY = value;}
}


PointF PixelPoint(PointF valuePoint)
{
PointF newPoint = new PointF();

newPoint.X = m_PaintRectangle.X + (valuePoint.X - m_MinX) *
m_PaintRectangle.Width / (m_MaxX - m_MinX);

newPoint.Y = m_PaintRectangle.Bottom - (valuePoint.Y - m_MinY)*
m_PaintRectangle.Height / (m_MaxY - m_MinY);

return newPoint;
}



public StockChart()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();



m_StockList = new ArrayList();


//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//

}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 16);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "绘制股票图";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// StockChart
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(492, 366);
this.Controls.Add(this.button1);
this.Name = "StockChart";
this.Text = "股票图表";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new StockChart());
}

private void button1_Click(object sender, System.EventArgs e)
{
this.MaxX = 2000;
this.MinX = 1996;
this.MaxY = 140;
this.MaxY = 0;

//Add stock for MicroSoft and Intel
StockChart.Stock aStock = new StockChart.Stock();
aStock.m_Ticker = "MSFT";
aStock.m_Color = Color.Red;
aStock.m_Price = new float[5]{36.1F,71.3F,119.35F,45.2F,64.9F};

this.AddStock(aStock);

aStock = new StockChart.Stock();
aStock.m_Ticker = "INTEL";
aStock.m_Color = Color.Blue;
aStock.m_Price = new float[5]{10.3F,23.34F,22.2F,8.78F,20.19F};



Graphics aGraphics = this.CreateGraphics();

//calculate the location and size of the rectangle
//within which we want to draw the graph...

m_PaintRectangle = new Rectangle(this.ClientRectangle.Location,this.ClientRectangle.Size);

Size s = new Size(12,14);

m_PaintRectangle.Inflate(-(6 * s.Width), -(6 * s.Height));
aGraphics.DrawRectangle(Pens.Black, m_PaintRectangle);

//Creat horizontal gridlines...


float y;
Pen aGridPen = new Pen(Color.Black);
aGridPen.DashStyle = DashStyle.Dot;
for(y = m_MinY + m_TickY; y <= m_MaxY; y += m_TickY)
{
aGraphics.DrawLine(aGridPen,
PixelPoint(new PointF(m_MinX,y)),
PixelPoint(new PointF(m_MaxX,y)));
}
aGridPen.Dispose();

//Creat the y axis tick marks...

for(y = m_MinY;y < m_MaxY; y += m_TickY)
{
PointF xaxisPoint = PixelPoint(new PointF(m_MinX,y));

aGraphics.DrawLine(Pens.Black,
xaxisPoint,
new PointF(xaxisPoint.X - s.Width / 2,xaxisPoint.Y));
}

//Creat x-axois tick marks00


float x;
for(x = m_MinX; x <= m_MaxX; x += m_TickX)
{
PointF yaxisPoint = PixelPoint(new PointF(x,m_MinY));

aGraphics.DrawLine(Pens.Black,
yaxisPoint,
new PointF(yaxisPoint.X,
yaxisPoint.Y + s.Height / 2));
}

//plot the stock data
foreach(Stock newStock in m_StockList)
{
Pen aPen = new Pen(newStock.m_Color,2);
float startX = m_MinX;

PointF startPoint = new PointF(m_MinX,newStock.m_Price[0]);
PointF endPoint = new PointF(m_MinX,newStock.m_Price[0]);

foreach(float price in newStock.m_Price)
{
endPoint.Y = price;
aGraphics.DrawLine(aPen,
PixelPoint(startPoint),
PixelPoint(endPoint));
startPoint = endPoint;
endPoint.X += 1;
}
aPen.Dispose();
}


} //end of button handler
}
}

搜索更多相关主题的帖子: using System summary Forms 提示 
2006-03-21 11:32
gongkezhu
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2006-3-21
收藏
得分:0 
大家不用回了,我搞定了!嘿嘿!

2006-03-22 08:20
zhou
Rank: 1
等 级:禁止发言
帖 子:429
专家分:0
注 册:2006-6-16
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽
2008-03-30 14:38
梦心
Rank: 4
来 自:福建平和
等 级:贵宾
威 望:13
帖 子:1910
专家分:0
注 册:2007-5-11
收藏
得分:0 
......
贴这么代码也没个注释
看疯了都...

我清高和我骄傲的倔强,在风中大声的唱:我不听,我不听~~做我自己最特别,呼呼~~啦啦~~~
我的博客园地址: [url]http://[/url]
2008-03-30 19:09
快速回复:[求助]大家看看我的程序的溢出错误!我调了一天了!就是提示溢出错误! ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018096 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved