예제 #1
0
        static void Main(string[] arg)
        {
            Process[] RunningProcesses = Process.GetProcessesByName("XiboClient");

            if(RunningProcesses.Length <= 1)
            {
                // Ensure our process has the highest priority
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

                Application.SetCompatibleTextRenderingDefault(false);

                Trace.Listeners.Add(new XiboTraceListener());
                Trace.AutoFlush = false;

                Form formMain;

                try
                {
                    if (arg.GetLength(0) > 0 && arg[0].ToString() == "o")
                    {
                        // If we are showing the options form, enable visual styles
                        Application.EnableVisualStyles();

                        Trace.WriteLine(new LogMessage("Main", "Options Started"), LogType.Info.ToString());
                        formMain = new OptionForm();
                    }
                    else
                    {
                        Trace.WriteLine(new LogMessage("Main", "Client Started"), LogType.Info.ToString());
                        formMain = new MainForm();
                    }

                    Application.Run(formMain);
                }
                catch (Exception ex)
                {
                    HandleUnhandledException(ex);
                }

                // Catch unhandled exceptions
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                // Always flush at the end
                Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString());
                Trace.Flush();
            }
            else
            {
                ShowWindowAsync(RunningProcesses[0].MainWindowHandle, 6);
                ShowWindowAsync(RunningProcesses[0].MainWindowHandle, 9);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: cnxsoft/xibo4arm
        static void Main(string[] arg)
        {
            Process[] RunningProcesses = Process.GetProcessesByName("XiboClient");

            if(RunningProcesses.Length <= 1)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                System.Diagnostics.Trace.Listeners.Add(new XiboTraceListener());
                System.Diagnostics.Trace.AutoFlush = false;

                Form formMain;

                try
                {
                    if (arg.GetLength(0) > 0)
                    {
                        System.Diagnostics.Trace.WriteLine(new LogMessage("Main", "Options Started"), LogType.Info.ToString());
                        formMain = new OptionForm();
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine(new LogMessage("Main", "Client Started"), LogType.Info.ToString());
                        formMain = new MainForm();
                    }

                    Application.Run(formMain);
                }
                catch (Exception ex)
                {
                    HandleUnhandledException(ex);
                }

                // Catch unhandled exceptions
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                // Always flush at the end
                System.Diagnostics.Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString());
                System.Diagnostics.Trace.Flush();
            }
            else
            {
                ShowWindowAsync(RunningProcesses[0].MainWindowHandle, 6);
                ShowWindowAsync(RunningProcesses[0].MainWindowHandle, 9);
            }
        }