Skip to content
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
20 changes: 14 additions & 6 deletions Knossos.NET/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ public override void OnFrameworkInitializationCompleted()

private void CreateMainWindow(IClassicDesktopStyleApplicationLifetime desktop)
{
if(mainVM == null)
if (mainVM == null)
{
mainVM = new MainWindowViewModel();
}
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
};

desktop.MainWindow = new MainWindow
mainVM = desktop.MainWindow.DataContext as MainWindowViewModel;
}
else
{
DataContext = mainVM
};
desktop.MainWindow = new MainWindow
{
DataContext = mainVM
};
}

desktop.MainWindow.Closing += (_, __) =>
{
Expand Down Expand Up @@ -101,6 +108,7 @@ private async void StartTrayIcon()
{
MainWindow.instance?.FixMarginButtomTasks();
}
MainWindow.instance?.SetSize(mainVM?.WindowWidth, mainVM?.WindowHeight);
trayIcon?.Dispose();
GC.Collect();
}
Expand Down
11 changes: 5 additions & 6 deletions Knossos.NET/ViewModels/Windows/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ public partial class MainWindowViewModel : ViewModelBase
/* UI Bindings, use the uppercase version, otherwise changes will not register */
[ObservableProperty]
internal string appTitle = "Knossos.NET v" + Knossos.AppVersion;
[ObservableProperty]
internal int windowWidth = 1200;
[ObservableProperty]
internal int windowHeight = 700;
public int? WindowWidth { get; private set; } = null;
public int? WindowHeight { get; private set; } = null;
[ObservableProperty]
internal int minWindowWidth = 900;
[ObservableProperty]
Expand Down Expand Up @@ -123,8 +121,8 @@ public MainWindowViewModel()
//Apply customization for Single TC Mode
Knossos.globalSettings.mainMenuOpen = CustomLauncher.MenuOpenFirstTime;
AppTitle = CustomLauncher.WindowTitle + " v" + Knossos.AppVersion;
WindowHeight = CustomLauncher.WindowHeight.HasValue ? CustomLauncher.WindowHeight.Value : 1200;
WindowWidth = CustomLauncher.WindowWidth.HasValue ? CustomLauncher.WindowWidth.Value : 700;
WindowHeight = CustomLauncher.WindowHeight;
WindowWidth = CustomLauncher.WindowWidth;
MinWindowWidth = CustomLauncher.MinWindowWidth.HasValue ? CustomLauncher.MinWindowWidth.Value : 900;
MinWindowHeight = CustomLauncher.MinWindowHeight.HasValue ? CustomLauncher.MinWindowHeight.Value : 500;
CustomHomeVM = new CustomHomeViewModel();
Expand All @@ -147,6 +145,7 @@ public MainWindowViewModel()
MainWindow.instance?.FixMarginButtomTasks();
}
}
MainWindow.instance?.SetSize(WindowWidth,WindowHeight);
if (!Knossos.initIsComplete)
{
//Normal Startup
Expand Down
2 changes: 0 additions & 2 deletions Knossos.NET/Views/Windows/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:v="using:Knossos.NET.Views"
Width="{Binding WindowWidth}"
Height="{Binding WindowHeight}"
MinWidth="{Binding MinWindowWidth}"
MinHeight="{Binding MinWindowHeight}"
x:DataType="vm:MainWindowViewModel"
Expand Down
13 changes: 13 additions & 0 deletions Knossos.NET/Views/Windows/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ public void FixMarginButtomTasks()
}
}

/// <summary>
/// Change size of the main window
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetSize(double? width, double? height)
{
if(width.HasValue)
this.Width = width.Value;
if(height.HasValue)
this.Height = height.Value;
}

protected override async void OnClosing(WindowClosingEventArgs e)
{
//Intercept closing, do stuff, then re-call close
Expand Down