Ejemplo n.º 1
0
        private static void OnGameFinish(Result <ExitStatus, TimeSpan, GClass_GameFinish> result)
        {
            GInterface22    backend         = ClientAppUtils.GetBackendSession();
            MainApplication mainApplication = MainAppUtils.GetMainApp();

            if (backend?.Profile == null || mainApplication == null)
            {
                _gameCallBack(result);
                return;
            }

            ESideType?eSideType = PrivateValueAccessor.GetPrivateFieldValue(mainApplication.GetType(),
                                                                            "esideType_0", mainApplication) as ESideType?;
            Profile profile      = backend.Profile;
            bool    isPlayerScav = false;

            if (eSideType != null && eSideType.GetValueOrDefault() == ESideType.Savage)
            {
                profile      = backend.ProfileOfPet;
                isPlayerScav = true;
            }

            try
            {
                CreatePlayerOwnerMonitor.Catched = false;
                ProfileSaveUtil.SaveProfileProgress(profile, result.Value0, backend.GetPhpSessionId(), isPlayerScav);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }

            _gameCallBack(result);
        }
Ejemplo n.º 2
0
 private static void Form_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         MainAppUtils.DestroyApp();
     }
     catch (Exception ex)
     {
         Log.ShowError(ex);
     }
 }
Ejemplo n.º 3
0
        static public void Init(TestContext context)
        {
            FrwConfig.Instance            = new FrwSimpleWinCRUDConfig();
            FrwConfig.Instance.ProfileDir = "Data\\TestProfile";//set custom profile name to prevent override demo database
            MainAppUtils.InitAppPaths();

            Console.WriteLine("FrwConfig.Instance.GlobalDir: " + FrwConfig.Instance.GlobalDir);
            Console.WriteLine("FrwConfig.Instance.ProfileDir: " + FrwConfig.Instance.ProfileDir);
            Console.WriteLine("FrwConfig.Instance.ComputerUserDir: " + FrwConfig.Instance.ComputerUserDir);
            Console.WriteLine("FrwConfig.Instance.UserTempDir: " + FrwConfig.Instance.UserTempDir);
        }
Ejemplo n.º 4
0
 private static void ApplicationContext_ThreadExit(object sender, EventArgs e)
 {
     try
     {
         JobManager.Instance.AbortAllJobsAndJobBatches();
     }
     catch (Exception ex)
     {
         Log.ShowError(ex);
     }
     MainAppUtils.DestroyApp();
 }
Ejemplo n.º 5
0
        static void Main()
        {
            MainAppUtils.AjustVideoSetting();
            try
            {
                Form form = null;
                try
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    if (!MainAppUtils.CheckForSingleInstance())
                    {
                        return;
                    }
                    log = Log.GetLogger();
                    //http://stackoverflow.com/questions/8137070/force-application-close-on-system-shutdown
                    //SystemEvents can help you. The SessionEnding occurs when the user is trying to log off or shut down the system.
                    Microsoft.Win32.SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                    //If you don't want to cancel the event, but just react to it appropriately, you should handle the SystemEvents.SessionEnded event instead.
                    Microsoft.Win32.SystemEvents.SessionEnded += SystemEvents_SessionEnded;

                    //for testing, remove this lines in real app
                    //var culture = new CultureInfo("en-US");
                    //CultureInfo.DefaultThreadCurrentCulture = culture;
                    //CultureInfo.DefaultThreadCurrentUICulture = culture;

                    //create instances of manager classes
                    FrwConfig.Instance  = new VpnSelectorConfig();
                    AppManager.Instance = new VpnSelectorAppManager();
                    AppManager.Instance.MainAppFormType = typeof(VpnSelectorMainForm);
                    Dm.Instance = new VpnSelectorDm();
                    //force load dlls with entities
                    //...
                    VpnSelectorLibLoader.Load();
                    //BaseProxyServer.CurrentType = typeof(FProxyServer);
                    //BaseProxyProvider.CurrentType = typeof(FProxyProvider);

                    MainAppUtils.InitAppPaths();

                    JSetting setting = FrwConfig.Instance.CreatePropertyIfNotExist(new JSetting()
                    {
                        Name                 = "RunAppInWindowsTray",
                        Description          = VpnSelectorLibRes.Run_application_in_windows_system_tray__next_run_,
                        Value                = true,
                        IsUser               = true,
                        IsAttachedToComputer = false
                    });

                    if (FrwConfig.Instance.GetPropertyValueAsBool(setting.Name, true))
                    {
                        applicationContext = new BaseApplicationContext();
                        applicationContext.DefaultTooltip = VpnSelectorLibRes.VPN_selector;
                        applicationContext.IconFileName   = "icon_vpn_selector.ico";
                        applicationContext.Load();
                        BaseApplicationContext.NotifyIcon.Icon = VpnSelectorLibRes.vpn_off;
                        applicationContext.ThreadExit         += ApplicationContext_ThreadExit;
                        Application.Run(applicationContext);
                    }
                    else
                    {
                        form              = AppManager.Instance.LoadDocPanelContainersState(true);
                        form.FormClosing += Form_FormClosing;
                        form.FormClosed  += Form_FormClosed;
                    }
                }
                catch (Exception ex)
                {
                    Log.ShowError("Error start app", ex);
                    Application.Exit();
                }
                if (form != null && !form.IsDisposed)
                {
                    Application.ThreadException += Application_ThreadException;
                    Application.Run(form);
                }
            }
            catch (Exception ex)
            {
                Log.ShowError("Error start app", ex);
                Application.Exit();
            }
        }