Esempio n. 1
0
        private void Switch(string name, bool autoRestart)
        {
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请选择要切换的账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!autoRestart)
            {
                if (YuanShenIsRunning())
                {
                    MessageBox.Show("原神正在运行,请先关闭原神进程后再切换账号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            if (chkSkipTips.Checked || MessageBox.Show($"是否要切换为[{name}]", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (autoRestart)
                {
                    var pros = Process.GetProcessesByName("YuanShen");
                    if (pros.Any())
                    {
                        pros[0].Kill();
                    }
                }
                YSAccount acct = YSAccount.ReadFromDisk(name);
                acct.WriteToRegedit();

                if (autoRestart)
                {
                    if (string.IsNullOrEmpty(txtPath.Text))
                    {
                        MessageBox.Show("请选择原神安装路径后,才能使用自动重启功能", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        chkAutoStartYS.Checked = false;
                    }
                    else
                    {
                        try
                        {
                            ProcessStartInfo startInfo = new ProcessStartInfo();
                            startInfo.UseShellExecute  = true;
                            startInfo.WorkingDirectory = Environment.CurrentDirectory;
                            startInfo.FileName         = Path.Combine(txtPath.Text, "Genshin Impact Game", "YuanShen.exe");
                            startInfo.Verb             = "runas";
                            startInfo.Arguments        = txtStartParam.Text;
                            Process.Start(startInfo);
                        }
                        catch
                        {
                        }
                    }
                }

                if (!chkSkipTips.Checked)
                {
                    MessageBox.Show($"账户[{name}]切换成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 2
0
        public static YSAccount ReadFromRegedit(bool needSettings)
        {
            YSAccount acct = new YSAccount();

            acct.MIHOYOSDK_ADL_PROD_CN_h3123967166 = GetStringFromRegedit("MIHOYOSDK_ADL_PROD_CN_h3123967166");
            if (needSettings)
            {
                acct.GENERAL_DATA_h2389025596 = GetStringFromRegedit("GENERAL_DATA_h2389025596");
            }
            return(acct);
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtAcctName.Text))
            {
                MessageBox.Show("请输入账号备注", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            YSAccount acct = YSAccount.ReadFromRegedit(chkSaveSettings.Checked);

            acct.Name = txtAcctName.Text;
            acct.WriteToDisk();
            this.Close();
        }
Esempio n. 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lvwAcct.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择要切换的账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string name = lvwAcct.SelectedItems[0]?.Text;

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请选择要切换的账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            YSAccount.DeleteFromDisk(name);
            RefreshList();
        }