Skip to content

Settings Form #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ jobs:
GDPIControl\publish\${{ matrix.framework }}\*.dll
GDPIControl\publish\${{ matrix.framework }}\GDPI\**\*
GDPIControl\publish\${{ matrix.framework }}\GDPIControl.runtimeconfig.json
GDPIControl\publish\${{ matrix.framework }}\GDPIControl.exe.config
if-no-files-found: error
2 changes: 1 addition & 1 deletion GDPIControl/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<value>Black</value>
</setting>
<setting name="Font" serializeAs="String">
<value>Segoe UI, 8.25pt</value>
<value>Segoe UI, 9pt</value>
</setting>
</GDPIControl.Properties.Settings>
</userSettings>
Expand Down
3 changes: 2 additions & 1 deletion GDPIControl/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ internal static class Config
Modeset = Modeset.M9,
CustomSettings1 = new GDPISettings(),
CustomSettings2 = new GDPISettings(),
CustomSettings3 = new GDPISettings()
CustomSettings3 = new GDPISettings(),
StopDriver = true
};

public static void Load()
Expand Down
10 changes: 9 additions & 1 deletion GDPIControl/Extensions/FormExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
using System;
using GDPIControl.Properties;
using System;
using System.Windows.Forms;

namespace GDPIControl.Extensions
{
internal static class FormExtensions
{
public static void BindSettings(this Form form)
{
form.DataBindings.Add(new Binding("Font", Settings.Default, "Font", true, DataSourceUpdateMode.OnPropertyChanged));
form.DataBindings.Add(new Binding("ForeColor", Settings.Default, "ForeColor", true, DataSourceUpdateMode.OnPropertyChanged));
form.DataBindings.Add(new Binding("BackColor", Settings.Default, "BackColor", true, DataSourceUpdateMode.OnPropertyChanged));
}

public static DialogResult ShowError(this Form form, Exception exception)
{
return MessageBox.Show(form, exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down
99 changes: 18 additions & 81 deletions GDPIControl/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 11 additions & 31 deletions GDPIControl/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public partial class FormMain : Form
public FormMain()
{
InitializeComponent();
this.BindSettings();
CustomModesets = new() {
Modeset.Custom1,
Modeset.Custom2,
Expand All @@ -42,10 +43,6 @@ public FormMain()
(RB_Custom_3,Modeset.Custom3)
};
RBModesets.First(X => X.Modeset == Settings.Modeset).Button.Checked = true;
MI_Autostart.Checked = Settings.AutostartGDPI;
MI_Minimized.Checked = Settings.LaunchMinimazed;
MI_Logon.Checked = ControlTask.IsRegistered;

BS_ControlSettings.DataSource = Settings;

RefreshUI();
Expand All @@ -60,6 +57,10 @@ private void CloseGDPIControl()
TrayControl.Visible = false;
TrayControl.Dispose();
RefreshArguments();
if (Settings.StopDriver)
{
GDPIProcess.StopDriver();
}
Application.Exit();
}

Expand Down Expand Up @@ -159,6 +160,12 @@ private void MI_About_Click(object sender, EventArgs e)
F.ShowDialog(this);
}

private void MI_Settings_Click(object sender, EventArgs e)
{
using var F = new FormSettings();
F.ShowDialog(this);
}

private void RB_CheckedChanged(object sender, EventArgs e)
{
var RB = (RadioButton)sender;
Expand Down Expand Up @@ -191,33 +198,6 @@ private void MI_Userlist_Click(object sender, EventArgs e)

#endregion Lists

#region Control settings

private void MI_Autostart_CheckedChanged(object sender, EventArgs e)
{
Config.Current.AutostartGDPI = MI_Autostart.Checked;
}

private void MI_Logon_Click(object sender, EventArgs e)
{
if (!ControlTask.IsRegistered)
{
ControlTask.Register();
}
else
{
ControlTask.Delete();
}
MI_Logon.Checked = ControlTask.IsRegistered;
}

private void MI_Minimized_CheckedChanged(object sender, EventArgs e)
{
Config.Current.LaunchMinimazed = MI_Minimized.Checked;
}

#endregion Control settings

#region Tray

private void MI_Close_Click(object sender, EventArgs e) => CloseGDPIControl();
Expand Down
4 changes: 3 additions & 1 deletion GDPIControl/Forms/FormAbout.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using GDPIControl.Extensions;
using System.Diagnostics;
using System.Windows.Forms;

namespace GDPIControl
Expand All @@ -8,6 +9,7 @@ public partial class FormAbout : Form
public FormAbout()
{
InitializeComponent();
this.BindSettings();
L_Version.Text = $"v{Application.ProductVersion}";
}

Expand Down
1 change: 1 addition & 0 deletions GDPIControl/Forms/FormBlacklist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public partial class FormBlacklist : Form
public FormBlacklist()
{
InitializeComponent();
this.BindSettings();
RBtoURI.Add(RB_AZ, @"https://antizapret.prostovpn.org/domains-export.txt");
RBtoURI.Add(RB_AZ1, @"https://p.thenewone.lol/domains-export.txt");
RBtoURI.Add(RB_AZ2, @"https://mirror.thetahex.ru/?key=blacklist-gdpi");
Expand Down
Loading