Skip to content

Commit

Permalink
Import UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilMacMullen committed Jun 30, 2024
1 parent 78f9f55 commit b44b7e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
13 changes: 10 additions & 3 deletions applications/lokqlDx/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion applications/lokqlDx/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
12 changes: 12 additions & 0 deletions applications/lokqlDx/WorkspaceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit b44b7e5

Please sign in to comment.