private void textBoxSetMemory_TextChanged(object sender, EventArgs e) { try { if (int.Parse(textBoxSetMemory.Text) > int.Parse(ComputerInfo.GetMemoryAvailable())) { textRemainMemoryActive.Text = (int.Parse(ComputerInfo.GetMemoryAvailable())).ToString() + " MB"; textBoxSetMemory.Text = (int.Parse(ComputerInfo.GetMemoryAvailable())).ToString(); } else { return; } } catch { textBoxSetMemory.Text = (int.Parse(ComputerInfo.GetMemoryAvailable())).ToString(); } }
public Main() { InitializeComponent(); // Read config file // Get computer info if (ComputerInfo.GetOSVersion() != "Error") { textOSVersionActive.Text = ComputerInfo.GetOSVersion(); } else { textOSVersionActive.Text = "获取失败"; } if (ComputerInfo.GetCPU() != "Error") { textCPUModelActive.Text = ComputerInfo.GetCPU(); } else { textCPUModelActive.Text = "获取失败"; } if (ComputerInfo.GetGPU() != "Error") { textGPUModelActive.Text = ComputerInfo.GetGPU(); } else { textGPUModelActive.Text = "获取失败"; } textTotalMemoryActive.Text = ComputerInfo.GetMemoryTotal().ToString() + " MB"; textRemainMemoryActive.Text = ComputerInfo.GetMemoryAvailable().ToString() + " MB"; textRecommendMemoryActive.Text = (int.Parse(ComputerInfo.GetMemoryTotal()) / 4).ToString() + " MB"; textBoxSetMemory.Text = (int.Parse(ComputerInfo.GetMemoryTotal()) / 4).ToString(); listBoxLoginType.SelectedIndex = 0; textBoxYggdrasilServer.Enabled = false; textBoxPassword.Enabled = false; buttonLogin.Enabled = false; listBoxPlayerRole.Enabled = false; textMimirNotice.Visible = false; // Todo: 这个实现将会被修改 // Find Javas if (!Java.Init()) { DialogResult = MessageBox.Show(text: "Java获取失败,可能是没有安装Java也可能是启动器的问题,请尝试安装Java或配置Java环境变量。\n(但仍可以尝试启动,不过产生任何异常概不负责,还要继续运行吗?)", caption: "EMCL 无法找到Java", buttons: MessageBoxButtons.OKCancel, icon: MessageBoxIcon.Error); if (DialogResult == DialogResult.OK) { checkBoxSetJavaPath.Checked = true; textBoxSetJavaPath.Enabled = true; textBoxSetJavaPath.Text = "java"; } else { Environment.Exit(2); } } else { textBoxSetJavaPath.Text = Java.JavaPath; comboBoxJavaSelect.Items.Add(JavaVersion); comboBoxJavaSelect.SelectedIndex = 0; } textJavaVersionActive.Text = JavaVersion; // Find versions Directory.CreateDirectory(GamePath); Directory.CreateDirectory(GamePath + "\\versions"); GetVersionsList(true); // Status textStatus.Text = "就绪"; }