mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Workshop - Did all the things (Markdown stuff)
This commit is contained in:
1 parent
c132edeb51
commit
a0536b4302
47 files changed
+1017
-521
No files matched your search
@@ -0,0 +1,32 @@
|
||||
<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:entries="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
xmlns:ui="clr-namespace:Artemis.UI"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.EntriesView"
|
||||
x:DataType="entries:EntriesViewModel">
|
||||
<controls:NavigationView PaneDisplayMode="Top"
|
||||
MenuItemsSource="{CompiledBinding Tabs}"
|
||||
SelectedItem="{CompiledBinding SelectedTab}"
|
||||
IsBackEnabled="True"
|
||||
IsBackButtonVisible="True"
|
||||
IsSettingsVisible="False"
|
||||
BackRequested="NavigationView_OnBackRequested">
|
||||
<controls:NavigationView.Styles>
|
||||
<Styles>
|
||||
<Style Selector="controls|NavigationView:topnavminimal /template/ SplitView Border#ContentGridBorder">
|
||||
<Setter Property="CornerRadius" Value="8 0 0 0" />
|
||||
</Style>
|
||||
</Styles>
|
||||
</controls:NavigationView.Styles>
|
||||
|
||||
<controls:Frame Name="TabFrame" IsNavigationStackEnabled="False" CacheSize="0" Padding="20">
|
||||
<controls:Frame.NavigationPageFactory>
|
||||
<ui:PageFactory/>
|
||||
</controls:Frame.NavigationPageFactory>
|
||||
</controls:Frame>
|
||||
</controls:NavigationView>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Reactive.Disposables;
|
||||
using Artemis.UI.Shared;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
public partial class EntriesView : ReactiveUserControl<EntriesViewModel>
|
||||
{
|
||||
public EntriesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.WhenActivated(d => { ViewModel.WhenAnyValue(vm => vm.Screen).WhereNotNull().Subscribe(Navigate).DisposeWith(d); });
|
||||
}
|
||||
|
||||
private void Navigate(ViewModelBase viewModel)
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(() => TabFrame.NavigateFromObject(viewModel));
|
||||
}
|
||||
|
||||
private void NavigationView_OnBackRequested(object? sender, NavigationViewBackRequestedEventArgs e)
|
||||
{
|
||||
ViewModel?.GoBack();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Routing;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
public class EntriesViewModel : RoutableHostScreen<RoutableScreen>
|
||||
{
|
||||
private readonly IRouter _router;
|
||||
private RouteViewModel? _selectedTab;
|
||||
private ObservableAsPropertyHelper<bool>? _viewingDetails;
|
||||
|
||||
public EntriesViewModel(IRouter router)
|
||||
{
|
||||
_router = router;
|
||||
|
||||
Tabs = new ObservableCollection<RouteViewModel>
|
||||
{
|
||||
new("Profiles", "workshop/entries/profiles/1", "workshop/entries/profiles"),
|
||||
new("Layouts", "workshop/entries/layouts/1", "workshop/entries/layouts")
|
||||
};
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
// Show back button on details page
|
||||
_viewingDetails = _router.CurrentPath.Select(p => p != null && p.Contains("details")).ToProperty(this, vm => vm.ViewingDetails).DisposeWith(d);
|
||||
// Navigate on tab change
|
||||
this.WhenAnyValue(vm => vm.SelectedTab)
|
||||
.WhereNotNull()
|
||||
.Subscribe(s => router.Navigate(s.Path, new RouterNavigationOptions {IgnoreOnPartialMatch = true}))
|
||||
.DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public bool ViewingDetails => _viewingDetails?.Value ?? false;
|
||||
public ObservableCollection<RouteViewModel> Tabs { get; }
|
||||
|
||||
public RouteViewModel? SelectedTab
|
||||
{
|
||||
get => _selectedTab;
|
||||
set => RaiseAndSetIfChanged(ref _selectedTab, value);
|
||||
}
|
||||
|
||||
public override async Task OnNavigating(NavigationArguments args, CancellationToken cancellationToken)
|
||||
{
|
||||
SelectedTab = Tabs.FirstOrDefault(t => t.Matches(args.Path));
|
||||
if (SelectedTab == null)
|
||||
await args.Router.Navigate(Tabs.First().Path);
|
||||
}
|
||||
|
||||
public void GoBack()
|
||||
{
|
||||
if (ViewingDetails)
|
||||
_router.GoBack();
|
||||
else
|
||||
_router.Navigate("workshop");
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@ public class EntryListItemViewModel : ActivatableViewModelBase
|
||||
switch (Entry.EntryType)
|
||||
{
|
||||
case EntryType.Layout:
|
||||
await _router.Navigate($"workshop/layouts/{Entry.Id}");
|
||||
await _router.Navigate($"workshop/entries/layouts/details/{Entry.Id}");
|
||||
break;
|
||||
case EntryType.Profile:
|
||||
await _router.Navigate($"workshop/profiles/{Entry.Id}");
|
||||
await _router.Navigate($"workshop/entries/profiles/details/{Entry.Id}");
|
||||
break;
|
||||
case EntryType.Plugin:
|
||||
break;
|
||||
|
||||
+2
-4
@@ -18,7 +18,7 @@ using StrawberryShake;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParameters>
|
||||
public abstract class EntryListViewModel : RoutableScreen<WorkshopListParameters>
|
||||
{
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IWorkshopClient _workshopClient;
|
||||
@@ -31,7 +31,7 @@ public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParame
|
||||
private int _totalPages = 1;
|
||||
private int _entriesPerPage = 10;
|
||||
|
||||
protected EntryListBaseViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel, INotificationService notificationService,
|
||||
protected EntryListViewModel(IWorkshopClient workshopClient, IRouter router, CategoriesViewModel categoriesViewModel, INotificationService notificationService,
|
||||
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
|
||||
{
|
||||
_workshopClient = workshopClient;
|
||||
@@ -143,6 +143,4 @@ public abstract class EntryListBaseViewModel : RoutableScreen<WorkshopListParame
|
||||
{
|
||||
return new EntryFilterInput {And = CategoriesViewModel.CategoryFilters};
|
||||
}
|
||||
|
||||
public EntryType? EntryType => null;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<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:entries="clr-namespace:Artemis.UI.Screens.Workshop.Entries"
|
||||
xmlns:tagsInput="clr-namespace:Artemis.UI.Shared.TagsInput;assembly=Artemis.UI.Shared"
|
||||
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||
xmlns:categories="clr-namespace:Artemis.UI.Screens.Workshop.Categories"
|
||||
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.EntrySpecificationsView"
|
||||
x:DataType="entries:EntrySpecificationsViewModel">
|
||||
<StackPanel>
|
||||
<StackPanel.Styles>
|
||||
<Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||
</Style>
|
||||
<Style Selector="Label">
|
||||
<Setter Property="Margin" Value="0 8 0 0"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
</StackPanel.Styles>
|
||||
|
||||
<Grid ColumnDefinitions="103,*">
|
||||
<StackPanel Grid.Column="0" Width="95">
|
||||
<Label Target="Name">Icon</Label>
|
||||
<Button Width="95"
|
||||
Height="95"
|
||||
Command="{CompiledBinding SelectIcon}"
|
||||
IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNull}}">
|
||||
<avalonia:MaterialIcon Kind="FolderOpen"
|
||||
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
||||
Width="30"
|
||||
Height="30" />
|
||||
</Button>
|
||||
<Border IsVisible="{CompiledBinding IconBitmap, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
ClipToBounds="True"
|
||||
CornerRadius="6"
|
||||
VerticalAlignment="Center"
|
||||
Width="95"
|
||||
Height="95">
|
||||
<Panel>
|
||||
<Image Source="{CompiledBinding IconBitmap}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></Image>
|
||||
<Button Classes="icon-button image-picker"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
Cursor="Hand"
|
||||
Command="{CompiledBinding SelectIcon}"
|
||||
ToolTip.Tip="Click to browse">
|
||||
</Button>
|
||||
</Panel>
|
||||
|
||||
</Border>
|
||||
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !IconValid}" TextWrapping="Wrap">
|
||||
Icon required
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Label Target="Name">Name</Label>
|
||||
<TextBox Name="Name" Text="{CompiledBinding Name}"></TextBox>
|
||||
|
||||
<Label Target="Summary" Margin="0 5 0 0">Summary</Label>
|
||||
<TextBox Name="Summary" Text="{CompiledBinding Summary}"></TextBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Label Margin="0 28 0 0">Categories</Label>
|
||||
<ItemsControl ItemsSource="{CompiledBinding Categories}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="categories:CategoryViewModel">
|
||||
<ToggleButton IsChecked="{CompiledBinding IsSelected}" Margin="0 0 5 5">
|
||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||
<avalonia:MaterialIcon Kind="{CompiledBinding Icon}" />
|
||||
<TextBlock Text="{CompiledBinding Name}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</ToggleButton>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !CategoriesValid}">
|
||||
At least one category is required
|
||||
</TextBlock>
|
||||
|
||||
<Label>Tags</Label>
|
||||
<tagsInput:TagsInput Tags="{CompiledBinding Tags}" />
|
||||
|
||||
<Label Target="DescriptionEditor" Margin="0 28 0 0">Description</Label>
|
||||
<Border Classes="card">
|
||||
<avaloniaEdit:TextEditor Height="250" Name="DescriptionEditor" Document="{CompiledBinding MarkdownDocument}"/>
|
||||
</Border>
|
||||
|
||||
|
||||
<DockPanel HorizontalAlignment="Stretch">
|
||||
<TextBlock Theme="{StaticResource CaptionTextBlockStyle}">Markdown supported, a better editor planned</TextBlock>
|
||||
<Button Margin="0 5" HorizontalAlignment="Right" Command="{CompiledBinding OpenMarkdownPreview}">Open preview</Button>
|
||||
</DockPanel>
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,34 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Immutable;
|
||||
using Avalonia.ReactiveUI;
|
||||
using AvaloniaEdit.TextMate;
|
||||
using TextMateSharp.Grammars;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
public partial class EntrySpecificationsView : ReactiveUserControl<EntrySpecificationsViewModel>
|
||||
{
|
||||
public EntrySpecificationsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
RegistryOptions options = new(ThemeName.Dark);
|
||||
TextMate.Installation? install = DescriptionEditor.InstallTextMate(options);
|
||||
|
||||
install.SetGrammar(options.GetScopeByExtension(".md"));
|
||||
}
|
||||
|
||||
#region Overrides of Visual
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
if (this.TryFindResource("SystemAccentColorLight3", out object? resource) && resource is Color color)
|
||||
DescriptionEditor.TextArea.TextView.LinkTextForegroundBrush = new ImmutableSolidColorBrush(color);
|
||||
base.OnAttachedToVisualTree(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Screens.Workshop.Categories;
|
||||
using Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.WebClient.Workshop;
|
||||
using Avalonia.Controls;
|
||||
using AvaloniaEdit.Document;
|
||||
using DynamicData;
|
||||
using DynamicData.Aggregation;
|
||||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Validation.Extensions;
|
||||
using ReactiveUI.Validation.Helpers;
|
||||
using StrawberryShake;
|
||||
using Bitmap = Avalonia.Media.Imaging.Bitmap;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||
|
||||
public class EntrySpecificationsViewModel : ValidatableViewModelBase
|
||||
{
|
||||
private readonly IWindowService _windowService;
|
||||
private ObservableAsPropertyHelper<bool>? _categoriesValid;
|
||||
private ObservableAsPropertyHelper<bool>? _iconValid;
|
||||
private string _description = string.Empty;
|
||||
private string _name = string.Empty;
|
||||
private string _summary = string.Empty;
|
||||
private Bitmap? _iconBitmap;
|
||||
private Window? _previewWindow;
|
||||
private TextDocument? _markdownDocument;
|
||||
|
||||
public EntrySpecificationsViewModel(IWorkshopClient workshopClient, IWindowService windowService)
|
||||
{
|
||||
_windowService = windowService;
|
||||
SelectIcon = ReactiveCommand.CreateFromTask(ExecuteSelectIcon);
|
||||
OpenMarkdownPreview = ReactiveCommand.Create(ExecuteOpenMarkdownPreview);
|
||||
|
||||
// this.WhenAnyValue(vm => vm.Description).Subscribe(d => MarkdownDocument.Text = d);
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
// Load categories
|
||||
Observable.FromAsync(workshopClient.GetCategories.ExecuteAsync).Subscribe(PopulateCategories).DisposeWith(d);
|
||||
|
||||
this.ClearValidationRules();
|
||||
|
||||
MarkdownDocument = new TextDocument(new StringTextSource(Description));
|
||||
MarkdownDocument.TextChanged += MarkdownDocumentOnTextChanged;
|
||||
Disposable.Create(() =>
|
||||
{
|
||||
_previewWindow?.Close();
|
||||
MarkdownDocument.TextChanged -= MarkdownDocumentOnTextChanged;
|
||||
MarkdownDocument = null;
|
||||
ClearIcon();
|
||||
}).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
private void MarkdownDocumentOnTextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Description = MarkdownDocument.Text;
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SelectIcon { get; }
|
||||
public ReactiveCommand<Unit, Unit> OpenMarkdownPreview { get; }
|
||||
|
||||
public ObservableCollection<CategoryViewModel> Categories { get; } = new();
|
||||
public ObservableCollection<string> Tags { get; } = new();
|
||||
public bool CategoriesValid => _categoriesValid?.Value ?? true;
|
||||
public bool IconValid => _iconValid?.Value ?? true;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => RaiseAndSetIfChanged(ref _name, value);
|
||||
}
|
||||
|
||||
public string Summary
|
||||
{
|
||||
get => _summary;
|
||||
set => RaiseAndSetIfChanged(ref _summary, value);
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => RaiseAndSetIfChanged(ref _description, value);
|
||||
}
|
||||
|
||||
public Bitmap? IconBitmap
|
||||
{
|
||||
get => _iconBitmap;
|
||||
set => RaiseAndSetIfChanged(ref _iconBitmap, value);
|
||||
}
|
||||
|
||||
public TextDocument? MarkdownDocument
|
||||
{
|
||||
get => _markdownDocument;
|
||||
set => RaiseAndSetIfChanged(ref _markdownDocument, value);
|
||||
}
|
||||
|
||||
public List<int> PreselectedCategories { get; set; } = new List<int>();
|
||||
|
||||
public void SetupDataValidation()
|
||||
{
|
||||
// Hopefully this can be avoided in the future
|
||||
// https://github.com/reactiveui/ReactiveUI.Validation/discussions/558
|
||||
this.ValidationRule(vm => vm.Name, s => !string.IsNullOrWhiteSpace(s), "Name is required");
|
||||
this.ValidationRule(vm => vm.Summary, s => !string.IsNullOrWhiteSpace(s), "Summary is required");
|
||||
this.ValidationRule(vm => vm.Description, s => !string.IsNullOrWhiteSpace(s), "Description is required");
|
||||
|
||||
// These don't use inputs that support validation messages, do so manually
|
||||
ValidationHelper iconRule = this.ValidationRule(vm => vm.IconBitmap, s => s != null, "Icon required");
|
||||
ValidationHelper categoriesRule = this.ValidationRule(vm => vm.Categories, Categories.ToObservableChangeSet().AutoRefresh(c => c.IsSelected).Filter(c => c.IsSelected).IsNotEmpty(),
|
||||
"At least one category must be selected"
|
||||
);
|
||||
_iconValid = iconRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.IconValid);
|
||||
_categoriesValid = categoriesRule.ValidationChanged.Select(c => c.IsValid).ToProperty(this, vm => vm.CategoriesValid);
|
||||
}
|
||||
|
||||
private async Task ExecuteSelectIcon()
|
||||
{
|
||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||
.HavingFilter(f => f.WithExtension("png").WithExtension("jpg").WithExtension("bmp").WithName("Bitmap image"))
|
||||
.ShowAsync();
|
||||
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
IconBitmap?.Dispose();
|
||||
IconBitmap = BitmapExtensions.LoadAndResize(result[0], 128);
|
||||
}
|
||||
|
||||
private void ExecuteOpenMarkdownPreview()
|
||||
{
|
||||
if (_previewWindow != null)
|
||||
{
|
||||
_previewWindow.Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
_previewWindow = _windowService.ShowWindow(out MarkdownPreviewViewModel _, this.WhenAnyValue(vm => vm.Description));
|
||||
_previewWindow.Closed += PreviewWindowOnClosed;
|
||||
}
|
||||
|
||||
private void PreviewWindowOnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
if (_previewWindow != null)
|
||||
_previewWindow.Closed -= PreviewWindowOnClosed;
|
||||
_previewWindow = null;
|
||||
}
|
||||
|
||||
private void ClearIcon()
|
||||
{
|
||||
IconBitmap?.Dispose();
|
||||
IconBitmap = null;
|
||||
}
|
||||
|
||||
private void PopulateCategories(IOperationResult<IGetCategoriesResult> result)
|
||||
{
|
||||
Categories.Clear();
|
||||
if (result.Data != null)
|
||||
Categories.AddRange(result.Data.Categories.Select(c => new CategoryViewModel(c) {IsSelected = PreselectedCategories.Contains(c.Id)}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<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:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
|
||||
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Tabs"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.Tabs.LayoutListView"
|
||||
x:DataType="tabs:LayoutListViewModel">
|
||||
<Grid ColumnDefinitions="300,*" RowDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
||||
<Border Classes="card" VerticalAlignment="Stretch">
|
||||
<StackPanel>
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
||||
<Border Classes="card-separator" />
|
||||
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True" />
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ScrollViewer>
|
||||
|
||||
<pagination:Pagination Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Margin="0 20 0 10"
|
||||
IsVisible="{CompiledBinding ShowPagination}"
|
||||
Value="{CompiledBinding Page}"
|
||||
Maximum="{CompiledBinding TotalPages}"
|
||||
HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||
|
||||
public partial class LayoutListView : ReactiveUserControl<LayoutListViewModel>
|
||||
{
|
||||
public LayoutListView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Artemis.UI.Screens.Workshop.Categories;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.WebClient.Workshop;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||
|
||||
public class LayoutListViewModel : EntryListViewModel
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public LayoutListViewModel(IWorkshopClient workshopClient,
|
||||
IRouter router,
|
||||
CategoriesViewModel categoriesViewModel,
|
||||
INotificationService notificationService,
|
||||
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
|
||||
: base(workshopClient, router, categoriesViewModel, notificationService, getEntryListViewModel)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of EntryListBaseViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetPagePath(int page)
|
||||
{
|
||||
return $"workshop/entries/layouts/{page}";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override EntryFilterInput GetFilter()
|
||||
{
|
||||
return new EntryFilterInput
|
||||
{
|
||||
And = new[]
|
||||
{
|
||||
new EntryFilterInput {EntryType = new EntryTypeOperationFilterInput {Eq = WebClient.Workshop.EntryType.Layout}},
|
||||
base.GetFilter()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||
xmlns:pagination="clr-namespace:Artemis.UI.Shared.Pagination;assembly=Artemis.UI.Shared"
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Tabs"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.Tabs.ProfileListView"
|
||||
x:DataType="tabs:ProfileListViewModel">
|
||||
<Grid ColumnDefinitions="300,*" RowDefinitions="*,Auto">
|
||||
<StackPanel Grid.Column="0" Grid.RowSpan="2" Margin="0 0 10 0" VerticalAlignment="Top">
|
||||
<Border Classes="card" VerticalAlignment="Stretch">
|
||||
<StackPanel>
|
||||
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Categories</TextBlock>
|
||||
<Border Classes="card-separator" />
|
||||
<ContentControl Content="{CompiledBinding CategoriesViewModel}"></ContentControl>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<ProgressBar Grid.Column="1" Grid.Row="0" VerticalAlignment="Top" Margin="0 0 20 0" IsVisible="{CompiledBinding IsLoading}" IsIndeterminate="True" />
|
||||
|
||||
<ScrollViewer Grid.Column="1" Grid.Row="0">
|
||||
<ItemsRepeater ItemsSource="{CompiledBinding Entries}" Margin="0 0 20 0">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Content="{CompiledBinding}" Margin="0 0 0 5"></ContentControl>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</ScrollViewer>
|
||||
|
||||
<pagination:Pagination Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Margin="0 20 0 10"
|
||||
IsVisible="{CompiledBinding ShowPagination}"
|
||||
Value="{CompiledBinding Page}"
|
||||
Maximum="{CompiledBinding TotalPages}"
|
||||
HorizontalAlignment="Center" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,11 @@
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||
|
||||
public partial class ProfileListView : ReactiveUserControl<ProfileListViewModel>
|
||||
{
|
||||
public ProfileListView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Artemis.UI.Screens.Workshop.Categories;
|
||||
using Artemis.UI.Shared.Routing;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.WebClient.Workshop;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Tabs;
|
||||
|
||||
public class ProfileListViewModel : EntryListViewModel
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ProfileListViewModel(IWorkshopClient workshopClient,
|
||||
IRouter router,
|
||||
CategoriesViewModel categoriesViewModel,
|
||||
INotificationService notificationService,
|
||||
Func<IGetEntries_Entries_Items, EntryListItemViewModel> getEntryListViewModel)
|
||||
: base(workshopClient, router, categoriesViewModel, notificationService, getEntryListViewModel)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of EntryListBaseViewModel
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string GetPagePath(int page)
|
||||
{
|
||||
return $"workshop/entries/profiles/{page}";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override EntryFilterInput GetFilter()
|
||||
{
|
||||
return new EntryFilterInput
|
||||
{
|
||||
And = new[]
|
||||
{
|
||||
new EntryFilterInput {EntryType = new EntryTypeOperationFilterInput {Eq = WebClient.Workshop.EntryType.Profile}},
|
||||
base.GetFilter()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<windowing:AppWindow 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:windows="clr-namespace:Artemis.UI.Screens.Workshop.Entries.Windows"
|
||||
xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia"
|
||||
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
|
||||
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Artemis.UI.Screens.Workshop.Entries.Windows.MarkdownPreviewView"
|
||||
x:DataType="windows:MarkdownPreviewViewModel"
|
||||
Icon="/Assets/Images/Logo/application.ico"
|
||||
Title="Artemis | Markdown Preview"
|
||||
Width="1200"
|
||||
Height="800">
|
||||
<Grid RowDefinitions="Auto,*" Margin="15">
|
||||
<StackPanel Grid.Row="0">
|
||||
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">Markdown Previewer</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Margin="0 10">
|
||||
<Run>In this window you can preview the Markdown you're writing in the main window of the application.</Run>
|
||||
<LineBreak/>
|
||||
<Run>The preview updates realtime, so it might be a good idea to keep this window visible while you're typing.</Run>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<controls:HyperlinkButton
|
||||
Grid.Row="0"
|
||||
Content="Learn more about Markdown on the wiki"
|
||||
NavigateUri="https://wiki.artemis-rgb.com/guides/user/markdown?mtm_campaign=artemis&mtm_kwd=markdown-editor"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top" />
|
||||
|
||||
<Border Grid.Row="1" Classes="card">
|
||||
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Markdown^}" MarkdownStyleName="FluentAvalonia" SaveScrollValueWhenContentUpdated="True">
|
||||
<mdxaml:MarkdownScrollViewer.Styles>
|
||||
<StyleInclude Source="/Styles/Markdown.axaml" />
|
||||
</mdxaml:MarkdownScrollViewer.Styles>
|
||||
</mdxaml:MarkdownScrollViewer>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
|
||||
</windowing:AppWindow>
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
using Artemis.UI.Shared;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||
|
||||
public partial class MarkdownPreviewView : ReactiveAppWindow<MarkdownPreviewViewModel>
|
||||
{
|
||||
public MarkdownPreviewView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using Artemis.UI.Shared;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop.Entries.Windows;
|
||||
|
||||
public class MarkdownPreviewViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public event EventHandler? Closed;
|
||||
|
||||
public IObservable<string> Markdown { get; }
|
||||
|
||||
public MarkdownPreviewViewModel(IObservable<string> markdown)
|
||||
{
|
||||
Markdown = markdown;
|
||||
}
|
||||
|
||||
protected virtual void OnClosed()
|
||||
{
|
||||
Closed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user