diff --git a/applications/lokqlDx/MainWindow.xaml.cs b/applications/lokqlDx/MainWindow.xaml.cs index b0fd575..812dc6a 100644 --- a/applications/lokqlDx/MainWindow.xaml.cs +++ b/applications/lokqlDx/MainWindow.xaml.cs @@ -18,6 +18,7 @@ public partial class MainWindow : Window { private readonly string[] _args; private readonly WpfConsole _console; + private readonly Size _minWindowSize = new(600, 400); private readonly PreferencesManager _preferenceManager = new(); private readonly WorkspaceManager _workspaceManager; @@ -111,12 +112,18 @@ private void UpdateUIFromWorkspace() private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { _preferenceManager.Load(); - var pathToLoad = _args.Any() ? _args[0] : _preferenceManager.Preferences.LastWorkspacePath; + var pathToLoad = _args.Any() + ? _args[0] + : _preferenceManager.Preferences.LastWorkspacePath; _workspaceManager.Load(pathToLoad); if (Width > 100 && Height > 100 && Left > 0 && Top > 0) { - Width = _preferenceManager.Preferences.WindowWidth; - Height = _preferenceManager.Preferences.WindowHeight; + Width = _preferenceManager.Preferences.WindowWidth < _minWindowSize.Width + ? _minWindowSize.Width + : _preferenceManager.Preferences.WindowWidth; + Height = _preferenceManager.Preferences.WindowHeight < _minWindowSize.Height + ? _minWindowSize.Height + : _preferenceManager.Preferences.WindowHeight; Left = _preferenceManager.Preferences.WindowLeft; Top = _preferenceManager.Preferences.WindowTop; } diff --git a/applications/lokqlDx/Preferences.cs b/applications/lokqlDx/Preferences.cs index b69e552..ce10ae4 100644 --- a/applications/lokqlDx/Preferences.cs +++ b/applications/lokqlDx/Preferences.cs @@ -3,7 +3,7 @@ public class Preferences { public string LastWorkspacePath { get; set; } = string.Empty; - public double FontSize { get; set; } + public double FontSize { get; set; } = 20; public string FontFamily { get; set; } = string.Empty; public double WindowWidth { get; set; } public double WindowHeight { get; set; } diff --git a/applications/lokqlDx/WorkspaceManager.cs b/applications/lokqlDx/WorkspaceManager.cs index 4b5697d..27ec2fd 100644 --- a/applications/lokqlDx/WorkspaceManager.cs +++ b/applications/lokqlDx/WorkspaceManager.cs @@ -71,6 +71,18 @@ public void Save(string path,string userText) public void Load(string path) { + if (!File.Exists(path)) + { + var rootSettingFolderPath = + System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), + "kustoloco"); + if (!Directory.Exists(rootSettingFolderPath)) + Directory.CreateDirectory(rootSettingFolderPath); + + path = System.IO.Path.Combine(rootSettingFolderPath, "settings"); + File.WriteAllText(path, JsonSerializer.Serialize(new Workspace())); + } + Path = path; try {