2025-03-28 09:49:56 +08:00

119 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
namespace HiiShe.Manager
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
//[DllImport("user32", CharSet = CharSet.Unicode)]
//static extern IntPtr FindWindow(string cls, string win);
//[DllImport("user32")]
//static extern IntPtr SetForegroundWindow(IntPtr hWnd);
//[DllImport("user32")]
//static extern bool IsIconic(IntPtr hWnd);
//[DllImport("user32")]
//static extern bool OpenIcon(IntPtr hWnd);
//protected override void OnStartup(StartupEventArgs e)
//{
// bool isNew;
// var mutex = new Mutex(true, "收银基础信息管理系统", out isNew);
// if (!isNew)
// {
// ActivateOtherWindow();
// Shutdown();
// }
//}
//private static void ActivateOtherWindow()
//{
// var other = FindWindow(null, "MainWindow");
// if (other != IntPtr.Zero)
// {
// SetForegroundWindow(other);
// if (IsIconic(other))
// OpenIcon(other);
// }
//}
public string BackgoodsCode { set; get; }
public string Backgoodsid { set; get; }
public string Type { set; get; }
public string StartDate { set; get; }
public string EndDate { set; get; }
public string window { set; get; }
public string Top { set; get; }
public string Left { set; get; }
System.Threading.Mutex mutex;
public App()
{
this.Startup += new StartupEventHandler(App_Startup);
}
void App_Startup(object sender, StartupEventArgs e)
{
bool ret;
mutex = new Mutex(true, "收银基础信息管理系统", out ret);
if (!ret)
{
//MessageBox.Show("已有一个程序实例运行");
Environment.Exit(0);
}
}
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length>0&&e.Args[0].ToString()=="login")
{
MainWindow window = new MainWindow();
window.WindowState = WindowState.Maximized;
window.Show();
}
else
{
MainWindow window = new MainWindow();
window.WindowState = WindowState.Maximized;
window.Show();
}
}
}
class Program
{
public static string InputArgs = "";
[STAThread]
static void Main(string[] args)
{
if (args.Length > 0 && args[0] == "login")
{
App app = new App();
app.InitializeComponent();
MainWindow window = new MainWindow();
window.WindowState = WindowState.Maximized;
app.MainWindow = window;
app.Run();
//App.Main();
}
else
{
App app = new App();
app.InitializeComponent();
Login window = new Login();
app.MainWindow = window;
app.Run();
//App.Main();
}
}
}
}