Пример #1
0
        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();
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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;
                }
            }
        }
Пример #4
0
        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();
            }
        }