mirror of
https://gitlab.com/2009scape/Saradomin-Launcher.git
synced 2026-08-01 14:19:14 -06:00
Simplify certain layouts, fix alignments.
This commit is contained in:
parent
054555afcb
commit
f471f17d67
11 changed files with 286 additions and 200 deletions
|
|
@ -1,8 +1,6 @@
|
|||
<Application x:Class="Saradomin.App"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:Saradomin.View.Controls"
|
||||
xmlns:default="clr-namespace:Avalonia.Themes.Default;assembly=Avalonia.Themes.Default">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Resources>
|
||||
<Color x:Key="DarkBackgroundColor">#3E3529</Color>
|
||||
<Color x:Key="DarkTranslucentBackgroundColor">#CC3E3529</Color>
|
||||
|
|
@ -101,7 +99,9 @@
|
|||
<StyleInclude Source="avares://Saradomin/Resources/Styles/GroupBox.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/CheckBox.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/ComboBox.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/Expander.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/TextBox.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/TextBlock.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/ScrollBar.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/NumericUpDown.axaml" />
|
||||
<StyleInclude Source="avares://Saradomin/Resources/Styles/Hyperlink.axaml" />
|
||||
|
|
|
|||
34
Saradomin/Resources/Styles/Expander.axaml
Normal file
34
Saradomin/Resources/Styles/Expander.axaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style Selector="ListBox.PluginList Expander">
|
||||
<Setter Property="ContentTransition" Value="{x:Null}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander /template/ ToggleButton#PART_toggle /template/ Border">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander /template/ ToggleButton#PART_toggle">
|
||||
<Setter Property="Foreground" Value="{StaticResource LightForegroundBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander /template/ Path">
|
||||
<Setter Property="Fill" Value="{StaticResource DarkForegroundBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander:pointerover /template/ ToggleButton#PART_toggle /template/ Border">
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander:pointerover /template/ ToggleButton#PART_toggle /template/ Path">
|
||||
<Setter Property="Fill" Value="{StaticResource MouseOverBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander:expanded /template/ ToggleButton#PART_toggle /template/ Path">
|
||||
<Setter Property="Fill" Value="{StaticResource AccentBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox.PluginList Expander:expanded /template/ ToggleButton#PART_toggle">
|
||||
<Setter Property="Foreground" Value="{StaticResource AccentBrush}" />
|
||||
</Style>
|
||||
</Styles>
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<Setter Property="Background" Value="{StaticResource DarkMediumBackgroundBrush}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource LightForegroundBrush}" />
|
||||
</Style>
|
||||
|
||||
|
||||
<Style Selector="ListBox.PluginList > ListBoxItem:selected /template/ ContentPresenter">
|
||||
<Setter Property="Background" Value="{StaticResource DarkMediumBackgroundBrush}" />
|
||||
</Style>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,36 @@
|
|||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style Selector="ScrollBar:vertical">
|
||||
<Setter Property="Width" Value="9" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Background="{StaticResource DarkBackgroundBrush}"
|
||||
Padding="1,0,0,0">
|
||||
<Track Minimum="{TemplateBinding Minimum}"
|
||||
Maximum="{TemplateBinding Maximum}"
|
||||
Value="{TemplateBinding Value, Mode=TwoWay}"
|
||||
ViewportSize="{TemplateBinding ViewportSize}"
|
||||
Orientation="{TemplateBinding Orientation}"
|
||||
DeferThumbDrag="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsDirectionReversed="True">
|
||||
<Track.Thumb>
|
||||
<Thumb Name="thumb"
|
||||
HorizontalAlignment="Stretch" />
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ScrollViewer.MainViewScrollViewer /template/ ScrollBar:vertical">
|
||||
<Setter Property="Width" Value="10" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border Background="{StaticResource MediumBackgroundBrush}"
|
||||
ClipToBounds="True"
|
||||
CornerRadius="0,4,0,0">
|
||||
<Grid RowDefinitions="Auto,*,Auto"
|
||||
Background="{StaticResource DarkBackgroundBrush}">
|
||||
<Track Grid.Row="1"
|
||||
Minimum="{TemplateBinding Minimum}"
|
||||
<Border CornerRadius="0,4,0,0"
|
||||
Background="{StaticResource DarkBackgroundBrush}">
|
||||
<Grid>
|
||||
<Track Minimum="{TemplateBinding Minimum}"
|
||||
Maximum="{TemplateBinding Maximum}"
|
||||
Value="{TemplateBinding Value, Mode=TwoWay}"
|
||||
ViewportSize="{TemplateBinding ViewportSize}"
|
||||
|
|
@ -18,7 +38,8 @@
|
|||
DeferThumbDrag="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsDirectionReversed="True">
|
||||
<Track.Thumb>
|
||||
<Thumb Name="thumb" Width="4" ClipToBounds="True" />
|
||||
<Thumb Name="thumb"
|
||||
HorizontalAlignment="Stretch" />
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
|
|
@ -30,7 +51,7 @@
|
|||
<Style Selector="Thumb#thumb">
|
||||
<Setter Property="Background" Value="{StaticResource DarkMediumBackgroundBrush}" />
|
||||
</Style>
|
||||
|
||||
|
||||
<Style Selector="Thumb#thumb /template/ Border">
|
||||
<Setter Property="Margin" Value="0,6" />
|
||||
</Style>
|
||||
|
|
|
|||
6
Saradomin/Resources/Styles/TextBlock.axaml
Normal file
6
Saradomin/Resources/Styles/TextBlock.axaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style Selector="TextBlock.NewsRenderView">
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Style>
|
||||
</Styles>
|
||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Web;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
using HtmlAgilityPack;
|
||||
|
|
@ -12,54 +13,40 @@ namespace Saradomin.Utilities
|
|||
public class HtmlRenderer
|
||||
{
|
||||
private int _listDescent = 0;
|
||||
private bool seenNonWhiteSpace = false;
|
||||
|
||||
private Stack<StackPanel> _panels = new();
|
||||
private StackPanel _container;
|
||||
private string _prefix;
|
||||
private InlineCollection _inlines;
|
||||
private HtmlNode _rootNode;
|
||||
|
||||
public StackPanel CurrentLine => _panels.Peek();
|
||||
|
||||
public HtmlRenderer(StackPanel container, HtmlNode rootNode)
|
||||
public HtmlRenderer(HtmlNode rootNode)
|
||||
{
|
||||
_container = container;
|
||||
_rootNode = rootNode;
|
||||
}
|
||||
|
||||
public void RenderToContainer()
|
||||
public InlineCollection Render()
|
||||
{
|
||||
_panels.Push(_container);
|
||||
Visit(_rootNode);
|
||||
_panels.Pop();
|
||||
_inlines = new();
|
||||
{
|
||||
Visit(_rootNode);
|
||||
}
|
||||
return _inlines;
|
||||
}
|
||||
|
||||
private void InNewBlockDo(Action<StackPanel> action)
|
||||
private void InNewBlockDo(Action action)
|
||||
{
|
||||
var line = new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Vertical,
|
||||
HorizontalAlignment = HorizontalAlignment.Left
|
||||
};
|
||||
_panels.Push(line);
|
||||
action(line);
|
||||
|
||||
_container.Children.Add(_panels.Pop());
|
||||
action();
|
||||
_inlines.Add(new LineBreak());
|
||||
}
|
||||
|
||||
private void CreateNewInlineTextElement(
|
||||
string text,
|
||||
FontWeight weight = FontWeight.Normal,
|
||||
double fontSize = 12,
|
||||
TextWrapping wrapping = TextWrapping.Wrap)
|
||||
double fontSize = 12
|
||||
)
|
||||
{
|
||||
CurrentLine.Children.Add(new TextBlock
|
||||
_inlines.Add(new Run(text)
|
||||
{
|
||||
Foreground = new SolidColorBrush(Colors.Black),
|
||||
FontSize = fontSize,
|
||||
FontWeight = weight,
|
||||
TextWrapping = wrapping,
|
||||
Text = text,
|
||||
Margin = new Thickness(_listDescent * 8, 0, 0, 0)
|
||||
FontSize = fontSize,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +64,7 @@ namespace Saradomin.Utilities
|
|||
{
|
||||
_listDescent++;
|
||||
{
|
||||
InNewBlockDo((_) =>
|
||||
InNewBlockDo(() =>
|
||||
{
|
||||
foreach (var child in htmlNode.ChildNodes)
|
||||
{
|
||||
|
|
@ -90,15 +77,29 @@ namespace Saradomin.Utilities
|
|||
|
||||
private void VisitListEntry(HtmlNode htmlNode)
|
||||
{
|
||||
foreach (var child in htmlNode.ChildNodes)
|
||||
_inlines.Add(new Run("• "));
|
||||
|
||||
for (var i = 0; i < htmlNode.ChildNodes.Count; i++)
|
||||
{
|
||||
var child = htmlNode.ChildNodes[i];
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
_prefix = " ";
|
||||
}
|
||||
|
||||
Visit(child);
|
||||
|
||||
_prefix = null;
|
||||
}
|
||||
|
||||
_prefix = null;
|
||||
_inlines.Add(new LineBreak());
|
||||
}
|
||||
|
||||
private void VisitParagraph(HtmlNode htmlNode)
|
||||
{
|
||||
InNewBlockDo((_) =>
|
||||
InNewBlockDo(() =>
|
||||
{
|
||||
foreach (var child in htmlNode.ChildNodes)
|
||||
{
|
||||
|
|
@ -115,21 +116,14 @@ namespace Saradomin.Utilities
|
|||
var text = HttpUtility.HtmlDecode(
|
||||
htmlNode.GetDirectInnerText().Trim(' ').Trim('\n')
|
||||
);
|
||||
if (!seenNonWhiteSpace && string.IsNullOrWhiteSpace(htmlNode.InnerText)) break;
|
||||
seenNonWhiteSpace = true;
|
||||
|
||||
if (htmlNode.ParentNode.Name == "li")
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
text = $"• {text}";
|
||||
}
|
||||
}
|
||||
|
||||
CreateNewInlineTextElement(text);
|
||||
|
||||
CreateNewInlineTextElement($"{_prefix}{text}");
|
||||
break;
|
||||
|
||||
case "br":
|
||||
_inlines.Add(new LineBreak());
|
||||
break;
|
||||
|
||||
case "strong":
|
||||
case "b":
|
||||
VisitBold(htmlNode);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -6,95 +6,105 @@
|
|||
xmlns:mvvm="clr-namespace:Glitonea.Mvvm;assembly=Glitonea"
|
||||
xmlns:vm="clr-namespace:Saradomin.ViewModel.Controls"
|
||||
DataContext="{mvvm:DataContextSource vm:PluginManagerViewModel}">
|
||||
<Border>
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<Border Grid.Row="0"
|
||||
Height="350"
|
||||
Margin="0,2,0,0"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1,1,0,1"
|
||||
ClipToBounds="True">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#BBFFFFFF"
|
||||
IsVisible="{Binding !!!PluginList.Count}"
|
||||
Text="Fetching plugin metadata..."
|
||||
ZIndex="9999"
|
||||
Width="425" />
|
||||
<ListBox Classes="PluginList"
|
||||
ItemsSource="{Binding PluginList}"
|
||||
SelectionMode="Single"
|
||||
ClipToBounds="True"
|
||||
IsVisible="{Binding PluginList.Count}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type model:PluginInfo}">
|
||||
<Grid ColumnDefinitions="250,50,100" RowDefinitions="*" >
|
||||
<TextBlock Grid.Column="1"
|
||||
Margin="2,5,2,0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Foreground="#BBFFFFFF"
|
||||
FontSize="11"
|
||||
Text="{Binding Version}" />
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Margin="-125,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.UpdateLocalPlugin}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Update"
|
||||
IsVisible="{Binding CanUpdate}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.InstallRemotePlugin}"
|
||||
CommandParameter="{Binding}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Install"
|
||||
IsVisible="{Binding !Installed}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.UninstallLocalPlugin}"
|
||||
CommandParameter="{Binding}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Uninstall"
|
||||
IsVisible="{Binding Installed}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
<Expander Grid.Column="0" Grid.Row="0" Header="{Binding Name}">
|
||||
<StackPanel>
|
||||
<TextBlock Margin="2,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#BBFFFFFF"
|
||||
FontSize="11"
|
||||
FontStyle="Oblique"
|
||||
Text="{Binding Author}" />
|
||||
|
||||
<TextBlock Margin="2,5,0,4"
|
||||
VerticalAlignment="Bottom"
|
||||
Foreground="#BBFFFFFF"
|
||||
TextWrapping="Wrap"
|
||||
FontSize="11"
|
||||
Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Grid Margin="0,0,0,4"
|
||||
RowDefinitions="Auto,*">
|
||||
<Grid Grid.Row="0"
|
||||
Margin="0,0,0,4">
|
||||
<TextBlock HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource DarkBackgroundBrush}">
|
||||
<Run Text="Status:" />
|
||||
<Run Text="{Binding CurrentStatusMessage}" />
|
||||
</TextBlock>
|
||||
|
||||
<Button Classes="Hyperlink"
|
||||
Content="check for updates"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Command="{Binding CheckForUpdates}"
|
||||
IsEnabled="{Binding !IsTransactionInProgress}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource DarkForegroundBrush}"
|
||||
IsVisible="{Binding !!!PluginList.Count}"
|
||||
Text="Reloading plugin registry..." />
|
||||
|
||||
<ListBox Grid.Row="1"
|
||||
Classes="PluginList"
|
||||
ItemsSource="{Binding PluginList}"
|
||||
SelectionMode="Single"
|
||||
ClipToBounds="True"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
IsVisible="{Binding PluginList.Count}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type model:PluginInfo}">
|
||||
<Grid ColumnDefinitions="250,50,100">
|
||||
<Expander Grid.Column="0"
|
||||
Header="{Binding Name}">
|
||||
<StackPanel>
|
||||
<TextBlock Margin="4,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="#BBFFFFFF"
|
||||
FontSize="11"
|
||||
FontStyle="Oblique"
|
||||
Text="{Binding Author}" />
|
||||
|
||||
<TextBlock Margin="4,5,0,4"
|
||||
VerticalAlignment="Bottom"
|
||||
Foreground="#BBFFFFFF"
|
||||
TextWrapping="Wrap"
|
||||
FontSize="11"
|
||||
Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Margin="2,5,2,0"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Right"
|
||||
Foreground="#BBFFFFFF"
|
||||
FontSize="11"
|
||||
Text="{Binding Version}" />
|
||||
<Button Grid.Column="2"
|
||||
Margin="-125,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.UpdateLocalPlugin}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Update"
|
||||
IsVisible="{Binding CanUpdate}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
<Button Grid.Column="2"
|
||||
Margin="0,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.InstallRemotePlugin}"
|
||||
CommandParameter="{Binding}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Install"
|
||||
IsVisible="{Binding !Installed}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
<Button Grid.Column="2"
|
||||
Margin="0,0,2,2"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding $parent[local:PluginManagerView].DataContext.UninstallLocalPlugin}"
|
||||
CommandParameter="{Binding}"
|
||||
VerticalAlignment="Top"
|
||||
Content="Uninstall"
|
||||
IsVisible="{Binding Installed}"
|
||||
IsEnabled="{Binding !$parent[local:PluginManagerView].DataContext.IsTransactionInProgress}" />
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
@ -117,11 +117,13 @@
|
|||
</HeaderedContentControl>
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel Grid.Column="1">
|
||||
<DockPanel Grid.Column="1"
|
||||
DockPanel.Dock="Top">
|
||||
<HeaderedContentControl Classes="GroupBox"
|
||||
DockPanel.Dock="Top"
|
||||
Header="client settings">
|
||||
<Grid RowDefinitions="Auto,*">
|
||||
<Grid RowDefinitions="Auto,*"
|
||||
Margin="0,0,0,4">
|
||||
<Grid Grid.Row="0" ColumnDefinitions="Auto, *">
|
||||
<Grid Grid.Column="0"
|
||||
RowDefinitions="Auto, Auto">
|
||||
|
|
@ -175,33 +177,15 @@
|
|||
Value="{Binding Client.Fps, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<HeaderedContentControl Grid.Row="1"
|
||||
Margin="0,4,0,4"
|
||||
Padding="3,0,0,0"
|
||||
BorderThickness="0"
|
||||
Classes="GroupBox"
|
||||
Header="plugin management">
|
||||
<DockPanel>
|
||||
<controls:PluginManagerView Margin="-2,2" Name="PmView"/>
|
||||
|
||||
<Button Margin="-141,-17,0,2"
|
||||
Width="140"
|
||||
Height="17"
|
||||
BorderBrush="{StaticResource DarkBorderBrush}"
|
||||
BorderThickness="1"
|
||||
Classes="OutsideNavigator"
|
||||
Command="{Binding #PmView.DataContext.CheckForUpdates}"
|
||||
VerticalAlignment="Top"
|
||||
Opacity="1"
|
||||
FontSize="11"
|
||||
Content="check for updates"
|
||||
ZIndex="9999"
|
||||
IsEnabled="{Binding !#PmView.DataContext.IsTransactionInProgress}" />
|
||||
</DockPanel>
|
||||
</HeaderedContentControl>
|
||||
</Grid>
|
||||
</HeaderedContentControl>
|
||||
|
||||
<HeaderedContentControl Classes="GroupBox"
|
||||
Header="plugin management"
|
||||
DockPanel.Dock="Top">
|
||||
<controls:PluginManagerView MaxHeight="346"/>
|
||||
</HeaderedContentControl>
|
||||
</DockPanel>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
|||
|
|
@ -102,9 +102,15 @@
|
|||
<ScrollViewer HorizontalAlignment="Stretch"
|
||||
Classes="MainViewScrollViewer"
|
||||
ClipToBounds="True"
|
||||
Content="{Binding ContentContainer}"
|
||||
HorizontalScrollBarVisibility="Hidden"
|
||||
VerticalScrollBarVisibility="Visible" />
|
||||
VerticalScrollBarVisibility="Visible">
|
||||
<TextBlock Classes="NewsRenderView"
|
||||
MaxWidth="768"
|
||||
Inlines="{Binding HtmlInlines}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
TextWrapping="Wrap"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</TabItem>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Glitonea.Mvvm;
|
||||
|
|
@ -18,6 +19,7 @@ namespace Saradomin.ViewModel.Controls
|
|||
|
||||
public bool IsTransactionInProgress { get; private set; }
|
||||
public ObservableCollection<PluginInfo> PluginList { get; private set; } = new();
|
||||
public string CurrentStatusMessage { get; set; } = "Idle...";
|
||||
|
||||
public PluginManagerViewModel(
|
||||
IPluginManagementService pluginManagementService,
|
||||
|
|
@ -27,15 +29,20 @@ namespace Saradomin.ViewModel.Controls
|
|||
_pluginDownloadService = pluginDownloadService;
|
||||
|
||||
Message.Subscribe<MainViewLoadedMessage>(this, MainViewLoaded);
|
||||
|
||||
PropertyChanged += ViewModelPropertyChanged;
|
||||
}
|
||||
|
||||
public async Task RefreshPluginCollections()
|
||||
{
|
||||
PluginList.Clear();
|
||||
|
||||
var remotePlugins =
|
||||
await _pluginDownloadService
|
||||
.GetAllMetadata(_pluginManagementService.PluginRepositoryPath, false, false);
|
||||
var remotePlugins =await _pluginDownloadService.GetAllMetadata(
|
||||
_pluginManagementService.PluginRepositoryPath,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
PluginList = new ObservableCollection<PluginInfo>(remotePlugins.OrderByDescending(x => x.Installed));
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +57,8 @@ namespace Saradomin.ViewModel.Controls
|
|||
try
|
||||
{
|
||||
IsTransactionInProgress = true;
|
||||
|
||||
UpdateStatusMessage($"Installing {pluginInfo.Name}...");
|
||||
|
||||
await _pluginDownloadService.DownloadPluginFiles(
|
||||
pluginInfo.Name,
|
||||
|
|
@ -83,10 +92,11 @@ namespace Saradomin.ViewModel.Controls
|
|||
{
|
||||
IsTransactionInProgress = true;
|
||||
|
||||
await _pluginManagementService.UninstallPlugin(pluginInfo.Name);
|
||||
UpdateStatusMessage($"Uninstalling {pluginInfo.Name}...");
|
||||
|
||||
await _pluginManagementService.UninstallPlugin(pluginInfo.Name);
|
||||
pluginInfo.Installed = false;
|
||||
|
||||
PluginList.Add(pluginInfo);
|
||||
|
||||
PluginList = new(PluginList.OrderByDescending(x => x.Installed));
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -106,16 +116,19 @@ namespace Saradomin.ViewModel.Controls
|
|||
{
|
||||
if (IsTransactionInProgress)
|
||||
return;
|
||||
IsTransactionInProgress = true;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var updatablePlugins =
|
||||
await _pluginDownloadService.GetAllMetadata(
|
||||
_pluginManagementService.PluginRepositoryPath,
|
||||
true,
|
||||
true
|
||||
);
|
||||
IsTransactionInProgress = true;
|
||||
|
||||
UpdateStatusMessage($"Checking for updates...");
|
||||
|
||||
var updatablePlugins = await _pluginDownloadService.GetAllMetadata(
|
||||
_pluginManagementService.PluginRepositoryPath,
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
foreach (var plugin in updatablePlugins)
|
||||
{
|
||||
|
|
@ -143,6 +156,8 @@ namespace Saradomin.ViewModel.Controls
|
|||
{
|
||||
IsTransactionInProgress = true;
|
||||
|
||||
UpdateStatusMessage($"Updating {pluginInfo.Name}...");
|
||||
|
||||
await _pluginDownloadService.DownloadPluginFiles(pluginInfo.Name, _pluginManagementService.PluginRepositoryPath);
|
||||
await RefreshPluginCollections();
|
||||
|
||||
|
|
@ -168,9 +183,30 @@ namespace Saradomin.ViewModel.Controls
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateStatusMessage(string message)
|
||||
{
|
||||
CurrentStatusMessage = message;
|
||||
}
|
||||
|
||||
private async void MainViewLoaded(MainViewLoadedMessage _)
|
||||
{
|
||||
await RefreshPluginCollections();
|
||||
}
|
||||
|
||||
private void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(IsTransactionInProgress):
|
||||
{
|
||||
if (!IsTransactionInProgress)
|
||||
{
|
||||
UpdateStatusMessage("Idle...");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using System.Net.Http;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Documents;
|
||||
using Avalonia.Metadata;
|
||||
using Glitonea.Mvvm;
|
||||
using Glitonea.Mvvm.Messaging;
|
||||
|
|
@ -33,7 +34,7 @@ namespace Saradomin.ViewModel.Windows
|
|||
public string LaunchText { get; private set; } = "Play!";
|
||||
|
||||
public bool DimContent { get; private set; }
|
||||
public StackPanel ContentContainer { get; private set; }
|
||||
public InlineCollection HtmlInlines { get; private set; }
|
||||
|
||||
public MainWindowViewModel(IClientLaunchService launchService,
|
||||
IClientUpdateService updateService,
|
||||
|
|
@ -51,11 +52,6 @@ namespace Saradomin.ViewModel.Windows
|
|||
_settingsService = settingsService;
|
||||
Launcher = _settingsService.Launcher;
|
||||
|
||||
ContentContainer = new StackPanel
|
||||
{
|
||||
Margin = new(4)
|
||||
};
|
||||
|
||||
Message.Subscribe<MainViewLoadedMessage>(this, MainViewLoaded);
|
||||
Message.Subscribe<NotificationBoxStateChangedMessage>(this, NotificatationBoxStateChanged);
|
||||
Message.Subscribe<ClientLaunchRequestedMessage>(this, ClientLaunchRequested);
|
||||
|
|
@ -94,9 +90,8 @@ namespace Saradomin.ViewModel.Windows
|
|||
node = doc.DocumentNode;
|
||||
}
|
||||
|
||||
ContentContainer.MaxWidth = 760;
|
||||
var renderer = new HtmlRenderer(ContentContainer, node);
|
||||
renderer.RenderToContainer();
|
||||
var renderer = new HtmlRenderer(node);
|
||||
HtmlInlines = renderer.Render();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue