Exemple #1
0
        public ServerControl(Server server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }

            InitializeComponent();

            _server                = server;
            _serverRunner          = new ServerRunner(server);
            _serverRunner.Stopped += OnStopped;

            Disposed += (sender, e) => _serverRunner.Dispose();

            txtName.Text    = server.Name;
            txtFolder.Text  = server.Folder;
            txtAddress.Text = server.Address.ToString();
            numPort.Value   = server.Port;
            txtMap.Text     = server.Map;
            numSlots.Value  = server.MaxPlayers;
            btnApplyGeneralSettings.Enabled = false;

            if (_serverRunner.TryRecoverProcess(out bool consoleVisible))
            {
                UpdateControls(EState.Running);
                btnHideShowConsole.Text = consoleVisible ? HIDE_CONSOLE_TEXT : SHOW_CONSOLE_TEXT;
            }
            else
            {
                UpdateControls(EState.Stopped);
            }
        }
Exemple #2
0
        private static void Dispose()
        {
            if (_disposing)
            {
                return;
            }

            _server?.Dispose();
            _updater?.Dispose();
            _cts.Cancel();
            _disposing = true;
        }