using CsharpHttpHelper; using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using UI.Framework.Forms; namespace FLSystem.Forms { public partial class LockForm : BaseForm { public LockForm(Size size) { InitializeComponent(); this.Size = size; //433, 236 this.panel1.Location = new Point(((size.Width - panel1.Width) / 2),((size.Height - panel1.Height) / 2)); } private void LockForm_Load(object sender, EventArgs e) { try { var account = Grant.Framework.GrantClient.Get().accounts; lb_LoginName.Text = "账号:" + account.username; //labelControl1.Text = Grant.Framework.GrantClient.Get().About["title"].ToString() + " 正在锁定中"; labelControl1.Text = "正在锁定中"; } catch (Exception ex) { } } private void simpleButton1_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(textEdit1.Text.Trim())) throw new Exception("请输入密码"); string pass = HttpExtend.DESEncrypt(textEdit1.Text.Trim(), "12345678", "12378946"); var Config = new Api.Framework.Tools.IniHelper(HttpExtend.MapFile("系统配置.ini", "Config")); var passData = Config.GetValue("帐号信息", "密码"); if (pass == passData) { isInputRightPwd = true; this.DialogResult = DialogResult.OK; } else throw new Exception("密码错误"); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } #region 控制无边框窗体的移动 //using System.Runtime.InteropServices; [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); private void Main_MouseDown(object sender, MouseEventArgs e) { //常量 int WM_SYSCOMMAND = 0x0112; //窗体移动 int SC_MOVE = 0xF010; int HTCAPTION = 0x0002; ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } #endregion private void simpleButton2_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } private bool isInputRightPwd = false; private void LockForm_FormClosing(object sender, FormClosingEventArgs e) { if (!isInputRightPwd) { e.Cancel = true; this.WindowState = FormWindowState.Minimized; } } } }