Esempio n. 1
0
        static void Main(params string[] arguments)
        {
            MainForm oForm = null;
            bool     bInstanceFlag;

            Mutex MyApplicationMutex = new Mutex(true, "CalculationOilPrice_Mutex", out bInstanceFlag);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MainForm());

            if (!bInstanceFlag)
            {
                oForm = new MainForm();
                SingleInstanceApplication.Run(oForm, NewInstanceHandler);
            }
            else
            {
                oForm = new MainForm(arguments);
                SingleInstanceApplication.Run(oForm, NewInstanceHandler);
                oForm.Close();
            }

            //_MainForm = new MainForm();
            //SingleInstanceApplication.Run(_MainForm, NewInstanceHandler);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            if (PriorProcess() != null)
            {
                return;
            }
            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += UIThreadException;

            // Set the unhandled exception mode to force all Windows Forms errors to go through
            // our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException +=
                CurrentDomain_UnhandledException;

            // ensure only a single instance of this app runs.
            var app = new SingleInstanceApplication();

            app.StartupNextInstance += OnAppStartupNextInstance;
            app.UnhandledException  += App_UnhandledException;
            _mainForm = new frmMain {
            };
            Control.CheckForIllegalCrossThreadCalls = false;
            if (Settings.Default.SettingsUpgradeNeeded)
            {
                Settings.Default.Upgrade();
                Settings.Default.SettingsUpgradeNeeded = false;
                Settings.Default.Save();
            }
            app.Run(_mainForm);
        }
Esempio n. 3
0
        static void Main()
        {
            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);
            SingleInstanceApplication.Run(new Main(), NewInstanceHandler);
        }
Esempio n. 4
0
 public static void Run(Form f, Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventHandler startupHandler)
 {
     SingleInstanceApplication app = new SingleInstanceApplication();
     app.MainForm = f;
     app.StartupNextInstance += startupHandler;
     app.Run(Environment.GetCommandLineArgs());
 }
Esempio n. 5
0
 protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
 {
     // First time app is launched
     app = new SingleInstanceApplication();
     app.Run();
     return(false);
 }
Esempio n. 6
0
 public static void Run(Form form, StartupNextInstanceEventHandler startupHandler)
 {
     SingleInstanceApplication app = new SingleInstanceApplication();
     app.MainForm = form;
     app.StartupNextInstance += startupHandler;
     app.Run(Environment.GetCommandLineArgs());
 }
    public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
    {
        SingleInstanceApplication app = new SingleInstanceApplication();

        app.MainForm             = f;
        app.StartupNextInstance += startupHandler;
        app.Run(Environment.GetCommandLineArgs());
    }
Esempio n. 8
0
 protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs eventArgs)
 {
     // First time _application is launched
     _commandLine = eventArgs.CommandLine;
     _application = new SingleInstanceApplication();
     _application.Run();
     return(false);
 }
Esempio n. 9
0
 public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
 {
     Form = f;
     var app = new SingleInstanceApplication { MainForm = f };
     app.StartupNextInstance += startupHandler;
     var args = Environment.GetCommandLineArgs();
     app.Run(args);
 }
 public static void Run(Form form)
 {
     _application = new SingleInstanceApplication {
         MainForm = form
     };
     _application.StartupNextInstance += NextInstanceHandler;
     _application.Run(Environment.GetCommandLineArgs());
 }
Esempio n. 11
0
    public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
    {
        SingleInstanceApplication app = new SingleInstanceApplication();

        app.MainForm             = f;
        app.StartupNextInstance += startupHandler;
        app.Run(new string[0]);
    }
Esempio n. 12
0
         static void Main(params string[] Arguments)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             mainForm = new MainForm(Arguments);
             SingleInstanceApplication.Run(mainForm, NewInstanceHandler);
 
         }
Esempio n. 13
0
        static void StartApplication()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var application = new SingleInstanceApplication(new Yal(hasMutex));

            application.StartupNextInstance += (sender, e) => { e.BringToForeground = true; };
            application.Run(Environment.GetCommandLineArgs());
        }
Esempio n. 14
0
 public static void Run(RibbonForm f, StartupNextInstanceEventHandler startupHandler)
 {
     SingleInstanceApplication app = new SingleInstanceApplication();
     app.MainForm= f;
     if (f.DialogResult != DialogResult.Cancel)
     {
         app.StartupNextInstance += startupHandler;
         app.Run(Environment.GetCommandLineArgs());
     }
 }
Esempio n. 15
0
            public static void Run(Form form, StartupNextInstanceEventHandler startupHandler)
            {
                form.Hide();
                form.WindowState = FormWindowState.Minimized;
                var app = new SingleInstanceApplication {
                    MainForm = form
                };

                app.StartupNextInstance += startupHandler;
                app.Run(Environment.GetCommandLineArgs());
            }
Esempio n. 16
0
        static void Main(string[] args)
        {
            //Properties.Settings.Default.FUser = "";
            //Properties.Settings.Default.FUser = "";
            //Properties.Settings.Default.FIsFirsStart = false;
            //Properties.Settings.Default.Save();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
            Cef.EnableHighDPISupport();
            var settings = new CefSettings()
            {
                CachePath = Path
                            .Combine(Environment
                                     .GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MessengerFB\\Cache")
            };

            settings.CefCommandLineArgs.Add("debug-plugin-loading", "1");
            settings.CefCommandLineArgs.Add("allow-outdated-plugins", "1");
            settings.CefCommandLineArgs.Add("always-authorize-plugins", "1");
            settings.CefCommandLineArgs.Add("disable-web-security", "1");
            settings.CefCommandLineArgs.Add("enable-npapi", "1");
            settings.CefCommandLineArgs.Add("enable-media-stream", "1");
            settings.CefCommandLineArgs.Add("enable_spellchecking", "0");
            settings.WindowlessRenderingEnabled = true;
            //settings.EnableNetSecurityExpiration = true;
            settings.BackgroundColor = Cef.ColorSetARGB(255, 85, 85, 85);
            if (Properties.Settings.Default.FStopGPU)
            {
                settings.SetOffScreenRenderingBestPerformanceArgs();
                settings.DisableGpuAcceleration();
            }
            settings.Locale             = "vi";
            settings.AcceptLanguageList = "en_US";
            Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

            //Application.Run(new frmMain());

            if (Properties.Settings.Default.FIsFirsStart)
            {
                frm = new frmMain();
                SingleInstanceApplication.Run(frm, NewInstanceHandler);
            }
            else
            {
                frm = new frmLogin();
                SingleInstanceApplication.Run(frm, NewInstanceHandler);
            }

            //frm1 = new frmIconTray();
            //SingleInstanceApplication.Run(frm1, NewInstanceHandlerNone);
            //Application.Run(new frmIconTray());
        }
Esempio n. 17
0
 private static void Main(params string[] args)
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     _mainForm = new PrinterForm
     {
         WindowState = FormWindowState.Minimized
     };
     _mainForm.Hide();
     SingleInstanceApplication.Run(new PrinterForm(), NewInstanceHandler);
 }
Esempio n. 18
0
    public static void Run(Form form)
    {
        var app = new SingleInstanceApplication
        {
            MainForm = form
        };

        app.StartupNextInstance += (s, e) => e.BringToForeground = true;

        app.Run(Environment.GetCommandLineArgs());
    }
Esempio n. 19
0
        public static void Main()
        {
            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += UIThreadException;

            // Set the unhandled exception mode to force all Windows Forms errors to go through
            // our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException +=
                CurrentDomain_UnhandledException;

            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-us");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
            Thread.CurrentThread.Name             = "MainThread";

            if (Settings.Default.UpgradeNeeded)
            {
                try
                {
                    Settings.Default.Upgrade();
                    Settings.Default.UpgradeNeeded = false;
                    Settings.Default.Save();
                }
                catch (Exception e)
                {
                    Settings.Default.Reset();
                    Settings.Default.UpgradeNeeded = false;
                    Settings.Default.Save();
                    MessageBox.Show(
                        "Error: Could not import settings from previous installation of " + Application.ProductName +
                        ".\nThis can happen if the configuration file was incorrectly edited by hand.\nDefault settings will be used instead.",
                        Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1);
                    _log.Error(e.Message, e);
                }
            }
            // ensure only a single instance of this app runs.
            var app = new SingleInstanceApplication();

            app.StartupNextInstance += OnAppStartupNextInstance;
            app.UnhandledException  += App_UnhandledException;
            if (Settings.Default.PollEveryNMillis < 20)
            {
                Settings.Default.PollEveryNMillis = 20;
                Settings.Default.Save();
            }

            mainForm = new frmMain();
            app.Run(mainForm);
        }
        /// <summary>
        /// Replaces the Application.Run method.
        /// </summary>
        /// <param name="view">The view to run.</param>
        /// <param name="args"></param>
        public static void Run(ISingleInstanceApplicationView view, params string[] args)
        {
            if (mView != null)
            {
                throw new InvalidOperationException("Run has already been called in this application scope.");
            }

            mView = view;

            SingleInstanceApplication app = new SingleInstanceApplication(mView.MainWindow);

            app.StartupNextInstance += new StartupNextInstanceEventHandler(app_StartupNextInstance);
            app.Startup             += new StartupEventHandler(app_Startup);
            app.Run(args);
        }
Esempio n. 21
0
            public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
            {
                SingleInstanceApplication app = new SingleInstanceApplication();
                app.MainForm = f;
                app.StartupNextInstance += startupHandler;

                Options options = new Options();

                if (!CommandLine.Parser.Default.ParseArguments(Environment.GetCommandLineArgs(), options))
                    Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);

                app.Startup += new StartupEventHandler(((Main)f).Init);

                app.Run(Environment.GetCommandLineArgs());
            }
Esempio n. 22
0
        static void Main()
        {
            Global.Init(DefineTerminal.getOEMName());


            //Application.Run(new BRB.Forms.frmWaresScan());
            //SingleInstanceApplication.Run(new Forms.frmDocGrid(TypeDoc.SupplyLogistic));
            //SingleInstanceApplication.Run(new Forms.frmWaresGrid(TypeDoc.SupplyLogistic, 3699652));
            SingleInstanceApplication.Run(new Forms.frmMain());
            //SingleInstanceApplication.Run(new Forms.frmDocSearch());
            //SingleInstanceApplication.Run(new Forms.frmAdvSettingsDoc());
            //SingleInstanceApplication.Run(new Forms.frmTest());
            //SingleInstanceApplication.Run(new Forms.frmWaresScan());
            //SingleInstanceApplication.Run(new Forms.frmAbout());
            //SingleInstanceApplication.Run(new Forms.frmSettings());
        }
Esempio n. 23
0
        static void Main()
        {
            // ensure only a single instance of this app runs.

            SingleInstanceApplication app = new SingleInstanceApplication();

            app.StartupNextInstance += new StartupNextInstanceEventHandler(OnAppStartupNextInstance);



            mainForm = new GameManager();

            app.Run(mainForm);
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
        }
Esempio n. 24
0
            public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
            {
                SingleInstanceApplication app = new SingleInstanceApplication();

                app.MainForm             = f;
                app.StartupNextInstance += startupHandler;

                Options options = new Options();

                if (!CommandLine.Parser.Default.ParseArguments(Environment.GetCommandLineArgs(), options))
                {
                    Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
                }

                app.Startup += new StartupEventHandler(((Main)f).Init);

                app.Run(Environment.GetCommandLineArgs());
            }
    static void Main(params string[] Arguments)
    {
        Form1 MainForm;
        bool  bInstanceFlag;
        Mutex MyApplicationMutex = new Mutex(true, "MyApp_Mutex", out bInstanceFlag);

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        if (!bInstanceFlag)
        {
            MainForm = new Form1();
            SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
        }
        else
        {
            MainForm = new Form1();
            SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
            MainForm.Close();
        }
    }
Esempio n. 26
0
        static void Main(params string[] Arguments)
        {
            bool  bInstanceFlag;
            Mutex mutex = new Mutex(true, "Sonic Downloader", out bInstanceFlag);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!bInstanceFlag)
            {
                MainForm = new Form1();
                SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
            }
            else
            {
                MainForm = new Form1();
                SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
                MainForm.notifyIcon1.Visible = false;
                MainForm.Close();
            }
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            try
            {
                MainForm.stopWatch = System.Diagnostics.Stopwatch.StartNew();
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(true);

                using (MainForm = new MainForm(args))
                    SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
            }
            catch (Exception ex)
            {
                string nl = Environment.NewLine;
                File.AppendAllText(exeDir + "\\FatalError.log", ex.ToString() + nl + nl, Encoding.Default);
                Process.Start(exeDir + "\\FatalError.log");
            }
            finally
            {
                MainForm.stopWatch.Reset();
            }
        }
Esempio n. 28
0
        static void Main()
        {
            try
            {
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(true);

                using (MainForm = new FormMain())
                {
                    SingleInstanceApplication.Run(MainForm, NewInstanceHandler);
                }
            }
            catch (Exception ex)
            {
                string nl = Environment.NewLine;
                File.AppendAllText(fatalErrorPath, ex.ToString() + nl + nl, Encoding.Default);
                Process.Start(fatalErrorPath);
            }
            finally
            {
            }
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            // Format DateTime theo US
            CultureInfo culture = new CultureInfo("en-US", true)
            {
                DateTimeFormat =
                {
                    ShortDatePattern = "yyyy/MM/dd",
                    LongDatePattern  = "yyyy/MM/dd HH:mm:ss",
                    LongTimePattern  = "HH:mm:ss",
                    DateSeparator    = "/"
                }
            };

            Application.CurrentCulture = culture;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Karaoke_1.Properties.Settings.Default.strConnect = "Server=.;Database=Karaoke;Trusted_Connection=True";
            //Karaoke_1.Properties.Settings.Default.strConnect = "";
            //Karaoke_1.Properties.Settings.Default.Save();

            bool Check = BUS.BUS_NameServer.Instance.Check_Connect(Karaoke_1.Properties.Settings.Default.strConnect);

            if (Check == true)
            {
                frm = new frmLogin();
            }
            else
            {
                frm = new frmConnect();
            }

            SingleInstanceApplication.Run(frm, NewInstanceHandler);
        }
Esempio n. 30
0
            protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
            {
                // First time app is launched
                base.OnStartup(e);
                app = new SingleInstanceApplication();
                app.Run();

                return false;
            }
Esempio n. 31
0
 protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
 {
     app = new SingleInstanceApplication();
     app.Run();
     return false;
 }
Esempio n. 32
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     SingleInstanceApplication.Run(new Form1(), StartupNextInstanceEventHandler);
 }
 static void Main(params string[] Arguments)
 {
     SingleInstanceApplication.Run(new ControlPanel(), NewInstanceHandler);
 }