diff --git a/ModerationClient/Views/MainWindow/ClientView.axaml b/ModerationClient/Views/MainWindow/ClientView.axaml
new file mode 100644
index 0000000..ba030e4
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/ClientView.axaml
@@ -0,0 +1,42 @@
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:views="clr-namespace:ModerationClient.Views"
+ xmlns:viewModels="clr-namespace:ModerationClient.ViewModels"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="ModerationClient.Views.ClientView"
+ x:DataType="viewModels:ClientViewModel">
+ <Grid Width="{Binding $parent.Width}" Height="{Binding $parent.Height}" RowDefinitions="*, Auto">
+ <Grid Grid.Row="0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="128" MinWidth="16" />
+ <ColumnDefinition Width="1" />
+ <ColumnDefinition Width="128" MinWidth="16" />
+ <ColumnDefinition Width="1" />
+ <ColumnDefinition Width="*" MinWidth="16" />
+ </Grid.ColumnDefinitions>
+ <TreeView Grid.Column="0" Background="Red" ItemsSource="{CompiledBinding DisplayedSpaces}" SelectedItem="{CompiledBinding CurrentSpace}">
+ <TreeView.ItemTemplate>
+ <TreeDataTemplate ItemsSource="{Binding ChildSpaces}">
+ <TextBlock Text="{Binding Name}" Height="20" />
+ </TreeDataTemplate>
+ </TreeView.ItemTemplate>
+ </TreeView>
+ <GridSplitter Grid.Column="1" Background="Black" ResizeDirection="Columns" />
+ <!-- <Rectangle Grid.Column="2" Fill="Green" /> -->
+ <ListBox Grid.Column="2" Background="Green" ItemsSource="{CompiledBinding CurrentSpace.ChildRooms}">
+ <ListBox.ItemTemplate>
+ <DataTemplate DataType="viewModels:RoomNode">
+ <TextBlock Text="{CompiledBinding Name}" Height="20" />
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
+ <GridSplitter Grid.Column="3" Background="Black" ResizeDirection="Columns" />
+ <Rectangle Grid.Column="4" Fill="Blue" />
+ </Grid>
+ <Grid Grid.Row="1" ColumnDefinitions="Auto, *, Auto" Background="Black">
+ <Label Grid.Column="2" Content="{CompiledBinding Status}" />
+ </Grid>
+ </Grid>
+</UserControl>
\ No newline at end of file
diff --git a/ModerationClient/Views/MainWindow/ClientView.axaml.cs b/ModerationClient/Views/MainWindow/ClientView.axaml.cs
new file mode 100644
index 0000000..894e807
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/ClientView.axaml.cs
@@ -0,0 +1,27 @@
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace ModerationClient.Views;
+
+public partial class ClientView : UserControl {
+
+ public ClientView() {
+ InitializeComponent();
+
+ // PropertyChanged += (_, e) => {
+ // switch (e.Property.Name) {
+ // case nameof(Width): {
+ // //make sure all columns fit
+ // var grid = this.LogicalChildren.OfType<Grid>().FirstOrDefault();
+ // if(grid is null) {
+ // Console.WriteLine("Failed to find Grid in ClientView");
+ // return;
+ // }
+ // Console.WriteLine($"ClientView width changed to {Width}");
+ // var columns = grid.ColumnDefinitions;
+ // break;
+ // }
+ // }
+ // };
+ }
+}
diff --git a/ModerationClient/Views/MainWindow/LoginView.axaml b/ModerationClient/Views/MainWindow/LoginView.axaml
new file mode 100644
index 0000000..5dc6533
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/LoginView.axaml
@@ -0,0 +1,23 @@
+<UserControl xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:views="clr-namespace:ModerationClient.Views"
+ xmlns:viewModels="clr-namespace:ModerationClient.ViewModels"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="ModerationClient.Views.LoginView"
+ x:DataType="viewModels:LoginViewModel">
+ <StackPanel>
+ <Label>Log in</Label>
+ <StackPanel Orientation="Horizontal">
+ <Label Width="100">User ID</Label>
+ <TextBox MinWidth="250" Text="{Binding Username, Mode=TwoWay}" />
+ </StackPanel>
+ <StackPanel Orientation="Horizontal">
+ <Label Width="100">Password</Label>
+ <MaskedTextBox MinWidth="250" PasswordChar="*" Text="{Binding Password, Mode=TwoWay}" />
+ </StackPanel>
+ <Button Click="Login">Login</Button>
+ <TextBlock Text="{CompiledBinding Exception}" Foreground="#ff3333"/>
+ </StackPanel>
+</UserControl>
\ No newline at end of file
diff --git a/ModerationClient/Views/MainWindow/LoginView.axaml.cs b/ModerationClient/Views/MainWindow/LoginView.axaml.cs
new file mode 100644
index 0000000..5e84ace
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/LoginView.axaml.cs
@@ -0,0 +1,18 @@
+using System;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using Avalonia.Markup.Xaml;
+using ModerationClient.ViewModels;
+
+namespace ModerationClient.Views;
+
+public partial class LoginView : UserControl {
+ public LoginView() {
+ InitializeComponent();
+ }
+
+ // ReSharper disable once AsyncVoidMethod
+ private async void Login(object? _, RoutedEventArgs __) {
+ await (DataContext as LoginViewModel ?? throw new InvalidCastException("LoginView did not receive LoginViewModel?")).LoginAsync();
+ }
+}
diff --git a/ModerationClient/Views/MainWindow/MainWindow.axaml b/ModerationClient/Views/MainWindow/MainWindow.axaml
new file mode 100644
index 0000000..ef13553
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/MainWindow.axaml
@@ -0,0 +1,39 @@
+<Window xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:vm="using:ModerationClient.ViewModels"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:views="clr-namespace:ModerationClient.Views"
+ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+ x:Class="ModerationClient.Views.MainWindow.MainWindow"
+ x:DataType="vm:MainWindowViewModel"
+ Icon="/Assets/avalonia-logo.ico"
+ Title="ModerationClient"
+ Width="1280" Height="720">
+ <!-- <Design.DataContext> -->
+ <!-- This only sets the DataContext for the previewer in an IDE,
+ to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
+ <!-- <vm:MainWindowViewModel /> -->
+ <!-- </Design.DataContext> -->
+
+ <Grid RowDefinitions="Auto, *">
+ <Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto" x:Name="TopPanel">
+ <StackPanel Orientation="Horizontal" Grid.Column="0">
+ <Label Content="{CompiledBinding Scale}" />
+ <Label>x</Label>
+ <Rectangle Width="32" />
+ <Label Content="{CompiledBinding ChildTargetWidth}" />
+ <Label>x</Label>
+ <Label Content="{CompiledBinding ChildTargetHeight}" />
+ </StackPanel>
+ <Label Grid.Column="2">Press '?' for keybinds</Label>
+ </Grid>
+ <Viewbox Grid.Row="1">
+ <ContentControl
+ Width="{CompiledBinding ChildTargetWidth}"
+ Background="#222222"
+ Height="{CompiledBinding ChildTargetHeight}"
+ Content="{CompiledBinding CurrentViewModel}" />
+ </Viewbox>
+ </Grid>
+</Window>
\ No newline at end of file
diff --git a/ModerationClient/Views/MainWindow/MainWindow.axaml.cs b/ModerationClient/Views/MainWindow/MainWindow.axaml.cs
new file mode 100644
index 0000000..01027c1
--- /dev/null
+++ b/ModerationClient/Views/MainWindow/MainWindow.axaml.cs
@@ -0,0 +1,124 @@
+using System;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Diagnostics;
+using Avalonia.Input;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using ModerationClient.Services;
+using ModerationClient.ViewModels;
+
+namespace ModerationClient.Views.MainWindow;
+
+public partial class MainWindow : Window {
+ public MainWindow(CommandLineConfiguration cfg, MainWindowViewModel dataContext, IHostApplicationLifetime appLifetime) {
+ InitializeComponent();
+ DataContext = dataContext;
+ _ = dataContext.AuthService.LoadProfileAsync().ContinueWith(x => {
+ if (x.IsFaulted) {
+ Console.WriteLine("Failed to load profile: " + x.Exception);
+ }
+ });
+ Console.WriteLine("mainwnd");
+#if DEBUG
+ this.AttachDevTools(new DevToolsOptions() {
+ ShowAsChildWindow = true,
+ LaunchView = DevToolsViewKind.LogicalTree,
+ });
+#endif
+ PropertyChanged += (sender, args) => {
+ // Console.WriteLine($"MainWindow PropertyChanged: {args.Property.Name} ({args.OldValue} -> {args.NewValue})");
+ switch (args.Property.Name) {
+ case nameof(ClientSize): {
+ if (DataContext is not MainWindowViewModel viewModel) {
+ Console.WriteLine("WARN: MainWindowViewModel is null, ignoring ClientSize change!");
+ return;
+ }
+
+ viewModel.PhysicalSize = new Size(ClientSize.Width, ClientSize.Height - TopPanel.Bounds.Height);
+ break;
+ }
+ }
+ };
+
+ TopPanel.PropertyChanged += (_, args) => {
+ if (args.Property.Name == nameof(Visual.Bounds)) {
+ if (DataContext is not MainWindowViewModel viewModel) {
+ Console.WriteLine("WARN: MainWindowViewModel is null, ignoring TopPanel.Bounds change!");
+ return;
+ }
+
+ viewModel.PhysicalSize = new Size(ClientSize.Width, ClientSize.Height - TopPanel.Bounds.Height);
+ }
+ };
+
+ dataContext.AuthService.PropertyChanged += (sender, args) => {
+ if (args.PropertyName == nameof(MatrixAuthenticationService.IsLoggedIn)) {
+ if (dataContext.AuthService.IsLoggedIn) {
+ // dataContext.CurrentViewModel = new ClientViewModel(dataContext.AuthService);
+ dataContext.CurrentViewModel = App.Current.Host.Services.GetRequiredService<ClientViewModel>();
+ var window = App.Current.Host.Services.GetRequiredService<UserManagementWindow>();
+ window.Show();
+ }
+ else {
+ dataContext.CurrentViewModel = new LoginViewModel(dataContext.AuthService);
+ }
+ }
+ };
+
+ dataContext.Scale = cfg.Scale;
+ Width *= cfg.Scale;
+ Height *= cfg.Scale;
+
+ appLifetime.ApplicationStopping.Register(() => {
+ Console.WriteLine("ApplicationStopping triggered");
+ Close();
+ });
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e) => OnKeyDown(this, e);
+
+ private void OnKeyDown(object? _, KeyEventArgs e) {
+ if (DataContext is not MainWindowViewModel viewModel) {
+ Console.WriteLine($"WARN: DataContext is {DataContext?.GetType().Name ?? "null"}, ignoring key press!");
+ return;
+ }
+
+ // Console.WriteLine("MainWindow KeyDown: " + e.Key);
+ if (e.Key == Key.Escape) {
+ viewModel.Scale = 1.0f;
+ }
+ else if (e.Key == Key.F1) {
+ viewModel.Scale -= 0.1f;
+ if (viewModel.Scale < 0.1f) {
+ viewModel.Scale = 0.1f;
+ }
+ }
+ else if (e.Key == Key.F2) {
+ viewModel.Scale += 0.1f;
+ if (viewModel.Scale > 5.0f) {
+ viewModel.Scale = 5.0f;
+ }
+ }
+ else if (e.KeyModifiers == KeyModifiers.Control) {
+ if (e.Key == Key.K) {
+ if (viewModel.CurrentViewModel is ClientViewModel clientViewModel) {
+ Console.WriteLine("QuickSwitcher invoked");
+ }
+ else Console.WriteLine("WARN: CurrentViewModel is not ClientViewModel, ignoring Quick Switcher");
+ }
+ else if (e.Key == Key.U ) {
+ Console.WriteLine("UserManagementWindow invoked");
+ var window = App.Current.Host.Services.GetRequiredService<UserManagementWindow>();
+ window.Show();
+ }
+ else if (e.Key == Key.F5) {
+ Console.WriteLine("Launching new process");
+ System.Diagnostics.Process.Start(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName, Environment.GetCommandLineArgs());
+ }
+ else if (e.Key == Key.F9) {
+
+ }
+ }
+ }
+}
\ No newline at end of file
|