diff --git a/KeyOverlay/AppWindow.cs b/KeyOverlay/AppWindow.cs index d235382..f90ce11 100644 --- a/KeyOverlay/AppWindow.cs +++ b/KeyOverlay/AppWindow.cs @@ -32,9 +32,9 @@ public class AppWindow private Clock _clock = new(); - public AppWindow() + public AppWindow(string configFileName) { - var config = ReadConfig(); + var config = ReadConfig(configFileName); var windowWidth = config["windowWidth"]; var windowHeight = config["windowHeight"]; _window = new RenderWindow(new VideoMode(uint.Parse(windowWidth!), uint.Parse(windowHeight!)), @@ -101,10 +101,12 @@ public AppWindow() _counter = true; } - private Dictionary ReadConfig() + private Dictionary ReadConfig(string configFileName) { var objectDict = new Dictionary(); - var file = File.ReadLines("config.txt").ToArray(); + var file = configFileName == null ? + File.ReadLines("config.txt").ToArray() : + File.ReadLines(configFileName).ToArray(); foreach (var s in file) objectDict.Add(s.Split("=")[0], s.Split("=")[1]); return objectDict; } diff --git a/KeyOverlay/Program.cs b/KeyOverlay/Program.cs index c3f6755..9911adc 100644 --- a/KeyOverlay/Program.cs +++ b/KeyOverlay/Program.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; namespace KeyOverlay { @@ -10,7 +11,7 @@ private static void Main(string[] args) AppWindow window; try { - window = new AppWindow(); + window = new AppWindow(args.FirstOrDefault()); } catch (Exception e) {