2024-04-18 08:38:59 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace CDSAE3_Lian_Lian_Kan.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class BufferForm : UserControl
|
|
|
|
|
{
|
|
|
|
|
public BufferForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2024-04-19 10:00:37 +08:00
|
|
|
|
public void SetEffect(Color begin, Color end)
|
2024-04-18 08:38:59 +08:00
|
|
|
|
{
|
|
|
|
|
BackColor = begin;
|
|
|
|
|
this.begin = begin;
|
|
|
|
|
this.Dock = DockStyle.Fill;
|
|
|
|
|
deltaRa = (0 - begin.R) / 5;
|
|
|
|
|
deltaGa = (0 - begin.G) / 5;
|
|
|
|
|
deltaBa = (0 - begin.B) / 5;
|
|
|
|
|
deltaRb = (end.R - 0) / 5;
|
|
|
|
|
deltaGb = (end.G - 0) / 5;
|
|
|
|
|
deltaBb = (end.B - 0) / 5;
|
|
|
|
|
this.end = Color.FromArgb(0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
Color begin;
|
|
|
|
|
Color end;
|
|
|
|
|
int deltaRa, deltaGa, deltaBa;
|
|
|
|
|
int deltaRb, deltaGb, deltaBb;
|
|
|
|
|
public async Task EffectAsync()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
begin = Color.FromArgb(begin.R + deltaRa, begin.G + deltaGa, begin.B + deltaBa);
|
|
|
|
|
SolidBrush brush = new SolidBrush(begin);
|
|
|
|
|
Graphics graphics = this.CreateGraphics();
|
|
|
|
|
graphics.FillRectangle(brush, 0, 0, Width, Height);
|
|
|
|
|
//await System.Timers.Timer.
|
|
|
|
|
await Task.Delay(100);
|
|
|
|
|
}
|
|
|
|
|
loading.Text = "";
|
|
|
|
|
BackColor = Color.FromArgb(0, 0, 0);
|
|
|
|
|
loading.Visible = true;
|
|
|
|
|
for (int i = 1; i < "Loading".Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string s = "Loading".Substring(0, i);
|
|
|
|
|
s += GetRandomStr("", "Loading".Length - i);
|
|
|
|
|
loading.Text = s;
|
|
|
|
|
await Task.Delay(100);
|
|
|
|
|
}
|
|
|
|
|
while (!Etcs.loadFinished)
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
await Console.Out.WriteLineAsync("等待完成");
|
|
|
|
|
loading.Text = "Loading" + new string('.', i % 4);
|
|
|
|
|
await Task.Delay(100);
|
|
|
|
|
}
|
|
|
|
|
loading.Visible = false;
|
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
end = Color.FromArgb(end.R + deltaRb, end.G + deltaGb, end.B + deltaBb);
|
|
|
|
|
SolidBrush brush = new SolidBrush(end);
|
|
|
|
|
Graphics graphics = this.CreateGraphics();
|
|
|
|
|
graphics.FillRectangle(brush, 0, 0, Width, Height);
|
|
|
|
|
await Task.Delay(100);
|
|
|
|
|
}
|
|
|
|
|
Visible = false;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
e.InnerException?.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private Random _random = new Random();
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 随机字符串
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="chars"></param>
|
|
|
|
|
/// <param name="length"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetRandomStr(string chars, int length)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(chars))
|
|
|
|
|
{
|
|
|
|
|
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghizklmnopqrstuvwxyz0123456789";
|
|
|
|
|
}
|
|
|
|
|
//const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
|
|
|
return new string(Enumerable.Repeat(chars, length)
|
|
|
|
|
.Select(s => s[_random.Next(s.Length)]).ToArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|