Ejemplo n.º 1
0
        //Instant Apply!  button
        private void buttonApplyNow_Click(object sender, EventArgs e)
        {
            //IF shift is hold while ckicking on the button, skip all the unnecessary checks to speed up the settings applying. INSANE INSTANT APPLY!
            bool skipChecks = false;
            if ((Control.ModifierKeys & Keys.Shift) != 0)
            {
                skipChecks = true;
            }

            if (this.testConfig())
            {
                PwrMzrSettings pm = this.collectDataFromControls();

                try
                {
                    if (skipChecks == false)
                    {
                        if (MessageBox.Show("The changes will be applied to the registry.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            this.pwrmzrManager.changePowermizerSettings(pm);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        //Skipping checks. Right to the nitty-gritty
                        this.pwrmzrManager.changePowermizerSettings(pm);
                    }
                }
                catch
                {
                    //All errors logged
                    MessageBox.Show("Could't change powermizer settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //Instant Apply!
                try
                {

                    log("Trying Instant Apply! ...");

                    //Query the data
                    List<string> data = this.pwrmzrManager.readInstantApplyInfo();

                    Guid videoGuid = new Guid(data[0]);
                    string instancePath = data[1].ToUpper();

                    //SLI SUPPORT
                    string instancePathSLI = null;
                    if (Properties.Settings.Default.SLIModeEnabled == true)
                    {
                        if (data.Count == 3)
                        {
                            instancePathSLI = data[2].ToUpper();
                        }
                    }

                    InstantApplyDisc dlg = new InstantApplyDisc();
                    DialogResult result;

                    if (skipChecks == false)
                    {
                        result = dlg.ShowDialog();
                    }
                    else //If we are skipping checks, let's go for it without showing any dialog at all.
                    {
                        result = DialogResult.OK;
                    }

                    if (result == DialogResult.OK)
                    {
                        //Reboot the device
                        logsub("Reinitializing device: " + instancePath);

                        DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, false);
                        DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, true);

                        logsub("Success...");

                        //SLI SUPPORT
                        if (Properties.Settings.Default.SLIModeEnabled == true)
                        {
                            if (instancePathSLI != null)//If we really have another device here, let's reboot it
                            {
                                //Reboot the device
                                logsub("Reinitializing SLI device: " + instancePathSLI);

                                DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, false);
                                DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, true);

                                logsub("Success... (SLIDevice).");
                            }
                        }

                        //dirty patch: After rebooting the device, due to temporary resolution change,
                        //the width of the dialog changes, so we fix it here.
                        if (this.expanded) this.Width = 900; else this.Width = 470;

                    }
                    else
                    {
                        return;
                    }
                }
                catch
                {
                    logsub("Error while trying Instant Apply! . Try rebooting manually.");
                    MessageBox.Show("At the moment your system does not support the Instant Apply! feature. Check debug console for more details.");
                    return;

                }
            }
        }
Ejemplo n.º 2
0
        //Instant Apply!  button
        private void buttonApplyNow_Click(object sender, EventArgs e)
        {
            //IF shift is hold while ckicking on the button, skip all the unnecessary checks to speed up the settings applying. INSANE INSTANT APPLY!
            bool skipChecks = false;

            if ((Control.ModifierKeys & Keys.Shift) != 0)
            {
                skipChecks = true;
            }


            if (this.testConfig())
            {
                PwrMzrSettings pm = this.collectDataFromControls();

                try
                {
                    if (skipChecks == false)
                    {
                        if (MessageBox.Show("The changes will be applied to the registry.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            this.pwrmzrManager.changePowermizerSettings(pm);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        //Skipping checks. Right to the nitty-gritty
                        this.pwrmzrManager.changePowermizerSettings(pm);
                    }
                }
                catch
                {
                    //All errors logged
                    MessageBox.Show("Could't change powermizer settings. Check debug console for more details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //Instant Apply!
                try
                {
                    log("Trying Instant Apply! ...");

                    //Query the data
                    List <string> data = this.pwrmzrManager.readInstantApplyInfo();

                    Guid   videoGuid    = new Guid(data[0]);
                    string instancePath = data[1].ToUpper();

                    //SLI SUPPORT
                    string instancePathSLI = null;
                    if (Properties.Settings.Default.SLIModeEnabled == true)
                    {
                        if (data.Count == 3)
                        {
                            instancePathSLI = data[2].ToUpper();
                        }
                    }



                    InstantApplyDisc dlg = new InstantApplyDisc();
                    DialogResult     result;


                    if (skipChecks == false)
                    {
                        result = dlg.ShowDialog();
                    }
                    else //If we are skipping checks, let's go for it without showing any dialog at all.
                    {
                        result = DialogResult.OK;
                    }


                    if (result == DialogResult.OK)
                    {
                        //Reboot the device
                        logsub("Reinitializing device: " + instancePath);

                        DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, false);
                        DeviceHelper.SetDeviceEnabled(videoGuid, instancePath, true);

                        logsub("Success...");


                        //SLI SUPPORT
                        if (Properties.Settings.Default.SLIModeEnabled == true)
                        {
                            if (instancePathSLI != null)//If we really have another device here, let's reboot it
                            {
                                //Reboot the device
                                logsub("Reinitializing SLI device: " + instancePathSLI);

                                DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, false);
                                DeviceHelper.SetDeviceEnabled(videoGuid, instancePathSLI, true);

                                logsub("Success... (SLIDevice).");
                            }
                        }

                        //dirty patch: After rebooting the device, due to temporary resolution change,
                        //the width of the dialog changes, so we fix it here.
                        if (this.expanded)
                        {
                            this.Width = 900;
                        }
                        else
                        {
                            this.Width = 470;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch
                {
                    logsub("Error while trying Instant Apply! . Try rebooting manually.");
                    MessageBox.Show("At the moment your system does not support the Instant Apply! feature. Check debug console for more details.");
                    return;
                }
            }
        }