1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

UI - Replaced Consolas with Roboto Mono

Workshop library - Added most of submission management
This commit is contained in:
Robert 2023-09-03 16:51:22 +02:00
parent a0536b4302
commit bf3d5fc75d
37 changed files with 487 additions and 274 deletions

View File

@ -32,7 +32,7 @@
<TextBox Text="{CompiledBinding Exception, Mode=OneTime}"
AcceptsReturn="True"
IsReadOnly="True"
FontFamily="Consolas"
FontFamily="{StaticResource RobotoMono}"
FontSize="12"
BorderThickness="0" />
</ScrollViewer>

View File

@ -43,6 +43,10 @@
<Button Classes="icon-button">
<avalonia:MaterialIcon Kind="Cog" />
</Button>
<Button Classes="danger">
Oohohoho daanger!
</Button>
</StackPanel>
</Border>
</Design.PreviewWith>
@ -104,4 +108,29 @@
<Style Selector="Button.title-bar-button:pointerover">
<Setter Property="Background" Value="Red"></Setter>
</Style>
<Style Selector="Button.danger">
<Setter Property="Background" Value="#D64848"></Setter>
</Style>
<Style Selector="Button.danger:pointerover">
<Style Selector="^ /template/ controls|FABorder#Root">
<Setter Property="Background" Value="#D65757"/>
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" />
</Style>
</Style>
<Style Selector="Button.danger:pressed">
<Style Selector="^ /template/ controls|FABorder#Root">
<Setter Property="Background" Value="#D64848" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" />
</Style>
</Style>
<Style Selector="Button.danger:disabled">
<Style Selector="^ /template/ controls|FABorder#Root">
<Setter Property="Background" Value="#D79D9C" />
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" />
</Style>
</Style>
</Styles>

View File

@ -66,7 +66,7 @@
<TextBlock Grid.Column="0" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<TextBlock Grid.Column="1"
Text="{CompiledBinding DisplayValue}"
FontFamily="Consolas"
FontFamily="{StaticResource RobotoMono}"
HorizontalAlignment="Right"
Margin="0 0 10 0" />
</Grid>
@ -81,7 +81,7 @@
IsVisible="{CompiledBinding IsEventPicker, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dataModelPicker:DataModelPicker}}}"/>
</StackPanel>
<ContentControl Grid.Column="1" Content="{CompiledBinding DisplayViewModel}" FontFamily="Consolas" Margin="0 0 10 0" />
<ContentControl Grid.Column="1" Content="{CompiledBinding DisplayViewModel}" FontFamily="{StaticResource RobotoMono}" Margin="0 0 10 0" />
</Grid>
</TreeDataTemplate>
@ -90,7 +90,7 @@
<TextBlock Grid.Column="0" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<TextBlock Grid.Column="1"
Text="{CompiledBinding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
FontFamily="{StaticResource RobotoMono}"
HorizontalAlignment="Right"
Margin="0 0 10 0" />
</Grid>

View File

@ -61,9 +61,13 @@
<DependentUpon>LayoutListView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Update="Screens\Workshop\Library\SubmissionsDetailView.axaml.cs">
<Compile Update="Screens\Workshop\Library\SubmissionDetailView.axaml.cs">
<DependentUpon>SubmissionsDetailView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Remove="Screens\Workshop\Entries\Windows\MarkdownPreviewView.axaml" />
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -12,6 +12,9 @@
MinWidth="600"
MinHeight="400"
PointerReleased="InputElement_OnPointerReleased">
<windowing:AppWindow.Resources>
</windowing:AppWindow.Resources>
<windowing:AppWindow.Styles>
<Styles>
<Style Selector="Border#TitleBarContainer">

View File

@ -45,7 +45,7 @@ public static class Routes
{
new RouteRegistration<InstalledTabViewModel>("installed"),
new RouteRegistration<SubmissionsTabViewModel>("submissions"),
new RouteRegistration<SubmissionsDetailViewModel>("submissions/{entryId:guid}"),
new RouteRegistration<SubmissionDetailViewModel>("submissions/{entryId:guid}"),
}
}
}

View File

@ -23,7 +23,7 @@
</TextBlock>
</StackPanel>
<TreeView Grid.Row="1" ItemsSource="{CompiledBinding MainDataModel.Children}">
<TreeView Grid.Row="1" ItemsSource="{CompiledBinding MainDataModel.Children}" Padding="0 0 15 0">
<TreeView.Styles>
<Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="{CompiledBinding IsVisualizationExpanded, Mode=TwoWay,DataType=dataModel:DataModelVisualizationViewModel}" />
@ -42,7 +42,7 @@
</TreeView.Styles>
<TreeView.DataTemplates>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{CompiledBinding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<Grid ColumnDefinitions="Auto,Auto,*" Margin="0 0 8 0">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{CompiledBinding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
@ -52,13 +52,14 @@
<TextBlock Grid.Column="1" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{CompiledBinding DisplayValue}"
FontFamily="Consolas"
FontSize="13"
FontFamily="{StaticResource RobotoMono}"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{CompiledBinding ListChildren}">
<Grid ColumnDefinitions="Auto,Auto,*">
<Grid ColumnDefinitions="Auto,Auto,*" Margin="0 0 8 0">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{CompiledBinding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
@ -67,12 +68,13 @@
<TextBlock Grid.Column="1" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{CompiledBinding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
FontSize="13"
FontFamily="{StaticResource RobotoMono}"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<Grid ColumnDefinitions="Auto,Auto,*" Margin="0 0 8 0">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
@ -82,11 +84,11 @@
<TextBlock Grid.Column="1" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<!-- Value display -->
<ContentControl Grid.Column="2" Content="{CompiledBinding DisplayViewModel}" FontFamily="Consolas" />
<ContentControl Grid.Column="2" Content="{CompiledBinding DisplayViewModel}" FontSize="13" FontFamily="{StaticResource RobotoMono}" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListItemViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<Grid ColumnDefinitions="Auto,Auto,*" Margin="0 0 8 0">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
@ -99,12 +101,12 @@
</StackPanel>
<!-- Value display -->
<ContentControl Grid.Column="2" Content="{CompiledBinding DisplayViewModel}" FontFamily="Consolas" />
<ContentControl Grid.Column="2" Content="{CompiledBinding DisplayViewModel}" FontSize="13" FontFamily="{StaticResource RobotoMono}" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}" ItemsSource="{CompiledBinding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<Grid ColumnDefinitions="Auto,Auto,*" Margin="0 0 8 0">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{CompiledBinding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
@ -113,7 +115,8 @@
<TextBlock Grid.Column="1" Text="{CompiledBinding PropertyDescription.Name}" ToolTip.Tip="{CompiledBinding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{CompiledBinding Path=CountDisplay, DataType=dataModel:DataModelListViewModel ,Mode=OneWay}"
FontFamily="Consolas"
FontSize="13"
FontFamily="{StaticResource RobotoMono}"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>

View File

@ -9,7 +9,7 @@
<ScrollViewer Name="LogsScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<SelectableTextBlock
Inlines="{CompiledBinding Lines}"
FontFamily="Consolas"
FontFamily="{StaticResource RobotoMono}"
SizeChanged="Control_OnSizeChanged"
SelectionBrush="{StaticResource TextControlSelectionHighlightColor}"
/>

View File

@ -19,7 +19,7 @@
<ScrollViewer Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Name="LogsScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<SelectableTextBlock
Inlines="{CompiledBinding Lines}"
FontFamily="Consolas"
FontFamily="{StaticResource RobotoMono}"
SizeChanged="Control_OnSizeChanged"
SelectionBrush="{StaticResource TextControlSelectionHighlightColor}" />
</ScrollViewer>

View File

@ -41,7 +41,7 @@
Text="{CompiledBinding Converter={StaticResource SKColorToStringConverter}, Mode=OneWay}"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
FontFamily="Consolas" />
FontFamily="{StaticResource RobotoMono}" />
<Border Margin="5 0 0 0"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
@ -61,16 +61,16 @@
</StackPanel>
</DataTemplate>
<DataTemplate DataType="core:ColorGradient">
<TextBlock Text="Color gradient" FontFamily="Consolas" />
<TextBlock Text="Color gradient" FontFamily="{StaticResource RobotoMono}" />
</DataTemplate>
<DataTemplate DataType="core:Numeric">
<TextBlock Text="{CompiledBinding Mode=OneWay}" FontFamily="Consolas" />
<TextBlock Text="{CompiledBinding Mode=OneWay}" FontFamily="{StaticResource RobotoMono}" />
</DataTemplate>
<DataTemplate DataType="collections:IList">
<TextBlock Text="{CompiledBinding Count, StringFormat='List - {0} item(s)', Mode=OneWay}" FontFamily="Consolas" />
<TextBlock Text="{CompiledBinding Count, StringFormat='List - {0} item(s)', Mode=OneWay}" FontFamily="{StaticResource RobotoMono}" />
</DataTemplate>
<DataTemplate DataType="system:Object">
<TextBlock Text="{CompiledBinding Mode=OneWay}" FontFamily="Consolas" />
<TextBlock Text="{CompiledBinding Mode=OneWay}" FontFamily="{StaticResource RobotoMono}" />
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>

View File

@ -7,99 +7,133 @@
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"
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="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 RowDefinitions="Auto,*,Auto">
<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>
<Grid ColumnDefinitions="103,*">
<StackPanel Grid.Column="0" Width="95">
<Label Target="Name" Margin="0">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>
</Border>
<TextBlock Foreground="{DynamicResource SystemFillColorCriticalBrush}" Margin="2 0" IsVisible="{CompiledBinding !IconValid}" TextWrapping="Wrap">
Icon required
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1">
<Label Target="Name" Margin="0">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>
<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>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="*,Auto,*">
<Border Grid.Column="0" BorderThickness="1"
BorderBrush="{DynamicResource TextControlBorderBrush}"
CornerRadius="{DynamicResource ControlCornerRadius}"
Background="{DynamicResource TextControlBackground}"
Padding="{DynamicResource TextControlThemePadding}">
<avaloniaEdit:TextEditor
FontFamily="{StaticResource RobotoMono}"
Name="DescriptionEditor"
Document="{CompiledBinding MarkdownDocument}"
WordWrap="True" />
</Border>
<GridSplitter Grid.Column="1" Margin="5 0"></GridSplitter>
<Border Grid.Column="2" Classes="card-condensed">
<mdxaml:MarkdownScrollViewer Margin="5 0"
Name="DescriptionPreview"
Markdown="{CompiledBinding Description}"
MarkdownStyleName="FluentAvalonia"
SaveScrollValueWhenContentUpdated="True">
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
</mdxaml:MarkdownScrollViewer>
</Border>
</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}" />
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox Name="SynchronizedScrolling" IsChecked="True" VerticalAlignment="Bottom">Synchronized scrolling</CheckBox>
<controls:HyperlinkButton
Margin="0 5 0 0"
Content="Learn more about Markdown on the wiki"
NavigateUri="https://wiki.artemis-rgb.com/guides/user/markdown?mtm_campaign=artemis&amp;mtm_kwd=markdown-editor"
HorizontalAlignment="Right"
VerticalAlignment="Top" />
</StackPanel>
<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>
</Grid>
</UserControl>

View File

@ -1,34 +1,100 @@
using System.Linq;
using Artemis.UI.Shared.Extensions;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Media.Immutable;
using Avalonia.ReactiveUI;
using AvaloniaEdit.TextMate;
using ReactiveUI;
using TextMateSharp.Grammars;
namespace Artemis.UI.Screens.Workshop.Entries;
public partial class EntrySpecificationsView : ReactiveUserControl<EntrySpecificationsViewModel>
{
private ScrollViewer? _editorScrollViewer;
private ScrollViewer? _previewScrollViewer;
private bool _updating;
public EntrySpecificationsView()
{
InitializeComponent();
DescriptionEditor.Options.AllowScrollBelowDocument = false;
RegistryOptions options = new(ThemeName.Dark);
TextMate.Installation? install = DescriptionEditor.InstallTextMate(options);
install.SetGrammar(options.GetScopeByExtension(".md"));
this.WhenActivated(_ => SetupScrollSync());
}
#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
private void SetupScrollSync()
{
if (_editorScrollViewer != null)
_editorScrollViewer.PropertyChanged -= EditorScrollViewerOnPropertyChanged;
if (_previewScrollViewer != null)
_previewScrollViewer.PropertyChanged -= PreviewScrollViewerOnPropertyChanged;
_editorScrollViewer = DescriptionEditor.GetVisualChildrenOfType<ScrollViewer>().FirstOrDefault();
_previewScrollViewer = DescriptionPreview.GetVisualChildrenOfType<ScrollViewer>().FirstOrDefault();
if (_editorScrollViewer != null)
_editorScrollViewer.PropertyChanged += EditorScrollViewerOnPropertyChanged;
if (_previewScrollViewer != null)
_previewScrollViewer.PropertyChanged += PreviewScrollViewerOnPropertyChanged;
}
private void EditorScrollViewerOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.Name != nameof(ScrollViewer.Offset) || _updating || SynchronizedScrolling.IsChecked != true)
return;
try
{
_updating = true;
SynchronizeScrollViewers(_editorScrollViewer, _previewScrollViewer);
}
finally
{
_updating = false;
}
}
private void PreviewScrollViewerOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.Name != nameof(ScrollViewer.Offset) || _updating || SynchronizedScrolling.IsChecked != true)
return;
try
{
_updating = true;
SynchronizeScrollViewers(_previewScrollViewer, _editorScrollViewer);
}
finally
{
_updating = false;
}
}
private void SynchronizeScrollViewers(ScrollViewer? source, ScrollViewer? target)
{
if (source == null || target == null)
return;
double sourceScrollableHeight = source.Extent.Height - source.Viewport.Height;
double targetScrollableHeight = target.Extent.Height - target.Viewport.Height;
if (sourceScrollableHeight != 0)
target.Offset = new Vector(target.Offset.X, targetScrollableHeight * (source.Offset.Y / sourceScrollableHeight));
}
}

View File

@ -5,15 +5,12 @@ 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;
@ -35,16 +32,13 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
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
@ -56,7 +50,6 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
MarkdownDocument.TextChanged += MarkdownDocumentOnTextChanged;
Disposable.Create(() =>
{
_previewWindow?.Close();
MarkdownDocument.TextChanged -= MarkdownDocumentOnTextChanged;
MarkdownDocument = null;
ClearIcon();
@ -66,11 +59,10 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
private void MarkdownDocumentOnTextChanged(object? sender, EventArgs e)
{
Description = MarkdownDocument.Text;
Description = MarkdownDocument?.Text ?? string.Empty;
}
public ReactiveCommand<Unit, Unit> SelectIcon { get; }
public ReactiveCommand<Unit, Unit> OpenMarkdownPreview { get; }
public ObservableCollection<CategoryViewModel> Categories { get; } = new();
public ObservableCollection<string> Tags { get; } = new();
@ -139,25 +131,6 @@ public class EntrySpecificationsViewModel : ValidatableViewModelBase
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();

View File

@ -1,43 +0,0 @@
<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&amp;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>

View File

@ -1,12 +0,0 @@
using Artemis.UI.Shared;
namespace Artemis.UI.Screens.Workshop.Entries.Windows;
public partial class MarkdownPreviewView : ReactiveAppWindow<MarkdownPreviewViewModel>
{
public MarkdownPreviewView()
{
InitializeComponent();
}
}

View File

@ -1,21 +0,0 @@
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);
}
}

View File

@ -0,0 +1,50 @@
<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:library="clr-namespace:Artemis.UI.Screens.Workshop.Library"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Library.SubmissionDetailView"
x:DataType="library:SubmissionDetailViewModel">
<UserControl.Resources>
<converters:DateTimeConverter x:Key="DateTimeConverter" />
</UserControl.Resources>
<Grid ColumnDefinitions="300,*">
<StackPanel Grid.Column="0" Spacing="10">
<Border Classes="card" VerticalAlignment="Top" Margin="0 0 10 0">
<StackPanel>
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">Management</TextBlock>
<Border Classes="card-separator" />
<TextBlock Margin="0 0 0 8">
<avalonia:MaterialIcon Kind="Downloads" />
<Run Classes="h5" Text="{CompiledBinding Entry.Downloads, FallbackValue=0}" />
<Run>downloads</Run>
</TextBlock>
<TextBlock Classes="subtitle"
ToolTip.Tip="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}}">
<avalonia:MaterialIcon Kind="Calendar" />
<Run>Created</Run>
<Run Text="{CompiledBinding Entry.CreatedAt, Converter={StaticResource DateTimeConverter}, ConverterParameter='humanize'}"></Run>
</TextBlock>
<Border Classes="card-separator" />
<StackPanel Spacing="5">
<Button HorizontalAlignment="Stretch" Command="{CompiledBinding CreateRelease}">
Create new release
</Button>
<Button Classes="danger" HorizontalAlignment="Stretch" Command="{CompiledBinding DeleteSubmission}">
Delete submission
</Button>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
<ContentControl Grid.Column="1" Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
</Grid>
</UserControl>

View File

@ -0,0 +1,11 @@
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Library;
public partial class SubmissionDetailView : ReactiveUserControl<SubmissionDetailViewModel>
{
public SubmissionDetailView()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,131 @@
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reactive;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Entries;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Shared.Routing;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop;
using Avalonia.Media.Imaging;
using ReactiveUI;
using StrawberryShake;
namespace Artemis.UI.Screens.Workshop.Library;
public class SubmissionDetailViewModel : RoutableScreen<WorkshopDetailParameters>
{
private readonly IWorkshopClient _client;
private readonly IHttpClientFactory _httpClientFactory;
private readonly Func<EntrySpecificationsViewModel> _getEntrySpecificationsViewModel;
private readonly IWindowService _windowService;
private readonly IRouter _router;
private IGetSubmittedEntryById_Entry? _entry;
private EntrySpecificationsViewModel? _entrySpecificationsViewModel;
public SubmissionDetailViewModel(IWorkshopClient client,
IHttpClientFactory httpClientFactory,
Func<EntrySpecificationsViewModel> entrySpecificationsViewModel,
IWindowService windowService,
IRouter router)
{
_client = client;
_httpClientFactory = httpClientFactory;
_getEntrySpecificationsViewModel = entrySpecificationsViewModel;
_windowService = windowService;
_router = router;
CreateRelease = ReactiveCommand.CreateFromTask(ExecuteCreateRelease);
DeleteSubmission = ReactiveCommand.CreateFromTask(ExecuteDeleteSubmission);
}
public ReactiveCommand<Unit, Unit> CreateRelease { get; }
public ReactiveCommand<Unit, Unit> DeleteSubmission { get; }
public EntrySpecificationsViewModel? EntrySpecificationsViewModel
{
get => _entrySpecificationsViewModel;
set => RaiseAndSetIfChanged(ref _entrySpecificationsViewModel, value);
}
public IGetSubmittedEntryById_Entry? Entry
{
get => _entry;
set => RaiseAndSetIfChanged(ref _entry, value);
}
public override async Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
{
IOperationResult<IGetSubmittedEntryByIdResult> result = await _client.GetSubmittedEntryById.ExecuteAsync(parameters.EntryId, cancellationToken);
if (result.IsErrorResult())
return;
Entry = result.Data?.Entry;
await ApplyFromEntry(cancellationToken);
}
private async Task ApplyFromEntry(CancellationToken cancellationToken)
{
if (Entry == null)
return;
EntrySpecificationsViewModel viewModel = _getEntrySpecificationsViewModel();
viewModel.IconBitmap = await GetEntryIcon(cancellationToken);
viewModel.Name = Entry.Name;
viewModel.Summary = Entry.Summary;
viewModel.Description = Entry.Description;
viewModel.PreselectedCategories = Entry.Categories.Select(c => c.Id).ToList();
viewModel.Tags.Clear();
foreach (string tag in Entry.Tags.Select(c => c.Name))
viewModel.Tags.Add(tag);
EntrySpecificationsViewModel = viewModel;
}
private async Task<Bitmap?> GetEntryIcon(CancellationToken cancellationToken)
{
if (Entry == null)
return null;
HttpClient client = _httpClientFactory.CreateClient(WorkshopConstants.WORKSHOP_CLIENT_NAME);
try
{
HttpResponseMessage response = await client.GetAsync($"entries/{Entry.Id}/icon", cancellationToken);
response.EnsureSuccessStatusCode();
Stream data = await response.Content.ReadAsStreamAsync(cancellationToken);
return new Bitmap(data);
}
catch (HttpRequestException)
{
// ignored
return null;
}
}
private Task ExecuteCreateRelease(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
private async Task ExecuteDeleteSubmission(CancellationToken cancellationToken)
{
if (Entry == null)
return;
bool confirmed = await _windowService.ShowConfirmContentDialog(
"Delete submission?",
"You cannot undo this by yourself.\r\n" +
"Users that have already downloaded your submission will keep it.");
if (!confirmed)
return;
IOperationResult<IRemoveEntryResult> result = await _client.RemoveEntry.ExecuteAsync(Entry.Id, cancellationToken);
result.EnsureNoErrors();
await _router.Navigate("workshop/library/submissions");
}
}

View File

@ -1,10 +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:library="clr-namespace:Artemis.UI.Screens.Workshop.Library"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Library.SubmissionsDetailView"
x:DataType="library:SubmissionsDetailViewModel">
<ContentControl Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
</UserControl>

View File

@ -1,11 +0,0 @@
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Workshop.Library;
public partial class SubmissionsDetailView : ReactiveUserControl<SubmissionsDetailViewModel>
{
public SubmissionsDetailView()
{
InitializeComponent();
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Screens.Workshop.Entries;
using Artemis.UI.Screens.Workshop.Parameters;
using Artemis.UI.Shared.Routing;
namespace Artemis.UI.Screens.Workshop.Library;
public class SubmissionsDetailViewModel : RoutableScreen<WorkshopDetailParameters>
{
public EntrySpecificationsViewModel EntrySpecificationsViewModel { get; }
public SubmissionsDetailViewModel(EntrySpecificationsViewModel entrySpecificationsViewModel)
{
EntrySpecificationsViewModel = entrySpecificationsViewModel;
}
public override Task OnNavigating(WorkshopDetailParameters parameters, NavigationArguments args, CancellationToken cancellationToken)
{
Console.WriteLine(parameters.EntryId);
return Task.CompletedTask;
}
}

View File

@ -11,7 +11,7 @@
<controls:NavigationView PaneDisplayMode="Top"
MenuItemsSource="{CompiledBinding Tabs}"
SelectedItem="{CompiledBinding SelectedTab}"
IsBackEnabled="{CompiledBinding CanGoBack}"
IsBackEnabled="True"
IsSettingsVisible="False"
IsBackButtonVisible="True"
BackRequested="NavigationView_OnBackRequested">

View File

@ -15,7 +15,7 @@ public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
{
private readonly IRouter _router;
private RouteViewModel? _selectedTab;
private ObservableAsPropertyHelper<bool>? _canGoBack;
private ObservableAsPropertyHelper<bool>? _viewingDetails;
/// <inheritdoc />
public WorkshopLibraryViewModel(IRouter router)
@ -30,8 +30,7 @@ public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
this.WhenActivated(d =>
{
// Show back button on details page
_canGoBack = _router.CurrentPath.Select(p => p != null && p.StartsWith("workshop/library/submissions/")).ToProperty(this, vm => vm.CanGoBack).DisposeWith(d);
_viewingDetails = _router.CurrentPath.Select(p => p != null && p.StartsWith("workshop/library/submissions/")).ToProperty(this, vm => vm.ViewingDetails).DisposeWith(d);
// Navigate on tab change
this.WhenAnyValue(vm => vm.SelectedTab)
.WhereNotNull()
@ -40,7 +39,7 @@ public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
});
}
public bool CanGoBack => _canGoBack?.Value ?? false;
public bool ViewingDetails => _viewingDetails?.Value ?? false;
public ObservableCollection<RouteViewModel> Tabs { get; }
public RouteViewModel? SelectedTab
@ -58,6 +57,9 @@ public class WorkshopLibraryViewModel : RoutableHostScreen<RoutableScreen>
public void GoBack()
{
_router.GoBack();
if (ViewingDetails)
_router.GoBack();
else
_router.Navigate("workshop");
}
}

View File

@ -21,8 +21,6 @@
</TextBlock>
</StackPanel>
<ScrollViewer Grid.Row="1" Padding="0 0 20 0" Margin="0 20 0 0">
<ContentControl Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
</ScrollViewer>
<ContentControl Grid.Row="1" Margin="0 20 0 0" Content="{CompiledBinding EntrySpecificationsViewModel}"></ContentControl>
</Grid>
</UserControl>

View File

@ -15,7 +15,7 @@
<!-- Adjust the ScrollViewer padding in AvaloniaEdit so scrollbar doesn't overlap text -->
<Style Selector="aedit|TextEditor /template/ ScrollViewer ScrollContentPresenter">
<Setter Property="Padding" Value="0 0 0 20" />
<Setter Property="Padding" Value="0 0 20 0" />
</Style>
<!-- set the selection color for the AvaloniaEdit boxes -->
@ -26,6 +26,7 @@
<Styles.Resources>
<ResourceDictionary>
<FontFamily x:Key="RobotoMono">avares://Artemis.UI/Assets/Fonts#Roboto Mono</FontFamily>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="TreeView.axaml"/>
</ResourceDictionary.MergedDictionaries>

View File

@ -25,7 +25,7 @@
Text="{CompiledBinding Converter={StaticResource SKColorToStringConverter}}"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
FontFamily="Consolas"/>
FontFamily="{StaticResource RobotoMono}"/>
<Border Margin="5 0 0 0"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
@ -46,7 +46,7 @@
</DataTemplate>
<DataTemplate DataType="system:Object">
<Border Classes="card-condensed" Margin="0,5,5,5 ">
<TextBlock Text="{CompiledBinding Converter={StaticResource JsonConverter}}" FontFamily="Consolas"/>
<TextBlock Text="{CompiledBinding Converter={StaticResource JsonConverter}}" FontFamily="{StaticResource RobotoMono}"/>
</Border>
</DataTemplate>
</ContentControl.DataTemplates>

View File

@ -38,5 +38,11 @@
<GraphQL Update="Queries\GetSubmittedEntries.graphql">
<Generator>MSBuild:GenerateGraphQLCode</Generator>
</GraphQL>
<GraphQL Update="Queries\GetSubmittedEntryById.graphql">
<Generator>MSBuild:GenerateGraphQLCode</Generator>
</GraphQL>
<GraphQL Update="Queries\RemoveEntry.graphql">
<Generator>MSBuild:GenerateGraphQLCode</Generator>
</GraphQL>
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
query GetSubmittedEntryById($id: UUID!) {
entry(id: $id) {
id
name
summary
entryType
downloads
createdAt
description
categories {
id
}
tags {
name
}
}
}

View File

@ -0,0 +1,5 @@
mutation RemoveEntry ($id: UUID!) {
removeEntry(id: $id) {
id
}
}

View File

@ -55,6 +55,7 @@ type Image {
type Mutation {
addEntry(input: CreateEntryInput!): Entry
removeEntry(id: UUID!): Entry
updateEntry(input: UpdateEntryInput!): Entry
}