This repository has been archived on 2024-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
CDSAE3/CDSAE3_Lian_Lian_Kan/Forms/MainForm.cs

68 lines
2.1 KiB
C#

using CDSAE3_Lian_Lian_Kan.Forms;
using CDSAE3_Lian_Lian_Kan.Properties;
using System.Text.Json;
using System.Text.Encodings.Web;
using System.Text.Unicode;
using System.ComponentModel;
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
using System.Runtime.InteropServices;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class LianLianKan : Form
{
public LianLianKan()
{
InitializeComponent();
Etcs.hunderd_millsecond_timer.Elapsed += StartFunc;
Etcs.form = this;
}
private void StartFunc(object? Sender, EventArgs e)
{
Etcs.hunderd_millsecond_timer.Elapsed -= StartFunc;
Form? menuForm = null;
Invoke(() => menuForm = new MenuForm());
Invoke(() => change_form(menuForm!, false, null, null));
}
public async Task change_form(Form newForm, bool doAnimation, Color? begin, Color? end)
{
if (doAnimation)
{
bufferForm.SetEffect(begin!.Value, end!.Value);
bufferForm.BringToFront();
bufferForm.Visible = true;
}
MainPanel.Controls.Clear();
newForm.TopLevel = false;
newForm.Dock = DockStyle.Fill;
(newForm as IThemeChangeable)?.SetTheme();
MainPanel.Controls.Add(newForm);
BeginInvoke(() => newForm.Show());
MainPanel.SendToBack();
ActiveControl = newForm;
if (doAnimation)
{
await bufferForm.EffectAsync();
bufferForm.Visible = false;
}
GC.Collect();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
KeyEventArgs e = new KeyEventArgs(keyData);
if (keyData == (Keys.Space))
{
Etcs.gameModeForm?.TogglePause();
return true;
}
if (keyData == (Keys.Escape))
{
Etcs.escapableForm?.Back();
return true;
}
return false;
}
}
}