Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBeekman committed Jul 12, 2024
2 parents bd90417 + 4552b3b commit 0e911d6
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/Artemis.UI/ArtemisLinkCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Windows.Input;
using Artemis.Core;
using Artemis.UI.Shared.Routing;

namespace Artemis.UI;

public class ArtemisLinkCommand: ICommand
{
public static IRouter? Router;

/// <inheritdoc />
public bool CanExecute(object? parameter) => true;

/// <inheritdoc />
public void Execute(object? parameter)
{
if (parameter is not string url || !Uri.TryCreate(url, UriKind.Absolute, out Uri? uri))
return;

if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
Utilities.OpenUrl(url);
else if (uri.Scheme == "artemis")
Router?.Navigate(uri.Host + uri.LocalPath);
}

/// <inheritdoc />
public event EventHandler? CanExecuteChanged;

}
8 changes: 8 additions & 0 deletions src/Artemis.UI/Controls/SplitMarkdownEditor.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
xmlns:avaloniaEdit="https://github.com/avaloniaui/avaloniaedit"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:fa="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:input="clr-namespace:System.Windows.Input;assembly=System.ObjectModel"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Controls.SplitMarkdownEditor">
<UserControl.Resources>
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<Grid RowDefinitions="Auto,*">
<Grid Row="0" ColumnDefinitions="Auto,*">
<Label Grid.Column="0" Name="DescriptionEditorLabel" Target="DescriptionEditor" Margin="0 28 0 0" />
Expand Down Expand Up @@ -41,6 +46,9 @@
Markdown="{CompiledBinding Document.Text, Mode=OneWay, ElementName=DescriptionEditor}"
MarkdownStyleName="FluentAvalonia"
SaveScrollValueWhenContentUpdated="True">
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down
5 changes: 4 additions & 1 deletion src/Artemis.UI/Screens/Root/RootViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public RootViewModel(ILogger logger,

router.SetRoot(this);
mainWindowService.ConfigureMainWindowProvider(this);

OpenScreen = ReactiveCommand.Create<string?>(ExecuteOpenScreen);
OpenDebugger = ReactiveCommand.CreateFromTask(ExecuteOpenDebugger);
Exit = ReactiveCommand.CreateFromTask(ExecuteExit);
Expand Down Expand Up @@ -107,6 +107,9 @@ public RootViewModel(ILogger logger,
_windowService.ShowExceptionDialog("Fatal error occured during initialization", e);
}
});

// This isn't pretty, but it's the most straightforward way to make sure the ArtemisLinkCommand has access to the router
ArtemisLinkCommand.Router = router;
}

public SidebarViewModel SidebarViewModel { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1400"
x:Class="Artemis.UI.Screens.Settings.Updating.ReleaseDetailsView"
x:DataType="updating:ReleaseDetailsViewModel">
<UserControl.Resources>
<shared:BytesToStringConverter x:Key="BytesToStringConverter" />
<converters:SubstringConverter x:Key="SubstringConverter" />
<converters:DateTimeConverter x:Key="DateTimeConverter" />
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<UserControl.Styles>
<Style Selector="Grid.info-container">
Expand Down Expand Up @@ -142,6 +144,9 @@
<Border Grid.Row="1" Classes="card-separator" />

<mdxaml:MarkdownScrollViewer Grid.Row="2" Markdown="{CompiledBinding Release.Changelog}" MarkdownStyleName="FluentAvalonia">
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml"/>
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:entryReleases="clr-namespace:Artemis.UI.Screens.Workshop.EntryReleases"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.EntryReleases.EntryReleaseView"
x:DataType="entryReleases:EntryReleaseViewModel">
<UserControl.Resources>
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<Grid RowDefinitions="Auto,Auto">
<Border Grid.Row="0" Classes="card" Margin="0 0 0 10">
<ContentControl Content="{CompiledBinding EntryReleaseInfoViewModel}"/>
Expand All @@ -24,6 +28,9 @@
Markdown="{CompiledBinding Release.Changelog}"
MarkdownStyleName="FluentAvalonia"
IsVisible="{CompiledBinding Release.Changelog, Converter={x:Static StringConverters.IsNotNullOrEmpty}}">
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:layout="clr-namespace:Artemis.UI.Screens.Workshop.Layout"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Layout.LayoutDescriptionView"
x:DataType="layout:LayoutDescriptionViewModel">
<UserControl.Resources>
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<StackPanel Spacing="10">
<Border Classes="card">
<ContentControl Content="{CompiledBinding ReleaseInfoViewModel}"/>
</Border>

<Border Classes="card">
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia">
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:plugins="clr-namespace:Artemis.UI.Screens.Workshop.Plugins"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Plugins.PluginDescriptionView"
x:DataType="plugins:PluginDescriptionViewModel">
<UserControl.Resources>
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<StackPanel Spacing="10">
<Border Classes="card">
<ContentControl Content="{CompiledBinding ReleaseInfoViewModel}"/>
</Border>

<Border Classes="card">
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia">
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight"
xmlns:ui="clr-namespace:Artemis.UI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfileDescriptionView"
x:DataType="profile:ProfileDescriptionViewModel">
<UserControl.Resources>
<ui:ArtemisLinkCommand x:Key="ArtemisLinkCommand" />
</UserControl.Resources>
<StackPanel Spacing="10">
<Border Classes="card">
<ContentControl Content="{CompiledBinding ReleaseInfoViewModel}"/>
</Border>

<Border Classes="card">
<mdxaml:MarkdownScrollViewer Markdown="{CompiledBinding Entry.Description}" MarkdownStyleName="FluentAvalonia" Name="MarkdownScrollViewer" >
<mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:Markdown HyperlinkCommand="{StaticResource ArtemisLinkCommand}" />
</mdxaml:MarkdownScrollViewer.Engine>
<mdxaml:MarkdownScrollViewer.Styles>
<StyleInclude Source="/Styles/Markdown.axaml" />
</mdxaml:MarkdownScrollViewer.Styles>
Expand Down

0 comments on commit 0e911d6

Please sign in to comment.