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#
Raw Permalink Normal View History

2024-03-22 09:03:01 +00:00
using CDSAE3_Lian_Lian_Kan.Forms;
2024-04-18 00:38:59 +00:00
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;
2024-04-19 02:00:37 +00:00
using System.Runtime.InteropServices;
2024-03-22 09:03:01 +00:00
2024-04-18 00:38:59 +00:00
namespace CDSAE3_Lian_Lian_Kan.Forms
2024-03-22 09:03:01 +00:00
{
public partial class LianLianKan : Form
{
public LianLianKan()
{
InitializeComponent();
2024-04-18 00:38:59 +00:00
Etcs.hunderd_millsecond_timer.Elapsed += StartFunc;
2024-04-02 13:57:04 +00:00
Etcs.form = this;
2024-03-22 09:03:01 +00:00
}
2024-04-18 00:38:59 +00:00
private void StartFunc(object? Sender, EventArgs e)
2024-03-22 09:03:01 +00:00
{
2024-04-18 00:38:59 +00:00
Etcs.hunderd_millsecond_timer.Elapsed -= StartFunc;
Form? menuForm = null;
2024-04-19 02:00:37 +00:00
Invoke(() => menuForm = new MenuForm());
Invoke(() => change_form(menuForm!, false, null, null));
2024-04-18 00:38:59 +00:00
}
2024-04-19 02:00:37 +00:00
public async Task change_form(Form newForm, bool doAnimation, Color? begin, Color? end)
2024-04-18 00:38:59 +00:00
{
if (doAnimation)
{
2024-04-19 02:00:37 +00:00
bufferForm.SetEffect(begin!.Value, end!.Value);
2024-04-18 00:38:59 +00:00
bufferForm.BringToFront();
bufferForm.Visible = true;
}
2024-03-22 09:03:01 +00:00
MainPanel.Controls.Clear();
2024-04-18 00:38:59 +00:00
newForm.TopLevel = false;
newForm.Dock = DockStyle.Fill;
(newForm as IThemeChangeable)?.SetTheme();
MainPanel.Controls.Add(newForm);
BeginInvoke(() => newForm.Show());
MainPanel.SendToBack();
2024-04-19 02:00:37 +00:00
ActiveControl = newForm;
2024-04-18 00:38:59 +00:00
if (doAnimation)
{
await bufferForm.EffectAsync();
bufferForm.Visible = false;
}
2024-04-02 13:57:04 +00:00
GC.Collect();
2024-03-22 09:03:01 +00:00
}
2024-04-19 02:00:37 +00:00
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
KeyEventArgs e = new KeyEventArgs(keyData);
if (keyData == (Keys.Space))
{
Etcs.gameModeForm?.TogglePause();
2024-04-22 05:48:40 +00:00
return true;
2024-04-19 02:00:37 +00:00
}
2024-04-22 05:48:40 +00:00
if (keyData == (Keys.Escape))
{
Etcs.escapableForm?.Back();
return true;
}
return false;
2024-04-19 02:00:37 +00:00
}
2024-03-22 09:03:01 +00:00
}
}