Skip to content

Commit

Permalink
Merge pull request #257 from artehe/ui-is-hards
Browse files Browse the repository at this point in the history
Update UI/UX for most pages
  • Loading branch information
artehe committed May 16, 2024
2 parents 22666ae + 1db131d commit 14dbb55
Show file tree
Hide file tree
Showing 66 changed files with 854 additions and 576 deletions.
2 changes: 1 addition & 1 deletion SIT.Manager/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<Application.Styles>
<sty:FluentAvaloniaTheme CustomAccentColor="#FF7F7F7F"/>
<labs:ControlThemes/>
<StyleInclude Source="avares://SIT.Manager.ASM/Assets/Styles/Theme.axaml"/>
<StyleInclude Source="avares://SIT.Manager.ASM/Theme/Theme.axaml"/>
</Application.Styles>
</Application>
4 changes: 2 additions & 2 deletions SIT.Manager/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public sealed partial class App : Application
/// </summary>
public IServiceProvider Services { get; }

public App() : this([]) { }

public App(string[] args)
{
Expand Down Expand Up @@ -246,8 +247,7 @@ private Task<int> ParseArguments(string[] args)
if (usernameValue != null && passwordValue != null)
{
var dcvm = Services.GetService<DirectConnectViewModel>();
DirectConnectViewModel dcvm = Services.GetRequiredService<DirectConnectViewModel>();
await dcvm.ConnectToServer(addressValue, usernameValue, passwordValue);
}
Expand Down
22 changes: 0 additions & 22 deletions SIT.Manager/Assets/Styles/Theme.axaml

This file was deleted.

2 changes: 1 addition & 1 deletion SIT.Manager/CrashApp.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
</Application.Resources>

<Application.Styles>
<StyleInclude Source="avares://SIT.Manager.ASM/Assets/Styles/Theme.axaml"/>
<StyleInclude Source="avares://SIT.Manager.ASM/Theme/Theme.axaml"/>
</Application.Styles>
</Application>
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/en-US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">Include Manager Logs</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">Console Output</system:String>
<system:String x:Key="ServerButtonStartToolTip">Start server.</system:String>
<system:String x:Key="ServerEditServerConfig">Edit Server Config</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">Edit Server</system:String>
Expand Down Expand Up @@ -326,7 +325,6 @@
<system:String x:Key="FileServiceProgressExtracting">Extracting file %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">Start Update</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">SIT Manager is updating for you please wait...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">The app restart as soon as it has finished</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">Updating</system:String>
Expand Down
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/ru-RU.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">Включить журналы менеджера</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">Вывод консоли</system:String>
<system:String x:Key="ServerButtonStartToolTip">Запустить сервер.</system:String>
<system:String x:Key="ServerEditServerConfig">Редактировать конфигурацию сервера</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">Редактировать сервер</system:String>
Expand Down Expand Up @@ -330,7 +329,6 @@
<system:String x:Key="FileServiceProgressExtracting">Извлечение файла %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">Начать обновление</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">Менеджер SIT обновляется, пожалуйста, подождите...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">Приложение перезапустится сразу после завершения обновления</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">Обновление</system:String>
Expand Down
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/uk-UA.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">Включити журнали менеджера</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">Виведення консолі</system:String>
<system:String x:Key="ServerButtonStartToolTip">Запустити сервер.</system:String>
<system:String x:Key="ServerEditServerConfig">Редагувати конфігурацію сервера</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">Редагувати сервер</system:String>
Expand Down Expand Up @@ -331,7 +330,6 @@
<system:String x:Key="FileServiceProgressExtracting">Видобування файлу %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">Почати оновлення</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">Менеджер SIT оновлюється, будь ласка, зачекайте...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">Застосунок перезапуститься, як тільки завершиться оновлення</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">Оновлення</system:String>
Expand Down
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/zh-CN.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">包括管理器日志</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">控制台输出</system:String>
<system:String x:Key="ServerButtonStartToolTip">启动服务器</system:String>
<system:String x:Key="ServerEditServerConfig">编辑服务器配置</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">编辑服务器配置文件</system:String>
Expand Down Expand Up @@ -331,7 +330,6 @@
<system:String x:Key="FileServiceProgressExtracting">提取文件 %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">开始更新</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">SIT 管理器正在更新,请稍候...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">更新完成后应用程序将重新启动</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">更新中</system:String>
Expand Down
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/zh-HK.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">包括管理員日誌</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">控制臺輸出</system:String>
<system:String x:Key="ServerButtonStartToolTip">啟動伺服器</system:String>
<system:String x:Key="ServerEditServerConfig">編輯伺服器配置</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">編輯伺服器配置檔案</system:String>
Expand Down Expand Up @@ -331,7 +330,6 @@
<system:String x:Key="FileServiceProgressExtracting">正在提取檔案 %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">開始更新</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">SIT 管理器正在進行更新,請稍候...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">更新完成後應用程式將重新啟動</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">更新中</system:String>
Expand Down
2 changes: 0 additions & 2 deletions SIT.Manager/Localization/zh-TW.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<system:String x:Key="ToolsManagerLogCheckboxContent">包括管理員日誌</system:String>

<!-- Server Page -->
<system:String x:Key="ServerConsoleOutputTitle">控制臺輸出</system:String>
<system:String x:Key="ServerButtonStartToolTip">啟動伺服器</system:String>
<system:String x:Key="ServerEditServerConfig">編輯伺服器設定</system:String>
<system:String x:Key="ServerEditServerConfigButtonToolTip">編輯伺服器設定檔</system:String>
Expand Down Expand Up @@ -331,7 +330,6 @@
<system:String x:Key="FileServiceProgressExtracting">正在解壓縮檔案 %1 (%2)</system:String>

<!-- Update Page -->
<system:String x:Key="UpdatePageUpdateButtonTitle">開始更新</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt1">SIT 管理員正在更新,請稍候...</system:String>
<system:String x:Key="UpdatePageUpdateInfoTextPt2">更新完成後應用程式將重新啟動</system:String>
<system:String x:Key="UpdatePageUpdatingTitle">更新中</system:String>
Expand Down
105 changes: 105 additions & 0 deletions SIT.Manager/Theme/Assists/BoxShadowAssist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;

namespace SIT.Manager.Theme.Assists;

public static class BoxShadowAssist
{
public static readonly AvaloniaProperty<bool> InsetProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, bool>("Inset", typeof(BoxShadowAssist), false);
public static readonly AvaloniaProperty<double> BlurProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, double>("Blur", typeof(BoxShadowAssist), 8);
public static readonly AvaloniaProperty<double> OffsetXProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, double>("OffsetX", typeof(BoxShadowAssist), 1.5);
public static readonly AvaloniaProperty<double> OffsetYProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, double>("OffsetY", typeof(BoxShadowAssist), 1.5);
public static readonly AvaloniaProperty<Color> ColorProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, Color>("Color", typeof(BoxShadowAssist), new Color(0xF0, 0x00, 0x00, 0x00));
public static readonly AvaloniaProperty<double> SpreadProperty = AvaloniaProperty.RegisterAttached<AvaloniaObject, double>("Spread", typeof(BoxShadowAssist), 4);

static BoxShadowAssist()
{
InsetProperty.Changed.Subscribe(InsetPropertyCallback);
BlurProperty.Changed.Subscribe(BlurPropertyCallback);
OffsetXProperty.Changed.Subscribe(OffsetXPropertyCallback);
OffsetYProperty.Changed.Subscribe(OffsetYPropertyCallback);
ColorProperty.Changed.Subscribe(ColorPropertyCallback);
SpreadProperty.Changed.Subscribe(SpreadPropertyCallback);
}


private static BoxShadows UpdateBoxShadow(bool inset, double blur, double offsetX, double offsetY, Color color, double spread)
{
return new BoxShadows(new()
{
IsInset = inset,
Blur = blur,
OffsetX = offsetX,
OffsetY = offsetY,
Color = color,
Spread = spread
});
}

private static void InsetPropertyCallback(AvaloniaPropertyChangedEventArgs<bool> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(args.NewValue.Value, GetBlur(args.Sender), GetOffsetX(args.Sender), GetOffsetY(args.Sender), GetColor(args.Sender), GetSpread(args.Sender));
}
}

private static void BlurPropertyCallback(AvaloniaPropertyChangedEventArgs<double> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(GetInset(args.Sender), args.NewValue.Value, GetOffsetX(args.Sender), GetOffsetY(args.Sender), GetColor(args.Sender), GetSpread(args.Sender));
}
}

private static void OffsetXPropertyCallback(AvaloniaPropertyChangedEventArgs<double> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(GetInset(args.Sender), GetBlur(args.Sender), args.NewValue.Value, GetOffsetY(args.Sender), GetColor(args.Sender), GetSpread(args.Sender));
}
}

private static void OffsetYPropertyCallback(AvaloniaPropertyChangedEventArgs<double> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(GetInset(args.Sender), GetBlur(args.Sender), GetOffsetX(args.Sender), args.NewValue.Value, GetColor(args.Sender), GetSpread(args.Sender));
}
}

private static void ColorPropertyCallback(AvaloniaPropertyChangedEventArgs<Color> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(GetInset(args.Sender), GetBlur(args.Sender), GetOffsetX(args.Sender), GetOffsetY(args.Sender), args.NewValue.Value, GetSpread(args.Sender));
}
}

private static void SpreadPropertyCallback(AvaloniaPropertyChangedEventArgs<double> args)
{
if (args.Sender is Border border)
{
border.BoxShadow = UpdateBoxShadow(GetInset(args.Sender), args.NewValue.Value, GetOffsetX(args.Sender), GetOffsetY(args.Sender), GetColor(args.Sender), args.NewValue.Value);
}
}

public static void SetInset(AvaloniaObject element, bool value) => element.SetValue(InsetProperty, value);
public static bool GetInset(AvaloniaObject element) => element.GetValue<bool>(InsetProperty);

public static void SeBlur(AvaloniaObject element, double value) => element.SetValue(BlurProperty, value);
public static double GetBlur(AvaloniaObject element) => element.GetValue<double>(BlurProperty);

public static void SetOffsetX(AvaloniaObject element, double value) => element.SetValue(OffsetXProperty, value);
public static double GetOffsetX(AvaloniaObject element) => element.GetValue<double>(OffsetXProperty);

public static void SetOffsetY(AvaloniaObject element, double value) => element.SetValue(OffsetYProperty, value);
public static double GetOffsetY(AvaloniaObject element) => element.GetValue<double>(OffsetYProperty);

public static void SetColor(AvaloniaObject element, Color value) => element.SetValue(ColorProperty, value);
public static Color GetColor(AvaloniaObject element) => element.GetValue<Color>(ColorProperty);

public static void SetSpread(AvaloniaObject element, double value) => element.SetValue(SpreadProperty, value);
public static double GetSpread(AvaloniaObject element) => element.GetValue<double>(SpreadProperty);
}
12 changes: 12 additions & 0 deletions SIT.Manager/Theme/Assists/Observable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Avalonia.Reactive;
using System;

namespace SIT.Manager.Theme.Assists;

public static class Observable
{
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> action)
{
return source.Subscribe(new AnonymousObserver<T>(action));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;

namespace SIT.Manager.Controls;
namespace SIT.Manager.Theme.Controls;

public class ActivatableUserControl : UserControl
{
Expand Down
60 changes: 60 additions & 0 deletions SIT.Manager/Theme/Controls/Card.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:SIT.Manager.Theme.Controls"
xmlns:assists="clr-namespace:SIT.Manager.Theme.Assists">
<Design.PreviewWith>
<Border Padding="40"
Background="{DynamicResource AppAccent}">
<controls:Card>
<TextBlock Text="Hello World!" />
</controls:Card>
</Border>
</Design.PreviewWith>

<ControlTheme x:Key="Card" TargetType="controls:Card">
<Setter Property="assists:BoxShadowAssist.Inset" Value="False" />
<Setter Property="assists:BoxShadowAssist.Blur" Value="8" />
<Setter Property="assists:BoxShadowAssist.OffsetX" Value="2" />
<Setter Property="assists:BoxShadowAssist.OffsetY" Value="2" />
<Setter Property="assists:BoxShadowAssist.Color" Value="{DynamicResource AppPrimary}" />
<Setter Property="assists:BoxShadowAssist.Spread" Value="4" />

<Setter Property="Background" Value="{DynamicResource AppPrimary}"/>
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="CornerRadius" Value="4" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Foreground" Value="{DynamicResource AppSecondary}"/>
<Setter Property="Padding" Value="8" />

<Setter Property="Template">
<ControlTemplate>
<Panel Name="PART_RootPanel">
<Border Name="PART_BackgroundBorder"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
assists:BoxShadowAssist.Inset="{TemplateBinding assists:BoxShadowAssist.Inset}"
assists:BoxShadowAssist.Blur="{TemplateBinding assists:BoxShadowAssist.Blur}"
assists:BoxShadowAssist.OffsetX="{TemplateBinding assists:BoxShadowAssist.OffsetX}"
assists:BoxShadowAssist.OffsetY="{TemplateBinding assists:BoxShadowAssist.OffsetY}"
assists:BoxShadowAssist.Color="{TemplateBinding assists:BoxShadowAssist.Color}"
assists:BoxShadowAssist.Spread="{TemplateBinding assists:BoxShadowAssist.Spread}"/>
<Border Name="PART_InnerBorder"
CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="{TemplateBinding InsideClipping}">
<ContentPresenter Name="ContentPresenter"
Padding="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
</Panel>
</ControlTemplate>
</Setter>
</ControlTheme>

<ControlTheme x:Key="{x:Type controls:Card}"
TargetType="controls:Card"
BasedOn="{StaticResource Card}" />
</ResourceDictionary>
19 changes: 19 additions & 0 deletions SIT.Manager/Theme/Controls/Card.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Avalonia;
using Avalonia.Controls;

namespace SIT.Manager.Theme.Controls;

public class Card : ContentControl
{
public static readonly StyledProperty<bool> InsideClippingProperty =
AvaloniaProperty.Register<Card, bool>(nameof(InsideClipping), true);

/// <summary>
/// Get or set the inside border clipping.
/// </summary>
public bool InsideClipping
{
get => GetValue(InsideClippingProperty);
set => SetValue(InsideClippingProperty, value);
}
}
Loading

0 comments on commit 14dbb55

Please sign in to comment.