Skip to content

Commit c40adfe

Browse files
committed
you can now properly copy text from the tip picker
1 parent 4f9e2c3 commit c40adfe

File tree

3 files changed

+22
-40
lines changed

3 files changed

+22
-40
lines changed

GPUPrefSwitcherGUI/MainForm.Designer.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GPUPrefSwitcherGUI/MainForm.cs

+21-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class MainForm : Form
1818
public MainForm()
1919
{
2020
InitializeComponent();
21-
21+
2222
Initialize();
2323
}
2424

@@ -41,7 +41,7 @@ private void Initialize()
4141

4242
TipRichTextBox.Visible = switcherOptions.CurrentOptions.EnableTips;
4343

44-
foreach(DataGridViewColumn dataGridViewColumn in dataGridView1.Columns)
44+
foreach (DataGridViewColumn dataGridViewColumn in dataGridView1.Columns)
4545
{
4646
dataGridViewColumn.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
4747
}
@@ -191,7 +191,7 @@ public static System.Drawing.Image GetIconImageFromPath(string path)
191191
catch (FileNotFoundException) { }
192192

193193
return iconForFile.ToBitmap();
194-
194+
195195
}
196196
//maybe get icons for UWP apps too
197197
//https://stackoverflow.com/questions/37686916/how-do-i-retrieve-a-windows-store-apps-icon-from-a-c-sharp-desktop-app
@@ -209,10 +209,10 @@ public static System.Drawing.Image GetIconImageFromPath(string path)
209209

210210
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
211211
{
212-
212+
213213
if (e.RowIndex < 0) return; //fixes null reference (row -1 is not an AppEntry)
214214

215-
if(e.ColumnIndex == EnableSwitcherCol)
215+
if (e.ColumnIndex == EnableSwitcherCol)
216216
{
217217
var enableSwitcherCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[e.RowIndex].Cells[EnableSwitcherCol];
218218
bool enableSwitcher = bool.Parse(enableSwitcherCell.Value.ToString());
@@ -571,16 +571,18 @@ private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateCh
571571
"Tip: You can click on (most) of the column headers to sort the app entries by that column.",
572572
"Tip: Changes do not enact until you hit \"Commit Changes\", which restarts the service (this is the result of power saving design; the service doesn't have to periodically update and make I/O requests this way).",
573573
"Tip: You can turn off tips from Options.",
574-
//"Tip: This is my first ever proper public app, consider donating to <> to show appreciation for my work!",
574+
"Tip: This is my first ever fully featured app, consider donating to ko-fi.com/sharpjd to show appreciation for my work!",
575575
"Tip: The config locations of games often require searching the web. PCGamingWiki is a potential database for these locations. Games also often put their config files in the AppData folders, Documents folder, or even their own game directory.",
576576
"Tip: You can click on the tip text box area for a new tip",
577577
"Tip: In the More Options menu, you can enable this app to execute Task Scheduler entries (e.g. for running scripts you write) upon plugging in/out for even greater flexibility.",
578578
"Tip: Some buttons and labels display tooltips with additional info if you hover over them."
579579
};
580580

581+
//seems to trigger after you release click
581582
private void TipRichTextBox_MouseClick(object sender, MouseEventArgs e)
582583
{
583-
PickNewTip();
584+
if(TipRichTextBox.SelectedText.Length==0) //don't pick new tip if we're selecting text
585+
PickNewTip();
584586
}
585587

586588
private void PickNewTip()
@@ -624,36 +626,42 @@ void UpdateResizableElements()
624626
int remainingWidth = dataGridView1.Width - requiredWidth;
625627

626628
int desiredColumnWidth_AppName = GetDesiredColumnWidth(dataGridView1, AppNameCol);
627-
int desiredColumnWidth_AppPath = GetDesiredColumnWidth(dataGridView1, AppPathCol);
629+
int desiredColumnWidth_AppPath = GetDesiredColumnWidth(dataGridView1, AppPathCol);
628630

629631
if (remainingWidth >= desiredColumnWidth_AppName + desiredColumnWidth_AppPath)
630632
{
631633
dataGridView1.Columns[AppNameCol].Width = desiredColumnWidth_AppName;
632634
dataGridView1.Columns[AppPathCol].Width = desiredColumnWidth_AppPath;
633-
} else
635+
}
636+
else
634637
{
635638
int columnWidthCalculated_AppName = (int)Math.Round(remainingWidth * 0.2);
636639
dataGridView1.Columns[AppNameCol].Width = columnWidthCalculated_AppName;
637640

638641
int columnWidthCalculated_AppPath = (int)Math.Round(remainingWidth * 0.8);
639642
dataGridView1.Columns[AppPathCol].Width = columnWidthCalculated_AppPath;
640643
}
641-
644+
642645
}
643646

644647
int GetDesiredColumnWidth(DataGridView dataGridView, int columnIndex)
645648
{
646649
int max = 0;
647-
foreach(DataGridViewRow row in dataGridView.Rows)
650+
foreach (DataGridViewRow row in dataGridView.Rows)
648651
{
649652
string text = row.Cells[columnIndex].Value.ToString();
650653
Size textSize = TextRenderer.MeasureText(text, dataGridView.Font);
651654

652-
if(textSize.Width > max) max = textSize.Width;
653-
655+
if (textSize.Width > max) max = textSize.Width;
656+
654657
}
655658
return max;
656659
}
660+
661+
private void TipRichTextBox_TextChanged(object sender, EventArgs e)
662+
{
663+
664+
}
657665
}
658666

659667
class GPUPreference(string displayText, int actualValue)

GPUPrefSwitcherGUI/MainForm.resx

-27
Original file line numberDiff line numberDiff line change
@@ -141,33 +141,6 @@
141141
<metadata name="ConfigureColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
142142
<value>True</value>
143143
</metadata>
144-
<metadata name="AppIconColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
145-
<value>True</value>
146-
</metadata>
147-
<metadata name="AppName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
148-
<value>True</value>
149-
</metadata>
150-
<metadata name="AppPath.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
151-
<value>True</value>
152-
</metadata>
153-
<metadata name="EnableSwitcher.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
154-
<value>True</value>
155-
</metadata>
156-
<metadata name="GPUPrefPluggedIn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
157-
<value>True</value>
158-
</metadata>
159-
<metadata name="GPUPrefOnBattery.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
160-
<value>True</value>
161-
</metadata>
162-
<metadata name="EnableFileSwapper.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
163-
<value>True</value>
164-
</metadata>
165-
<metadata name="ConfigureColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
166-
<value>True</value>
167-
</metadata>
168-
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
169-
<value>17, 17</value>
170-
</metadata>
171144
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
172145
<value>17, 17</value>
173146
</metadata>

0 commit comments

Comments
 (0)