100分求一个C#做的体育比赛的控制软件源码 jiangsheng(蒋晟.Net[MVP]) ( ) 信誉:110 Blog 加为好友 2007-5-18 6:01:23 得分: 0 自己先拿计算器联系一下怎么写需求分析 嗯 不要都只知道 要. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我自己也做了一部分,可是不懂怎么显示到窗口的字体,变成LED那样的 using System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.Windows.Forms;namespace testgrid{ class SevenSegmentDisplay { Graphics g; static byte[,] bySegment ={{1,1,1,0,1,1,1}, {0,0,1,0,0,1,0}, {1,0,1,1,1,0,1}, {1,0,1,1,0,1,1}, {0,1,1,1,0,1,0}, {1,1,0,1,0,1,1}, {1,1,0,1,1,1,1}, {1,0,1,0,0,1,0}, {1,1,1,1,1,1,1}, {1,1,1,1,0,1,1}}; readonly Point[][] apt = new Point[7][]; public SevenSegmentDisplay(Graphics g) { this.g = g; apt[0] = new Point[] { new Point(3, 2), new Point(39, 2), new Point(31, 10), new Point(11, 10) }; apt[1] = new Point[] { new Point(2, 3), new Point(10, 11), new Point(10, 31), new Point(2, 35) }; apt[2] = new Point[] { new Point(40, 3), new Point(40, 35), new Point(32, 31), new Point(32, 11) }; apt[3] = new Point[] { new Point(3, 36), new Point(11, 32), new Point(31, 32), new Point(39, 36), new Point(31, 40), new Point(11, 40) }; apt[4] = new Point[] { new Point(2, 37), new Point(10, 41), new Point(10, 61), new Point(2, 69) }; apt[5] = new Point[] { new Point(40, 37), new Point(40, 69), new Point(32, 61), new Point(32, 41) }; apt[6] = new Point[] { new Point(11, 62), new Point(31, 62), new Point(39, 70), new Point(3, 70) }; } public SizeF MeasureString(string str,Font font) { SizeF sizef = new SizeF(0, g.DpiX * font.SizeInPoints / 72); for (int i = 0; i < str.Length; i++) { if (char.IsDigit(str[i])) sizef.Width += 42 * g.DpiX * font.SizeInPoints / 72 / 72; else if (str[i] == ':') sizef.Width += 12 * g.DpiX * font.SizeInPoints / 72 / 72; } return sizef; } public void DrawString(string str, Font font, Brush br, float x, float y) { for (int i = 0; i < str.Length; i++) { if (char.IsDigit(str[i])) { x = Number(str[i] - '0', font, br, x, y); } else if (str[i] == ':') x = Colon(font, br, x, y); } } float Number(int num, Font font, Brush br, float x, float y) { for (int i = 0; i < apt.Length; i++) { if (bySegment[num, i] == 1) Fill(apt[i], font, br, x, y); } return x + 42 * g.DpiX * font.SizeInPoints / 72 / 72; } float Colon(Font font, Brush br, float x, float y) { Point[][] apt = new Point[2][]; apt[0] = new Point[] { new Point(2, 21), new Point(6, 17), new Point(10, 21), new Point(6, 25) }; apt[1] = new Point[] { new Point(2, 51), new Point(6, 47), new Point(10, 51), new Point(6, 55) }; for (int i = 0; i < apt.Length; i++) Fill(apt[i], font, br, x, y); return x + 12 * g.DpiX * font.SizeInPoints / 72 / 72; } void Fill(Point[] apt, Font font, Brush br, float x, float y) { PointF[] aptf = new PointF[apt.Length]; for (int i = 0; i < apt.Length; i++) { aptf[i].X = x + apt[i].X * g.DpiX * font.SizeInPoints / 72 / 72; aptf[i].Y = y + apt[i].Y * g.DpiY * font.SizeInPoints / 72 / 72; } g.FillPolygon(br, aptf); } }} using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Globalization;namespace testgrid{ public partial class SevenSegmentClock : Form { DateTime dt; public SevenSegmentClock() { InitializeComponent(); BackColor = Color.White; ResizeRedraw = true; MinimumSize = SystemInformation.MinimizedWindowSize + new Size(0, 1); dt = DateTime.Now; Timer timer = new Timer(); timer.Tick+=new EventHandler(timer_Tick); timer.Interval = 100; timer.Enabled = true; } void timer_Tick(object sender, EventArgs e) { DateTime dtnow = DateTime.Now; dtnow = new DateTime(dtnow.Year, dtnow.Month, dtnow.Day, dtnow.Hour, dtnow.Minute, dtnow.Second); if (dtnow != dt) { dt = dtnow; Invalidate(); } } protected override void OnPaint(PaintEventArgs e) { SevenSegmentDisplay ssd = new SevenSegmentDisplay(e.Graphics); string strTime = dt.ToString("T", DateTimeFormatInfo.InvariantInfo); SizeF sizef = ssd.MeasureString(strTime, Font); float fScale = Math.Min(ClientSize.Width / sizef.Width, ClientSize.Height / sizef.Height); Font font = new Font(Font.FontFamily, fScale * Font.SizeInPoints); sizef = ssd.MeasureString(strTime, font); ssd.DrawString(strTime, font, Brushes.Red, (ClientSize.Width - sizef.Width) / 2, (ClientSize.Height - sizef.Height) / 2); } }} 以上是类似LCD显示时间的例子 64位dll访问32位的 c#反射如何获取一个类的基本信息如PublicKeyToken等 怎样实现按钮随ListBox选中项移动而跟随移动 系统做完了,想打包程序... winform 中怎么保存这个图 c#十进制到二进制的转换 C#面向对象问题,根据类中的属性定位到所属的类,动态实例化 rdlc报表设计程序,能单独安装吗? 关于C#取数据的一个问题,请大家帮帮忙啊(急) winform下用Webclient上传文件,默认大小不能超过1M,该如何解决? 动态控件 click事件 关于一个C#程序,急!!!!
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;namespace testgrid
{
class SevenSegmentDisplay
{
Graphics g;
static byte[,] bySegment ={{1,1,1,0,1,1,1},
{0,0,1,0,0,1,0},
{1,0,1,1,1,0,1},
{1,0,1,1,0,1,1},
{0,1,1,1,0,1,0},
{1,1,0,1,0,1,1},
{1,1,0,1,1,1,1},
{1,0,1,0,0,1,0},
{1,1,1,1,1,1,1},
{1,1,1,1,0,1,1}};
readonly Point[][] apt = new Point[7][];
public SevenSegmentDisplay(Graphics g)
{
this.g = g;
apt[0] = new Point[] { new Point(3, 2), new Point(39, 2), new Point(31, 10), new Point(11, 10) };
apt[1] = new Point[] { new Point(2, 3), new Point(10, 11), new Point(10, 31), new Point(2, 35) };
apt[2] = new Point[] { new Point(40, 3), new Point(40, 35), new Point(32, 31), new Point(32, 11) };
apt[3] = new Point[] { new Point(3, 36), new Point(11, 32), new Point(31, 32), new Point(39, 36), new Point(31, 40), new Point(11, 40) };
apt[4] = new Point[] { new Point(2, 37), new Point(10, 41), new Point(10, 61), new Point(2, 69) };
apt[5] = new Point[] { new Point(40, 37), new Point(40, 69), new Point(32, 61), new Point(32, 41) };
apt[6] = new Point[] { new Point(11, 62), new Point(31, 62), new Point(39, 70), new Point(3, 70) };
}
public SizeF MeasureString(string str,Font font)
{
SizeF sizef = new SizeF(0, g.DpiX * font.SizeInPoints / 72);
for (int i = 0; i < str.Length; i++)
{
if (char.IsDigit(str[i]))
sizef.Width += 42 * g.DpiX * font.SizeInPoints / 72 / 72;
else if (str[i] == ':')
sizef.Width += 12 * g.DpiX * font.SizeInPoints / 72 / 72;
}
return sizef;
}
public void DrawString(string str, Font font, Brush br, float x, float y)
{
for (int i = 0; i < str.Length; i++)
{
if (char.IsDigit(str[i]))
{
x = Number(str[i] - '0', font, br, x, y);
}
else if (str[i] == ':')
x = Colon(font, br, x, y);
}
}
float Number(int num, Font font, Brush br, float x, float y)
{
for (int i = 0; i < apt.Length; i++)
{
if (bySegment[num, i] == 1)
Fill(apt[i], font, br, x, y);
}
return x + 42 * g.DpiX * font.SizeInPoints / 72 / 72;
}
float Colon(Font font, Brush br, float x, float y)
{
Point[][] apt = new Point[2][];
apt[0] = new Point[] { new Point(2, 21), new Point(6, 17), new Point(10, 21), new Point(6, 25) };
apt[1] = new Point[] { new Point(2, 51), new Point(6, 47), new Point(10, 51), new Point(6, 55) };
for (int i = 0; i < apt.Length; i++)
Fill(apt[i], font, br, x, y);
return x + 12 * g.DpiX * font.SizeInPoints / 72 / 72;
}
void Fill(Point[] apt, Font font, Brush br, float x, float y)
{
PointF[] aptf = new PointF[apt.Length];
for (int i = 0; i < apt.Length; i++)
{
aptf[i].X = x + apt[i].X * g.DpiX * font.SizeInPoints / 72 / 72;
aptf[i].Y = y + apt[i].Y * g.DpiY * font.SizeInPoints / 72 / 72;
}
g.FillPolygon(br, aptf);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;namespace testgrid
{
public partial class SevenSegmentClock : Form
{
DateTime dt;
public SevenSegmentClock()
{
InitializeComponent();
BackColor = Color.White;
ResizeRedraw = true;
MinimumSize = SystemInformation.MinimizedWindowSize + new Size(0, 1);
dt = DateTime.Now;
Timer timer = new Timer();
timer.Tick+=new EventHandler(timer_Tick);
timer.Interval = 100;
timer.Enabled = true;
} void timer_Tick(object sender, EventArgs e)
{
DateTime dtnow = DateTime.Now;
dtnow = new DateTime(dtnow.Year, dtnow.Month, dtnow.Day, dtnow.Hour, dtnow.Minute, dtnow.Second);
if (dtnow != dt)
{
dt = dtnow;
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
SevenSegmentDisplay ssd = new SevenSegmentDisplay(e.Graphics);
string strTime = dt.ToString("T", DateTimeFormatInfo.InvariantInfo);
SizeF sizef = ssd.MeasureString(strTime, Font);
float fScale = Math.Min(ClientSize.Width / sizef.Width, ClientSize.Height / sizef.Height);
Font font = new Font(Font.FontFamily, fScale * Font.SizeInPoints);
sizef = ssd.MeasureString(strTime, font);
ssd.DrawString(strTime, font, Brushes.Red, (ClientSize.Width - sizef.Width) / 2, (ClientSize.Height - sizef.Height) / 2); }
}
}