📄 frmmain.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace JPMLab_LanTalker_Client
{
public partial class frmMain : Form
{
/// <summary>
/// Const part
/// </summary>
const int PANEL_MAX = 2;
const int PANEL_LOGIN = 0;
const int PANEL_FRIENDS = 1;
const int PANEL_NEWS = 2;
const int NOWBUT_NULL = -1;
const int NOWBUT_LAST = 0;
const int NOWBUT_NEXT = 1;
const int NOWBUT_CPANEL = 2;
const int NOWBUT_LOGIN = 3;
const int NOWBUT_CANCEL = 4;
string[] STRG_SEX = { "女", "男" };
const int MAX_DIRBEWRITE = 11;
const int MAX_DIRFRIEND = 4;
/// <summary>
/// Delegate part
/// </summary>
public delegate void NowBut_Move(int X, int Y);
public delegate void DrawNowBut_Down();
public delegate void DrawNowBut_Up();
public delegate void DrawNowPanel();
/// <summary>
/// Current GDI Object
/// </summary>
SolidBrush sb_Black = new SolidBrush(Color.Black);
SolidBrush sb_White = new SolidBrush(Color.White);
SolidBrush sb_Gray = new SolidBrush(Color.FromArgb(51, 51, 51));
Font ft_This;
Bitmap UIBuffer;
Graphics UIBufGraphics;
Graphics UIFGraphics;
/// <summary>
/// The current index of the logo picture on login panel
/// </summary>
int LogoIndex;
Thread thdCartoonLogo;
/// <summary>
/// Current panel index and his some info
/// </summary>
int PanelIndex;
string NowPanel;
string OtherPanel;
DrawNowPanel Panel_Draw;
NowBut_Move Panel_NB_Move;
DrawNowBut_Down Panel_DrawNB_Down;
DrawNowBut_Up Panel_DrawNB_Up;
/// <summary>
/// DataSource
/// </summary>
int NowFLStartRow;
int NowUser_Move;
/// <summary>
/// Engine button index
/// </summary>
int NowBut;
/// <summary>
/// Some Attribute
/// </summary>
public System.Drawing.Icon MainNotIcon
{
set
{
notMain.Icon = value;
}
get
{
return notMain.Icon;
}
}
/// <summary>
/// Construction
/// </summary>
public frmMain()
{
Rectangle t_rect;
InitializeComponent();
t_rect = Screen.PrimaryScreen.WorkingArea;
this.SetDesktopBounds(t_rect.Width - 199, (t_rect.Height - 425) / 2, 189, 425);
UIBuffer = new Bitmap(188, 430);
UIBufGraphics = Graphics.FromImage(UIBuffer);
LogoIndex = 0;
PanelIndex = PANEL_LOGIN;
NowBut = NOWBUT_NULL;
NowPanel = global::JPMLab_LanTalker_Client.Properties.Resources.STR_PANELLOGIN;
OtherPanel = global::JPMLab_LanTalker_Client.Properties.Resources.STR_OPANELLOGIN;
Panel_Draw = new DrawNowPanel(Panel_Draw_Login);
Panel_NB_Move = new NowBut_Move(NowBut_Login_Move);
Panel_DrawNB_Down = new DrawNowBut_Down(DrawNowBut_Login_Down);
Panel_DrawNB_Up = new DrawNowBut_Up(DrawNowBut_Login_Up);
ft_This = this.Font;
NowFLStartRow = 0;
NowUser_Move = -1;
}
/// <summary>
/// Login-Panel's function
/// </summary>
private void LoadPanel_Login()
{
labLogo.Visible = true;
txtAccount.Visible = true;
pwdPassword.Visible = true;
NowPanel = global::JPMLab_LanTalker_Client.Properties.Resources.STR_PANELLOGIN;
OtherPanel = global::JPMLab_LanTalker_Client.Properties.Resources.STR_OPANELLOGIN;
Panel_Draw = new DrawNowPanel(Panel_Draw_Login);
Panel_NB_Move = new NowBut_Move(NowBut_Login_Move);
Panel_DrawNB_Down = new DrawNowBut_Down(DrawNowBut_Login_Down);
Panel_DrawNB_Up = new DrawNowBut_Up(DrawNowBut_Login_Up);
thdCartoonLogo.Resume();
}
private void UnloadPanel_Login()
{
labLogo.Visible = false;
txtAccount.Visible = false;
pwdPassword.Visible = false;
thdCartoonLogo.Suspend();
}
private void Panel_Draw_Login()
{
/// Draw image
UIBufGraphics.DrawImageUnscaledAndClipped(ilsLogo.Images[0], new Rectangle(44, 122, 82, 56));
UIBufGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_PROGRESS, new Rectangle(30, 198, 124, 25));
UIBufGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGINBG, new Rectangle(24, 246, 135, 46));
UIBufGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGIN, new Rectangle(67, 294, 41, 19));
UIBufGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_CANCEL, new Rectangle(113, 294, 41, 19));
}
private void NowBut_Login_Move(int X, int Y)
{
if (X > 67 && X < 108 && Y > 294 && Y < 311)
{
if (NowBut != NOWBUT_LOGIN)
{
DrawNowBut_Login_Move(NOWBUT_LOGIN);
}
}
else if (X > 113 && X < 154 && Y > 294 && Y < 311)
{
if (NowBut != NOWBUT_CANCEL)
{
DrawNowBut_Login_Move(NOWBUT_CANCEL);
}
}
else
{
if (NowBut != NOWBUT_NULL)
{
DrawNowBut_Login_Move(NOWBUT_NULL);
}
}
}
private void DrawNowBut_Login_Move(int CurBut)
{
if (NowBut == NOWBUT_LOGIN)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGIN, new Rectangle(67, 294, 41, 19));
}
else if (NowBut == NOWBUT_CANCEL)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_CANCEL, new Rectangle(113, 294, 41, 19));
}
NowBut = CurBut;
if (NowBut == NOWBUT_LOGIN)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGIN_MOVE, new Rectangle(67, 294, 41, 19));
}
else if (NowBut == NOWBUT_CANCEL)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_CANCEL_MOVE, new Rectangle(113, 294, 41, 19));
}
}
private void DrawNowBut_Login_Down()
{
if (NowBut == NOWBUT_LOGIN)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGIN_DOWN, new Rectangle(67, 294, 41, 19));
txtAccount.Enabled = false;
pwdPassword.Enabled = false;
if (OperationCenter.UserLogin(txtAccount.Text, pwdPassword.Text, DrawNowProgress) == true)
{
ChangePanel(PanelIndex + 1);
}
txtAccount.Enabled = true;
pwdPassword.Enabled = true;
}
else if (NowBut == NOWBUT_CANCEL)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_CANCEL_DOWN, new Rectangle(113, 294, 41, 19));
///
this.Close();
}
}
private void DrawNowBut_Login_Up()
{
if (NowBut == NOWBUT_LOGIN)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_LOGIN, new Rectangle(67, 294, 41, 19));
}
else if (NowBut == NOWBUT_CANCEL)
{
UIFGraphics.DrawImageUnscaledAndClipped(global::JPMLab_LanTalker_Client.Properties.Resources.BMP_CANCEL, new Rectangle(113, 294, 41, 19));
}
}
public void thdfunCartoonLogo()
{
while (true)
{
LogoIndex += 1;
if (LogoIndex > 3)
{
LogoIndex = 0;
}
this.CreateGraphics().DrawImageUnscaledAndClipped(ilsLogo.Images[LogoIndex], new Rectangle(44, 122, 82, 56));
Thread.Sleep(180);
}
}
private void timLogo_Tick(object sender, EventArgs e)
{
LogoIndex += 1;
if (LogoIndex > 3)
{
LogoIndex = 0;
}
this.UIFGraphics.DrawImageUnscaledAndClipped(ilsLogo.Images[LogoIndex], new Rectangle(44, 122, 82, 56));
}
/// <summary>
/// Friends-Panel's function
/// </summary>
private void LoadPanel_Friends()
{
vsbFriends.Visible = true;
vsbFriends.Maximum = OperationCenter._FriendList.Count;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -