using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
namespace Wuyin.ShoesManager
{
///
/// Start 的摘要说明。
///
public class Start
{
static FlashScreen fs = null;
static string[] commandLineArgs = null;
static bool isTest = false;
static bool isXp = false;
public static bool IsInXp
{
get
{
return isXp;
}
}
public static FlashScreen flashScreen
{
get
{
return fs;
}
}
public static string[] CommandLineArgs
{
get
{
return commandLineArgs;
}
}
public Start()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
private static void ShowFocusWindow(int hwnd)
{
CommonClass.ShowWindow(hwnd,CommonClass.nCmdShow.SW_SHOW);
CommonClass.SetForegroundWindow(hwnd);
}
[STAThread]
public static void Main(string[] args)
{
bool noLogo = false;
commandLineArgs = args;
int hwnd = CommonClass.FindWindow(null,"无垠鞋业管理系统 - 登录");
if(hwnd>0)
{
ShowFocusWindow(hwnd);
return;
}
Process[] Procs = Process.GetProcesses();
foreach(Process P in Procs)
{
string title = P.MainWindowTitle;
if(title.StartsWith("无垠鞋业管理系统"))
{
hwnd = CommonClass.FindWindow(null,P.MainWindowTitle);
ShowFocusWindow(hwnd);
return;
}
}
//如果在XP下则使用CommonControl 6 控件
if(Environment.OSVersion.Version.Major > 4 & Environment.OSVersion.Version.Minor > 0 )
{
isXp = true;
if(!File.Exists(Application.ExecutablePath + ".manifest"))
{
StreamWriter sr = new StreamWriter(Application.ExecutablePath + ".manifest");
sr.Write("\n
sr.Close();
System.Diagnostics.Process P = System.Diagnostics.Process.Start(Application.ExecutablePath);
Application.ExitThread();
Application.Exit();
return;
}
}
foreach(string arg in args)
{
if(arg.ToUpper().EndsWith("NOLOGO"))
{
noLogo = true;
}
if(arg.ToUpper().EndsWith("/TEST"))
isTest=true;
}
//显示SplashForm
if(!noLogo)
{
fs = new FlashScreen();
fs.Show();
}
//登录
Wuyin.ShoesManager.frmLogin frm=new frmLogin();
CommonClass.RecursivelyFormatForWinXP(frm);
DialogResult result = frm.ShowDialog();
if(result!=DialogResult.Yes)
{
frm.Close();
if(fs!=null)
fs.Close();
Application.Exit();
}
else
{
frm.Close();
StartMainForm();
}
}
private static void StartMainForm()
{
fs.HideForm();
if(!isTest)
Application.Run(main.GetMainWindow);
else
Application.Run(new Form1());
}
}
}