private void VolumeMonitor_Click(object sender, EventArgs e) { try { if (VolumeMonitor.Checked != true) { if (MaxStockClock < 1100) { DialogResult dialogResult = MessageBox.Show("Enabling a mixer on a computer with poor specs could make the driver stutter.\n\nAre you sure you want to enable it?", "Weak processor detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { VolumeMonitor.Checked = true; Settings.SetValue("VolumeMonitor", "1", RegistryValueKind.DWord); MeterFunc.EnableLEDs(); VUStatus = true; MeterFunc.ChangeMeter(0, 0); MeterFunc.ChangeMeter(1, 0); } } else if (MaxStockClock >= 1100) { VolumeMonitor.Checked = true; Settings.SetValue("VolumeMonitor", "1", RegistryValueKind.DWord); MeterFunc.EnableLEDs(); VUStatus = true; MeterFunc.ChangeMeter(0, 0); MeterFunc.ChangeMeter(1, 0); } } else { VolumeMonitor.Checked = false; Settings.SetValue("VolumeMonitor", "0", RegistryValueKind.DWord); MeterFunc.DisableLEDs(); VUStatus = false; } } catch (Exception ex) { MessageBox.Show("Can not write settings to the registry!\n\nPress OK to quit.\n\n.NET error:\n" + ex.Message.ToString(), "Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
private void VolumeCheck_Tick(object sender, EventArgs e) { try { // Something is messed up, fix it try { if (Debug.GetValueKind("leftvol") != RegistryValueKind.DWord || Debug.GetValueKind("rightvol") != RegistryValueKind.DWord) { Debug.SetValue("leftvol", 0, RegistryValueKind.DWord); Debug.SetValue("rightvol", 0, RegistryValueKind.DWord); } } catch { try { Debug.DeleteValue("leftvol"); Debug.DeleteValue("rightvol"); Debug.SetValue("leftvol", 0, RegistryValueKind.DWord); Debug.SetValue("rightvol", 0, RegistryValueKind.DWord); } catch { /* Can't do much about it */ } } // Parse the volume, and make a percentage out of it int left = Convert.ToInt32(Debug.GetValue("leftvol", 1)); int right = Convert.ToInt32(Debug.GetValue("rightvol", 1)); var perc = ((double)((left + right) / 2) / 32768) * 100; // Print the percentage VolLevel.Text = String.Format("{0}%", Math.Round(perc, 0)); // Check if mono rendering is enabled, and change the view accordingly if (Convert.ToInt32(Settings.GetValue("MonoRendering", 0)) == 1) { Size UseSize = new Size(39, 5); LLab.Size = new Size(39, 16); LLab.Text = "LVL"; ChangeLeftChannelSize(UseSize); MeterFunc.ChangeMeter(0, left); MeterFunc.ChangeMeter(1, 0); MeterFunc.AverageMeter(left, left); } else { Size UseSize = new Size(16, 5); LLab.Size = new Size(16, 16); LLab.Text = "L"; ChangeLeftChannelSize(UseSize); MeterFunc.ChangeMeter(0, left); MeterFunc.ChangeMeter(1, right); MeterFunc.AverageMeter(left, right); } // I SLEEP x3x System.Threading.Thread.Sleep(1); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }