コード例 #1
0
        private void runPortableMenu_Clicked(object sender, EventArgs e)
        {
            Utility.ModifyRegistry.ModifyRegistry mr = new Utility.ModifyRegistry.ModifyRegistry();
            MenuItem portMenu = (MenuItem)sender;

            if (portMenu.Checked == true)
            {
                portMenu.Checked = false;
                mr.Write("runPortable", "false");
                Console.WriteLine("Writing key 'runPortable' to registry with value 'false'");
            }
            else
            {
                portMenu.Checked = true;
                mr.Write("runPortable", true);
                Console.WriteLine("Writing key 'runPortable' to registry with value 'true'");
            }
        }
コード例 #2
0
ファイル: frmCL.cs プロジェクト: douglas125/OpenCLTemplate
        private void btnWriteToRegistry_Click(object sender, EventArgs e)
        {
            string msg = lblConfirmModReg.Text + "\n";

            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT - GPU_MAX_HEAP_SIZE = " + lblRecomHeapSize.Text + "\n";
            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDelay = " + lblTdrDelay.Text + "\n";
            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDdiDelay = " + lblTdrDdiDelay.Text + "\n";

            if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry();
                reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT";
                try
                {
                    reg.Write("GPU_MAX_HEAP_SIZE", lblRecomHeapSize.Text);
                }
                catch { }

                reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers";
                int val;
                try
                {
                    int.TryParse(lblRecomTdrDelay.Text, out val);
                    reg.Write("TdrDelay", val);
                }
                catch { }

                try
                {
                    int.TryParse(lblRecomTdrDdiDelay.Text, out val);
                    reg.Write("TdrDdiDelay", val);
                }
                catch { }

                ReadImportantRegistryEntries();

                MessageBox.Show(lblReboot.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
ファイル: frmCL.cs プロジェクト: hrehfeld/opencltemplate
        private void btnWriteToRegistry_Click(object sender, EventArgs e)
        {
            string msg = lblConfirmModReg.Text + "\n";
            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT - GPU_MAX_HEAP_SIZE = " + lblRecomHeapSize.Text + "\n";
            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDelay = " + lblTdrDelay.Text + "\n";
            msg += "HKEY_LOCAL_MACHINE\\SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers - TdrDdiDelay = " + lblTdrDdiDelay.Text + "\n";

            if (MessageBox.Show(msg, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Utility.ModifyRegistry.ModifyRegistry reg = new Utility.ModifyRegistry.ModifyRegistry();
                reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\SESSION MANAGER\\ENVIRONMENT";
                try
                {
                    reg.Write("GPU_MAX_HEAP_SIZE", lblRecomHeapSize.Text);
                }
                catch { }

                reg.SubKey = "SYSTEM\\CURRENTCONTROLSET\\CONTROL\\GraphicsDrivers";
                int val;
                try
                {
                    int.TryParse(lblRecomTdrDelay.Text, out val);
                    reg.Write("TdrDelay", val);
                }
                catch { }

                try
                {
                    int.TryParse(lblRecomTdrDdiDelay.Text, out val);
                    reg.Write("TdrDdiDelay", val);
                }
                catch { }

                ReadImportantRegistryEntries();

                MessageBox.Show(lblReboot.Text, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #4
0
        void loadSettings()
        {
            if (File.Exists(Environment.CurrentDirectory + @"\Data\settings.ini"))
            {
                try
                {
                    currentConfig = settingsFile.ReadValue("Settings", "lastConfig");
                    if (currentConfig == "null")
                    {
                        //do null stuff
                    }
                    showAnimationPane = bool.Parse(settingsFile.ReadValue("Settings", "showAnimation"));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                Utility.ModifyRegistry.ModifyRegistry mr = new Utility.ModifyRegistry.ModifyRegistry();
                try
                {
                    string runPortableStr = mr.Read("runPortable");
                    Console.WriteLine("RegKey 'runPortable' is equal to {0}", runPortableStr.ToString());
                    if (runPortableStr == null)
                    {
                        throw new InvalidDataException();
                    }
                    else if (runPortableStr == "true")
                    {
                        runPortable = true;
                        runPortableEvents();
                    }
                    else if (runPortableStr == "false")
                    {
                        runPortable = false; writeInitialIni(); loadSettings();
                    }
                    else
                    {
                        throw new InvalidDataException();
                    }
                }
                catch
                {
                    DialogResult dr = MessageBox.Show("We can't seem to find a Data directory alongside the NPC Editor executable. Would you like to run this application as a \"Portable\" app?", "No Data Directory Detected", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    switch (dr)
                    {
                    case (DialogResult.Yes):
                        mr.Write("runPortable", "true");
                        break;

                    case (DialogResult.No):
                        mr.Write("runPortable", "false");
                        writeInitialIni();
                        loadSettings();
                        break;

                    case (DialogResult.Cancel):
                        Environment.Exit(0);
                        break;
                    }
                }
            }
        }