コード例 #1
0
        private void InitializeSettings()
        {
            this.ProcessKillerKeyTextbox.GotFocus  += ProcessKillerKeyTextbox_GotFocus;
            this.ProcessKillerKeyTextbox.LostFocus += ProcessKillerKeyTextbox_OnDeFocus;
            this.CountDownKeyTextBox.GotFocus      += CountDownKeyTextBox_GotFocus;
            this.CountDownKeyTextBox.LostFocus     += CountDownKeyTextBox_OnDeFocus;

            Enum.TryParse(KeySettings.Default.ProcessKillerKey.ToString(), out _userDefinedProcessKillerKey);
            Enum.TryParse(KeySettings.Default.CountDownKey.ToString(), out _userDefinedCountDownKey);
            _disableProcessKiller = KeySettings.Default.DisableProcessKiller;
            var timerCountDownTime         = KeySettings.Default.TimerCountDownTime;
            var timerCountDownWarnningTime = KeySettings.Default.TimerCountDownWarnningTime;
            var gameDicPath = KeySettings.Default.GameDicPath;
            var serverName  = KeySettings.Default.ServerName;

            if (KeySettings.Default.Ipsettingmode.Equals("manual"))
            {
                this.rb_auto.Checked   = false;
                this.rb_manual.Checked = true;
            }
            else
            {
                this.rb_auto.Checked   = true;
                this.rb_manual.Checked = false;
            }
            txt_area.Text = KeySettings.Default.areaName;
            txt_ip.Text   = KeySettings.Default.Serveraddr;
            txt_port.Text = KeySettings.Default.Serverport;

            this.ProcessKillerKeyTextbox.Text           = _userDefinedProcessKillerKey.ToString();
            this.CountDownKeyTextBox.Text               = _userDefinedCountDownKey.ToString();
            this.TimerCountDownTimeTextBox.Text         = timerCountDownTime.ToString();
            this.TimerCountDownWarnningTimeTextBox.Text = timerCountDownWarnningTime.ToString();

            initipsetting();
            if (!string.IsNullOrEmpty(gameDicPath))
            {
                this.GameDicPathTextBox.Text = gameDicPath;
            }

            if (_disableProcessKiller)
            {
                this.DisableProcessKillCheckBox.Checked = _disableProcessKiller;
                this.ProcessKillerKeyTextbox.Enabled    = !_disableProcessKiller;
            }
            //获取大区服务器配置
            //var serverList = DNServerInfo.GetServerListFromResource();
            var serverList = DNServerInfo.GetServerListFromResourcebyxml();



            this.ServerSelectionBox.Items.AddRange(serverList.Select(s => s.Name).ToArray());
            if (!string.IsNullOrEmpty(serverName))
            {
                this.ServerSelectionBox.SelectedItem = serverName;
            }

            this.CancelButton.Select();
        }
コード例 #2
0
        private void InitializeSettings()
        {
            this.ProcessKillerKeyTextbox.GotFocus  += ProcessKillerKeyTextbox_GotFocus;
            this.ProcessKillerKeyTextbox.LostFocus += ProcessKillerKeyTextbox_OnDeFocus;
            this.CountDownKeyTextBox.GotFocus      += CountDownKeyTextBox_GotFocus;
            this.CountDownKeyTextBox.LostFocus     += CountDownKeyTextBox_OnDeFocus;

            Enum.TryParse(KeySettings.Default.ProcessKillerKey.ToString(), out _userDefinedProcessKillerKey);
            Enum.TryParse(KeySettings.Default.CountDownKey.ToString(), out _userDefinedCountDownKey);
            _disableProcessKiller = KeySettings.Default.DisableProcessKiller;
            var timerCountDownTime         = KeySettings.Default.TimerCountDownTime;
            var timerCountDownWarnningTime = KeySettings.Default.TimerCountDownWarnningTime;
            var gameDicPath = KeySettings.Default.GameDicPath;
            var serverName  = KeySettings.Default.ServerName;

            this.ProcessKillerKeyTextbox.Text           = _userDefinedProcessKillerKey.ToString();
            this.CountDownKeyTextBox.Text               = _userDefinedCountDownKey.ToString();
            this.TimerCountDownTimeTextBox.Text         = timerCountDownTime.ToString();
            this.TimerCountDownWarnningTimeTextBox.Text = timerCountDownWarnningTime.ToString();

            if (!string.IsNullOrEmpty(gameDicPath))
            {
                this.GameDicPathTextBox.Text = gameDicPath;
            }

            if (_disableProcessKiller)
            {
                this.DisableProcessKillCheckBox.Checked = _disableProcessKiller;
                this.ProcessKillerKeyTextbox.Enabled    = !_disableProcessKiller;
            }

            var serverList = DNServerInfo.GetServerListFromResource();

            this.ServerSelectionBox.Items.AddRange(serverList.Select(s => s.Name).ToArray());
            if (!string.IsNullOrEmpty(serverName))
            {
                this.ServerSelectionBox.SelectedItem = serverName;
            }

            this.CancelButton.Select();
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: yromen/repository
        /// <summary>
        /// 启动游戏
        /// </summary>
        private void start_game_button_click(object sender, EventArgs e)
        {
            _startGameButton.Enabled = false;

            try
            {
                if (string.IsNullOrEmpty(_gameDicPath))
                {
                    throw new FileNotFoundException(Resources.DNExe_NotFound_Message);
                }

                string fileName = Resources.DragonNest_LauncherExe_Name;

                var instanceCount = _processMonitor.GetRunningProcesses().Count;

                //if (instanceCount > 0)
                //{
                var instanceId = _getNextAvailableInstanceId(instanceCount);
                fileName = $"{Resources.DragonNest_Exe_Name}-PK-{instanceId}";
                File.Copy(Path.Combine(_gameDicPath, Resources.DragonNest_Exe_Name + ".exe"), Path.Combine(_gameDicPath, fileName + ".exe"), overwrite: true);
                _setCompatFlags(Path.Combine(_gameDicPath, fileName + ".exe"));
                //}

                string handleExePath = Path.Combine(_gameDicPath, "handle.exe");

                var serverName = KeySettings.Default.Ipsettingmode.Equals("manual")? KeySettings.Default.areaName : KeySettings.Default.ServerName;
                if (string.IsNullOrEmpty(serverName))
                {
                    throw new Exception(Resources.DNServer_NotFound_Message);
                }

                var serverList = KeySettings.Default.Ipsettingmode.Equals("manual") ? DNServerInfo.GetServerListbymanual() : DNServerInfo.GetServerListFromResourcebyxml();

                var server = serverList.First(s => string.Equals(serverName, s.Name));

                string args = $"/ip:{server.IpAddress} /port:{server.Port} /Lver:2 /use_packing";

                var handleFile = Path.Combine(_gameDicPath, "handle.exe");
                _extractHandleExeToTempFolderIfNotFound(handleFile);

                var appLauncher = new MutexAppLauncher(handleExePath, Resources.DragonNest_Exe_Name);
                appLauncher.Launch(_gameDicPath, fileName, args);

                if (KeySettings.Default.IsFirstTimeClickOnStartButton)
                {
                    MessageBox.Show(Resources.MainForm_start_game_button_first_click_message, Resources.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    KeySettings.Default.IsFirstTimeClickOnStartButton = false;
                    KeySettings.Default.Save();
                }
                _startGameButton.Text = Resources.MainForm_start_game_button_game_start_message;

                AppTracker.TrackEvent("AppLauncher", $"Launch_Instance_{instanceCount + 1}");
            }
            catch (Exception ex)
            {
                _startGameButton.Enabled = true;
                _startGameButton.Text    = Resources.MainForm_GetStartGameButton_title;
                Console.WriteLine(ex);
                MessageBox.Show(ex.Message, Resources.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Task.Run(() =>
            {
                Thread.Sleep(20 * 1000);
                if (IsDisposed || !this.IsHandleCreated)
                {
                    return;
                }

                this.BeginInvoke(new MethodInvoker(() =>
                {
                    _startGameButton.Text    = Resources.MainForm_GetStartGameButton_title;
                    _startGameButton.Enabled = true;
                }));
            });
        }