diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml
deleted file mode 100644
index bc6b75d..0000000
--- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml
+++ /dev/null
@@ -1,12 +0,0 @@
-<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"
- mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
- x:Class="MatrixRoomUtils.Desktop.Components.NavigationStack">
- <StackPanel x:Name="dock">
- <Label>NagivationStack</Label>
- <StackPanel x:Name="navPanel" Orientation="Horizontal"></StackPanel>
- <ContentControl x:Name="content"></ContentControl>
- </StackPanel>
-</UserControl>
\ No newline at end of file
diff --git a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs b/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
deleted file mode 100644
index 92c617b..0000000
--- a/MatrixRoomUtils.Desktop/Components/NavigationStack.axaml.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Markup.Xaml;
-
-namespace MatrixRoomUtils.Desktop.Components;
-
-public partial class NavigationStack : UserControl {
- public NavigationStack() {
- InitializeComponent();
- }
-
- // private void InitializeComponent() {
- // AvaloniaXamlLoader.Load(this);
- // buildView();
- // }
-
- protected override void OnLoaded(RoutedEventArgs e) {
- base.OnLoaded(e);
- buildView();
- }
-
- private void buildView() {
- if (navPanel is null) {
- Console.WriteLine("NavigationStack buildView called while navpanel is null!");
- // await Task.Delay(100);
- // if (navPanel is null)
- // await buildView();
- // else Console.WriteLine("navpanel is not null!");
- }
- navPanel.Children.Clear();
- foreach (var item in _stack) {
- Button btn = new() {
- Content = item.Name
- };
- btn.Click += (_, _) => {
- PopTo(_stack.IndexOf(item));
- buildView();
- };
- navPanel.Children.Add(btn);
- }
- content.Content = Current?.View ?? new UserControl();
- }
-
-
- public class NavigationStackItem {
- public string Name { get; set; }
- public string Description { get; set; } = "";
- public UserControl View { get; set; }
- }
-
- private List<NavigationStackItem> _stack = new();
-
- public NavigationStackItem? Current => _stack.LastOrDefault();
-
- public void Push(string name, UserControl view) {
- _stack.Add(new NavigationStackItem {
- Name = name,
- View = view
- });
- buildView();
- }
-
- public void Pop() {
- _stack.RemoveAt(_stack.Count - 1);
- buildView();
- }
-
- public void PopTo(int index) {
- _stack.RemoveRange(index, _stack.Count - index);
- buildView();
- }
-}
diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml
deleted file mode 100644
index 0e43d99..0000000
--- a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml
+++ /dev/null
@@ -1,21 +0,0 @@
-<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:components="clr-namespace:MatrixRoomUtils.Desktop.Components.Pages"
- xmlns:components1="clr-namespace:MatrixRoomUtils.Desktop.Components"
- xmlns:abstractions="clr-namespace:MatrixRoomUtils.Abstractions;assembly=MatrixRoomUtils.Abstractions"
-
- mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
- x:Class="MatrixRoomUtils.Desktop.Components.Pages.RoomList"
- x:DataType="components:RoomList"
- DataContext="{Binding $self}"
- >
- <ListBox ItemsSource="{Binding Rooms}">
- <ListBox.ItemTemplate>
- <DataTemplate DataType="abstractions:RoomInfo">
- <components1:RoomListEntry Room="{Binding Path=.}"/>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
-</UserControl>
diff --git a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs b/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs
deleted file mode 100644
index 53c3063..0000000
--- a/MatrixRoomUtils.Desktop/Components/Pages/RoomList.axaml.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Collections.ObjectModel;
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-using MatrixRoomUtils.Abstractions;
-
-namespace MatrixRoomUtils.Desktop.Components.Pages;
-
-public partial class RoomList : UserControl {
- private ObservableCollection<RoomInfo> Rooms { get; set; } = new();
-
- public RoomList() {
- InitializeComponent();
- }
-}
\ No newline at end of file
diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml
deleted file mode 100644
index db22ccc..0000000
--- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml
+++ /dev/null
@@ -1,16 +0,0 @@
-<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:components="clr-namespace:MatrixRoomUtils.Desktop.Components"
- mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="32"
- x:Class="MatrixRoomUtils.Desktop.Components.RoomListEntry"
-
- x:DataType="components:RoomListEntry"
- DataContext="{Binding $self}"
- >
- <StackPanel Orientation="Horizontal">
- <Image MaxWidth="64" x:Name="RoomIcon"></Image>
- <Label x:Name="RoomName" Content="{Binding Room.RoomName}"></Label>
- </StackPanel>
-</UserControl>
diff --git a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs b/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs
deleted file mode 100644
index 73115a2..0000000
--- a/MatrixRoomUtils.Desktop/Components/RoomListEntry.axaml.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Avalonia.Controls;
-using Avalonia.Interactivity;
-using Avalonia.Media.Imaging;
-using LibMatrix;
-using LibMatrix.EventTypes.Spec.State;
-using LibMatrix.EventTypes.Spec.State.RoomInfo;
-using LibMatrix.Helpers;
-using LibMatrix.Interfaces.Services;
-using LibMatrix.Services;
-using MatrixRoomUtils.Abstractions;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-
-namespace MatrixRoomUtils.Desktop.Components;
-
-public partial class RoomListEntry : UserControl {
- public RoomInfo Room { get; set; }
-
- public RoomListEntry() {
- InitializeComponent();
- }
-
- protected override void OnLoaded(RoutedEventArgs e) {
- base.OnLoaded(e);
- RoomName.Content = Room.Room.RoomId;
- Task.WhenAll(GetRoomName(), GetRoomIcon());
- }
-
- private async Task GetRoomName() {
- try {
- var nameEvent = await Room.GetStateEvent("m.room.name");
- if (nameEvent?.TypedContent is RoomNameEventContent nameData)
- RoomName.Content = nameData.Name;
- }
- catch (MatrixException e) {
- if (e.ErrorCode != "M_NOT_FOUND")
- throw;
- }
- }
-
- private async Task GetRoomIcon() {
- try {
- using var hc = new HttpClient();
- var avatarEvent = await Room.GetStateEvent("m.room.avatar");
- if (avatarEvent?.TypedContent is RoomAvatarEventContent avatarData) {
- var mxcUrl = avatarData.Url;
- var resolvedUrl = await Room.Room.GetResolvedRoomAvatarUrlAsync();
-
- // await using var svc = _serviceScopeFactory.CreateAsyncScope();
- // var hs = await svc.ServiceProvider.GetService<MRUStorageWrapper>()?.GetCurrentSessionOrPrompt()!;
- // var hsResolver = svc.ServiceProvider.GetService<HomeserverResolverService>();
- // var storage = svc.ServiceProvider.GetService<TieredStorageService>()?.CacheStorageProvider;
- // var resolvedUrl = await hsResolver.ResolveMediaUri(hs.ServerName, mxcUrl);
- var storage = new FileStorageProvider("cache");
- var storageKey = $"media/{mxcUrl.Replace("mxc://", "").Replace("/", ".")}";
- try {
- if (!await storage.ObjectExistsAsync(storageKey))
- await storage.SaveStreamAsync(storageKey, await hc.GetStreamAsync(resolvedUrl));
-
- RoomIcon.Source = new Bitmap(await storage.LoadStreamAsync(storageKey) ?? throw new NullReferenceException());
- }
- catch (IOException) { }
- catch (MatrixException e) {
- if (e.ErrorCode != "M_UNKNOWN")
- throw;
- }
- }
- }
- catch (MatrixException e) {
- if (e.ErrorCode != "M_NOT_FOUND")
- throw;
- }
- }
-}
|