diff --git a/FullscreenLock.sln b/FullscreenLock.sln
index 21d6ed3..168c187 100644
--- a/FullscreenLock.sln
+++ b/FullscreenLock.sln
@@ -12,14 +12,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Debug|x64.ActiveCfg = Debug|x64
+ {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Debug|x64.Build.0 = Debug|x64
+ {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Release|x64.ActiveCfg = Release|x64
+ {7A92E5B0-CFAF-4182-B4EE-48C5F0E66CB8}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/FullscreenLock/App.config b/FullscreenLock/App.config
index 88fa402..4bfa005 100644
--- a/FullscreenLock/App.config
+++ b/FullscreenLock/App.config
@@ -1,6 +1,6 @@
-
+
-
+
-
\ No newline at end of file
+
diff --git a/FullscreenLock/Checker.cs b/FullscreenLock/Checker.cs
index 10926ad..82ec922 100644
--- a/FullscreenLock/Checker.cs
+++ b/FullscreenLock/Checker.cs
@@ -1,108 +1,126 @@
-using System;
-using System.Runtime.InteropServices;
-using System.Windows.Forms;
-using System.Drawing;
-using System.Diagnostics;
-
-namespace FullscreenLock
-{
- class Checker
- {
- readonly Timer t = new Timer();
- bool ForegroundFullscreenState = false;
- public event EventHandler ActiveStateChanged;
- public event EventHandler ForegroundFullscreenStateChanged;
-
- // Import a bunch of win32 API calls.
- [DllImport("user32.dll")]
- private static extern IntPtr GetForegroundWindow();
- [DllImport("user32.dll", SetLastError = true)]
- public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
- [DllImport("user32.dll", SetLastError = true)]
- private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
- [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
- public static extern bool ClipCursor(ref RECT rcClip);
- [DllImport("user32.dll")]
- private static extern IntPtr GetDesktopWindow();
- [DllImport("user32.dll")]
- private static extern IntPtr GetShellWindow();
-
- public Checker()
- {
- t.Tick += new EventHandler(CheckForFullscreenApps);
- t.Interval = 100;
- t.Start();
- }
-
- public void ActiveStateToggled(object sender, EventArgs e)
- {
- if (t.Enabled)
- {
- t.Stop();
- }
- else
- {
- t.Start();
- }
-
- ActiveStateChanged?.Invoke(this, new BoolEventArgs(t.Enabled));
- }
-
- private void CheckForFullscreenApps(object sender, EventArgs e)
- {
- bool NewFullscreenState = IsForegroundFullScreen();
-
- //If the fullscreen state changed, set the new state and emit the change event
- if (ForegroundFullscreenState != NewFullscreenState)
- {
- ForegroundFullscreenState = NewFullscreenState;
- ForegroundFullscreenStateChanged?.Invoke(this, new BoolEventArgs(NewFullscreenState));
- }
- }
-
- public static bool IsForegroundFullScreen()
- {
- //Get the handles for the desktop and shell now.
- IntPtr desktopHandle = GetDesktopWindow();
- IntPtr shellHandle = GetShellWindow();
- Rectangle screenBounds;
- IntPtr hWnd;
-
- hWnd = GetForegroundWindow();
- if (hWnd != null && !hWnd.Equals(IntPtr.Zero))
- {
- //Check we haven't picked up the desktop or the shell
- if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
- {
- GetWindowRect(hWnd, out RECT appBounds);
- //determine if window is fullscreen
- screenBounds = Screen.FromHandle(hWnd).Bounds;
- GetWindowThreadProcessId(hWnd, out uint procid);
- var proc = Process.GetProcessById((int)procid);
- if ((appBounds.Bottom - appBounds.Top) == screenBounds.Height && (appBounds.Right - appBounds.Left) == screenBounds.Width)
- {
- Console.WriteLine(proc.ProcessName);
- Cursor.Clip = screenBounds;
- return true;
- }
- else
- {
- Cursor.Clip = Rectangle.Empty;
- return false;
- }
- }
- }
- return false;
- }
- }
-
- public class BoolEventArgs : EventArgs
- {
- public bool Bool { get; set; }
-
+using System;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using System.Drawing;
+using System.Diagnostics;
+
+namespace FullscreenLock
+{
+ class Checker
+ {
+ readonly Timer t = new Timer();
+ bool ForegroundFullscreenState = false;
+ public event EventHandler ActiveStateChanged;
+ public event EventHandler ForegroundFullscreenStateChanged;
+
+ // Import a bunch of win32 API calls.
+ [DllImport("user32.dll")]
+ private static extern IntPtr GetForegroundWindow();
+ [DllImport("user32.dll", SetLastError = true)]
+ public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
+ [DllImport("user32.dll", SetLastError = true)]
+ private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
+ [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
+ public static extern bool ClipCursor(ref RECT rcClip);
+ [DllImport("user32.dll")]
+ private static extern IntPtr GetDesktopWindow();
+ [DllImport("user32.dll")]
+ private static extern IntPtr GetShellWindow();
+
+ public Checker()
+ {
+ t.Tick += new EventHandler(CheckForFullscreenApps);
+ t.Interval = 100;
+ t.Start();
+ }
+
+ public void ActiveStateToggled(object sender, EventArgs e)
+ {
+ if (t.Enabled)
+ {
+ t.Stop();
+ }
+ else
+ {
+ t.Start();
+ }
+
+ ActiveStateChanged?.Invoke(this, new BoolEventArgs(t.Enabled));
+ }
+
+ private void CheckForFullscreenApps(object sender, EventArgs e)
+ {
+ bool NewFullscreenState = IsForegroundFullScreen();
+
+ //If the fullscreen state changed, set the new state and emit the change event
+ if (ForegroundFullscreenState != NewFullscreenState)
+ {
+ ForegroundFullscreenState = NewFullscreenState;
+ ForegroundFullscreenStateChanged?.Invoke(this, new BoolEventArgs(NewFullscreenState));
+ }
+ }
+
+ public static bool IsForegroundFullScreen()
+ {
+ //Get the handles for the desktop and shell now.
+ IntPtr desktopHandle = GetDesktopWindow();
+ IntPtr shellHandle = GetShellWindow();
+ Rectangle screenBounds;
+ IntPtr hWnd;
+
+ hWnd = GetForegroundWindow();
+ if (hWnd != null && !hWnd.Equals(IntPtr.Zero))
+ {
+ //Check we haven't picked up the desktop or the shell
+ if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
+ {
+ GetWindowRect(hWnd, out RECT appBounds);
+ //determine if window is fullscreen
+ screenBounds = Screen.FromHandle(hWnd).Bounds;
+
+ //determine process, to check the whitelist
+ Process proc = null;
+ try
+ {
+ GetWindowThreadProcessId(hWnd, out uint procid);
+ proc = Process.GetProcessById((int)procid);
+ }
+ catch (Exception) { }
+
+ if (proc != null)
+ {
+ if ((appBounds.Bottom - appBounds.Top) == screenBounds.Height && (appBounds.Right - appBounds.Left) == screenBounds.Width
+ && !IsWhitelisted(proc.MainModule.FileName))
+ {
+ Console.WriteLine(proc.ProcessName);
+ Cursor.Clip = screenBounds;
+ return true;
+ }
+ else
+ {
+ Cursor.Clip = Rectangle.Empty;
+ return false;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static bool IsWhitelisted(string sFullPathToProgram)
+ {
+ return Program.Settings_File.Instance.asWhitelist.ConvertAll(s => s.ToLower()).Contains(sFullPathToProgram.ToLower());
+ }
+ }
+
+ public class BoolEventArgs : EventArgs
+ {
+ public bool Bool { get; set; }
+
public BoolEventArgs(bool b)
{
Bool = b;
- }
- }
-}
+ }
+ }
+}
diff --git a/FullscreenLock/FullscreenLock.Designer.cs b/FullscreenLock/FullscreenLock.Designer.cs
index 4a8586f..55c0a9e 100644
--- a/FullscreenLock/FullscreenLock.Designer.cs
+++ b/FullscreenLock/FullscreenLock.Designer.cs
@@ -34,6 +34,7 @@ private void InitializeComponent()
this.ToggleButton = new System.Windows.Forms.Button();
this.StatusLabel = new System.Windows.Forms.Label();
this.MadeByLabel = new System.Windows.Forms.Label();
+ this.buttonSettings = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// ToggleButton
@@ -69,6 +70,18 @@ private void InitializeComponent()
this.MadeByLabel.Text = "✨ Made by Blåberry and the community ✨";
this.MadeByLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
+ // buttonSettings
+ //
+ this.buttonSettings.Cursor = System.Windows.Forms.Cursors.Default;
+ this.buttonSettings.Font = new System.Drawing.Font("Segoe MDL2 Assets", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.buttonSettings.Location = new System.Drawing.Point(186, 12);
+ this.buttonSettings.Name = "buttonSettings";
+ this.buttonSettings.Size = new System.Drawing.Size(30, 30);
+ this.buttonSettings.TabIndex = 3;
+ this.buttonSettings.Text = "";
+ this.buttonSettings.UseVisualStyleBackColor = true;
+ this.buttonSettings.Click += new System.EventHandler(this.buttonSettings_Click);
+ //
// FullscreenLock
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);
@@ -76,6 +89,7 @@ private void InitializeComponent()
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(229, 141);
+ this.Controls.Add(this.buttonSettings);
this.Controls.Add(this.ToggleButton);
this.Controls.Add(this.MadeByLabel);
this.Controls.Add(this.StatusLabel);
@@ -99,6 +113,7 @@ private void InitializeComponent()
private System.Windows.Forms.Button ToggleButton;
public System.Windows.Forms.Label StatusLabel;
- private System.Windows.Forms.Label MadeByLabel;
+ private System.Windows.Forms.Label MadeByLabel;
+ private Button buttonSettings;
}
}
diff --git a/FullscreenLock/FullscreenLock.cs b/FullscreenLock/FullscreenLock.cs
index f2a16b3..8728a90 100644
--- a/FullscreenLock/FullscreenLock.cs
+++ b/FullscreenLock/FullscreenLock.cs
@@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
+using static FullscreenLock.Settings;
namespace FullscreenLock
{
@@ -7,6 +8,7 @@ public partial class FullscreenLock : Form
{
public event EventHandler ActiveStateToggled;
+
public FullscreenLock()
{
InitializeComponent();
@@ -48,5 +50,11 @@ public void ForegroundFullscreenStateChanged(object sender, BoolEventArgs e)
{
StatusLabel.Text = e.Bool ? "Fullscreen app in focus" : "Waiting for focus";
}
+
+ private void buttonSettings_Click(object sender, EventArgs e)
+ {
+ Settings settings = new Settings(this);
+ settings.Show();
+ }
}
}
diff --git a/FullscreenLock/FullscreenLock.csproj b/FullscreenLock/FullscreenLock.csproj
index a5298c1..5f55c7b 100644
--- a/FullscreenLock/FullscreenLock.csproj
+++ b/FullscreenLock/FullscreenLock.csproj
@@ -9,9 +9,11 @@
Properties
FullscreenLock
FullscreenLock
- v4.5.2
+ v4.8
512
true
+ false
+
publish\
true
Disk
@@ -24,12 +26,11 @@
true
0
1.0.0.%2a
- false
false
true
- AnyCPU
+ x64
true
full
false
@@ -51,6 +52,28 @@
gaben.ico
+
+ FullscreenLock.Program
+
+
+ true
+ bin\Debug\
+ DEBUG;TRACE
+ full
+ x64
+ 7.3
+ prompt
+
+
+ bin\Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ 7.3
+ prompt
+ true
+
@@ -79,6 +102,12 @@
+
+ Form
+
+
+ Settings.cs
+
FullscreenLock.cs
@@ -92,6 +121,9 @@
Resources.resx
True
+
+ Settings.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/FullscreenLock/Program.cs b/FullscreenLock/Program.cs
index 8657536..200db06 100644
--- a/FullscreenLock/Program.cs
+++ b/FullscreenLock/Program.cs
@@ -3,11 +3,14 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
+using static FullscreenLock.Settings;
namespace FullscreenLock
-{
+{
static class Program
{
+ public static SettingsFile Settings_File { get; set; } = new SettingsFile();
+
///
/// The main entry point for the application.
///
diff --git a/FullscreenLock/Properties/AssemblyInfo.cs b/FullscreenLock/Properties/AssemblyInfo.cs
index 0be4513..2e43f91 100644
--- a/FullscreenLock/Properties/AssemblyInfo.cs
+++ b/FullscreenLock/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-using System.Reflection;
+using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FullscreenLock")]
-[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.3.0.0")]
+[assembly: AssemblyFileVersion("1.3.0.0")]
diff --git a/FullscreenLock/Properties/Settings.Designer.cs b/FullscreenLock/Properties/Settings.Designer.cs
index df672ee..37b9090 100644
--- a/FullscreenLock/Properties/Settings.Designer.cs
+++ b/FullscreenLock/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace FullscreenLock.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
diff --git a/FullscreenLock/Settings.Designer.cs b/FullscreenLock/Settings.Designer.cs
new file mode 100644
index 0000000..552341d
--- /dev/null
+++ b/FullscreenLock/Settings.Designer.cs
@@ -0,0 +1,112 @@
+namespace FullscreenLock
+{
+ partial class Settings
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.tabControlMain = new System.Windows.Forms.TabControl();
+ this.tabPageWhitelist = new System.Windows.Forms.TabPage();
+ this.dataGridViewWhitelist = new System.Windows.Forms.DataGridView();
+ this.ColProgram = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.tabControlMain.SuspendLayout();
+ this.tabPageWhitelist.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewWhitelist)).BeginInit();
+ this.SuspendLayout();
+ //
+ // tabControlMain
+ //
+ this.tabControlMain.Controls.Add(this.tabPageWhitelist);
+ this.tabControlMain.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControlMain.Location = new System.Drawing.Point(0, 0);
+ this.tabControlMain.Name = "tabControlMain";
+ this.tabControlMain.SelectedIndex = 0;
+ this.tabControlMain.Size = new System.Drawing.Size(639, 450);
+ this.tabControlMain.TabIndex = 0;
+ //
+ // tabPageWhitelist
+ //
+ this.tabPageWhitelist.Controls.Add(this.dataGridViewWhitelist);
+ this.tabPageWhitelist.Location = new System.Drawing.Point(4, 22);
+ this.tabPageWhitelist.Name = "tabPageWhitelist";
+ this.tabPageWhitelist.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPageWhitelist.Size = new System.Drawing.Size(631, 424);
+ this.tabPageWhitelist.TabIndex = 1;
+ this.tabPageWhitelist.Text = "Whitelist";
+ this.tabPageWhitelist.UseVisualStyleBackColor = true;
+ //
+ // dataGridViewWhitelist
+ //
+ this.dataGridViewWhitelist.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridViewWhitelist.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColProgram});
+ this.dataGridViewWhitelist.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.dataGridViewWhitelist.Location = new System.Drawing.Point(3, 3);
+ this.dataGridViewWhitelist.Name = "dataGridViewWhitelist";
+ this.dataGridViewWhitelist.Size = new System.Drawing.Size(625, 418);
+ this.dataGridViewWhitelist.TabIndex = 0;
+ //
+ // ColProgram
+ //
+ this.ColProgram.HeaderText = "Full path to the whitelisted program";
+ this.ColProgram.Name = "Program";
+ this.ColProgram.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+ this.ColProgram.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+ this.ColProgram.ToolTipText = "like \'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe\'";
+ this.ColProgram.Width = 550;
+ //
+ // Settings
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.ClientSize = new System.Drawing.Size(639, 450);
+ this.Controls.Add(this.tabControlMain);
+ this.MaximizeBox = false;
+ this.MaximumSize = new System.Drawing.Size(655, 489);
+ this.MinimizeBox = false;
+ this.MinimumSize = new System.Drawing.Size(655, 489);
+ this.Name = "Settings";
+ this.ShowIcon = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.Text = "Settings";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Settings_FormClosing);
+ this.tabControlMain.ResumeLayout(false);
+ this.tabPageWhitelist.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridViewWhitelist)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TabControl tabControlMain;
+ private System.Windows.Forms.TabPage tabPageWhitelist;
+ private System.Windows.Forms.DataGridView dataGridViewWhitelist;
+ private System.Windows.Forms.DataGridViewTextBoxColumn ColProgram;
+ }
+}
\ No newline at end of file
diff --git a/FullscreenLock/Settings.cs b/FullscreenLock/Settings.cs
new file mode 100644
index 0000000..23ea205
--- /dev/null
+++ b/FullscreenLock/Settings.cs
@@ -0,0 +1,124 @@
+using System.Collections.Generic;
+using System.Windows.Forms;
+using System.Xml.Serialization;
+using System.IO;
+using System;
+
+namespace FullscreenLock
+{
+ public partial class Settings : Form
+ {
+ public Settings(FullscreenLock mainForm)
+ {
+ InitializeComponent();
+
+ #region Whitelist
+ InitWhiteListDataGrid();
+ #endregion
+
+ }
+
+ private void Settings_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ // Save all
+ #region Whitelist
+ Program.Settings_File.Instance.asWhitelist.Clear();
+ foreach (DataGridViewRow row in dataGridViewWhitelist.Rows)
+ {
+ object oValue = row.Cells[0].Value;
+ if (oValue != null)
+ Program.Settings_File.Instance.asWhitelist.Add(oValue.ToString());
+ }
+ #endregion
+
+ Program.Settings_File.SaveLocal();
+ }
+
+ #region Whitelist methods
+ public void InitWhiteListDataGrid()
+ {
+ foreach (string sProgramName in Program.Settings_File.Instance.asWhitelist)
+ dataGridViewWhitelist.Rows.Add(sProgramName);
+ }
+ #endregion
+
+
+ public class SettingsFile
+ {
+ public string LocalFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FullScreenLock.xml");
+
+ private SettingsContent _settings = null;
+ public SettingsContent Instance
+ {
+ get {
+ if (_settings == null)
+ _settings = new SettingsContent();
+
+ return _settings;
+ }
+
+ private set { _settings = value; }
+ }
+
+
+
+ public SettingsFile()
+ {
+ LoadLocal();
+ }
+
+ public bool LoadLocal()
+ {
+ bool bRtn = true;
+ try
+ {
+ XmlSerializer serializer = new XmlSerializer(typeof(SettingsContent));
+ SettingsContent localLoaded;
+ using (FileStream fs = new FileStream(LocalFile, FileMode.Open))
+ localLoaded = (SettingsContent) serializer.Deserialize(fs);
+
+ if (localLoaded == null)
+ throw new Exception();
+
+ _settings = localLoaded;
+
+
+ } catch (Exception)
+ {
+ bRtn = false;
+ }
+
+ return bRtn;
+ }
+
+ public bool SaveLocal()
+ {
+ bool bRtn = true;
+ try
+ {
+ if (File.Exists(LocalFile))
+ File.Delete(LocalFile);
+
+ XmlSerializer serializer = new XmlSerializer(typeof(SettingsContent));
+ using (FileStream fs = new FileStream(LocalFile, FileMode.Create))
+ serializer.Serialize(fs, Instance);
+ }
+ catch (Exception)
+ {
+ bRtn = false;
+ }
+
+ return bRtn;
+ }
+
+ #region XML construct
+ [XmlRoot("Settings")]
+ public class SettingsContent
+ {
+ [XmlArray("Whitelist")]
+ public List asWhitelist { get; set; } = new List();
+ }
+ #endregion
+ }
+ }
+}
diff --git a/FullscreenLock/Settings.resx b/FullscreenLock/Settings.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FullscreenLock/Settings.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file