diff --git a/ModerationClient/Views/MainWindow/ClientView.axaml b/ModerationClient/Views/MainWindow/ClientView.axaml
index ba030e4..e0cd4e0 100644
--- a/ModerationClient/Views/MainWindow/ClientView.axaml
+++ b/ModerationClient/Views/MainWindow/ClientView.axaml
@@ -4,36 +4,42 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:ModerationClient.Views"
xmlns:viewModels="clr-namespace:ModerationClient.ViewModels"
+ xmlns:spaceTreeNodes="clr-namespace:ModerationClient.Models.SpaceTreeNodes"
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="256" MinWidth="16" />
<ColumnDefinition Width="1" />
- <ColumnDefinition Width="128" MinWidth="16" />
+ <ColumnDefinition Width="256" MinWidth="16" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="*" MinWidth="16" />
</Grid.ColumnDefinitions>
- <TreeView Grid.Column="0" Background="Red" ItemsSource="{CompiledBinding DisplayedSpaces}" SelectedItem="{CompiledBinding CurrentSpace}">
+ <TreeView Grid.Column="0" Background="#202020" ItemsSource="{CompiledBinding DisplayedSpaces}" SelectedItem="{CompiledBinding CurrentSpace}">
<TreeView.ItemTemplate>
- <TreeDataTemplate ItemsSource="{Binding ChildSpaces}">
+ <!-- <TreeView.Styles> -->
+ <!-- <Style Selector="TreeViewItem"> -->
+ <!-- <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> -->
+ <!-- </Style> -->
+ <!-- </TreeView.Styles> -->
+ <TreeDataTemplate ItemsSource="{Binding ChildSpaces}" DataType="spaceTreeNodes:SpaceNode">
<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 Grid.Column="2" Background="#242424" ItemsSource="{CompiledBinding CurrentSpace.ChildRooms}">
<ListBox.ItemTemplate>
- <DataTemplate DataType="viewModels:RoomNode">
+ <DataTemplate DataType="spaceTreeNodes: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" />
+ <Rectangle Grid.Column="4" Fill="#282828" />
</Grid>
<Grid Grid.Row="1" ColumnDefinitions="Auto, *, Auto" Background="Black">
<Label Grid.Column="2" Content="{CompiledBinding Status}" />
diff --git a/ModerationClient/Views/MainWindow/ClientView.axaml.cs b/ModerationClient/Views/MainWindow/ClientView.axaml.cs
index 894e807..5b0f62d 100644
--- a/ModerationClient/Views/MainWindow/ClientView.axaml.cs
+++ b/ModerationClient/Views/MainWindow/ClientView.axaml.cs
@@ -1,5 +1,4 @@
using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
namespace ModerationClient.Views;
diff --git a/ModerationClient/Views/MainWindow/LoginView.axaml.cs b/ModerationClient/Views/MainWindow/LoginView.axaml.cs
index 5e84ace..ea2f59d 100644
--- a/ModerationClient/Views/MainWindow/LoginView.axaml.cs
+++ b/ModerationClient/Views/MainWindow/LoginView.axaml.cs
@@ -1,12 +1,12 @@
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
-using Avalonia.Markup.Xaml;
using ModerationClient.ViewModels;
namespace ModerationClient.Views;
public partial class LoginView : UserControl {
+ private LoginViewModel? ViewModel => DataContext as LoginViewModel;
public LoginView() {
InitializeComponent();
}
diff --git a/ModerationClient/Views/MainWindow/MainWindow.axaml b/ModerationClient/Views/MainWindow/MainWindow.axaml
index ef13553..c45b296 100644
--- a/ModerationClient/Views/MainWindow/MainWindow.axaml
+++ b/ModerationClient/Views/MainWindow/MainWindow.axaml
@@ -17,23 +17,28 @@
<!-- </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}" />
+ <Grid RowDefinitions="Auto, *"
+ Background="#202020"
+ Width="{CompiledBinding ChildTargetWidth}"
+ Height="{CompiledBinding ChildTargetHeight}">
+ <Grid Grid.Row="0" ColumnDefinitions="Auto, *, Auto" x:Name="TopPanel" Background="#000000">
+ <StackPanel Orientation="Horizontal" Grid.Column="0">
+ <Label>[F1 -]</Label>
+ <Label Content="{CompiledBinding Scale}" />
+ <Label>x</Label>
+ <Label>[+ F2]</Label>
+ <Rectangle Width="32" />
+ <Label>VRes =</Label>
+ <Label Content="{CompiledBinding ChildTargetWidth}" />
+ <Label>x</Label>
+ <Label Content="{CompiledBinding ChildTargetHeight}" />
+ </StackPanel>
+ <Label Grid.Column="2">Press '?' for keybinds</Label>
+ </Grid>
+ <ContentControl Grid.Row="1" Content="{CompiledBinding CurrentViewModel}" />
+ </Grid>
</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
index 01027c1..cc3534d 100644
--- a/ModerationClient/Views/MainWindow/MainWindow.axaml.cs
+++ b/ModerationClient/Views/MainWindow/MainWindow.axaml.cs
@@ -1,23 +1,55 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using ArcaneLibs.Extensions;
using Avalonia;
using Avalonia.Controls;
-using Avalonia.Diagnostics;
using Avalonia.Input;
+using LibMatrix.Responses;
+using LibMatrix.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ModerationClient.Services;
using ModerationClient.ViewModels;
+#if DEBUG
+using Avalonia.Diagnostics;
+#endif
+
namespace ModerationClient.Views.MainWindow;
public partial class MainWindow : Window {
+ private readonly CommandLineConfiguration _cfg;
+
public MainWindow(CommandLineConfiguration cfg, MainWindowViewModel dataContext, IHostApplicationLifetime appLifetime) {
+ _cfg = cfg;
InitializeComponent();
DataContext = dataContext;
_ = dataContext.AuthService.LoadProfileAsync().ContinueWith(x => {
if (x.IsFaulted) {
Console.WriteLine("Failed to load profile: " + x.Exception);
}
+
+ dataContext.CurrentViewModel = dataContext.AuthService.IsLoggedIn
+ ? App.Current.Host.Services.GetRequiredService<ClientViewModel>()
+ : new LoginViewModel(dataContext.AuthService);
+
+ if (!dataContext.AuthService.IsLoggedIn) {
+ 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);
+ }
+ }
+ };
+ }
});
Console.WriteLine("mainwnd");
#if DEBUG
@@ -35,36 +67,23 @@ public partial class MainWindow : Window {
return;
}
- viewModel.PhysicalSize = new Size(ClientSize.Width, ClientSize.Height - TopPanel.Bounds.Height);
+ // viewModel.PhysicalSize = new Size(ClientSize.Width, ClientSize.Height - TopPanel.Bounds.Height);
+ viewModel.PhysicalSize = new Size(ClientSize.Width, ClientSize.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);
- }
- }
- };
+ // 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.Scale = cfg.Scale;
Width *= cfg.Scale;
@@ -76,9 +95,13 @@ public partial class MainWindow : Window {
});
}
- protected override void OnKeyDown(KeyEventArgs e) => OnKeyDown(this, e);
+ protected override void OnKeyDown(KeyEventArgs e) => OnKeyDown(this, e).ContinueWith(t => {
+ if (t.IsFaulted) {
+ Console.WriteLine("OnKeyDown faulted: " + t.Exception);
+ }
+ });
- private void OnKeyDown(object? _, KeyEventArgs e) {
+ private async Task OnKeyDown(object? _, KeyEventArgs e) {
if (DataContext is not MainWindowViewModel viewModel) {
Console.WriteLine($"WARN: DataContext is {DataContext?.GetType().Name ?? "null"}, ignoring key press!");
return;
@@ -100,6 +123,11 @@ public partial class MainWindow : Window {
viewModel.Scale = 5.0f;
}
}
+ else if (e.Key == Key.Pause) {
+ if (viewModel.CurrentViewModel is ClientViewModel clientViewModel) {
+ clientViewModel.Paused = !clientViewModel.Paused;
+ }
+ }
else if (e.KeyModifiers == KeyModifiers.Control) {
if (e.Key == Key.K) {
if (viewModel.CurrentViewModel is ClientViewModel clientViewModel) {
@@ -107,7 +135,7 @@ public partial class MainWindow : Window {
}
else Console.WriteLine("WARN: CurrentViewModel is not ClientViewModel, ignoring Quick Switcher");
}
- else if (e.Key == Key.U ) {
+ else if (e.Key == Key.U) {
Console.WriteLine("UserManagementWindow invoked");
var window = App.Current.Host.Services.GetRequiredService<UserManagementWindow>();
window.Show();
@@ -116,8 +144,31 @@ public partial class MainWindow : Window {
Console.WriteLine("Launching new process");
System.Diagnostics.Process.Start(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName, Environment.GetCommandLineArgs());
}
- else if (e.Key == Key.F9) {
-
+ else if (e.Key == Key.F9) { }
+ else if (e.Key == Key.D) {
+ List<LoginResponse> mxids = new();
+ var hsps = App.Current.Services.GetRequiredService<HomeserverProviderService>();
+ var rhs = await hsps.GetRemoteHomeserver("matrixunittests.rory.gay", enableServer: false);
+ for (int i = 0; i < 64; i++) {
+ Console.WriteLine("Debugging invoked");
+ var main = await rhs.RegisterAsync(Guid.NewGuid().ToString(), "password");
+ mxids.Add(main);
+ Console.WriteLine($"Registered: {main.UserId} {main.AccessToken} - {mxids.Count}");
+ }
+
+ foreach (var mxid in mxids) {
+ Console.WriteLine("Launching new process: ");
+ var args = (_cfg with {
+ Profile = "mut-" + mxid.UserId,
+ ProfileDirectory = null,
+ LoginData = mxid.ToJson(),
+ TestConfiguration = new() {
+ Mxids = mxids.Select(x => x.UserId).ToList()
+ }
+ }).Serialise();
+ Console.WriteLine(string.Join(' ', args));
+ System.Diagnostics.Process.Start(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName, args);
+ }
}
}
}
|