private void SaveUserSettings()
        {
            if (!string.IsNullOrEmpty(this.ProcessKillerKeyTextbox.Text))
            {
                KeySettings.Default.ProcessKillerKey = (int)_userDefinedProcessKillerKey;
            }

            if (!string.IsNullOrEmpty(this.CountDownKeyTextBox.Text))
            {
                KeySettings.Default.CountDownKey = (int)_userDefinedCountDownKey;
            }

            if (!string.IsNullOrEmpty(this.GameDicPathTextBox.Text))
            {
                KeySettings.Default.GameDicPath = this.GameDicPathTextBox.Text;
            }

            if (this.ServerSelectionBox.SelectedItem != null)
            {
                if (!string.Equals(this.ServerSelectionBox.Text, KeySettings.Default.ServerName, StringComparison.CurrentCultureIgnoreCase))
                {
                    AppTracker.TrackEvent("Settings", $"SetServer_{this.ServerSelectionBox.Text}");
                }
                KeySettings.Default.ServerName = this.ServerSelectionBox.SelectedItem.ToString();
            }

            KeySettings.Default.TimerCountDownTime = int.Parse(this.TimerCountDownTimeTextBox.Text);

            KeySettings.Default.TimerCountDownWarnningTime = int.Parse(this.TimerCountDownWarnningTimeTextBox.Text);

            KeySettings.Default.DisableProcessKiller = this.DisableProcessKillCheckBox.Checked;

            KeySettings.Default.Save(); // Saves settings in application configuration file
        }
Пример #2
0
        private void exit_button_Click(object sender, EventArgs e)
        {
            _runningTimer.Stop();
            var runningHours = (int)Math.Round(_runningTimer.Elapsed.TotalHours);

            AppTracker.TrackEvent("Timer", $"AppRunningTime_{runningHours}");
            Application.Exit();
        }
Пример #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //KeySettings.Default.Reset();

            // check admin privilege
            if (IsAdministrator())
            {
                var currentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(3);
                AppTracker.TrackEvent("Application", $"Start_Version_{currentVersion}");
                Application.Run(new MainForm());
            }
            else
            {
                ShowAdminPrivilegeMessageBox();
            }
        }
Пример #4
0
        /// <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;
                }));
            });
        }
Пример #5
0
 private void new_version_link_clicked(object sender, EventArgs e)
 {
     AppTracker.TrackEvent("MainForm", "NewVersionLinkClicked");
     Process.Start(Resources.Application_Web_HomePage);
 }