mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
封装GeneralForm
This commit is contained in:
parent
a0b54ec03b
commit
ef2476e421
@ -43,9 +43,7 @@
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="UI\Login\Login.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="UI\Login\Login.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -10,6 +10,8 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
{
|
||||
public partial class ExitButton : Button
|
||||
{
|
||||
public GeneralForm? RelativeForm { get; set; }
|
||||
|
||||
public ExitButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -27,6 +29,8 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
Size = new System.Drawing.Size(47, 47);
|
||||
TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
UseVisualStyleBackColor = false;
|
||||
|
||||
Click += ExitButton_Click;
|
||||
}
|
||||
|
||||
public ExitButton(IContainer container)
|
||||
@ -47,6 +51,19 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
Size = new System.Drawing.Size(47, 47);
|
||||
TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
UseVisualStyleBackColor = false;
|
||||
|
||||
Click += ExitButton_Click;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自带的关闭按钮,可以重写
|
||||
/// 绑定RelativeForm才能生效
|
||||
/// </summary>
|
||||
/// <param name="sender">object?</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected virtual void ExitButton_Click(object? sender, EventArgs e)
|
||||
{
|
||||
RelativeForm?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,13 +28,27 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Title = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Title
|
||||
//
|
||||
this.Title.Font = new System.Drawing.Font("LanaPixel", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||
this.Title.Location = new System.Drawing.Point(3, 3);
|
||||
this.Title.Name = "Title";
|
||||
this.Title.Size = new System.Drawing.Size(387, 47);
|
||||
this.Title.TabIndex = 9;
|
||||
this.Title.Text = "Please Override";
|
||||
this.Title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.Title.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Title_MouseDown);
|
||||
this.Title.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Title_MouseMove);
|
||||
//
|
||||
// GeneralForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(536, 284);
|
||||
this.Controls.Add(this.Title);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "GeneralForm";
|
||||
this.Text = "GeneralForm";
|
||||
@ -43,5 +57,7 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected Label Title;
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Title_MouseDown(object sender, MouseEventArgs e)
|
||||
protected virtual void Title_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
//判断是否为鼠标左键
|
||||
if (e.Button == MouseButtons.Left)
|
||||
@ -40,7 +40,7 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Title_MouseMove(object sender, MouseEventArgs e)
|
||||
protected virtual void Title_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
|
||||
@ -57,4 +57,10 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Title.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@ -10,6 +10,8 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
{
|
||||
public partial class MinButton : Button
|
||||
{
|
||||
public GeneralForm? RelativeForm { get; set; }
|
||||
|
||||
public MinButton()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -27,6 +29,8 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
Size = new System.Drawing.Size(47, 47);
|
||||
TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
UseVisualStyleBackColor = false;
|
||||
|
||||
Click += MinForm_Click;
|
||||
}
|
||||
|
||||
public MinButton(IContainer container)
|
||||
@ -47,6 +51,22 @@ namespace Milimoe.FunGame.Desktop.Library.Component
|
||||
Size = new System.Drawing.Size(47, 47);
|
||||
TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
UseVisualStyleBackColor = false;
|
||||
|
||||
Click += MinForm_Click;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自带的最小化窗口
|
||||
/// 绑定RelativeForm才能生效
|
||||
/// </summary>
|
||||
/// <param name="sender">object?</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
private void MinForm_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (RelativeForm != null)
|
||||
{
|
||||
RelativeForm.WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
4
FunGame.Desktop/UI/Login/Login.Designer.cs
generated
4
FunGame.Desktop/UI/Login/Login.Designer.cs
generated
@ -63,7 +63,7 @@
|
||||
this.ExitButton.TabIndex = 7;
|
||||
this.ExitButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.ExitButton.UseVisualStyleBackColor = false;
|
||||
this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click);
|
||||
this.ExitButton.RelativeForm = this;
|
||||
//
|
||||
// MinButton
|
||||
//
|
||||
@ -83,6 +83,7 @@
|
||||
this.MinButton.TabIndex = 6;
|
||||
this.MinButton.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.MinButton.UseVisualStyleBackColor = false;
|
||||
this.MinButton.RelativeForm = this;
|
||||
//
|
||||
// Title
|
||||
//
|
||||
@ -221,7 +222,6 @@
|
||||
|
||||
private Library.Component.ExitButton ExitButton;
|
||||
private Library.Component.MinButton MinButton;
|
||||
private Label Title;
|
||||
private Label Username;
|
||||
private Label Password;
|
||||
private TextBox UsernameText;
|
||||
|
||||
@ -1,55 +1,14 @@
|
||||
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;
|
||||
using Milimoe.FunGame.Desktop.Library.Component;
|
||||
|
||||
namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
public partial class Login : Form
|
||||
public partial class Login : GeneralForm
|
||||
{
|
||||
private int loc_x, loc_y; // 窗口当前坐标
|
||||
|
||||
public Login()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标按下,开始移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
//判断是否为鼠标左键
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//获取鼠标左键按下时的位置
|
||||
loc_x = e.Location.X;
|
||||
loc_y = e.Location.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标移动,正在移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//计算鼠标移动距离
|
||||
Left += e.Location.X - loc_x;
|
||||
Top += e.Location.Y - loc_y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开注册界面
|
||||
/// </summary>
|
||||
@ -59,15 +18,5 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
new Register().ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ExitButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
7
FunGame.Desktop/UI/Main/Main.Designer.cs
generated
@ -35,7 +35,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
|
||||
this.Exit = new FunGame.Desktop.Library.Component.ExitButton(this.components);
|
||||
this.Title = new System.Windows.Forms.Label();
|
||||
this.MinForm = new System.Windows.Forms.Button();
|
||||
this.MinForm = new Library.Component.MinButton();
|
||||
this.Connection = new System.Windows.Forms.Label();
|
||||
this.Light = new System.Windows.Forms.Label();
|
||||
this.SendTalkText = new System.Windows.Forms.Button();
|
||||
@ -125,7 +125,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
this.MinForm.TabIndex = 14;
|
||||
this.MinForm.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.MinForm.UseVisualStyleBackColor = false;
|
||||
this.MinForm.Click += new System.EventHandler(this.MinForm_Click);
|
||||
this.MinForm.RelativeForm = this;
|
||||
//
|
||||
// Connection
|
||||
//
|
||||
@ -607,8 +607,7 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
#endregion
|
||||
|
||||
private ExitButton Exit;
|
||||
private Label Title;
|
||||
private Button MinForm;
|
||||
private MinButton MinForm;
|
||||
private Label Connection;
|
||||
private Label Light;
|
||||
private Button StartMatch;
|
||||
|
||||
@ -15,7 +15,7 @@ using Milimoe.FunGame.Core.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
public partial class Main : Form
|
||||
public partial class Main : GeneralForm
|
||||
{
|
||||
|
||||
#region 变量定义
|
||||
@ -26,8 +26,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
public int MaxRetryTimes { get; } = SocketSet.MaxRetryTimes; // 最大重试连接次数
|
||||
public int CurrentRetryTimes { get; set; } = -1; // 当前重试连接次数
|
||||
|
||||
private int loc_x, loc_y; // 窗口当前坐标
|
||||
|
||||
/**
|
||||
* 定义全局对象
|
||||
*/
|
||||
@ -811,37 +809,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标按下,开始移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
//判断是否为鼠标左键
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//获取鼠标左键按下时的位置
|
||||
loc_x = e.Location.X;
|
||||
loc_y = e.Location.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标移动,正在移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//计算鼠标移动距离
|
||||
Left += e.Location.X - loc_x;
|
||||
Top += e.Location.Y - loc_y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始匹配
|
||||
/// </summary>
|
||||
@ -1165,16 +1132,6 @@ namespace Milimoe.FunGame.Desktop.UI
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最小化窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MinForm_Click(object sender, EventArgs e)
|
||||
{
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 工具方法
|
||||
|
||||
1
FunGame.Desktop/UI/Register/Register.Designer.cs
generated
1
FunGame.Desktop/UI/Register/Register.Designer.cs
generated
@ -241,7 +241,6 @@
|
||||
|
||||
private Library.Component.ExitButton ExitButton;
|
||||
private Library.Component.MinButton MinButton;
|
||||
private Label Title;
|
||||
private Label Username;
|
||||
private Label Password;
|
||||
private Label CheckPassword;
|
||||
|
||||
@ -1,55 +1,14 @@
|
||||
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;
|
||||
using Milimoe.FunGame.Desktop.Library.Component;
|
||||
|
||||
namespace Milimoe.FunGame.Desktop.UI
|
||||
{
|
||||
public partial class Register : Form
|
||||
public partial class Register : GeneralForm
|
||||
{
|
||||
private int loc_x, loc_y; // 窗口当前坐标
|
||||
|
||||
public Register()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标按下,开始移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
//判断是否为鼠标左键
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//获取鼠标左键按下时的位置
|
||||
loc_x = e.Location.X;
|
||||
loc_y = e.Location.Y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标移动,正在移动主窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Title_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//计算鼠标移动距离
|
||||
Left += e.Location.X - loc_x;
|
||||
Top += e.Location.Y - loc_y;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭窗口
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user