下午好呀! 我想请教大家一个.NET问题,关于红路灯倒计时的数字图案显示问题!

qq_34936450 2016-05-23 01:01:51


如何使用c#窗体程序实现图片上红路灯倒计时这个数字的图案(不是数字而是数字的图案)呀!
...全文
292 14 打赏 收藏 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2016-05-24
  • 打赏
  • 举报
回复
            var g = e.Graphics;
using (var p = new GraphicsPath())
{
p.AddString("ABC", new FontFamily("Arial"), 1, 15f, new Point(0, 0), new StringFormat());
var b = p.GetBounds();
for (var y = b.Top; y <= b.Bottom; y++)
{
for (var x = b.Left; x <= b.Right; x++)
{
if (p.IsVisible(x, y))
{
g.FillEllipse(Brushes.Red, new RectangleF(x * 10, y * 10, 9, 9));
}
}
}
}
crystal_lz 2016-05-23
  • 打赏
  • 举报
回复
crystal_lz 2016-05-23
  • 打赏
  • 举报
回复

using System;
using System.Collections.Generic;
using System.Text;

using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;

namespace WindowsFormsApplication3
{
public class LEDScreen : Control
{
private int _DotWidth = 10;
[Description("点阵的大小")]
public int DotWidth {
get { return _DotWidth; }
set {
if (value < 0) throw new ArgumentException("点宽度必须大于0");
_DotWidth = value;
this.Width = 0;
this.Invalidate();
}
}

private Size _ScreenSize = new Size(10, 10);
[Description("屏幕分辨率")]
public Size ScreenSize {
get { return _ScreenSize; }
set {
if (value.Width < 0 || value.Height < 0)
throw new ArgumentException("无效的屏幕尺寸");
_ScreenSize = value;
_Swith = new bool[value.Width, value.Height];
this.Width = 0; //触发 SetBoundsCore 函数
this.Invalidate();
}
}

private Color _LigthColor = Color.Red;
[Description("亮灯的颜色")]
public Color LigthColor {
get { return _LigthColor; }
set {
_LigthColor = value;
this.Invalidate();
}
}

private Color _GrayColor = Color.Gray;
[Description("灭灯的颜色")]
public Color GrayColor {
get { return _GrayColor; }
set {
_GrayColor = value;
this.Invalidate();
}
}

private bool[,] _Swith = new bool[10, 10];

public bool[,] Swith {
get { return _Swith; }
}

public LEDScreen() {
this.BackColor = Color.Black;
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}

protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
using (SolidBrush sb = new SolidBrush(this._GrayColor)) {
for (int x = 0; x < this._ScreenSize.Width; x++) {
for (int y = 0; y < this._ScreenSize.Height; y++) {
sb.Color = this._Swith[x, y] ? this._LigthColor : this._GrayColor;
g.FillEllipse(sb, x * this._DotWidth, y * this._DotWidth, this._DotWidth, this._DotWidth);
}
}
}
base.OnPaint(e);
}
//代码控制控件的大小
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
width = this._ScreenSize.Width * this._DotWidth + 1;
height = this._ScreenSize.Height * this._DotWidth + 1;
base.SetBoundsCore(x, y, width, height, specified);
}
}
}


闲来无事做 打个酱油 做了一下你这个东西 自己参考把实现方式太多了
qq_34936450 2016-05-23
  • 打赏
  • 举报
回复
就是这样的数字图案!求大神编程实现这张图的数字图案的效果!谢谢
qq_34936450 2016-05-23
  • 打赏
  • 举报
回复
大家能帮我写下吗? 百度了数码管字体这块,都是一些压缩文件,解压了也没发现该怎么用!麻烦大家了。
qq_34936450 2016-05-23
  • 打赏
  • 举报
回复
我去找找看,谢谢呀!
socg 2016-05-23
  • 打赏
  • 举报
回复
下一个数码管字体,放在资源里,内存加载
qq_34936450 2016-05-23
  • 打赏
  • 举报
回复
简单说就是要实现倒计时的功能,但是在窗体程序上输出类似红路灯倒计时这样的数字图案。
qq_34936450 2016-05-23
  • 打赏
  • 举报
回复
不需要颜色,需要这样的数字图案做一个倒计时器!
拜一刀 2016-05-23
  • 打赏
  • 举报
回复
你是要在电脑上显示图案还是控制什么数码管之类的硬件啊....
白衣如花 2016-05-23
  • 打赏
  • 举报
回复
换图片或者改变图片的颜色
xdashewan 2016-05-23
  • 打赏
  • 举报
回复
有图就去网上找图,找不到就自己画,再不行无非就是那几个灯,你也放个8字形的等,写个算法让指定的灯亮起来就是数字
zbdzjx 2016-05-23
  • 打赏
  • 举报
回复
找10个这样子的数字图片去显示
xuzuning 2016-05-23
  • 打赏
  • 举报
回复
不明白是什么意思

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧