Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();

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


            string[] args = new string[e.CommandLine.Count];
            for (int i = 0; i < e.CommandLine.Count; i++)
            {
                args[i] = e.CommandLine[i];
            }
            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            SingleInstanceApplication app = (SingleInstanceApplication)sender;

            foreach (Form form in app.OpenForms)
            {
                if (form.Name == "Main")
                {
                    ((Main)form).HandleNewInstance(options);
                    break;
                }
            }
        }
Exemplo n.º 6
0
        private void Load()
        {
            if (_loaded)
            {
                return;
            }

            _loaded = true;

            try
            {
                _settings.Load();
            }
            catch (ConfigurationException ex)
            {
                if (!(ex.InnerException is ConfigurationErrorsException configError) ||
                    string.IsNullOrEmpty(configError.Filename))
                {
                    throw;
                }

                File.Delete(configError.Filename);
                SingleInstanceApplication.ReleaseSingleInstanceLock();
                Process.Start(System.Windows.Application.ResourceAssembly.Location);
                Environment.Exit(0);
            }
        }
Exemplo n.º 7
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());
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
         static void Main(params string[] Arguments)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             mainForm = new MainForm(Arguments);
             SingleInstanceApplication.Run(mainForm, NewInstanceHandler);
 
         }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
0
 private void PlatformOnHide(SingleInstanceApplication application)
 {
     DebugOutput("****** PlatformOnHide on thread: " + System.Threading.Thread.CurrentThread.ManagedThreadId);
     if ((application != null) && (application.MainWindow != null))
     {
         application.MainWindow.Destroyed -= HandleMainWindowDestroyed;
     }
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
0
 public static void Run(Form form)
 {
     _application = new SingleInstanceApplication {
         MainForm = form
     };
     _application.StartupNextInstance += NextInstanceHandler;
     _application.Run(Environment.GetCommandLineArgs());
 }
Exemplo n.º 14
0
    public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
    {
        SingleInstanceApplication app = new SingleInstanceApplication();

        app.MainForm             = f;
        app.StartupNextInstance += startupHandler;
        app.Run(new string[0]);
    }
 private void PlatformOnHide(SingleInstanceApplication application)
 {
     if ((application != null) && (application.MainWindow != null))
     {
         application.MainWindow.WindowShouldClose = _previousShouldClosePredicate;
         _previousShouldClosePredicate            = null;
     }
 }
    public static void Run(Form f, StartupNextInstanceEventHandler startupHandler)
    {
        SingleInstanceApplication app = new SingleInstanceApplication();

        app.MainForm             = f;
        app.StartupNextInstance += startupHandler;
        app.Run(Environment.GetCommandLineArgs());
    }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(Program));

            try
            {
                log.Info(LogFormat.Message("", "Application_start", LogStatus.Success, ""));

                MultiLanguageManager.SetDefaultLabelsDictionary <DSW.Localisation.Labels.Dictionary>();
                MultiLanguageManager.SetDefaultMessageDictionary <DSW.Localisation.Messages.Dictionary>();

                if (SingleInstanceApplication.IsExist())
                {
                    FormUtility.EnableTaskBar(false);
                    FormUtility.EnableTaskBar(true);

                    MessageUtility.DisplayErrorMsg(MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_MS029),
                                                   MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_CAP001));

                    log.Info(LogFormat.Message("", "Application_end", LogStatus.Failed, DSW.Localisation.Messages.Dictionary.Common.HT_COM_MS029));

                    Application.Exit();

                    return;
                }

                FormUtility.EnableTaskBar(false);

                AppDataService.SetSettingApiAddress(Setting.ApiAddress);

                var appModule       = new AppModule();
                var mvvmApplication = new MvvmApplication(appModule);

                mvvmApplication.Run <StocktakeNewView>();

                FormUtility.EnableTaskBar(true);

                log.Info(LogFormat.Message("", "Application_end", LogStatus.Success, ""));

                LogManager.Shutdown();
            }
            catch (Exception ex)
            {
                log.Info(LogFormat.Message("", "Application_end", LogStatus.Failed, ex.Message + Environment.NewLine + ex.StackTrace));

                LogManager.Shutdown();

                FormUtility.EnableTaskBar(false);
                FormUtility.EnableTaskBar(true);

                MessageUtility.DisplayErrorMsg(ex.Message,
                                               MultiLanguageManager.Messages.GetString(DSW.Localisation.Messages.Dictionary.Common.HT_COM_CAP001));

                Application.Exit();
            }
        }
 private void PlatformOnShow(SingleInstanceApplication application)
 {
     if ((application != null) && (application.MainWindow != null))
     {
         _previousShouldClosePredicate            = application.MainWindow.WindowShouldClose;
         application.MainWindow.WindowShouldClose = MainWindowShouldClose;
     }
     DebugOutput("****** SHOWING PROGRESS from thread: " + NSThread.Current.Handle + ", MAIN: " + NSThread.MainThread.Handle);
 }
Exemplo n.º 19
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());
     }
 }
Exemplo n.º 20
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());
        }
Exemplo n.º 21
0
 /// <summary>
 /// Single instance callback handler.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="SingleInstanceApplication.InstanceCallbackEventArgs"/> instance containing the event data.</param>
 private static void SingleInstanceCallback(object sender, SingleInstanceApplication.InstanceCallbackEventArgs args)
 {
     if (args == null || _mainFrm == null) return;
     Action<bool> d = (bool x) =>
     {
         _mainFrm.AppendArgs(args.CommandLineArgs);
         _mainFrm.Activate(x);
     };
     _mainFrm.Invoke(d, true);
 }
Exemplo n.º 22
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);
 }
Exemplo n.º 23
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());
            }
Exemplo n.º 24
0
    public static void Run(Form form)
    {
        var app = new SingleInstanceApplication
        {
            MainForm = form
        };

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

        app.Run(Environment.GetCommandLineArgs());
    }
Exemplo n.º 25
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());
        }
Exemplo n.º 26
0
        protected override void OnExit(object sender, ExitEventArgs eventArgs)
        {
            Logger.Info("Exiting application.");

            // Clean up.
            _editor.Shutdown();
            _serviceContainer.Dispose();
            SingleInstanceApplication.Cleanup();

            // Set application's exit code.
            eventArgs.ApplicationExitCode = _editor.ExitCode;
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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());
            }
Exemplo n.º 29
0
        /// <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);
        }
Exemplo n.º 30
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);
        }
Exemplo n.º 31
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());
        }
Exemplo n.º 32
0
        private static void InitContainer()
        {
            var application = new SingleInstanceApplication();

            _controller = new ApplicationController(new LightInjectAdapder())
                          .RegisterInstance(application)
                          .RegisterInstance(application.ApplicationContext)
                          .RegisterService <ISmartShipmentsSettingsHelper, SmartShipmentsSettingsHelper>()
                          .RegisterService <ISmartShipmentMessagesProvider, SmartShipmentMessagesProvider>()
                          .RegisterService <ISingleInstanceManager, SingleInstanceManager>()
                          .RegisterServicePerContainer <ISettings, SmartShipmentSettings>()
                          .RegisterView <IFloatMenuView, FloatMenuWindow>()
                          .RegisterView <ISmartSettingsDialogView, SmartShipmentSettingsDialog>();

            //Logger
            _controller.RegisterServicePerContainer <ILogger, SmartShipmentLogger>();

            //UI Automation
            _controller.RegisterService <IUIAutomationBrowserHelper, UIAutomationBrowserHelper>();

            //Network adapter
            _controller.RegisterService <IWebServiceHelper, WebServiceSoapHelper>();

            _controller.RegisterService <IAcumaticaUriParser, AcumaticaUriParser>()
            .RegisterService <IBrowserHelper, BrowserHelper>()
            .RegisterService <IAcumaticaNetworkProvider, AcumaticaNetworkProvider>();

            //Cache
            _controller.RegisterServicePerContainer <IShipmentAutomationCache, ShipmentAutomationCache>();

            //Export & Import contexts
            _controller.RegisterService <ISmartShipmentExportContext, SmartShipmentExportContext>();

            //File Watcher
            _controller.RegisterService <ISmartShipmentFilesMonitor, SmartShipmentFilesMonitor>();
            _controller.RegisterService <ISmartShipmentFileProvider, SmartShipmentFileProvider>(ApplicationTypes.UpsWorldShip.ToString());
            _controller.RegisterService <ISmartShipmentFileProvider, SmartShipmentFedexFileProvider>(ApplicationTypes.FedExShipmentManager.ToString());
            _controller.RegisterService <ISmartShipmentExportParametersParser, SmartShipmentUpsExportParametersParser>(ApplicationTypes.UpsWorldShip.ToString());
            _controller.RegisterService <ISmartShipmentExportParametersParser, SmartShipmentFedexExportParametersParser>(ApplicationTypes.FedExShipmentManager.ToString());
            _controller.RegisterService <ISmartShipmentFileWatcher, SmartShipmentFileWatcher>();

            //Applications adapters
            _controller.RegisterService <IShipmentApplicationHelper, UpsShipmentApplicationHelper>(ApplicationTypes.UpsWorldShip.ToString())
            .RegisterService <IShipmentApplicationHelper, FedexShipmentApplicationHelper>(ApplicationTypes.FedExShipmentManager.ToString())
            .RegisterService <IShipmentApplicationAdapter, ShipmentApplicationAdapter>();
        }
Exemplo n.º 33
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());
            }
Exemplo n.º 34
0
        public static void NewInstanceHandler(object sender, StartupNextInstanceEventArgs e)
        {
            //first parameter is application path
            //second is parameter from proffix
            //string sParams = e.CommandLine[1];
            //MessageBox.Show(sParams);

            if (sender != null && (e.CommandLine != null && e.CommandLine.Count > 0))
            {
                //_MainForm.ShowModule(Library.Global.ApplicationModules.PriceModuleCalculation, e.CommandLine.ToArray());
                SingleInstanceApplication app = (SingleInstanceApplication)sender;
                MainForm oForm = (MainForm)app.OpenForms[0];

                e.BringToForeground = true;
                oForm.CallByProffix(e.CommandLine.ToArray());
                //oForm.ShowModule(Library.Global.ApplicationModules.PriceModuleCalculation, e.CommandLine.ToArray());
            }
        }
Exemplo n.º 35
0
        private static async Task Run(string[] args)
        {
            // The app v1.13.0 starts update installer under local SYSTEM account.
            // Therefore, when update is complete, the installer starts the app under
            // SYSTEM account too. The app running under local SYSTEM account
            // cannot access user settings.
            //
            // If the app detects it is started under local SYSTEM account, it
            // tries to restart itself under current user account.
            var shouldRestartAsUser = ElevatedApplication.RunningAsSystem();

            if (shouldRestartAsUser)
            {
                await Task.Delay(2000);

                ElevatedApplication.LaunchAsUser();
                return;
            }

            if (await SingleInstanceApplication.InitializeAsFirstInstance("{588dc704-8eac-4a43-9345-ec7186b23f05}", args))
            {
                AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyLoadFailed;

                SetDllDirectories();

                var config = GetConfig();

                InitCrashReporting(config);
                CreateProfileOptimization(config);

                var app = new App();
                app.InitializeComponent();

                _bootstrapper = new Bootstrapper(args);
                _bootstrapper.Initialize();

                HandleIntentionalCrash(app, args);

                app.Run();
            }
        }
Exemplo n.º 36
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;
            }