新手学C#,想请教一下大家怎样编写一个可以满屏幕出现的玫瑰的程序
我是一个新手,自学c#。看到了有些小程序可以满屏幕出现玫瑰(我有这个程序),但是我想自己编写一个,求指导!我希望自己编出来后送给女朋友。这里不是叫大家帮我编写一个,而是指教一下, 我想自己编!谢谢 --------------------编程问答-------------------- shell外壳编程应用SysListView32类句柄
进行开发 --------------------编程问答-------------------- 把现成的程序放在C:\,比如叫1.exe
你的程序调用:
Process.Start("c:\\1.exe"); --------------------编程问答-------------------- --------------------编程问答-------------------- 2楼的方法屌爆了! --------------------编程问答-------------------- 画一张Form,在Form里面放个picturebox,加载一张图,控件visiable=false,下面加一个button,button.text="我花了1000万请人写的程序,不过没什么,这只是小意思,哥有钱",click事件picturebox.visiable=true --------------------编程问答-------------------- +1
--------------------编程问答--------------------
using System;--------------------编程问答-------------------- 简化后,实现6张图循环:
using System.Drawing;
using System.Windows.Forms;
namespace 显示图片
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//form1属性设置如下:
//FormBorderStyle设置为none,即窗体为panel
//topmost设置为true
//this.TransparencyKey设置为control,即窗体为透明。
this.WindowState = FormWindowState.Maximized;//窗体为全屏
}
private void Form1_Click(object sender, EventArgs e)
{
Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
Random rd = new Random();
for (int i = 0; i < 8; i++)
show_image_in_random_point(rd.Next(this.Width - 1), rd.Next(this.Width - 1), rd.Next(5, 10), rd.Next(32, 128));
}
public void show_image_in_random_point(int x, int y, int r, int h)
{
Graphics g = this.CreateGraphics();
Image image = Image.FromFile("bug.png");//图片
int nXStart = x - r < 0 ? 0 : x - r;
int nYStart = y - r < 0 ? 0 : y - r;
for (int posX = nXStart; posX < this.Width; posX++)
{
for (int posY = nYStart; posY < this.Height; posY++)
{
if ((posX - x) * (posX - x) + (posY - y) * (posY - y) < r * r)
g.DrawImage(image, posX, posY);
}
}
}
}
}
using System;--------------------编程问答-------------------- 第二个Width改为Height
using System.Drawing;
using System.Windows.Forms;
namespace 显示图片
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//form1属性设置如下:
//FormBorderStyle设置为none,即窗体为panel
//topmost设置为true
//this.TransparencyKey设置为control,即窗体为透明。
this.WindowState = FormWindowState.Maximized;//窗体为全屏
}
private void Form1_Click(object sender, EventArgs e)
{
Close();
}
int image_id = 0;
int count = 0;
private void timer1_Tick(object sender, EventArgs e)//interval设置为200
{
Random r = new Random();
show_image_in_random_point(r.Next(this.Width - 1), r.Next(this.Width - 1));
}
public void show_image_in_random_point(int x, int y)
{
Graphics g = this.CreateGraphics();
Image image = Image.FromFile(image_id.ToString() + ".png");
image_id++;
if (image_id == 5) image_id = 0;//6张图循环
count++;
if (count == 1000)Close();
g.DrawImage(image, x, y);
}
}
}
--------------------编程问答-------------------- 这代码真啰嗦
show_image_in_random_point(r.Next(this.Width - 1), r.Next(this.Height - 1));
Graphics g = this.CreateGraphics();
Image image = Image.FromFile(image_id.ToString() + ".png");
image_id++;
if (image_id == 5) image_id = 0;//6张图循环
count++;
if (count == 1000)Close();
g.DrawImage(image, x, y);
直接这样就行了
Image image = Image.FromFile((image_id++ % 6).ToString() + ".png");
CreateGraphics.DrawImage(image, x, y);
if (image_id == 1000) Close(); --------------------编程问答--------------------
多谢指正!用整除的确漂亮多了。
顺便上个:虫子铺满屏幕.exe
http://download.csdn.net/detail/xiedingan/4609288
--------------------编程问答-------------------- --------------------编程问答-------------------- 一年前的帖子也顶起来了? --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答--------------------
1年前的帖子··· --------------------编程问答-------------------- 前两天不是才有个人写了个花在飞的么,自己改下不就可以了么
http://bbs.csdn.net/topics/390663374#post-396282743 --------------------编程问答--------------------
+1
补充:.NET技术 , C#