mirror of
https://github.com/Orbmu2k/nvidiaProfileInspector.git
synced 2026-01-03 20:38:09 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f626e8a0 | ||
|
|
f62aa86ccc | ||
|
|
345444619c | ||
|
|
50006f114a | ||
|
|
a3b524e7d9 | ||
|
|
109fdd066a |
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -9,13 +10,14 @@ namespace nspector.Common.Helper
|
||||
internal class InputBox
|
||||
{
|
||||
|
||||
internal static DialogResult Show(string title, string promptText, ref string value, List<string> invalidInputs, string mandatoryFormatRegExPattern, int maxLength)
|
||||
internal static DialogResult Show(string title, string promptText, ref string value, List<string> invalidInputs, string mandatoryFormatRegExPattern, int maxLength, bool allowExeBrowse = false)
|
||||
{
|
||||
var form = new Form();
|
||||
var label = new Label();
|
||||
var textBox = new TextBox();
|
||||
var buttonOk = new Button();
|
||||
var buttonCancel = new Button();
|
||||
var buttonBrowse = new Button();
|
||||
var imageBox = new PictureBox();
|
||||
|
||||
EventHandler textchanged = delegate (object sender, EventArgs e)
|
||||
@@ -43,10 +45,23 @@ namespace nspector.Common.Helper
|
||||
buttonOk.Enabled = true;
|
||||
};
|
||||
|
||||
EventHandler buttonBrowse_Click = delegate (object sender, EventArgs e)
|
||||
{
|
||||
var openDialog = new OpenFileDialog();
|
||||
openDialog.DefaultExt = "*.exe";
|
||||
openDialog.Filter = "Application EXE Name|*.exe|Application Absolute Path|*.exe";
|
||||
|
||||
if (openDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string applicationName = new FileInfo(openDialog.FileName).Name;
|
||||
if (openDialog.FilterIndex == 2)
|
||||
applicationName = openDialog.FileName;
|
||||
textBox.Text = applicationName;
|
||||
}
|
||||
};
|
||||
|
||||
textBox.TextChanged += textchanged;
|
||||
|
||||
|
||||
form.Text = title;
|
||||
label.Text = promptText;
|
||||
textBox.Text = value;
|
||||
@@ -55,28 +70,47 @@ namespace nspector.Common.Helper
|
||||
|
||||
buttonOk.Text = "OK";
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonBrowse.Text = "Browse...";
|
||||
buttonOk.DialogResult = DialogResult.OK;
|
||||
buttonCancel.DialogResult = DialogResult.Cancel;
|
||||
|
||||
buttonOk.Enabled = false;
|
||||
|
||||
label.SetBounds(Dpi(9), Dpi(20), Dpi(372), Dpi(13));
|
||||
textBox.SetBounds(Dpi(12), Dpi(36), Dpi(352), Dpi(20));
|
||||
buttonOk.SetBounds(Dpi(228), Dpi(72), Dpi(75), Dpi(23));
|
||||
buttonCancel.SetBounds(Dpi(309), Dpi(72), Dpi(75), Dpi(23));
|
||||
textBox.SetBounds(Dpi(12), Dpi(44), Dpi(352), Dpi(20));
|
||||
buttonOk.SetBounds(Dpi(224), Dpi(72), Dpi(75), Dpi(23));
|
||||
buttonCancel.SetBounds(Dpi(305), Dpi(72), Dpi(75), Dpi(23));
|
||||
|
||||
imageBox.SetBounds(Dpi(368), Dpi(36), Dpi(16), Dpi(16));
|
||||
if (allowExeBrowse)
|
||||
{
|
||||
textBox.SetBounds(Dpi(12), Dpi(44), Dpi(286), Dpi(20));
|
||||
buttonBrowse.SetBounds(Dpi(305), Dpi(39), Dpi(75), Dpi(23));
|
||||
buttonBrowse.Click += buttonBrowse_Click;
|
||||
}
|
||||
|
||||
imageBox.SetBounds(Dpi(368), Dpi(44), Dpi(16), Dpi(16));
|
||||
|
||||
label.AutoSize = true;
|
||||
label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
imageBox.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
|
||||
textBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonBrowse.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
|
||||
form.ClientSize = new Size(Dpi(396), Dpi(107));
|
||||
form.ClientSize = new Size(Math.Max(Dpi(300), label.Right + Dpi(10)), form.ClientSize.Height);
|
||||
form.Controls.AddRange(new Control[] { label, textBox, imageBox, buttonOk, buttonCancel });
|
||||
form.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
form.MinimumSize = form.Size;
|
||||
form.MaximumSize = new Size(form.MinimumSize.Width * 2, form.MinimumSize.Height);
|
||||
|
||||
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
|
||||
if (!allowExeBrowse)
|
||||
form.Controls.Add(imageBox);
|
||||
else
|
||||
form.Controls.Add(buttonBrowse);
|
||||
|
||||
form.ShowIcon = false;
|
||||
form.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
form.StartPosition = FormStartPosition.CenterParent;
|
||||
form.MinimizeBox = false;
|
||||
form.MaximizeBox = false;
|
||||
|
||||
1
nspector/frmDrvSettings.Designer.cs
generated
1
nspector/frmDrvSettings.Designer.cs
generated
@@ -408,6 +408,7 @@
|
||||
this.lblApplications.Size = new System.Drawing.Size(840, 17);
|
||||
this.lblApplications.TabIndex = 25;
|
||||
this.lblApplications.Text = "fsagame.exe, bond.exe, herozero.exe";
|
||||
this.lblApplications.DoubleClick += new System.EventHandler(this.tsbAddApplication_Click);
|
||||
//
|
||||
// toolStripButton5
|
||||
//
|
||||
|
||||
@@ -537,6 +537,10 @@ namespace nspector
|
||||
{
|
||||
ScaleFactor = lblWidth330.Width / 330;
|
||||
|
||||
// Later Windows versions changed DPI scaling method, check with Graphics and use it if larger
|
||||
using (Graphics g = CreateGraphics())
|
||||
ScaleFactor = Math.Max(ScaleFactor, Math.Max(g.DpiX / 96f, g.DpiY / 96f));
|
||||
|
||||
chSettingID.Width = lblWidth330.Width;
|
||||
chSettingValueHex.Width = lblWidth96.Width;
|
||||
}
|
||||
@@ -627,6 +631,8 @@ namespace nspector
|
||||
ResetSelectedValue();
|
||||
}
|
||||
|
||||
ToolTip appPathsTooltip = new ToolTip() { InitialDelay = 250 };
|
||||
|
||||
private void ChangeCurrentProfile(string profileName)
|
||||
{
|
||||
if (profileName == GetBaseProfileName() || profileName == _baseProfileName)
|
||||
@@ -636,6 +642,7 @@ namespace nspector
|
||||
tsbDeleteProfile.Enabled = false;
|
||||
tsbAddApplication.Enabled = false;
|
||||
tssbRemoveApplication.Enabled = false;
|
||||
appPathsTooltip.SetToolTip(lblApplications, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -643,9 +650,9 @@ namespace nspector
|
||||
tsbDeleteProfile.Enabled = true;
|
||||
tsbAddApplication.Enabled = true;
|
||||
tssbRemoveApplication.Enabled = true;
|
||||
appPathsTooltip.SetToolTip(lblApplications, "Double-click to add application");
|
||||
}
|
||||
|
||||
|
||||
RefreshCurrentProfile();
|
||||
}
|
||||
|
||||
@@ -806,7 +813,15 @@ namespace nspector
|
||||
}
|
||||
}
|
||||
else
|
||||
ResetCurrentProfile();
|
||||
{
|
||||
if (MessageBox.Show(this,
|
||||
"Restore profile to NVIDIA driver defaults?",
|
||||
"Restore profile",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
ResetCurrentProfile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tsbRefreshProfile_Click(object sender, EventArgs e)
|
||||
@@ -917,15 +932,24 @@ namespace nspector
|
||||
|
||||
private void tsbAddApplication_Click(object sender, EventArgs e)
|
||||
{
|
||||
var openDialog = new OpenFileDialog();
|
||||
openDialog.DefaultExt = "*.exe";
|
||||
openDialog.Filter = "Application EXE Name|*.exe|Application Absolute Path|*.exe";
|
||||
if (_CurrentProfile == GetBaseProfileName() || _CurrentProfile == _baseProfileName)
|
||||
return;
|
||||
|
||||
if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
var applications = new Dictionary<string, string>();
|
||||
_currentProfileSettingItems = _drs.GetSettingsForProfile(_CurrentProfile, GetSettingViewMode(), ref applications);
|
||||
|
||||
var existingPaths = new HashSet<string>(applications.Values, StringComparer.OrdinalIgnoreCase);
|
||||
var applicationName = "";
|
||||
|
||||
if (InputBox.Show("Add Application", "Enter an application path/filename/UWP ID to add to the profile:", ref applicationName, new List<string>(), "", 2048, true) == DialogResult.OK)
|
||||
{
|
||||
string applicationName = new FileInfo(openDialog.FileName).Name;
|
||||
if (openDialog.FilterIndex == 2)
|
||||
applicationName = openDialog.FileName;
|
||||
// Add new application path
|
||||
if (existingPaths.Contains(applicationName))
|
||||
{
|
||||
MessageBox.Show("This application is already assigned to this profile!",
|
||||
"Error adding Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -936,25 +960,26 @@ namespace nspector
|
||||
if (ex.Status == Native.NVAPI2.NvAPI_Status.NVAPI_EXECUTABLE_ALREADY_IN_USE || ex.Status == Native.NVAPI2.NvAPI_Status.NVAPI_ERROR)
|
||||
{
|
||||
if (lblApplications.Text.ToUpper().IndexOf(" " + applicationName.ToUpper() + ",") != -1)
|
||||
MessageBox.Show("This application executable is already assigned to this profile!",
|
||||
MessageBox.Show("This application is already assigned to this profile!",
|
||||
"Error adding Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
else
|
||||
{
|
||||
string profileNames = _scanner.FindProfilesUsingApplication(applicationName);
|
||||
if (profileNames == "")
|
||||
MessageBox.Show("This application executable might already be assigned to another profile!",
|
||||
MessageBox.Show("This application might already be assigned to another profile!",
|
||||
"Error adding Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
else
|
||||
MessageBox.Show(
|
||||
"This application executable is already assigned to the following profiles: " +
|
||||
"This application is already assigned to the following profiles: " +
|
||||
profileNames, "Error adding Application", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw;
|
||||
}
|
||||
|
||||
RefreshCurrentProfile();
|
||||
}
|
||||
RefreshCurrentProfile();
|
||||
}
|
||||
|
||||
private void tssbRemoveApplication_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user