private void buttonOK_Click(object sender, EventArgs e) { if (!gGame.CanSerialize()) { return; } // Settings tab foreach (ListViewItem item in SettingsList.Items) { string FileName = item.Text; if (gGame.Settings.ContainsKey(FileName)) { gGame.Settings[FileName].IsEnabled = item.Checked; } } // Power Profiles tab gGame.PowerProfiles.Clear(); foreach (ListViewItem item in ProfilesList.Items) { PowerProfile profile = MainForm.ProfileDB[(Guid)item.Tag]; if (item.Checked) { gGame.PowerProfiles.Add(profile.ProfileGuid, profile); } } gGame.SanityCheck(); gForm.InsertOrUpdateGameItem(gGame, false); this.Close(); }
private void numericUpDown8_ValueChanged(object sender, EventArgs e) { ListViewItem item = ProfilesList.SelectedItems[0]; Guid ProfileGuid = (Guid)item.Tag; PowerProfile CurrentProfile = Profiles[ProfileGuid]; CurrentProfile.IntelGPU = numericUpDown8.Value.ToString(); CurrentProfile.JustUpdated = true; }
public void DigestProfile(PowerProfile profile, bool isMerged) { if (profile.HasLongPowerMax()) { TurboBoostLongPowerMax = profile.TurboBoostLongPowerMax; } if (profile.HasShortPowerMax()) { TurboBoostShortPowerMax = profile.TurboBoostShortPowerMax; } if (profile.HasCPUCore()) { CPUCore = profile.CPUCore; } if (profile.HasIntelGPU()) { IntelGPU = profile.IntelGPU; } if (profile.HasCPUCache()) { CPUCache = profile.CPUCache; } if (profile.HasSystemAgent()) { SystemAgent = profile.SystemAgent; } if (profile.HasPowerBalanceCPU()) { PowerBalanceCPU = profile.PowerBalanceCPU; } if (profile.HasPowerBalanceGPU()) { PowerBalanceGPU = profile.PowerBalanceGPU; } if (isMerged) { if (profile.ApplyPriority != -1) { ProfileName += (ProfileName.Equals("") ? "" : " & ") + profile.ProfileName; Merged++; } } else { ProfileName = profile.ProfileName; ApplyMask = profile.ApplyMask; ApplyPriority = profile.ApplyPriority; } ComputeHex(); }
public bool Equals(PowerProfile compare) { if (TurboBoostLongPowerMax != compare.TurboBoostLongPowerMax || TurboBoostShortPowerMax != compare.TurboBoostShortPowerMax || CPUCore != compare.CPUCore || CPUCache != compare.CPUCache || IntelGPU != compare.IntelGPU || SystemAgent != compare.SystemAgent || PowerBalanceCPU != compare.PowerBalanceCPU || PowerBalanceGPU != compare.PowerBalanceGPU) { return(false); } return(true); }
private void MenuItemRemoveSetting_Click(object sender, EventArgs e) { ListViewItem item = ProfilesList.SelectedItems[0]; Guid ProfileGuid = (Guid)item.Tag; ProfilesList.Items.Remove(item); Profiles.Remove(ProfileGuid); if (MainForm.ProfileDB.ContainsKey(ProfileGuid)) { PowerProfile profile = MainForm.ProfileDB[ProfileGuid]; profile.Remove(); } }
private void ProfilesList_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.Label == null) { return; } ListViewItem item = ProfilesList.SelectedItems[0]; Guid ProfileGuid = (Guid)item.Tag; PowerProfile CurrentProfile = Profiles[ProfileGuid]; CurrentProfile.ProfileName = e.Label; CurrentProfile.JustUpdated = true; }
private void MenuItemCreateSetting_Click(object sender, EventArgs e) { string ProfileName = Interaction.InputBox("Please make sure profile name is not already used.", "New Power Profile"); if (ProfileName == "") { MessageBox.Show("Profile name can't be empty."); return; } PowerProfile pP = new PowerProfile(ProfileName); MainForm.ProfileDB[pP.ProfileGuid] = pP; Profiles[pP.ProfileGuid] = pP; ListViewItem newProfile = new ListViewItem(new string[] { pP.ProfileName }, pP.ProfileName); newProfile.Tag = pP.ProfileGuid; ProfilesList.Items.Add(newProfile); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { ListViewItem item = ProfilesList.SelectedItems[0]; Guid ProfileGuid = (Guid)item.Tag; PowerProfile CurrentProfile = Profiles[ProfileGuid]; // reset before updating CurrentProfile._ApplyMask = 0; if (listBoxTriggers.GetSelected(0)) { CurrentProfile._ApplyMask |= ProfileMask.OnBattery; } if (listBoxTriggers.GetSelected(1)) { CurrentProfile._ApplyMask |= ProfileMask.PluggedIn; } if (listBoxTriggers.GetSelected(2)) { CurrentProfile._ApplyMask |= ProfileMask.ExternalGPU; } if (listBoxTriggers.GetSelected(3)) { CurrentProfile._ApplyMask |= ProfileMask.ExternalScreen; } if (listBoxTriggers.GetSelected(4)) { CurrentProfile._ApplyMask |= ProfileMask.OnStartup; } if (listBoxTriggers.GetSelected(5)) { CurrentProfile._ApplyMask |= ProfileMask.OnStatusChange; } if (listBoxTriggers.GetSelected(6)) { CurrentProfile._ApplyMask |= ProfileMask.GameBounds; } }
private void ProfilesList_SelectedIndexChanged(object sender, EventArgs e) { MenuItemRemoveSetting.Enabled = false; groupBoxPowerBalance.Enabled = false; groupBoxPowerProfile.Enabled = false; groupBoxFIVR.Enabled = false; groupBoxTriggers.Enabled = false; foreach (ListViewItem item in ProfilesList.SelectedItems) { Guid ProfileGuid = (Guid)item.Tag; if (MainForm.ProfileDB.ContainsKey(ProfileGuid)) { groupBoxPowerProfile.Enabled = true; groupBoxTriggers.Enabled = true; switch (MainForm.CurrentCPU.Constructor) { case CPU.Manufacturer.Intel: groupBoxFIVR.Enabled = true; groupBoxPowerBalance.Enabled = true; break; case CPU.Manufacturer.AMD: groupBoxFIVR.Enabled = false; groupBoxPowerBalance.Enabled = false; break; } MenuItemRemoveSetting.Enabled = true; } } foreach (Control ctrl in groupBoxFIVR.Controls) { if (ctrl.GetType() == typeof(TextBox)) { ctrl.Text = ""; } } foreach (Control ctrl in groupBoxPowerProfile.Controls) { if (ctrl.GetType() == typeof(TextBox)) { ctrl.Text = ""; } } foreach (ListViewItem item in ProfilesList.SelectedItems) { string ProfileName = item.Text; Guid ProfileGuid = (Guid)item.Tag; PowerProfile CurrentProfile = Profiles[ProfileGuid]; bool isOnBattery = CurrentProfile._ApplyMask.HasFlag(ProfileMask.OnBattery); bool isPluggedIn = CurrentProfile._ApplyMask.HasFlag(ProfileMask.PluggedIn); bool isExtGPU = CurrentProfile._ApplyMask.HasFlag(ProfileMask.ExternalGPU); bool isOnScreen = CurrentProfile._ApplyMask.HasFlag(ProfileMask.ExternalScreen); bool isOnBoot = CurrentProfile._ApplyMask.HasFlag(ProfileMask.OnStartup); bool isOnStatusChange = CurrentProfile._ApplyMask.HasFlag(ProfileMask.OnStatusChange); bool isGameBounds = CurrentProfile._ApplyMask.HasFlag(ProfileMask.GameBounds); // Misc numericUpDown1.Value = CurrentProfile.HasLongPowerMax() ? decimal.Parse(CurrentProfile.TurboBoostLongPowerMax) : 0; numericUpDown2.Value = CurrentProfile.HasShortPowerMax() ? decimal.Parse(CurrentProfile.TurboBoostShortPowerMax) : 0; numericUpDown3.Value = CurrentProfile.HasPowerBalanceCPU() ? decimal.Parse(CurrentProfile.PowerBalanceCPU) : 9; numericUpDown4.Value = CurrentProfile.HasPowerBalanceGPU() ? decimal.Parse(CurrentProfile.PowerBalanceGPU) : 13; // FIVR numericUpDown5.Value = CurrentProfile.HasCPUCore() ? decimal.Parse(CurrentProfile.CPUCore) : 0; numericUpDown6.Value = CurrentProfile.HasCPUCache() ? decimal.Parse(CurrentProfile.CPUCache) : 0; numericUpDown7.Value = CurrentProfile.HasSystemAgent() ? decimal.Parse(CurrentProfile.SystemAgent) : 0; numericUpDown8.Value = CurrentProfile.HasIntelGPU() ? decimal.Parse(CurrentProfile.IntelGPU) : 0; // Triggers listBoxTriggers.ClearSelected(); if (isOnBattery) { listBoxTriggers.SetSelected(0, true); } if (isPluggedIn) { listBoxTriggers.SetSelected(1, true); } if (isExtGPU) { listBoxTriggers.SetSelected(2, true); } if (isOnScreen) { listBoxTriggers.SetSelected(3, true); } if (isOnBoot) { listBoxTriggers.SetSelected(4, true); } if (isOnStatusChange) { listBoxTriggers.SetSelected(5, true); } if (isGameBounds) { listBoxTriggers.SetSelected(6, true); } } }
private void ProfilesList_SelectedIndexChanged(object sender, EventArgs e) { foreach (Control ctrl in groupBoxFIVR.Controls) { if (ctrl.GetType() == typeof(TextBox)) { ctrl.Text = ""; } } foreach (Control ctrl in groupBoxPowerProfile.Controls) { if (ctrl.GetType() == typeof(TextBox)) { ctrl.Text = ""; } } foreach (ListViewItem item in ProfilesList.SelectedItems) { string ProfileName = item.Text; Guid ProfileGuid = (Guid)item.Tag; PowerProfile profile = MainForm.ProfileDB[ProfileGuid]; // Misc if (profile.HasLongPowerMax()) { textBox1.Text = profile.TurboBoostLongPowerMax; } if (profile.HasShortPowerMax()) { textBox2.Text = profile.TurboBoostShortPowerMax; } if (profile.HasPowerBalanceCPU()) { textBox3.Text = profile.PowerBalanceCPU; } if (profile.HasPowerBalanceGPU()) { textBox4.Text = profile.PowerBalanceGPU; } // FIVR if (profile.HasCPUCore()) { textBox5.Text = profile.CPUCore; } if (profile.HasCPUCache()) { textBox6.Text = profile.CPUCache; } if (profile.HasSystemAgent()) { textBox7.Text = profile.SystemAgent; } if (profile.HasIntelGPU()) { textBox8.Text = profile.IntelGPU; } } }
public void SetPowerProfile(PowerProfile profile) { // skip update on similar profiles if (MainForm.CurrentProfile.Equals(profile)) { return; } string command = null; string tool = null; if (Constructor == Manufacturer.Intel) { // skip if unsupported platform if (MCHBAR == null || !MCHBAR.Contains("0x")) { return; } tool = MainForm.path_rw; command = "/Min /Nologo /Stdout /command=\"Delay 1000;"; if (profile.HasLongPowerMax()) { command += $"w16 {MCHBAR}a0 0x8{profile.GetLongPowerMax().Substring(0, 1)}{profile.GetLongPowerMax().Substring(1)};"; command += $"wrmsr 0x610 0x0 0x00dd8{profile.GetLongPowerMax()};"; } if (profile.HasShortPowerMax()) { command += $"w16 {MCHBAR}a4 0x8{profile.GetShortPowerMax().Substring(0, 1)}{profile.GetShortPowerMax().Substring(1)};"; command += $"wrmsr 0x610 0x0 0x00438{profile.GetShortPowerMax()};"; } if (profile.HasCPUCore()) { command += $"wrmsr 0x150 0x80000011 0x{profile.GetVoltageCPU()};"; } if (profile.HasIntelGPU()) { command += $"wrmsr 0x150 0x80000111 0x{profile.GetVoltageGPU()};"; } if (profile.HasCPUCache()) { command += $"wrmsr 0x150 0x80000211 0x{profile.GetVoltageCache()};"; } if (profile.HasSystemAgent()) { command += $"wrmsr 0x150 0x80000411 0x{profile.GetVoltageSA()};"; } if (profile.HasPowerBalanceCPU()) { command += $"wrmsr 0x642 0x00000000 0x000000{profile.GetPowerBalanceCPU()};"; } if (profile.HasPowerBalanceGPU()) { command += $"wrmsr 0x63a 0x00000000 0x000000{profile.GetPowerBalanceGPU()};"; } command += "Delay 1000;rwexit\""; } else if (Constructor == Manufacturer.AMD) { tool = MainForm.path_ryz; command = ""; if (profile.HasLongPowerMax()) { command += $"--slow-limit={profile.TurboBoostLongPowerMax}000 --stapm-limit={profile.TurboBoostLongPowerMax}000 "; } if (profile.HasShortPowerMax()) { command += $"--fast-limit={profile.TurboBoostLongPowerMax}000 "; } } // execute command if (command == null || tool == null) { return; } ProcessStartInfo PowerProcess = new ProcessStartInfo { CreateNoWindow = true, UseShellExecute = false, Arguments = command, WindowStyle = ProcessWindowStyle.Hidden, FileName = tool, Verb = "runas" }; Process.Start(PowerProcess); // update current profile string multiple = profile.Merged > 1 ? "s" : ""; string content = string.Format(MainForm.CurrentResource.GetString("PowerProfileApplied"), multiple, profile.GetName()); MainForm.CurrentProfile = profile; MainForm.SendNotification(content, true, true); // play sound if (MainForm.PlaySound) { SoundPlayer player = new SoundPlayer(Properties.Resources.Sample_0006); player.Play(); } }