using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Timers;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ButcherFactory.Controls
|
|
{
|
|
public partial class FormTemplate : Form
|
|
{
|
|
System.Timers.Timer timer;
|
|
|
|
public FormTemplate()
|
|
{
|
|
InitializeComponent();
|
|
if (!DesignMode)
|
|
{
|
|
this.FormClosing += delegate
|
|
{
|
|
if (timer != null)
|
|
timer.Dispose();
|
|
};
|
|
}
|
|
if (CheckDesingModel.IsDesingMode)
|
|
return;//如果处于设计模式,返回
|
|
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
if (!DesignMode)
|
|
{
|
|
TitleLbl.Text = Text;
|
|
logoPanel.BackgroundImage = Image.FromFile("Images\\logo.png");
|
|
titlePanel.BackgroundImage = Image.FromFile("Images\\formTitle.png");
|
|
timerTick(null, null);
|
|
timer = new System.Timers.Timer(1000);
|
|
timer.Elapsed += timerTick;
|
|
timer.AutoReset = true;
|
|
timer.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void timerTick(object sender, ElapsedEventArgs e)
|
|
{
|
|
var arr = "日一二三四五六";
|
|
this.Invoke(new Action(delegate
|
|
{
|
|
timeLbl.Text = string.Format("{0} {1:HH:mm}", DateTime.Now.Hour > 12 ? "下午" : "上午", DateTime.Now);
|
|
dateLbl.Text = string.Format(string.Format("{0:yyyy年MM月dd日}/星期{1}", DateTime.Today, arr[(int)DateTime.Now.DayOfWeek]));
|
|
}));
|
|
}
|
|
|
|
private void closeBtn_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
internal class CheckDesingModel
|
|
{
|
|
public static bool IsDesingMode
|
|
{
|
|
get
|
|
{
|
|
bool ReturnFlag = false;
|
|
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
|
|
ReturnFlag = true;
|
|
else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
|
|
ReturnFlag = true;
|
|
//if (ReturnFlag)
|
|
// Msg.Warning("设计模式");
|
|
//else Msg.Warning("非设计模式!");
|
|
return ReturnFlag;
|
|
}
|
|
}
|
|
}
|
|
}
|