写完排行榜了

This commit is contained in:
lichx
2024-04-18 08:38:59 +08:00
parent 3e81b973e9
commit 7cf048fd7c
113 changed files with 2589 additions and 200 deletions
+63
View File
@@ -0,0 +1,63 @@
namespace CDSAE3_Lian_Lian_Kan.Forms
{
partial class BufferForm
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
loading = new Label();
SuspendLayout();
//
// loading
//
loading.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
loading.AutoSize = true;
loading.Font = new Font("Microsoft YaHei UI", 20F);
loading.ForeColor = Color.White;
loading.Location = new Point(711, 604);
loading.Name = "loading";
loading.Size = new Size(208, 52);
loading.TabIndex = 0;
loading.Text = "Loading...";
loading.Visible = false;
//
// BufferForm
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ActiveCaptionText;
Controls.Add(loading);
Name = "BufferForm";
Size = new Size(1012, 710);
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label loading;
}
}
+101
View File
@@ -0,0 +1,101 @@
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();
}
public void SetEffect(Color begin, Color end, bool havePicture, Image? picture)
{
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());
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+88
View File
@@ -0,0 +1,88 @@
namespace CDSAE3_Lian_Lian_Kan.Forms
{
partial class Charts
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
= new Label();
back = new PictureBox();
tablePanel = new Panel();
((System.ComponentModel.ISupportInitialize)back).BeginInit();
SuspendLayout();
//
// 排行榜
//
.AutoSize = true;
.Font = new Font("Microsoft YaHei UI", 20F);
.Location = new Point(649, 18);
.Name = "排行榜";
.Size = new Size(142, 52);
.TabIndex = 1;
.Text = "排行榜";
//
// back
//
back.Image = Properties.Resources.left_arrow;
back.Location = new Point(37, 18);
back.Name = "back";
back.Size = new Size(75, 75);
back.SizeMode = PictureBoxSizeMode.Zoom;
back.TabIndex = 3;
back.TabStop = false;
back.Click += back_Click;
//
// tablePanel
//
tablePanel.AutoScroll = true;
tablePanel.Location = new Point(37, 132);
tablePanel.Name = "tablePanel";
tablePanel.Size = new Size(1323, 720);
tablePanel.TabIndex = 5;
//
// Charts
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(249, 211, 171);
ClientSize = new Size(1418, 904);
Controls.Add(tablePanel);
Controls.Add(back);
Controls.Add();
FormBorderStyle = FormBorderStyle.None;
Name = "Charts";
Text = "charts";
((System.ComponentModel.ISupportInitialize)back).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label ;
private PictureBox back;
private Panel tablePanel;
}
}
+129
View File
@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
using System.Threading.Tasks;
using System.Windows.Forms;
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
using static CDSAE3_Lian_Lian_Kan.Etcs;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class Charts : Form, IThemeChangeable
{
private int[] _width = { 504, 328, 156, 157, 178 };
private int _top = 0, _left = 0;
public Charts()
{
InitializeComponent();
scoreRecord = JsonSerializer.Deserialize<Etcs.ScoreRecord>(File.ReadAllText("Resources\\charts.json"), new JsonSerializerOptions()
{
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
})!;
}
private Label[] LabelsMaker(string[] info, int height, Color? color, Font? font)
{
int oriHeight = height;
color ??= Color.FromArgb(0, 0, 0, 0);
List<Label> labels = new();
int temp_left = _left;
for (int i = 0; i < 5; i++)
{
labels.Add(new Label { Text = info[i], Width = _width[i], Height = height, Left = temp_left, Top = _top, BackColor = color.Value, Font = font, TextAlign = ContentAlignment.MiddleCenter });
temp_left += _width[i];
height = Math.Max(labels[i].Height, height);
tablePanel.Controls.Add(labels[i]);
}
if (oriHeight < height)
foreach (var item in labels)
item.Height = height;
_top += height;
return labels.ToArray();
}
ScoreRecord scoreRecord;
public void Init()
{
var lt = scoreRecord.RecordInfos;
if (lt == null || lt.Count == 0)
return;
lt = lt.OrderByDescending(x => x.Score).ToList();
for (int i = 1; i <= lt.Count; i++)
{
List<string> strings = new List<string>();
strings.Add(lt[i - 1].Name!);
strings.Add(string.Format("{0:yyyy}-" + "{0:MM}-" + "{0:dd}" + " {0:HH}:{0:mm}", lt[i - 1].Time));
strings.Add($"{lt[i - 1].CostTime!.Value / 60}:{((lt[i - 1].CostTime!.Value % 60) < 10 ? ("0" + (lt[i - 1].CostTime!.Value % 60).ToString()) : (lt[i - 1].CostTime!.Value % 60).ToString())}");
strings.Add(lt[i - 1].Score.ToString()!);
strings.Add(lt[i - 1].Difficulty!);
Invoke(() => LabelsMaker(strings.ToArray(), 60, null, Font = new Font("Microsoft YaHei UI", 18F)));
//Invoke(() => table.RowStyles.Add(new RowStyle(SizeType.Absolute, 60)));
//var x = new Label { Text = lt[i - 1].Name, Font = new Font("Microsoft YaHei UI", 18F) };
//x.Dock = DockStyle.Fill;
//Invoke(() => table.Controls.Add(x, 0, i));
//x = new Label { Text = string.Format("{0:yyyy}-" + "{0:MM}-" + "{0:dd}" + " {0:HH}:{0:mm}", lt[i - 1].Time), Font = new Font("Microsoft YaHei UI", 18F) };
//x.Dock = DockStyle.Fill;
//Invoke(() => table.Controls.Add(x, 1, i));
//int t = lt[i - 1].CostTime!.Value;
//x = new Label { Text = $"{t / 60}:{((t % 60) < 10 ? ("0" + (t % 60).ToString()) : (t % 60).ToString())}", Font = new Font("Microsoft YaHei UI", 18F) };
//x.Dock = DockStyle.Fill;
//Invoke(() => table.Controls.Add(x, 2, i));
//x = new Label { Text = lt[i - 1].Score.ToString(), Font = new Font("Microsoft YaHei UI", 18F) };
//x.Dock = DockStyle.Fill;
//Invoke(() => table.Controls.Add(x, 3, i));
//x = new Label { Text = lt[i - 1].Difficulty, Font = new Font("Microsoft YaHei UI", 18F) };
//x.Dock = DockStyle.Fill;
//Invoke(() => table.Controls.Add(x, 4, i));
}
Console.WriteLine("Charts Fill done");
}
public void AddRecord(Etcs.RecordInfo recordInfo)
{
scoreRecord.RecordInfos!.Add(recordInfo);
using StreamWriter fileWriter = new StreamWriter("Resources\\charts.json");
fileWriter.Write(JsonSerializer.Serialize(scoreRecord, new JsonSerializerOptions { WriteIndented = true }));
}
public void SetTheme()
{
//(30,135) 504 328 156 157 178
Etcs.ThemeInfo themeInfo = Etcs.currentThemeInfo;
BackColor = Color.FromArgb(themeInfo.ThemeColor![0], themeInfo.ThemeColor[1], themeInfo.ThemeColor[2]);
string[] title_info = { "姓名", "完成时间", "用时", "分数", "难度" };
if (themeInfo.ThemeColor[0] < themeInfo.ThemeColor[2])
{
LabelsMaker(title_info, 65, Color.FromArgb(50, 255, 255, 255), Font = new Font("Microsoft YaHei UI", 18F));
tablePanel.BackColor = Color.FromArgb(50, 255, 255, 255);
}
else
{
LabelsMaker(title_info, 65, Color.FromArgb(50, 0, 0, 0), Font = new Font("Microsoft YaHei UI", 18F));
tablePanel.BackColor = Color.FromArgb(50, 0, 0, 0);
}
if (themeInfo.PlayPanelUsePicture)
{
if (themeInfo.PlayPanelPictureIsOutPicture)
BackgroundImage = new Bitmap(themeInfo.PlayPanelPictureName!);
else
BackgroundImage = (Image)Etcs.res_Manager.GetObject(themeInfo.PictureName!, Etcs.res_Culture)!;
back.BackColor = Color.FromArgb(0, 0, 0, 0);
.BackColor = Color.FromArgb(0, 0, 0, 0);
}
Thread initThread = new Thread(Init);
initThread.Start();
}
private async void back_Click(object sender, EventArgs e)
{
Thread thread= new Thread(()=>Invoke(()=>tablePanel.Controls.Clear()));
_left = _top = 0;
await Etcs.form!.change_form((Etcs.gameMenuForm as Form)!, false, null, null, false, null);
thread.Start();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+101
View File
@@ -0,0 +1,101 @@
namespace CDSAE3_Lian_Lian_Kan.Forms
{
partial class FinishedMessageBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
info = new Label();
nameTextBox = new TextBox();
scoreLabel = new Label();
= new Button();
SuspendLayout();
//
// info
//
info.AutoSize = true;
info.Font = new Font("Microsoft YaHei UI", 20F);
info.Location = new Point(124, 36);
info.Name = "info";
info.Size = new Size(394, 52);
info.TabIndex = 0;
info.Text = "恭喜 请留下你的名字";
//
// nameTextBox
//
nameTextBox.Font = new Font("Microsoft YaHei UI", 18F, FontStyle.Italic, GraphicsUnit.Point, 134);
nameTextBox.ForeColor = SystemColors.ScrollBar;
nameTextBox.Location = new Point(112, 192);
nameTextBox.Name = "nameTextBox";
nameTextBox.Size = new Size(424, 53);
nameTextBox.TabIndex = 1;
nameTextBox.Text = "Anonymous";
nameTextBox.Enter += nameTextBox_Enter;
//
// scoreLabel
//
scoreLabel.AutoSize = true;
scoreLabel.Font = new Font("Microsoft YaHei UI", 15F);
scoreLabel.Location = new Point(210, 114);
scoreLabel.Name = "scoreLabel";
scoreLabel.Size = new Size(197, 39);
scoreLabel.TabIndex = 2;
scoreLabel.Text = "分数:66666";
//
// 确定
//
.Location = new Point(257, 273);
.Name = "确定";
.Size = new Size(112, 34);
.TabIndex = 3;
.Text = "确定";
.UseVisualStyleBackColor = true;
.Click += _Click;
//
// FinishedMessageBox
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(627, 343);
Controls.Add();
Controls.Add(scoreLabel);
Controls.Add(nameTextBox);
Controls.Add(info);
FormBorderStyle = FormBorderStyle.SizableToolWindow;
Name = "FinishedMessageBox";
Text = "游戏结束";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label info;
private TextBox nameTextBox;
private Label scoreLabel;
private Button ;
}
}
@@ -0,0 +1,43 @@
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 FinishedMessageBox : Form
{
public FinishedMessageBox()
{
InitializeComponent();
}
int score = 0;
int costTime = 0;
public FinishedMessageBox(int score,int costTime)
{
InitializeComponent();
this.score = score;
this.costTime = costTime;
scoreLabel.Text = "分数:" + score.ToString();
scoreLabel.Location = new Point((649 - scoreLabel.Size.Width) / 2, scoreLabel.Location.Y);
}
private void nameTextBox_Enter(object sender, EventArgs e)
{
nameTextBox.Font = new Font("Microsoft YaHei UI", 15F);
nameTextBox.ForeColor = Color.FromArgb(0,0,0);
nameTextBox.Text = "";
}
private void _Click(object sender, EventArgs e)
{
Etcs.charts.AddRecord(new Etcs.RecordInfo { Name = nameTextBox.Text==""?"Anonymous": nameTextBox.Text ,Score = score,Time = DateTime.Now,CostTime = costTime,Difficulty = Etcs.current_difficulty.ToString()});
Close();
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+3
View File
@@ -29,6 +29,7 @@
private void InitializeComponent()
{
playPanel = new TableLayoutPanel();
initWorker = new System.ComponentModel.BackgroundWorker();
SuspendLayout();
//
// playPanel
@@ -52,11 +53,13 @@
Controls.Add(playPanel);
Name = "GameControl";
Size = new Size(1400, 800);
Load += GameControl_Load;
ResumeLayout(false);
}
#endregion
private TableLayoutPanel playPanel;
private System.ComponentModel.BackgroundWorker initWorker;
}
}
+36 -8
View File
@@ -1,4 +1,5 @@
using CDSAE3_Lian_Lian_Kan.Boards;
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -25,10 +26,36 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
{
InitializeComponent();
DoubleBuffered = true;
Etcs.game_form = this;
playPanel_set(board.make_board());
iGameMode = Etcs.game_mode_form;
initWorker.WorkerReportsProgress = true;
initWorker.WorkerSupportsCancellation = true;
initWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWorker);
initWorker.RunWorkerCompleted += InitWorker_RunWorkerCompleted;
Etcs.gameForm = this;
iGameMode = Etcs.gameModeForm;
}
private void InitWorker_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
{
Etcs.loadFinished = true;
}
public void GameControl_Load(object sender, EventArgs e)
{
Console.WriteLine("start");
Etcs.loadFinished = false;
initWorker.RunWorkerAsync();
Console.WriteLine("end");
}
protected override void OnPaint(PaintEventArgs e)
{
Console.WriteLine(e);
base.OnPaint(e);
}
private void bgWorker_DoWorker(object? sender, DoWorkEventArgs e)
{
playPanel_set(board.make_board());
}
void playPanel_set(int[,] bd)
{
playPanel.SuspendLayout();
@@ -36,20 +63,21 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
for (int i = 0; i < playPanel.RowCount; i++)
for (int j = 0; j < playPanel.ColumnCount; j++)
{
Console.WriteLine(i.ToString() + j.ToString());
if (bd[i, j] == -1)
{
var x = new Single_Block(Etcs.trans_Image, (j, i));
x.Dock = DockStyle.Fill;
playPanel.Controls.Add(x, j, i);
Invoke(() => playPanel.Controls.Add(x, j, i));
}
else
{
var x = new Single_Block(bd[i, j], Etcs.def_Color, Etcs.sel_Color, (j, i));
x.Dock = DockStyle.Fill;
playPanel.Controls.Add(x, j, i);
Invoke(() => playPanel.Controls.Add(x, j, i));
}
}
playPanel.ResumeLayout();
Invoke(() => playPanel.ResumeLayout());
}
/// <summary>
/// 由form和to两个点获取方向
@@ -153,8 +181,8 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
}
internal void de_set_tip()
{
foreach (var control in hint_blocks)
control.de_path();
for (int i = 0; i < hint_blocks.Count; i++)
hint_blocks[i].de_path();
hint_blocks.Clear();
}
public void Selected_Handler(Single_Block sender, SelectedEventArgs e)
@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="initWorker.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -3,8 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CDSAE3_Lian_Lian_Kan.Forms
namespace CDSAE3_Lian_Lian_Kan.Forms.Interface
{
public interface IGameControl
{
@@ -12,7 +11,7 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
public void Exchange_Handler(object? sender, EventArgs e);
public void Search_Handler(object? sender, SearchEventArgs e);
}
public class SearchEventArgs:EventArgs
public class SearchEventArgs : EventArgs
{
public bool set_search { get; set; } = false;//true : search
}
@@ -4,13 +4,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CDSAE3_Lian_Lian_Kan.Forms
namespace CDSAE3_Lian_Lian_Kan.Forms.Interface
{
public class AddScoreArgs : EventArgs
{
public int score { get; set; }
}
public class FinishArgs: EventArgs
public class FinishArgs : EventArgs
{
public enum Finish_Type
{
@@ -19,7 +19,7 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
}
public Finish_Type finish_Type { get; set; }
}
public interface IGameMode
public interface IGameMode : IThemeChangeable
{
public void De_pause(object sender, EventArgs e);
public void Score_Add(object sender, AddScoreArgs e);
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public interface IMenuForm:IThemeChangeable
{
public void playFormToMenu();
}
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public interface IThemeChangeable
{
public void SetTheme();
}
}
-1
View File
@@ -7,7 +7,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class Item : UserControl
+35 -36
View File
@@ -28,8 +28,6 @@
/// </summary>
private void InitializeComponent()
{
game_Panel = new Panel();
gameControl = new GameControl();
back = new PictureBox();
energy_bar = new ProgressBar();
Score_Label = new Label();
@@ -40,34 +38,18 @@
search = new PictureBox();
exchange = new PictureBox();
upper_search = new Item();
game_Panel.SuspendLayout();
game_Panel = new Panel();
gameControl = new GameControl();
((System.ComponentModel.ISupportInitialize)back).BeginInit();
((System.ComponentModel.ISupportInitialize)sp_button).BeginInit();
((System.ComponentModel.ISupportInitialize)search).BeginInit();
((System.ComponentModel.ISupportInitialize)exchange).BeginInit();
game_Panel.SuspendLayout();
SuspendLayout();
//
// game_Panel
//
game_Panel.BackColor = Color.FromArgb(50, 0, 0, 0);
game_Panel.Controls.Add(gameControl);
game_Panel.Location = new Point(20, 143);
game_Panel.Name = "game_Panel";
game_Panel.Size = new Size(1400, 800);
game_Panel.TabIndex = 0;
//
// gameControl
//
gameControl.BackColor = Color.FromArgb(0, 0, 0, 0);
gameControl.Dock = DockStyle.Fill;
gameControl.Location = new Point(0, 0);
gameControl.Name = "gameControl";
gameControl.Size = new Size(1400, 800);
gameControl.TabIndex = 0;
//
// back
//
back.BackColor = Color.FromArgb(249, 211, 171);
back.BackColor = Color.FromArgb(0, 0, 0, 0);
back.Image = Properties.Resources.left_arrow;
back.Location = new Point(30, 31);
back.Name = "back";
@@ -88,7 +70,7 @@
// Score_Label
//
Score_Label.AutoSize = true;
Score_Label.BackColor = Color.FromArgb(249, 211, 171);
Score_Label.BackColor = Color.FromArgb(0, 0, 0, 0);
Score_Label.Font = new Font("Microsoft YaHei UI", 18F);
Score_Label.Location = new Point(1093, 43);
Score_Label.Name = "Score_Label";
@@ -99,7 +81,7 @@
// factor
//
factor.AutoSize = true;
factor.BackColor = Color.FromArgb(249, 211, 171);
factor.BackColor = Color.FromArgb(0, 0, 0, 0);
factor.Font = new Font("Microsoft YaHei UI", 18F);
factor.Location = new Point(578, 42);
factor.Name = "factor";
@@ -110,7 +92,7 @@
// time
//
time.AutoSize = true;
time.BackColor = Color.FromArgb(249, 211, 171);
time.BackColor = Color.FromArgb(0, 0, 0, 0);
time.Font = new Font("Microsoft YaHei UI", 18F);
time.Location = new Point(195, 43);
time.Name = "time";
@@ -121,7 +103,7 @@
// score
//
score.AutoSize = true;
score.BackColor = Color.FromArgb(249, 211, 171);
score.BackColor = Color.FromArgb(0, 0, 0, 0);
score.Font = new Font("Microsoft YaHei UI", 18F);
score.Location = new Point(1214, 43);
score.Name = "score";
@@ -131,7 +113,7 @@
//
// sp_button
//
sp_button.BackColor = Color.FromArgb(249, 211, 171);
sp_button.BackColor = Color.FromArgb(0, 0, 0, 0);
sp_button.Image = Properties.Resources.play_buttton;
sp_button.Location = new Point(1350, 31);
sp_button.Name = "sp_button";
@@ -143,7 +125,7 @@
//
// search
//
search.BackColor = Color.FromArgb(249, 211, 171);
search.BackColor = Color.FromArgb(0, 0, 0, 0);
search.Image = Properties.Resources.search;
search.Location = new Point(360, 31);
search.Name = "search";
@@ -155,7 +137,7 @@
//
// exchange
//
exchange.BackColor = Color.FromArgb(249, 211, 171);
exchange.BackColor = Color.FromArgb(0, 0, 0, 0);
exchange.Image = Properties.Resources.exchange;
exchange.Location = new Point(455, 31);
exchange.Name = "exchange";
@@ -172,6 +154,25 @@
upper_search.Name = "upper_search";
upper_search.Size = new Size(70, 70);
upper_search.TabIndex = 12;
upper_search.Visible = false;
//
// game_Panel
//
game_Panel.BackColor = Color.FromArgb(50, 0, 0, 0);
game_Panel.Controls.Add(gameControl);
game_Panel.Location = new Point(20, 143);
game_Panel.Name = "game_Panel";
game_Panel.Size = new Size(1400, 800);
game_Panel.TabIndex = 0;
//
// gameControl
//
gameControl.BackColor = Color.FromArgb(0, 0, 0, 0);
gameControl.Dock = DockStyle.Fill;
gameControl.Location = new Point(0, 0);
gameControl.Name = "gameControl";
gameControl.Size = new Size(1400, 800);
gameControl.TabIndex = 13;
//
// Leisure_Mode
//
@@ -179,9 +180,7 @@
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(249, 211, 171);
ClientSize = new Size(1439, 960);
Controls.Add(upper_search);
Controls.Add(exchange);
Controls.Add(search);
Controls.Add(sp_button);
Controls.Add(score);
Controls.Add(time);
@@ -190,22 +189,21 @@
Controls.Add(energy_bar);
Controls.Add(back);
Controls.Add(game_Panel);
DoubleBuffered = true;
Controls.Add(upper_search);
Controls.Add(search);
FormBorderStyle = FormBorderStyle.None;
Name = "Leisure_Mode";
Text = "Leisure_Mode";
game_Panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)back).EndInit();
((System.ComponentModel.ISupportInitialize)sp_button).EndInit();
((System.ComponentModel.ISupportInitialize)search).EndInit();
((System.ComponentModel.ISupportInitialize)exchange).EndInit();
game_Panel.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private Panel game_Panel;
private PictureBox back;
private ProgressBar energy_bar;
private Label Score_Label;
@@ -215,7 +213,8 @@
private PictureBox sp_button;
private PictureBox search;
private PictureBox exchange;
private GameControl gameControl;
private Item upper_search;
private Panel game_Panel;
private GameControl gameControl;
}
}
+53 -39
View File
@@ -9,7 +9,10 @@ using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
using CDSAE3_Lian_Lian_Kan.Boards;
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
using CDSAE3_Lian_Lian_Kan.Properties;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static CDSAE3_Lian_Lian_Kan.Etcs;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
@@ -17,40 +20,17 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
{
public Leisure_Mode()
{
Etcs.game_mode_form = this;
Etcs.gameModeForm = this;
InitializeComponent();
upper_search.Item_Init(Resources.search, (70, 70),Color.FromArgb(253, 161, 60));
//Etcs.hunderd_millsecond_timer.Elapsed += hundred_millsecond_Timer_Tick;
upper_search.Item_Init(Resources.search, (70, 70), Color.FromArgb(253, 161, 60));
time.Text = (left_time / 60).ToString().PadLeft(2, '0') + ":" + (left_time % 60).ToString().PadLeft(2, '0');
upper_search_ori_position = upper_search.Location;
timer = new System.Timers.Timer(1000);
timer.Elapsed += Timer_Tick;
timer.Enabled = true;
timer.Enabled = false;
}
System.Timers.Timer timer;
int hundred_up_timer = 0;
//private void hundred_millsecond_Timer_Tick(object? sender, ElapsedEventArgs e)
//{
// if (_listening_timer)
// hundred_up_timer++;
// else
// return;
// //if(search_mode)
// //{
// // //down to up
// // //BeginInvoke(() => upper_search.Location = new Point(upper_search_ori_position.X, upper_search_ori_position.Y + (int)(70 * (search_left_time - hundred_up_timer * 0.1) / Etcs.search_left_time)));
// // //BeginInvoke(() => upper_search.set_progress(70-upper_search.Location.Y+upper_search_ori_position.Y));
// //}
// if (hundred_up_timer == 10)
// {
// BeginInvoke(() => upper_search.Location = new Point(upper_search_ori_position.X, upper_search_ori_position.Y + (int)(70 * (1 - ((search_left_time - hundred_up_timer * 0.1) / Etcs.search_left_time)))));
// BeginInvoke(() => upper_search.set_progress(70 - upper_search.Location.Y + upper_search_ori_position.Y));
// hundred_up_timer = 0;
// Timer_Tick(sender, e);
// }
//}
Point upper_search_ori_position;
int left_time = Etcs.left_time;
bool is_pause = true;
@@ -64,7 +44,7 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
{
left_time--;
BeginInvoke(() => time.Text = (left_time / 60).ToString().PadLeft(2, '0') + ":" + (left_time % 60).ToString().PadLeft(2, '0'));
if(search_mode)
if (search_mode)
{
search_left_time--;
if (search_left_time < 0)
@@ -72,9 +52,12 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
search_mode = false;
gameControl.Search_Handler(this, new SearchEventArgs { set_search = false });
BeginInvoke(() => upper_search.set_progress(0));
BeginInvoke(() => upper_search.Visible = false);
}
SuspendLayout();
BeginInvoke(() => upper_search.Location = new Point(upper_search_ori_position.X, upper_search_ori_position.Y + (int)(70 * (1 - ((search_left_time - hundred_up_timer * 0.1) / Etcs.search_left_time)))));
BeginInvoke(() => upper_search.set_progress(70 - upper_search.Location.Y + upper_search_ori_position.Y));
ResumeLayout();
}
if (current_base <= 0)
{
@@ -106,6 +89,11 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
if (is_pause)
Sp_button_Click(sender, e);
}
public void Do_pause(object sender,EventArgs e)
{
if (!is_pause)
Sp_button_Click(sender, e);
}
public void Score_Add(object sender, AddScoreArgs e)
{
@@ -145,25 +133,35 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
}
public void Finished_Handler(object sender, FinishArgs e)
{
//TODO finish form
switch (e.finish_Type)
BeginInvoke(() =>
{
case FinishArgs.Finish_Type.All_done:
MessageBox.Show("Congratulation!");
break;
case FinishArgs.Finish_Type.Time_out:
MessageBox.Show("Time Out!");
break;
}
timer.Close();
switch (e.finish_Type)
{
case FinishArgs.Finish_Type.All_done:
Do_pause(this, new EventArgs());
Form form = new FinishedMessageBox(cur_score, Etcs.left_time - left_time);
form.FormClosed += ((sender, args) => {
Dispose();
Close();
Etcs.form?.change_form(charts, false, null, null, false, null); });
form.ShowDialog();
break;
case FinishArgs.Finish_Type.Time_out:
Thread thread = new Thread(() => MessageBox.Show("时间到!"));
thread.Start();
back_Click(this, new EventArgs());
break;
}
});
}
private void back_Click(object sender, EventArgs e)
{
Dispose();
Close();
//Etcs.hunderd_millsecond_timer.Elapsed -= hundred_millsecond_Timer_Tick;
timer.Close();
Etcs.form?.change_form(new Leisure_Mode_MenuForm());
Etcs.gameMenuForm!.playFormToMenu();
}
private void exchange_Click(object sender, EventArgs e)
@@ -173,9 +171,25 @@ namespace CDSAE3_Lian_Lian_Kan.Forms
private void search_Click(object sender, EventArgs e)
{
gameControl.Search_Handler(this, new SearchEventArgs { set_search = true});
gameControl.Search_Handler(this, new SearchEventArgs { set_search = true });
search_mode = true;
search_left_time = Etcs.search_left_time;
upper_search.Visible = true;
}
public void SetTheme()
{
Etcs.ThemeInfo themeInfo = Etcs.currentThemeInfo;
BackColor = Color.FromArgb(themeInfo.ThemeColor![0], themeInfo.ThemeColor[1], themeInfo.ThemeColor[2]);
gameControl.BackColor = BackColor;
//gameControl.BackgroundImage = (Image)res_Manager.GetObject(themeInfo.PictureName!, Etcs.res_Culture)!;
if (themeInfo.PlayPanelUsePicture)
{
if (themeInfo.PlayPanelPictureIsOutPicture)
BackgroundImage = new Bitmap(themeInfo.PlayPanelPictureName!);
else
BackgroundImage = (Image)res_Manager.GetObject(themeInfo.PictureName!, Etcs.res_Culture)!;
}
}
}
}
+28 -10
View File
@@ -32,35 +32,38 @@
to_settings = new Button();
start_Game = new Button();
to_Challenge_mode = new Button();
mainLabel = new Label();
SuspendLayout();
//
// to_table_of_scores
//
to_table_of_scores.BackColor = Color.FromArgb(249, 211, 171);
to_table_of_scores.BackColor = Color.White;
to_table_of_scores.Font = new Font("Microsoft YaHei UI", 18F);
to_table_of_scores.Location = new Point(939, 363);
to_table_of_scores.Location = new Point(934, 695);
to_table_of_scores.Name = "to_table_of_scores";
to_table_of_scores.Size = new Size(172, 65);
to_table_of_scores.TabIndex = 0;
to_table_of_scores.Text = "分榜";
to_table_of_scores.Text = "分榜";
to_table_of_scores.UseVisualStyleBackColor = false;
to_table_of_scores.Click += to_table_of_scores_Click;
//
// to_settings
//
to_settings.BackColor = Color.FromArgb(249, 211, 171);
to_settings.BackColor = Color.White;
to_settings.Font = new Font("Microsoft YaHei UI", 18F);
to_settings.Location = new Point(939, 505);
to_settings.Location = new Point(934, 549);
to_settings.Name = "to_settings";
to_settings.Size = new Size(172, 65);
to_settings.TabIndex = 1;
to_settings.Text = "设置";
to_settings.UseVisualStyleBackColor = false;
to_settings.Click += to_settings_Click;
//
// start_Game
//
start_Game.BackColor = Color.FromArgb(249, 211, 171);
start_Game.BackColor = Color.White;
start_Game.Font = new Font("Microsoft YaHei UI", 18F);
start_Game.Location = new Point(354, 363);
start_Game.Location = new Point(934, 268);
start_Game.Name = "start_Game";
start_Game.Size = new Size(172, 65);
start_Game.TabIndex = 2;
@@ -70,25 +73,39 @@
//
// to_Challenge_mode
//
to_Challenge_mode.BackColor = Color.FromArgb(249, 211, 171);
to_Challenge_mode.BackColor = Color.White;
to_Challenge_mode.Font = new Font("Microsoft YaHei UI", 18F);
to_Challenge_mode.Location = new Point(354, 505);
to_Challenge_mode.Location = new Point(934, 404);
to_Challenge_mode.Name = "to_Challenge_mode";
to_Challenge_mode.Size = new Size(172, 65);
to_Challenge_mode.TabIndex = 3;
to_Challenge_mode.Text = "挑战模式";
to_Challenge_mode.UseVisualStyleBackColor = false;
//
// mainLabel
//
mainLabel.BackColor = Color.FromArgb(0, 0, 0, 0);
mainLabel.Font = new Font("Microsoft YaHei UI", 50F);
mainLabel.ForeColor = Color.FromArgb(255, 192, 128);
mainLabel.Location = new Point(850, 80);
mainLabel.Name = "mainLabel";
mainLabel.Size = new Size(373, 151);
mainLabel.TabIndex = 4;
mainLabel.Text = "连连看";
//
// Leisure_Mode_MenuForm
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.MainPicture;
BackgroundImage = Properties.Resources.Fern;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(1440, 960);
Controls.Add(mainLabel);
Controls.Add(to_Challenge_mode);
Controls.Add(start_Game);
Controls.Add(to_settings);
Controls.Add(to_table_of_scores);
DoubleBuffered = true;
FormBorderStyle = FormBorderStyle.None;
Name = "Leisure_Mode_MenuForm";
Text = "MenuForm";
@@ -101,5 +118,6 @@
private Button to_settings;
private Button start_Game;
private Button to_Challenge_mode;
private Label mainLabel;
}
}
@@ -1,27 +1,73 @@
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
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class Leisure_Mode_MenuForm : Form
public partial class Leisure_Mode_MenuForm : Form, IMenuForm
{
public Leisure_Mode_MenuForm()
{
InitializeComponent();
Etcs.gameMenuForm = this;
Etcs.song_Audio_Processer.set_albums("C418");
Etcs.song_Audio_Processer.set_song(Etcs.song_Audio_Processer.get_next_song());
SetTheme();
}
Color menuThemeColor, playThemeColor;
bool IsOutPicture = false;
bool AnimationUseImage = false;
Image? playPanelImage;
public void SetTheme()
{
Etcs.ThemeInfo theme = Etcs.currentThemeInfo;
AnimationUseImage = theme.AnimationUseImage;
IsOutPicture = theme.IsOutPicture;
if (IsOutPicture)
BackgroundImage = new Bitmap(theme.PictureName!);
else
BackgroundImage = (Image)Etcs.res_Manager.GetObject(theme.PictureName!, Etcs.res_Culture)!;
if (theme.PlayPanelUsePicture)
if (theme.PlayPanelPictureIsOutPicture)
playPanelImage = new Bitmap(theme.PlayPanelPictureName!);
else
playPanelImage = (Image)Etcs.res_Manager.GetObject(theme.PlayPanelPictureName!, Etcs.res_Culture)!;
start_Game.Location = new Point(theme.StartGamePos![0], theme.StartGamePos[1]);
to_Challenge_mode.Location = new Point(theme.ChallengeModePos![0], theme.ChallengeModePos[1]);
to_table_of_scores.Location = new Point(theme.ScoreBoardPos![0], theme.ScoreBoardPos[1]);
to_settings.Location = new Point(theme.SettingsPos![0], theme.SettingsPos[1]);
menuThemeColor = Color.FromArgb(theme.ThemeColor![0], theme.ThemeColor[1], theme.ThemeColor[2]);
Color buttonColor = theme.ButtonColor!.Count == 3 ? Color.FromArgb(theme.ButtonColor![0], theme.ButtonColor![1], theme.ButtonColor![2]) :
Color.FromArgb(theme.ButtonColor![0], theme.ButtonColor![1], theme.ButtonColor![2], theme.ButtonColor![3]);
playThemeColor = Color.FromArgb(theme.PlayAreaThemeColor![0], theme.PlayAreaThemeColor[1], theme.PlayAreaThemeColor[2]);
start_Game.BackColor = buttonColor;
to_Challenge_mode.BackColor = buttonColor;
to_table_of_scores.BackColor = buttonColor;
to_settings.BackColor = buttonColor;
start_Game.Size = new Size(theme.ButtonSize![0], theme.ButtonSize[1]);
to_Challenge_mode.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
to_table_of_scores.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
to_settings.Size = new Size(theme.ButtonSize[0], theme.ButtonSize[1]);
mainLabel.Font = new Font(theme.Font!, float.Parse(theme.FontSize!));
mainLabel.BackColor = buttonColor;
mainLabel.ForeColor = Color.FromArgb(theme.FontColor![0], theme.FontColor[1], theme.FontColor[2]);
mainLabel.Location = new Point(theme.FontBlockPos![0], theme.FontBlockPos[1]);
mainLabel.Size = new Size(theme.FontBlockSize![0], theme.FontBlockSize[1]);
}
public void playFormToMenu()
{
Etcs.form?.change_form(this, true, playThemeColor, menuThemeColor, AnimationUseImage, playPanelImage!);
}
private void start_Game_Click(object sender, EventArgs e)
{
Etcs.form?.change_form(new Leisure_Mode());
Etcs.form?.change_form(new Leisure_Mode(), true, menuThemeColor, playThemeColor, AnimationUseImage, this.BackgroundImage);
}
private void to_settings_Click(object sender, EventArgs e)
{
Etcs.form?.change_form(Etcs.setting, false, null, null, false, null);
}
private void to_table_of_scores_Click(object sender, EventArgs e)
{
Etcs.form?.change_form(Etcs.charts, false, null, null, false, null);
}
}
}
+14 -1
View File
@@ -1,4 +1,4 @@
namespace CDSAE3_Lian_Lian_Kan
namespace CDSAE3_Lian_Lian_Kan.Forms
{
partial class LianLianKan
{
@@ -29,6 +29,7 @@
private void InitializeComponent()
{
MainPanel = new Panel();
bufferForm = new BufferForm();
SuspendLayout();
//
// MainPanel
@@ -40,12 +41,23 @@
MainPanel.Size = new Size(1440, 960);
MainPanel.TabIndex = 0;
//
// bufferForm
//
bufferForm.BackColor = SystemColors.ActiveCaptionText;
bufferForm.Dock = DockStyle.Fill;
bufferForm.Location = new Point(0, 0);
bufferForm.Name = "bufferForm";
bufferForm.Size = new Size(1440, 960);
bufferForm.TabIndex = 0;
bufferForm.Visible = false;
//
// LianLianKan
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1440, 960);
Controls.Add(MainPanel);
Controls.Add(bufferForm);
DoubleBuffered = true;
MaximumSize = new Size(1462, 1016);
MinimumSize = new Size(1462, 1016);
@@ -57,5 +69,6 @@
#endregion
private Panel MainPanel;
private BufferForm bufferForm;
}
}
+33 -12
View File
@@ -1,27 +1,48 @@
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;
namespace CDSAE3_Lian_Lian_Kan
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class LianLianKan : Form
{
public LianLianKan()
{
InitializeComponent();
current_form = this;
change_form(new Leisure_Mode_MenuForm());
Etcs.hunderd_millsecond_timer.Elapsed += StartFunc;
Etcs.form = this;
}
Form current_form;
public void change_form(Form form)
private void StartFunc(object? Sender, EventArgs e)
{
if (current_form == form)
return;
current_form = form;
Etcs.hunderd_millsecond_timer.Elapsed -= StartFunc;
Form? menuForm = null;
Invoke(() => menuForm = new Leisure_Mode_MenuForm());
Invoke(() => change_form(menuForm!, false, null, null, false, null));
}
public async Task change_form(Form newForm, bool doAnimation, Color? begin, Color? end, bool haveImage, Image? image)
{
if (doAnimation)
{
bufferForm.SetEffect(begin!.Value, end!.Value, haveImage, image);
bufferForm.BringToFront();
bufferForm.Visible = true;
}
MainPanel.Controls.Clear();
form.TopLevel = false;
form.Dock = DockStyle.Fill;
MainPanel.Controls.Add(form);
form.Show();
newForm.TopLevel = false;
newForm.Dock = DockStyle.Fill;
(newForm as IThemeChangeable)?.SetTheme();
MainPanel.Controls.Add(newForm);
BeginInvoke(() => newForm.Show());
MainPanel.SendToBack();
if (doAnimation)
{
await bufferForm.EffectAsync();
bufferForm.Visible = false;
}
GC.Collect();
}
}
+552 -1
View File
@@ -28,18 +28,569 @@
/// </summary>
private void InitializeComponent()
{
back = new PictureBox();
= new Label();
contextPanel = new Panel();
button1 = new Button();
= new Label();
themeSelector = new ComboBox();
= new Label();
albumSelector = new ComboBox();
psButton = new PictureBox();
nextSong = new PictureBox();
lastSong = new PictureBox();
songName = new Label();
= new Label();
= new Label();
soundScapeVolumeText = new TextBox();
songVolumeText = new TextBox();
soundScapeVolume = new TrackBar();
= new Label();
= new Label();
musicVolume = new TrackBar();
= new Label();
groupDifficulty = new GroupBox();
time = new TextBox();
= new Label();
x4 = new Label();
x2 = new Label();
x3 = new Label();
x1 = new Label();
hardHeight = new Label();
normalHeight = new Label();
easyHeight = new Label();
hardWidth = new Label();
normalWidth = new Label();
easyWidth = new Label();
cusHeight = new TextBox();
cusWidth = new TextBox();
custom = new RadioButton();
hard = new RadioButton();
normal = new RadioButton();
easy = new RadioButton();
((System.ComponentModel.ISupportInitialize)back).BeginInit();
contextPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)psButton).BeginInit();
((System.ComponentModel.ISupportInitialize)nextSong).BeginInit();
((System.ComponentModel.ISupportInitialize)lastSong).BeginInit();
((System.ComponentModel.ISupportInitialize)soundScapeVolume).BeginInit();
((System.ComponentModel.ISupportInitialize)musicVolume).BeginInit();
groupDifficulty.SuspendLayout();
SuspendLayout();
//
// back
//
back.BackColor = Color.FromArgb(0, 0, 0, 0);
back.Image = Properties.Resources.left_arrow;
back.Location = new Point(27, 18);
back.Name = "back";
back.Size = new Size(60, 60);
back.SizeMode = PictureBoxSizeMode.Zoom;
back.TabIndex = 20;
back.TabStop = false;
back.Click += back_ClickAsync;
//
// 设置
//
.AutoSize = true;
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 20F);
.Location = new Point(670, 26);
.Name = "设置";
.Size = new Size(102, 52);
.TabIndex = 22;
.Text = "设置";
//
// contextPanel
//
contextPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
contextPanel.BackColor = SystemColors.ScrollBar;
contextPanel.Controls.Add(button1);
contextPanel.Controls.Add();
contextPanel.Controls.Add(themeSelector);
contextPanel.Controls.Add();
contextPanel.Controls.Add(albumSelector);
contextPanel.Controls.Add(psButton);
contextPanel.Controls.Add(nextSong);
contextPanel.Controls.Add(lastSong);
contextPanel.Controls.Add(songName);
contextPanel.Controls.Add();
contextPanel.Controls.Add();
contextPanel.Controls.Add(soundScapeVolumeText);
contextPanel.Controls.Add(songVolumeText);
contextPanel.Controls.Add(soundScapeVolume);
contextPanel.Controls.Add();
contextPanel.Controls.Add();
contextPanel.Controls.Add(musicVolume);
contextPanel.Controls.Add();
contextPanel.Controls.Add(groupDifficulty);
contextPanel.Location = new Point(71, 103);
contextPanel.Name = "contextPanel";
contextPanel.Size = new Size(1219, 1209);
contextPanel.TabIndex = 21;
//
// button1
//
button1.AutoSize = true;
button1.BackColor = Color.FromArgb(0, 0, 0, 0);
button1.Font = new Font("Microsoft YaHei UI", 15F);
button1.Location = new Point(499, 824);
button1.Name = "button1";
button1.Size = new Size(177, 49);
button1.TabIndex = 34;
button1.Text = "创建新主题";
button1.UseVisualStyleBackColor = false;
//
// 当前主题
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 829);
.Name = "当前主题";
.Size = new Size(171, 45);
.TabIndex = 33;
.Text = "当前主题:";
//
// themeSelector
//
themeSelector.FormattingEnabled = true;
themeSelector.Location = new Point(264, 833);
themeSelector.Name = "themeSelector";
themeSelector.Size = new Size(182, 32);
themeSelector.TabIndex = 32;
themeSelector.SelectedIndexChanged += themeSelector_SelectedIndexChanged;
//
// 主题
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 763);
.Name = "主题";
.Size = new Size(83, 36);
.TabIndex = 31;
.Text = "主题";
//
// albumSelector
//
albumSelector.FormattingEnabled = true;
albumSelector.Location = new Point(364, 599);
albumSelector.Name = "albumSelector";
albumSelector.Size = new Size(182, 32);
albumSelector.TabIndex = 30;
albumSelector.SelectedIndexChanged += albumSelector_SelectedIndexChanged;
//
// psButton
//
psButton.BackColor = Color.FromArgb(0, 0, 0, 0);
psButton.Image = Properties.Resources.pause;
psButton.Location = new Point(380, 665);
psButton.Name = "psButton";
psButton.Size = new Size(60, 60);
psButton.SizeMode = PictureBoxSizeMode.Zoom;
psButton.TabIndex = 29;
psButton.TabStop = false;
psButton.Click += psButton_Click;
//
// nextSong
//
nextSong.Image = Properties.Resources.next;
nextSong.Location = new Point(499, 665);
nextSong.Name = "nextSong";
nextSong.Size = new Size(60, 60);
nextSong.SizeMode = PictureBoxSizeMode.Zoom;
nextSong.TabIndex = 28;
nextSong.TabStop = false;
nextSong.Click += nextSong_Click;
//
// lastSong
//
lastSong.BackColor = Color.FromArgb(0, 0, 0, 0);
lastSong.Image = Properties.Resources.last;
lastSong.Location = new Point(260, 665);
lastSong.Name = "lastSong";
lastSong.Size = new Size(60, 60);
lastSong.SizeMode = PictureBoxSizeMode.Zoom;
lastSong.TabIndex = 27;
lastSong.TabStop = false;
lastSong.Click += lastSong_Click;
//
// songName
//
songName.BackColor = Color.FromArgb(0, 0, 0, 0);
songName.Font = new Font("Microsoft YaHei UI", 15F);
songName.Location = new Point(593, 594);
songName.Name = "songName";
songName.Size = new Size(695, 45);
songName.TabIndex = 26;
songName.Text = "歌曲:";
//
// 专辑
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(260, 594);
.Name = "专辑";
.Size = new Size(109, 45);
.TabIndex = 25;
.Text = "专辑:";
//
// 当前播放
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 594);
.Name = "当前播放";
.Size = new Size(171, 45);
.TabIndex = 24;
.Text = "当前播放:";
//
// soundScapeVolumeText
//
soundScapeVolumeText.BackColor = Color.FromArgb(199, 161, 121);
soundScapeVolumeText.BorderStyle = BorderStyle.FixedSingle;
soundScapeVolumeText.Font = new Font("Microsoft YaHei UI", 15F);
soundScapeVolumeText.Location = new Point(810, 521);
soundScapeVolumeText.Name = "soundScapeVolumeText";
soundScapeVolumeText.Size = new Size(96, 46);
soundScapeVolumeText.TabIndex = 23;
soundScapeVolumeText.Text = "60";
soundScapeVolumeText.TextChanged += soundScapeVolumeText_TextChanged;
//
// songVolumeText
//
songVolumeText.BackColor = Color.FromArgb(199, 161, 121);
songVolumeText.BorderStyle = BorderStyle.FixedSingle;
songVolumeText.Font = new Font("Microsoft YaHei UI", 15F);
songVolumeText.Location = new Point(810, 452);
songVolumeText.Name = "songVolumeText";
songVolumeText.Size = new Size(96, 46);
songVolumeText.TabIndex = 18;
songVolumeText.Text = "60";
songVolumeText.TextChanged += songVolumeText_TextChanged;
//
// soundScapeVolume
//
soundScapeVolume.Location = new Point(260, 524);
soundScapeVolume.Maximum = 100;
soundScapeVolume.Name = "soundScapeVolume";
soundScapeVolume.Size = new Size(544, 69);
soundScapeVolume.TabIndex = 22;
soundScapeVolume.Value = 60;
soundScapeVolume.Scroll += soundScapeVolume_Scroll;
//
// 音效音量
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 524);
.Name = "音效音量";
.Size = new Size(143, 43);
.TabIndex = 21;
.Text = "音效音量";
//
// 音乐音量
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 452);
.Name = "音乐音量";
.Size = new Size(143, 43);
.TabIndex = 20;
.Text = "音乐音量";
//
// musicVolume
//
musicVolume.Location = new Point(260, 452);
musicVolume.Maximum = 100;
musicVolume.Name = "musicVolume";
musicVolume.Size = new Size(544, 69);
musicVolume.TabIndex = 19;
musicVolume.Value = 60;
musicVolume.Scroll += musicVolume_Scroll;
//
// 音乐
//
.BackColor = Color.FromArgb(0, 0, 0, 0);
.Font = new Font("Microsoft YaHei UI", 15F);
.Location = new Point(86, 394);
.Name = "音乐";
.Size = new Size(83, 36);
.TabIndex = 18;
.Text = "音乐";
//
// groupDifficulty
//
groupDifficulty.BackColor = Color.FromArgb(0, 0, 0, 0);
groupDifficulty.Controls.Add(time);
groupDifficulty.Controls.Add();
groupDifficulty.Controls.Add(x4);
groupDifficulty.Controls.Add(x2);
groupDifficulty.Controls.Add(x3);
groupDifficulty.Controls.Add(x1);
groupDifficulty.Controls.Add(hardHeight);
groupDifficulty.Controls.Add(normalHeight);
groupDifficulty.Controls.Add(easyHeight);
groupDifficulty.Controls.Add(hardWidth);
groupDifficulty.Controls.Add(normalWidth);
groupDifficulty.Controls.Add(easyWidth);
groupDifficulty.Controls.Add(cusHeight);
groupDifficulty.Controls.Add(cusWidth);
groupDifficulty.Controls.Add(custom);
groupDifficulty.Controls.Add(hard);
groupDifficulty.Controls.Add(normal);
groupDifficulty.Controls.Add(easy);
groupDifficulty.Font = new Font("Microsoft YaHei UI", 15F);
groupDifficulty.Location = new Point(61, 33);
groupDifficulty.Name = "groupDifficulty";
groupDifficulty.Size = new Size(512, 317);
groupDifficulty.TabIndex = 2;
groupDifficulty.TabStop = false;
groupDifficulty.Text = " 难度";
//
// time
//
time.BackColor = Color.FromArgb(199, 161, 121);
time.BorderStyle = BorderStyle.FixedSingle;
time.Location = new Point(138, 250);
time.Name = "time";
time.Size = new Size(96, 46);
time.TabIndex = 17;
time.Text = "3:00";
time.Enter += time_Enter;
time.Validated += time_Validated;
//
// 时间
//
.Location = new Point(25, 252);
.Name = "时间";
.Size = new Size(83, 36);
.TabIndex = 16;
.Text = "时间";
//
// x4
//
x4.AutoSize = true;
x4.Location = new Point(240, 193);
x4.Name = "x4";
x4.Size = new Size(32, 39);
x4.TabIndex = 14;
x4.Text = "x";
//
// x2
//
x2.AutoSize = true;
x2.Location = new Point(240, 96);
x2.Name = "x2";
x2.Size = new Size(32, 39);
x2.TabIndex = 13;
x2.Text = "x";
//
// x3
//
x3.AutoSize = true;
x3.Location = new Point(240, 143);
x3.Name = "x3";
x3.Size = new Size(32, 39);
x3.TabIndex = 15;
x3.Text = "x";
//
// x1
//
x1.AutoSize = true;
x1.Location = new Point(240, 49);
x1.Name = "x1";
x1.Size = new Size(32, 39);
x1.TabIndex = 3;
x1.Text = "x";
//
// hardHeight
//
hardHeight.Location = new Point(278, 146);
hardHeight.Name = "hardHeight";
hardHeight.Size = new Size(96, 36);
hardHeight.TabIndex = 12;
hardHeight.Text = "12";
//
// normalHeight
//
normalHeight.Location = new Point(278, 99);
normalHeight.Name = "normalHeight";
normalHeight.Size = new Size(96, 36);
normalHeight.TabIndex = 11;
normalHeight.Text = "8";
//
// easyHeight
//
easyHeight.Location = new Point(278, 52);
easyHeight.Name = "easyHeight";
easyHeight.Size = new Size(96, 36);
easyHeight.TabIndex = 10;
easyHeight.Text = "4";
//
// hardWidth
//
hardWidth.Location = new Point(138, 146);
hardWidth.Name = "hardWidth";
hardWidth.Size = new Size(96, 36);
hardWidth.TabIndex = 9;
hardWidth.Text = "21";
//
// normalWidth
//
normalWidth.Location = new Point(138, 99);
normalWidth.Name = "normalWidth";
normalWidth.Size = new Size(96, 36);
normalWidth.TabIndex = 8;
normalWidth.Text = "24";
//
// easyWidth
//
easyWidth.Location = new Point(138, 52);
easyWidth.Name = "easyWidth";
easyWidth.Size = new Size(96, 36);
easyWidth.TabIndex = 7;
easyWidth.Text = "7";
//
// cusHeight
//
cusHeight.BackColor = Color.FromArgb(199, 161, 121);
cusHeight.BorderStyle = BorderStyle.FixedSingle;
cusHeight.Location = new Point(278, 191);
cusHeight.Name = "cusHeight";
cusHeight.Size = new Size(96, 46);
cusHeight.TabIndex = 6;
cusHeight.Text = "高?";
cusHeight.TextChanged += cusHeight_TextChanged;
//
// cusWidth
//
cusWidth.BackColor = Color.FromArgb(199, 161, 121);
cusWidth.BorderStyle = BorderStyle.FixedSingle;
cusWidth.Location = new Point(138, 191);
cusWidth.Name = "cusWidth";
cusWidth.Size = new Size(96, 46);
cusWidth.TabIndex = 5;
cusWidth.Text = "宽?";
cusWidth.TextChanged += cusWidth_TextChanged;
//
// custom
//
custom.AutoSize = true;
custom.Font = new Font("Microsoft YaHei UI", 15F);
custom.Location = new Point(0, 192);
custom.Name = "custom";
custom.Size = new Size(132, 43);
custom.TabIndex = 4;
custom.Text = "自定义";
custom.UseVisualStyleBackColor = true;
custom.CheckedChanged += Difficulty_CheckedChanged;
//
// hard
//
hard.AutoSize = true;
hard.Font = new Font("Microsoft YaHei UI", 15F);
hard.Location = new Point(0, 143);
hard.Name = "hard";
hard.Size = new Size(102, 43);
hard.TabIndex = 3;
hard.Text = "困难";
hard.UseVisualStyleBackColor = true;
hard.CheckedChanged += Difficulty_CheckedChanged;
//
// normal
//
normal.AutoSize = true;
normal.Checked = true;
normal.Font = new Font("Microsoft YaHei UI", 15F);
normal.Location = new Point(0, 94);
normal.Name = "normal";
normal.Size = new Size(102, 43);
normal.TabIndex = 2;
normal.TabStop = true;
normal.Text = "普通";
normal.UseVisualStyleBackColor = true;
normal.CheckedChanged += Difficulty_CheckedChanged;
//
// easy
//
easy.AutoSize = true;
easy.Font = new Font("Microsoft YaHei UI", 15F);
easy.Location = new Point(0, 45);
easy.Name = "easy";
easy.Size = new Size(102, 43);
easy.TabIndex = 1;
easy.Text = "简单";
easy.UseVisualStyleBackColor = true;
easy.CheckedChanged += Difficulty_CheckedChanged;
//
// Setting
//
AutoScaleDimensions = new SizeF(11F, 24F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(756, 571);
AutoScroll = true;
BackColor = Color.FromArgb(199, 161, 121);
ClientSize = new Size(1440, 960);
Controls.Add();
Controls.Add(contextPanel);
Controls.Add(back);
DoubleBuffered = true;
FormBorderStyle = FormBorderStyle.None;
Name = "Setting";
Text = "Setting";
((System.ComponentModel.ISupportInitialize)back).EndInit();
contextPanel.ResumeLayout(false);
contextPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)psButton).EndInit();
((System.ComponentModel.ISupportInitialize)nextSong).EndInit();
((System.ComponentModel.ISupportInitialize)lastSong).EndInit();
((System.ComponentModel.ISupportInitialize)soundScapeVolume).EndInit();
((System.ComponentModel.ISupportInitialize)musicVolume).EndInit();
groupDifficulty.ResumeLayout(false);
groupDifficulty.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private PictureBox back;
private Label ;
private Panel contextPanel;
private Button button1;
private Label ;
private ComboBox themeSelector;
private Label ;
private ComboBox albumSelector;
private PictureBox psButton;
private PictureBox nextSong;
private PictureBox lastSong;
private Label songName;
private Label ;
private Label ;
private TextBox soundScapeVolumeText;
private TextBox songVolumeText;
private TrackBar soundScapeVolume;
private Label ;
private Label ;
private TrackBar musicVolume;
private Label ;
private GroupBox groupDifficulty;
private TextBox time;
private Label ;
private Label x4;
private Label x2;
private Label x3;
private Label x1;
private Label hardHeight;
private Label normalHeight;
private Label easyHeight;
private Label hardWidth;
private Label normalWidth;
private Label easyWidth;
private TextBox cusHeight;
private TextBox cusWidth;
private RadioButton custom;
private RadioButton hard;
private RadioButton normal;
private RadioButton easy;
}
}
+240 -1
View File
@@ -7,14 +7,253 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CDSAE3_Lian_Lian_Kan.Forms.Interface;
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class Setting : Form
public partial class Setting : Form, IThemeChangeable
{
private readonly List<string> _albums;
private readonly List<string> _themes;
TextBox[] textBoxes;
public Setting()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
textBoxes = [cusWidth, cusHeight, time, songVolumeText, soundScapeVolumeText];
_albums = Etcs.musics.Keys.ToList();
albumSelector.Items.AddRange(_albums.ToArray());
_themes = Etcs.themes.Keys.ToList();
themeSelector.Items.AddRange(_themes.ToArray());
themeSelector.SelectedItem = "Fruit";
SetTheme();
}
public void SetTheme()
{
Etcs.ThemeInfo themeInfo = Etcs.currentThemeInfo;
BackColor = Color.FromArgb(themeInfo.ThemeColor![0], themeInfo.ThemeColor[1], themeInfo.ThemeColor[2]);
foreach (var item in textBoxes)
{
contextPanel.BackColor = BackColor;
item.BackColor = BackColor;
}
}
bool is_pause = false;
public void Resume()
{
is_pause = false;
psButton.Image = Properties.Resources.pause;
Etcs.song_Audio_Processer.resume_song();
}
public void Pause()
{
is_pause = true;
psButton.Image = Properties.Resources.play_buttton;
Etcs.song_Audio_Processer.pause_song();
}
private void psButton_Click(object sender, EventArgs e)
{
if (is_pause)
Resume();
else
Pause();
}
private void lastSong_Click(object sender, EventArgs e)
{
Etcs.song_Audio_Processer.set_song(Etcs.song_Audio_Processer.get_last_song());
}
private void nextSong_Click(object sender, EventArgs e)
{
Etcs.song_Audio_Processer.set_song(Etcs.song_Audio_Processer.get_next_song());
}
internal void SetSongInfo(string songName)
{
this.songName.Text = "歌曲:" + songName;
Console.WriteLine(this.songName.Text);
}
internal void SetAlbum(string albumName)
{
if ((albumSelector.SelectedItem?.ToString() ?? "") != albumName)
{
albumSelector.SelectedItem = albumName;
}
}
private void albumSelector_SelectedIndexChanged(object sender, EventArgs e)
{
var s = albumSelector.SelectedItem?.ToString();
if (s != null)
Etcs.song_Audio_Processer.set_albums(s);
nextSong_Click(this, new EventArgs());
}
private void musicVolume_Scroll(object? sender, EventArgs e)
{
Etcs.song_Audio_Processer.volume_change(musicVolume.Value);
if (sender != null)
songVolumeText.Text = musicVolume.Value.ToString();
}
private void soundScapeVolume_Scroll(object? sender, EventArgs e)
{
Etcs.Info_Volume = soundScapeVolume.Value;
if (sender != null)
soundScapeVolumeText.Text = soundScapeVolume.Value.ToString();
}
private bool _canBack = true;
private async void back_ClickAsync(object sender, EventArgs e)
{
CusSize_Validated(this, new EventArgs());
if (_canBack)
await Etcs.form!.change_form((Etcs.gameMenuForm as Form)!, false, null, null, false, null);
}
private void SetTimeText(int t) => time.Text = $"{t / 60}:{((t % 60) < 10 ? ("0" + (t % 60).ToString()) : (t % 60).ToString())}";
private int CalcTime(int total) => (int)(Math.Ceiling((double)total / 50)) * 60;//50per minute 向上取整
private int LimitedCalcTime(int total) => (int)((double)total / 90 * 60);//90per minute 不取整 极限值
private void Difficulty_CheckedChanged(object sender, EventArgs e)
{
switch ((sender as RadioButton)!.Name)
{
case "easy":
Etcs.current_difficulty = Etcs.Difficulty.easy;
break;
case "normal":
Etcs.current_difficulty = Etcs.Difficulty.normal;
break;
case "hard":
Etcs.current_difficulty = Etcs.Difficulty.hard;
break;
case "custom":
Etcs.current_difficulty = Etcs.Difficulty.custom;
break;
}
var (a, b) = Etcs.get_length_width();
int ans = CalcTime(a * b);
Etcs.left_time = ans;
SetTimeText(ans);
}
private bool _cusDataChanged = false;
private void cusWidth_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(cusWidth.Text, out int a))
{
_cusDataChanged = true;
Etcs.cus_width = a;
custom.Checked = true;
Difficulty_CheckedChanged(custom, e);
}
else
cusWidth.Text = new string(cusWidth.Text.Where(x => char.IsDigit(x)).ToArray());
}
private void cusHeight_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(cusHeight.Text, out int a))
{
_cusDataChanged = true;
Etcs.cus_height = a;
custom.Checked = true;
Difficulty_CheckedChanged(custom, e);
}
else
cusHeight.Text = new string(cusHeight.Text.Where(x => char.IsDigit(x)).ToArray());
}
private void CusSize_Validated(object sender, EventArgs e)
{
if (!_cusDataChanged)
return;
var (a, b) = Etcs.get_length_width();
int total = a * b;
if (Etcs.left_time < LimitedCalcTime(total))
{
int t = LimitedCalcTime(total);
DialogResult result = MessageBox.Show($"你这个时间挺极限的,建议设置的时间不小于{t / 60}:{((t % 60) < 10 ? ("0" + (t % 60).ToString()) : (t % 60).ToString())} \n 确定退出吗?", "注意", MessageBoxButtons.OKCancel);
if (result == DialogResult.Cancel || result == DialogResult.None)
_canBack = false;
}
}
int lastTime = 0;
private int getTime()
{
string s = time.Text;
string[] strings = s.Split(":");
return int.Parse(strings[0]) * 60 + int.Parse(strings[1]);
}
private void time_Enter(object sender, EventArgs e)
{
lastTime = getTime();
}
private void time_Validated(object sender, EventArgs e)
{
int newTime = 0;
try
{
newTime = getTime();
}
catch (Exception)
{
MessageBox.Show(Text = "输入格式错误");
SetTimeText(lastTime);
}
if (lastTime != newTime)
{
_cusDataChanged = true;
Etcs.left_time = newTime;
}
}
private void songVolumeText_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(songVolumeText.Text, out int a))
{
if (a > 100)
a = 100;
if (a < 0)
a = 0;
songVolumeText.Text = a.ToString();
if (sender != null)
{
musicVolume.Value = a;
musicVolume_Scroll(null, e);
}
}
else
songVolumeText.Text = new string(songVolumeText.Text.Where(x => char.IsDigit(x)).ToArray());
}
private void soundScapeVolumeText_TextChanged(object sender, EventArgs e)
{
if (int.TryParse(soundScapeVolumeText.Text, out int a))
{
if (a > 100)
a = 100;
if (a < 0)
a = 0;
soundScapeVolumeText.Text = a.ToString();
if (sender != null)
{
soundScapeVolume.Value = a;
soundScapeVolume_Scroll(null, e);
}
}
else
soundScapeVolumeText.Text = new string(soundScapeVolumeText.Text.Where(x => char.IsDigit(x)).ToArray());
}
private void themeSelector_SelectedIndexChanged(object sender, EventArgs e)
{
var s = themeSelector.SelectedItem?.ToString();
if (s == null || s.Length == 0)
return;
Etcs.currentThemeInfo = Etcs.themes[s!];
SetTheme();
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace CDSAE3_Lian_Lian_Kan
namespace CDSAE3_Lian_Lian_Kan.Forms
{
partial class Single_Block
{
+16 -15
View File
@@ -11,16 +11,16 @@ using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
namespace CDSAE3_Lian_Lian_Kan
namespace CDSAE3_Lian_Lian_Kan.Forms
{
public partial class Single_Block : UserControl
{
public Single_Block()
{
InitializeComponent();
if (Etcs.game_form == null)
if (Etcs.gameForm == null)
throw new Exception("game_form is null but try to make a new Single_Block");
Selected += Etcs.game_form.Selected_Handler;
Selected += Etcs.gameForm.Selected_Handler;
}
public Single_Block(int image, Color default_backColor, Color select_Color, (int, int) pos)
@@ -34,9 +34,9 @@ namespace CDSAE3_Lian_Lian_Kan
sel_color = select_Color;
BackColor = default_backColor;
picture.BackColor = default_backColor;
if (Etcs.game_form == null)
if (Etcs.gameForm == null)
throw new Exception("game_form is null but try to make a new Single_Block");
Selected += Etcs.game_form.Selected_Handler;
Selected += Etcs.gameForm.Selected_Handler;
}
public Single_Block(Image image, (int, int) pos)
@@ -46,9 +46,9 @@ namespace CDSAE3_Lian_Lian_Kan
picture.SizeMode = PictureBoxSizeMode.Zoom;
BackColor = Color.FromArgb(0, 0, 0, 0);
can_be_selected = false;
if (Etcs.game_form == null)
if (Etcs.gameForm == null)
throw new Exception("game_form is null but try to make a new Single_Block");
Selected += Etcs.game_form.Selected_Handler;
Selected += Etcs.gameForm.Selected_Handler;
}
@@ -124,23 +124,24 @@ namespace CDSAE3_Lian_Lian_Kan
public void Image_change(Image new_image)
{
images_queue.Enqueue(new_image);
if(Image_setting_thread == null || !Image_setting_thread.IsAlive)
if (Image_setting_thread == null || !Image_setting_thread.IsAlive)
{
Image_setting_thread = new Thread(() =>
{
while (images_queue.TryDequeue(out Image? image))
{
lock (image)
try
{
try
{
lock (image)
{
Image_set(image);
}
catch (Exception)
{
images_queue.Enqueue(image);
}
}
catch (Exception)
{
images_queue.Enqueue(image);
}
}
});
Image_setting_thread.Start();