private void MainForm_Load(object sender, EventArgs e) { changeLabel.Text = "Add: 0\r\nRemove: 0"; int ScreenMode = 1; int ResolutionX = 0; int ResolutionY = 0; int ResolutionFreq = 0; RegistryKey registry = null; try { registry = Registry.CurrentUser.OpenSubKey(registryKeyPath, false); if (registry != null) { object value = registry.GetValue("ScreenMode"); if (value != null) { ScreenMode = (int)value; } value = registry.GetValue("ResolutionX"); if (value != null) { ResolutionX = (int)value; } value = registry.GetValue("ResolutionY"); if (value != null) { ResolutionY = (int)value; } value = registry.GetValue("ResolutionFreq"); if (value != null) { ResolutionFreq = (int)value; } } } finally { if (registry != null) { registry.Close(); } } DisplayModeList displayModeList = new DisplayModeList(); foreach (DEVMODE mode in displayModeList) { if (mode.dmPelsWidth >= 800 && mode.dmPelsHeight >= 480 && mode.dmBitsPerPel >= 16) { resolutionBox.Items.Add(new DisplayMode(mode)); if (mode.dmPelsWidth == ResolutionX && mode.dmPelsHeight == ResolutionY && mode.dmDisplayFrequency == ResolutionFreq) { resolutionBox.SelectedIndex = resolutionBox.Items.Count - 1; } } } if (resolutionBox.SelectedIndex < 0) { resolutionBox.SelectedIndex = resolutionBox.Items.Count - 1; } switch (ScreenMode) { case 0: screenWindowRadio.Checked = true; break; case 1: screenNormalRadio.Checked = true; break; case 2: screenResolutionRadio.Checked = true; break; } installer = new Installer(); english = new AddOn(AddOnType.Language, "english", false); english.Name = "English"; Text += " " + AddOn.VersionToString(thisVersion); }
private void list_SelectedIndexChanged(object sender, EventArgs e) { if (list.SelectedItems.Count == 0) { creatorLabel.Text = ""; infoLabel.Text = ""; readmeButton.Visible = false; } else { AddOn addOn = (AddOn)list.SelectedItems[0].Tag; creatorLabel.Text = "Created by " + addOn.Creator; infoLabel.Text = addOn.Info; readmeButton.Visible = addOn.Installed && addOn.Readme != "" && File.Exists(Installer.GetReadmePath(addOn)); } }
private void okButton_Click(object sender, EventArgs e) { //AddOnSet testSet = new AddOnSet(); //AddOn addOn1 = new AddOn(AddOnType.AI, "X1", false); //addOn1.URL = "http://c-evo.org//files//v06_legal.exe"; //addOn1.Size = 690176; //testSet.Add(addOn1); //AddOn addOn2 = new AddOn(AddOnType.AI, "X2", false); //addOn2.URL = "http://c-evo.org//files//cevosetup.exe"; //addOn2.Size = 2957161; //testSet.Add(addOn2); //AddOn addOn3 = new AddOn(AddOnType.AI, "X3", false); //addOn3.URL = "http://c-evo.org//files//v0147.exe"; //addOn3.Size = 1953792; //testSet.Add(addOn3); //installer.Install(testSet); RegistryKey registry = Registry.CurrentUser.CreateSubKey(registryKeyPath); if (screenWindowRadio.Checked) { registry.SetValue("ScreenMode", 0); } else if (screenNormalRadio.Checked) { registry.SetValue("ScreenMode", 1); } else if (screenResolutionRadio.Checked) { registry.SetValue("ScreenMode", 2); if (resolutionBox.SelectedIndex >= 0) { registry.SetValue("ResolutionX", ((DisplayMode)resolutionBox.SelectedItem).mode.dmPelsWidth); registry.SetValue("ResolutionY", ((DisplayMode)resolutionBox.SelectedItem).mode.dmPelsHeight); registry.SetValue("ResolutionBPP", ((DisplayMode)resolutionBox.SelectedItem).mode.dmBitsPerPel); registry.SetValue("ResolutionFreq", ((DisplayMode)resolutionBox.SelectedItem).mode.dmDisplayFrequency); } } registry.Close(); installer.Uninstall(LanguageRemoveSet); installer.Uninstall(mapSelector.RemoveSet); installer.Uninstall(aiSelector.RemoveSet); installer.Install(LanguageAddSet); installer.Install(mapSelector.AddSet); installer.Install(aiSelector.AddSet); if (installer.InstallOrdered) { Visible = false; ProgressDialog progressDialog = new ProgressDialog(installer); progressDialog.Text = "Downloading..."; progressDialog.ShowDialog(); TextViewer textViewer = new TextViewer(); foreach (AddOn addOn in installer.Added) { if (addOn.Readme != "" && File.Exists(Installer.GetReadmePath(addOn))) { textViewer.ShowReadme(addOn); } } } else { installer.Go(); // remove only or nothing, expect this not to require progress indication } CloseAndRun(); }