using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.Diagnostics;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Start();
timer3.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Opacity = 0;
count = false;
Random rdn = new Random();
int i = rdn.Next(imageList1.Images.Count);
this.BackgroundImage = imageList1.Images[i];
this.BackgroundImageLayout = ImageLayout.Stretch;
timer1.Stop();
timer2.Start();
}
private bool op = true, count = false;
private int picnum = 0;
private void timer2_Tick(object sender, EventArgs e)
{
if (this.Opacity == 1) { op = false; }
if (this.Opacity == 0) { op = true; if (count == false) { count = true; } else { count = false; } }
if (count == false) { timer2.Stop(); timer1.Start(); }
if (op == false) { this.Opacity -= 0.1; }
else { this.Opacity += 0.1; }
}
private void button1_Click(object sender, EventArgs e)
{
if (Clipboard.ContainsText())
{
richTextBox1.Text = Clipboard.GetText();
string[] strArr = Clipboard.GetText().Split(' ');
foreach (string abc in strArr)
{
listBox1.Items.Add(abc);
}
}
}
private void richTextBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
button1.Focus();
}
}
private void Form1_Load(object sender, EventArgs e)
{
/* string RunningProcess = Process.GetCurrentProcess().ProcessName;
Process[] processes = Process.GetProcessesByName(RunningProcess);
if (processes.Length > 1)
{
MessageBox.Show("Application is already running", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
Application.ExitThread();
}*/
bool exist;
System.Threading.Mutex mx = new System.Threading.Mutex(true, "only once", out exist);
if (exist)
{
mx.ReleaseMutex();
}
else
{
MessageBox.Show("one at a time!", "notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
}
private void timer3_Tick(object sender, EventArgs e)
{
Rectangle bounds = this.Bounds;
Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
bitmap.Save("test" + picnum + ".jpg");
picnum++;
this.Refresh();
}
}
}
No comments:
Post a Comment