Esempio n. 1
0
        public static RconWindow GetRconForServer(Server server)
        {
            if (!RconWindows.TryGetValue(server, out RconWindow window) || !window.IsLoaded)
            {
                window = new RconWindow(new RconParameters()
                {
                    WindowTitle     = String.Format(GlobalizedApplication.Instance.GetResourceString("RCON_TitleLabel"), server.Runtime.ProfileSnapshot.ProfileName),
                    WindowExtents   = server.Profile.RconWindowExtents,
                    PlayerListWidth = server.Profile.RconPlayerListWidth,

                    Server           = server,
                    InstallDirectory = server.Runtime.ProfileSnapshot.InstallDirectory,
                    GameFile         = server.Runtime.ProfileSnapshot.GameFile,
                    ProfileId        = server.Runtime.ProfileSnapshot.ProfileId,
                    ProfileName      = server.Runtime.ProfileSnapshot.ProfileName,
                    MaxPlayers       = server.Runtime.MaxPlayers,
                    RconHost         = server.Runtime.ProfileSnapshot.ServerIP,
                    RconPort         = server.Runtime.ProfileSnapshot.RconPort,
                    RconPassword     = server.Runtime.ProfileSnapshot.RconPassword,
                });
                RconWindows[server] = window;
            }

            return(window);
        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);
            RconWindow.CloseAllWindows();
            PlayerListWindow.CloseAllWindows();
            ServerMonitorWindow.CloseAllWindows();
            this.versionChecker.DisposeAsync().DoNotWait();

            var installFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var backupFolder  = IOUtils.NormalizePath(string.IsNullOrWhiteSpace(Config.Default.BackupPath)
                ? Path.Combine(Config.Default.DataPath, Config.Default.BackupRelativePath)
                : Path.Combine(Config.Default.BackupPath));

            SettingsUtils.BackupUserConfigSettings(Config.Default, "userconfig.json", installFolder, backupFolder);
            SettingsUtils.BackupUserConfigSettings(CommonConfig.Default, "commonconfig.json", installFolder, backupFolder);
        }