- [C#] Di chuyển và thay đổi kích thước Control Winform khi ứng dụng đang chạy
- [VB.NET] Chia sẻ source tạo sắp xếp đội hình bóng đá Line-ups đội bóng
- [C#] Hướng dẫn chỉnh sửa Text của label trực tiếp trên winform
- [C#] Hướng dẫn custom TextBox giống Ultraviewer trên Winform
- [C#] Show Modal Winform like Bootstrap
- [DATABASE] Thứ tự thực hiện mệnh đề truy vấn SELECT trong Sqlserver
- [C#] Hướng dẫn viết addin Excel Lấy hình ảnh từ URL internet vào Excel
- [DATABASE] TSQL view max length all column data trên table Sqlserver
- [DEVEXPRESS] Hướng dẫn sử dụng MailMerge kèm Hình ảnh trên Winform
- [DATABASE] Hướng dẫn truy vấn xem kích thước lưu trữ của từng bảng ghi Table trên sqlserver
- [C#] Hướng dẫn Fake Date Time sử dụng thư viện Harmony
- [DATABASE] Phân biệt câu lệnh DDL và DML trong sqlserver
- [C#] Hướng dẫn convert file mã HTML sang file Pdf trên winform
- [DEVEXPRESS] Tạo các loại mã vạch Barcode trực tiếp trên Devexpress Barcode API
- [DEVEXPRESS] Hướng dẫn custom Simple button thành Progressbar
- [DATABASE] Tách số và chữ từ chuỗi - hàm tối ưu hóa tách số và chữ trong Sqlserver
- [C#] Tìm kiếm gần đúng Full Text Search sử dụng thư viện Lucene.NET
- [C#] Chia sẻ tài liệu, sdk và source code máy chấm công dòng máy ZKTeco
- [C#] Memory Cache là gì, và sử dụng trong ứng dụng Winform
- [DATABASE] Khóa chính Primary Key trong Sqlserver
[C#] Chia sẻ source code make Crazy Error Message Effect Bomb Windows
Xin chào các bạn, bài viết hôm nay mình chia sẻ các bạn source code Crazy Effect Error Message trên winform, khi người dùng click vào sẻ hiển thị ngẫu nhiên các thông báo lỗi.
[C#] Crazy Error Windows
Video demo ứng dụng:
Source code C#:
using bs;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
namespace CrazyError
{
public partial class Form1 : Form
{
private int step = 30;
bool dixuong = true;
bool dilen = false;
bool dungtrai = false;
bool dungphai = false;
Random r= new Random();
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(0, 0);
}
public Point GetRandomScreenLocation()
{
Random rand = new Random();
Screen screen = Screen.PrimaryScreen;
int x = rand.Next(screen.Bounds.Left, screen.Bounds.Right);
int y = rand.Next(screen.Bounds.Top, screen.Bounds.Bottom);
return new Point(x, y);
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Rectangle screenBounds = Screen.PrimaryScreen.Bounds;
var listForm = new List<Form>();
var listForm2 = new List<Form>();
var listForm3 = new List<Form>();
var rnd = new Random();
var task1 = Task.Run(() =>
{
for (int i = 1; i <= 50; i++)
{
var formrand = r.Next(1, 4);
Form frm;
if (formrand == 1)
{
frm = new Form2();
}
else if (formrand == 2)
{
frm = new Form3();
}
else {
frm = new Form4();
}
listForm2.Add(frm);
frm.StartPosition = FormStartPosition.Manual;
var point = GetRandomScreenLocation();
frm.Location = point;
this.BeginInvoke(new Action(() =>
{
frm.Show();
if (i == 50) {
foreach (var item in listForm2)
{
item.Close();
}
}
}));
Task.Delay(150).Wait();
}
});
task1.ContinueWith(t => {
Task.Run(() =>
{
var temp = new Form2();
int x = 100;
int y = 100;
for (int i = 1; i <= 500; i++)
{
Form form;
form = new Form2();
form.Name = $"form{i}";
listForm.Add(form);
form.StartPosition = FormStartPosition.Manual;
form.Location = new Point(x, y);
if (form.Top + form.Height >= screenBounds.Bottom)
{
dilen = true;
dixuong = false;
}
if (form.Left + form.Width >= screenBounds.Right)
{
dungphai = true;
dungtrai = false;
}
if (form.Left <= screenBounds.Left)
{
dungtrai = true;
dungphai = false;
}
if (form.Top <= screenBounds.Top)
{
dilen = false;
dixuong = true;
}
if (dilen)
{
if (dungphai)
{
x = x - step;
}
else
{
x = x + step;
}
y = y - step;
}
if (dixuong)
{
y = y + step;
if (dungtrai)
{
x = x + step;
}
else
{
x = x - step;
}
}
this.BeginInvoke(new Action(() =>
{
form.Show();
if (i > 20 && i < 200)
{
foreach (var item in listForm)
{
var intNumber = Convert.ToInt32(item.Name.Replace("form", ""));
if (i - intNumber == 20)
{
item.Close();
}
}
}
if (i == 500)
{
foreach (var item in listForm)
{
item.Close();
}
var frm = new BsodForm();
frm.Show();
}
}));
Task.Delay(30).Wait();
}
});
Task.Run(() =>
{
var temp = new Form3();
int x = 350;
int y = 500;
for (int i = 1; i <= 400; i++)
{
Form form;
form = new Form3();
form.Name = $"form{i}";
listForm3.Add(form);
form.StartPosition = FormStartPosition.Manual;
form.Location = new Point(x, y);
if (form.Top + form.Height >= screenBounds.Bottom)
{
dilen = true;
dixuong = false;
}
if (form.Left + form.Width >= screenBounds.Right)
{
dungphai = true;
dungtrai = false;
}
if (form.Left <= screenBounds.Left)
{
dungtrai = true;
dungphai = false;
}
if (form.Top <= screenBounds.Top)
{
dilen = false;
dixuong = true;
}
if (dilen)
{
if (dungphai)
{
x = x - step;
}
else
{
x = x + step;
}
y = y - step;
}
if (dixuong)
{
y = y + step;
if (dungtrai)
{
x = x + step;
}
else
{
x = x - step;
}
}
this.BeginInvoke(new Action(() =>
{
form.Show();
if (i > 20 && i < 200)
{
foreach (var item in listForm3)
{
var intNumber = Convert.ToInt32(item.Name.Replace("form", ""));
if (i - intNumber == 20)
{
item.Close();
}
}
}
if (i == 400)
{
foreach (var item in listForm3)
{
item.Close();
}
}
}));
Task.Delay(30).Wait();
}
});
});
}
}
}
Thanks for watching!