You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/FormMain.cs

125 lines
3.2 KiB
C#

using HslCommunication.LogNet;
using HZH_Controls.Forms;
using NewLife.Threading;
using System;
1 month ago
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 RfidWeb.Frm;
using Tool;
1 month ago
namespace RfidWeb
{
public partial class FormMain : Form
{
private ILogNet logNet = ILogNetFactory.GetLogNet;
TimerX _timer;
1 month ago
public FormMain()
{
InitializeComponent();
//if (this.FormBorderStyle == FormBorderStyle.None)
//{
// this.FormBorderStyle = FormBorderStyle.FixedSingle;
// this.WindowState = FormWindowState.Normal;
//}
//else
//{
// this.FormBorderStyle = FormBorderStyle.None;
// this.WindowState = FormWindowState.Maximized;
//}
Init();
}
private void Init()
{
_timer = new TimerX(TimeState, null, 10, 1000);
// 如果所有的日志在记录之前需要在控制台显示出来
logNet.BeforeSaveToFile += (object sender, HslEventArgs e) =>
1 month ago
{
Console.WriteLine(e.HslMessage.ToString());
};
logNet.ConsoleOutput = true;
logNet.WriteInfo("nihao");
this.panContent.Controls.Clear();
this.panContent.Controls.Add(new UserMain());
}
/// <summary>移除过期的缓存项</summary>
void TimeState(Object state)
{
var dataTime = DateTime.Now;
this.Invoke(() =>
1 month ago
{
label1.Text = dataTime.ToString("yyyy'/'MM'/'dd");
label2.Text = dataTime.ToString("HH:mm:ss");
});
1 month ago
}
private void btnExit_Click(object sender, EventArgs e)
{
if (FrmDialog.ShowDialog(this, "是否退出系统?", "提示窗体", true)
== System.Windows.Forms.DialogResult.OK)
{
Application.Exit();
}
}
private void SetBackGroupImage(Button button)
{
var imageOld = Properties.Resources.btn;
List<Button> ls = new List<Button>()
{
btnMain,
btnArgument,
btnAlarm,
btnAccount,
btnMes
};
foreach (var bt in ls)
{
if (bt.BackgroundImage != imageOld)
{
bt.BackgroundImage=imageOld;
}
}
var imageNew = Properties.Resources.btn_sel1;
if (button != null)
{
button.BackgroundImage = imageNew;
}
}
private void btnMain_Click(object sender, EventArgs e)
{
SetBackGroupImage(sender as Button);
}
private void btnArgument_Click(object sender, EventArgs e)
{
SetBackGroupImage(sender as Button);
}
private void btnAlarm_Click(object sender, EventArgs e)
{
SetBackGroupImage(sender as Button);
1 month ago
}
}
}