Skip to content

Commit

Permalink
Merge pull request #18 from kuiperzone/dev/andyt/work
Browse files Browse the repository at this point in the history
Dev/andyt/work
  • Loading branch information
kuiperzone authored Mar 27, 2023
2 parents 09b5e64 + 18ae883 commit 7c9e243
Show file tree
Hide file tree
Showing 32 changed files with 1,575 additions and 162 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
###############################################################################

TODO
/INTERNAL

###############################################################################
# Hidden
Expand Down Expand Up @@ -41,13 +42,9 @@ desktop.ini
**/*-[Rr][Ee][Ll][Ee][Aa][Ss][Ee]*/
**/[Pp][Rr][Oo][Ff][Ii][Ll][Ee]*/

# Build, Deploy, Internal
# Build, AppDir
**/[Bb][Ll][Dd]/
**/[Bb][Uu][Ii][Ll][Dd]*/
**/[Dd][Ee][Pp][Ll][Oo][Yy]*/
**/[Ii][Nn][Tt][Ee][Rr][Nn][Aa][Ll]*/

# AppDir
**/[Aa][Pp][Pp][Dd][Ii][Rr]*/

# Temp
Expand Down
2 changes: 1 addition & 1 deletion AvantGarde.Test/AvantGarde.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<IsPublishable>false</IsPublishable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
69 changes: 69 additions & 0 deletions AvantGarde.pupnet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# PUPNET DEPLOY 1.0.1

# APP PREAMBLE
AppBaseName = AvantGarde
AppFriendlyName = Avant Garde
AppId = zone.kuiper.AvantGarde
AppVersionRelease = 1.1.0[1]
AppShortSummary = A cross-platform XAML Previewer for the Avalonia .NET Framework
AppLicenseId = GPL-3.0-or-later
AppLicenseFile = LICENSE

# PUBLISHER
PublisherName = Kuiper Zone
PublisherCopyright = Copyright (C) Andy Thomas 2022-23
PublisherLinkName = Project Page
PublisherLinkUrl = https://github.com/kuiperzone/AvantGarde
PublisherEmail = contact@kuiper.zone

# DESKTOP INTEGRATION
DesktopNoDisplay = false
DesktopTerminal = false
DesktopFile = Deploy/AvantGarde.desktop
StartCommand =
PrimeCategory = Development
MetaFile = Deploy/AvantGarde.metainfo.xml
IconFiles = """
Deploy/AvantGarde.ico
Deploy/AvantGarde.svg
Deploy/AvantGarde.16x16.png
Deploy/AvantGarde.24x24.png
Deploy/AvantGarde.32x32.png
Deploy/AvantGarde.48x48.png
Deploy/AvantGarde.64x64.png
Deploy/AvantGarde.96x96.png
Deploy/AvantGarde.128x128.png
Deploy/AvantGarde.256x256.png
"""

# DOTNET PUBLISH
DotnetProjectPath =
DotnetPublishArgs = -p:Version=${APP_VERSION} --self-contained true -p:DebugType=None -p:DebugSymbols=false
DotnetPostPublish =
DotnetPostPublishOnWindows =

# PACKAGE OUTPUT
PackageName = AvantGarde
OutputDirectory = Deploy/OUT

# APPIMAGE OPTIONS
AppImageArgs =
AppImageVersionOutput = false

# FLATPAK OPTIONS
FlatpakPlatformRuntime = org.freedesktop.Platform
FlatpakPlatformSdk = org.freedesktop.Sdk
FlatpakPlatformVersion = 22.08
FlatpakFinishArgs = """
--socket=wayland
--socket=x11
--filesystem=host
--share=network
"""
FlatpakBuilderArgs =

# WINDOWS SETUP OPTIONS
SetupCommandPrompt =
SetupMinWindowsVersion = 10
SetupSignTool =
SetupVersionOutput = false
5 changes: 3 additions & 2 deletions AvantGarde/App.axaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:AvantGarde.Views"
x:Class="AvantGarde.App"

xmlns:vm="using:AvantGarde.ViewModels"
x:DataType="vm:AvantViewModel"
x:Class="AvantGarde.App">

RequestedThemeVariant="Default">
<!-- TBD requires this above in Avalonia 11 -->
<!-- RequestedThemeVariant="Default" -->

<Application.Styles>
<FluentTheme />
Expand Down
22 changes: 14 additions & 8 deletions AvantGarde/AvantGarde.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Authors>Andy Thomas</Authors>
<Copyright>© Andy Thomas 2022-23</Copyright>
<Company>Kuiper Zone</Company>
<Description>Avant Garde is a cross-platform XAML previewer for the C# Avalonia Framework.</Description>
<Description>Avant Garde is a cross-platform XAML previewer for the Avalonia .NET Framework.</Description>
<Language>en-US</Language>
<PackageProjectUrl>https://github.com/kuiperzone/AvantGarde</PackageProjectUrl>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -36,15 +36,21 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia" Version="0.10.19" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.19" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.19" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.19" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.19" />

<PackageReference Include="Avalonia.Themes.Simple" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview6" />

<!-- TBD for removal in Avalonia 11 -->
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />

<!-- TBD Avalonia 11
<PackageReference Include="Avalonia.Themes.Simple" Version="11" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11" />
-->

<PackageReference Include="KuiperZone.Utility.Yaap" Version="2.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AvantGarde/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static int Main(string[] args)
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
return 1;
}

Expand Down
65 changes: 56 additions & 9 deletions AvantGarde/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

using Avalonia;
using Avalonia.Media;
using Avalonia.Themes.Fluent;
using AvantGarde.Projects;
using AvantGarde.ViewModels;

Expand All @@ -30,7 +31,12 @@ public sealed class AppSettings : JsonSettings
{
private const int MaxRecent = 10;

// TBD Removal in 11
private static FluentTheme? _theme;
private bool _isDarkTheme;

private Application? _app;
private string _appFontFamily = GlobalModel.DefaultAppFamily;
private double _appFontSize = GlobalModel.DefaultFontSize;
private string _monoFontFamily = GlobalModel.DefaultMonoFamily;
private double _monoFontSize = GlobalModel.DefaultFontSize;
Expand All @@ -49,13 +55,33 @@ public AppSettings()
public AppSettings(Application app)
{
_app = app;
_theme = (FluentTheme)app.Styles[0];
}

/// <summary>
/// Gets or sets the UI theme. Setting with instance constructed with Application
/// will change the theme throughout.
/// </summary>
public bool IsDarkTheme
{
get { return _isDarkTheme; }
set
{
if (_isDarkTheme != value)
{
_isDarkTheme = value;
if (_app != null && _theme != null)
{
_theme.Mode = value ? FluentThemeMode.Dark : FluentThemeMode.Light;
GlobalModel.Global.Assets.IsDarkTheme = value;
GlobalModel.Global.Colors.IsDarkTheme = value;
}
}
}
}

/* TBD Avalonia 11
public bool IsDarkTheme
{
get { return _app?.RequestedThemeVariant == Avalonia.Styling.ThemeVariant.Dark; }
Expand All @@ -67,10 +93,10 @@ public bool IsDarkTheme
GlobalModel.Global.Assets.IsDarkTheme = value;
GlobalModel.Global.Colors.IsDarkTheme = value;
}


}
}
*/


/// <summary>
/// Gets or sets the application font size. Setting with instance constructed with Application
Expand All @@ -88,7 +114,8 @@ public double AppFontSize
{
_appFontSize = value;

// We can only set this once
// ContentControlThemeFontFamily
// We can only set this once. This only works on Fluent.
// Until Window.FontSize can be used as way to change app FontSize,
// the application must be restarted to take effect.
// SEE: https://github.com/AvaloniaUI/Avalonia/discussions/7539
Expand All @@ -100,6 +127,31 @@ public double AppFontSize
}
}

/// <summary>
/// Gets or sets the application font family.
/// </summary>
public string AppFontFamily
{
get { return _appFontFamily; }

set
{
value = value.Trim();

if (value.Length == 0)
{
value = GlobalModel.DefaultAppFamily;
}

_appFontFamily = value;

if (_app != null)
{
GlobalModel.Global.AppFontFamily = new FontFamily(value);
}
}
}

/// <summary>
/// Gets or sets the application monospace font size. Setting with instance constructed with Application
/// will change throughout application.
Expand Down Expand Up @@ -156,11 +208,6 @@ public string MonoFontFamily
/// </summary>
public PreviewWindowTheme PreviewTheme { get; set; }

/// <summary>
/// Gets or sets whether to pin main window.
/// </summary>
public bool IsTopmost { get; set; }

/// <summary>
/// Gets or sets whether window is maximized.
/// </summary>
Expand Down Expand Up @@ -258,9 +305,9 @@ public void AssignFrom(AppSettings other)
IsDarkTheme = other.IsDarkTheme;
AppFontSize = other.AppFontSize;
MonoFontSize = other.MonoFontSize;
AppFontFamily = other.AppFontFamily;
MonoFontFamily = other.MonoFontFamily;
PreviewTheme = other.PreviewTheme;
IsTopmost = other.IsTopmost;
IsMaximized = other.IsMaximized;
Width = other.Width;
Height = other.Height;
Expand Down
3 changes: 2 additions & 1 deletion AvantGarde/Utility/ControlExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public static Window GetOwnerWindow(this StyledElement control)

if (control.Parent != null)
{
return GetOwnerWindow(control.Parent);
// TBD remove cast with Avalonia 11
return GetOwnerWindow((StyledElement)control.Parent);
}

throw new ArgumentException("Element has no owner window");
Expand Down
36 changes: 34 additions & 2 deletions AvantGarde/ViewModels/GlobalModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class GlobalModel : ReactiveObject
{
private double _appFontSize = DefaultFontSize;
private double _monoFontSize = DefaultFontSize;
private FontFamily _appFontFamily = DefaultAppFamily;
private FontFamily _monoFontFamily = DefaultMonoFamily;

/// <summary>
Expand All @@ -47,23 +48,37 @@ protected GlobalModel()
/// <summary>
/// Maximum font size.
/// </summary>
public const double MaxFontSize = 24;
public const double MaxFontSize = 32;

/// <summary>
/// Default font size.
/// </summary>
public const double DefaultFontSize = 14;

/// <summary>
/// Default app font family.
/// </summary>
public const string DefaultAppFamily = "Ubuntu, Noto Sans, sans";

/// <summary>
/// Default mono font family.
/// </summary>
public const string DefaultMonoFamily = "Source Code Pro, monospace";

/// <summary>
/// Gets the web page link name.
/// </summary>
public static string WebPage { get; } = "Project Page";

/// <summary>
/// Gets the web page link URL.
/// </summary>
public static string WebUrl { get; } = "https://github.com/kuiperzone/AvantGarde";

public static string Copyright { get; } = "Copyright 2023 Andy Thomas";
/// <summary>
/// Gets the copyright string.
/// </summary>
public static string Copyright { get; } = "Copyright (C) 2022-23 Andy Thomas";

/// <summary>
/// Gets the application version.
Expand Down Expand Up @@ -161,6 +176,23 @@ public double MonoFontSize
}
}

/// <summary>
/// Gets or sets the application font family.
/// </summary>
public FontFamily AppFontFamily
{
get { return _appFontFamily; }

set
{
if (_appFontFamily.Name != value)
{
_appFontFamily = value;
this.RaisePropertyChanged(nameof(AppFontFamily));
}
}
}

/// <summary>
/// Gets or sets the monospace font family.
/// </summary>
Expand Down
4 changes: 0 additions & 4 deletions AvantGarde/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class MainWindowViewModel : PreviewOptionsViewModel
public MainWindowViewModel()
{
_isWelcomeVisible = App.Settings.ShowWelcome;
_isTopmost = App.Settings.IsTopmost;
UpdateRecentMenu();
}

Expand Down Expand Up @@ -76,9 +75,6 @@ public bool IsTopmost
Owner.Topmost = value;
}

App.Settings.IsTopmost = value;
App.Settings.Write();

this.RaisePropertyChanged(nameof(IsTopmost));
}
}
Expand Down
Loading

0 comments on commit 7c9e243

Please sign in to comment.