Skip to content

Commit

Permalink
Maui Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed May 31, 2022
1 parent a927b8f commit 56951ce
Show file tree
Hide file tree
Showing 32 changed files with 295 additions and 290 deletions.
2 changes: 1 addition & 1 deletion references/ArchiSteamFarm
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,80 @@
using System.Linq;
using SteamKit2;

namespace System.Application.Converters
namespace System.Application.Converters;

public class StringFormatConverter : IValueConverter, IMultiValueConverter
{
public class StringFormatConverter : IValueConverter, IMultiValueConverter
{
const string Size = "size";
const string Money = "money";
const string Size = "size";
const string Money = "money";

static object? Format(object? value, object? parameter, CultureInfo culture)
static object? Format(object? value, object? parameter, CultureInfo culture)
{
if (value is not string str) str = value?.ToString() ?? string.Empty;
if (parameter is not string para) para = parameter?.ToString() ?? string.Empty;
if (!string.IsNullOrEmpty(para))
{
if (value is not string str) str = value?.ToString() ?? string.Empty;
if (parameter is not string para) para = parameter?.ToString() ?? string.Empty;
if (!string.IsNullOrEmpty(para))
if (string.Equals(para, Size, StringComparison.OrdinalIgnoreCase)
&& decimal.TryParse(str, out var num))
{
(var length, string unit) = IOPath.GetSize(num);
if (length == 0)
return "0 B";
return $"{length:###,###.##} {unit}";
}
else if (decimal.TryParse(str, out decimal d))
{
if (string.Equals(para, Size, StringComparison.OrdinalIgnoreCase)
&& decimal.TryParse(str, out var num))
if (parameter is ECurrencyCode c1)
{
(var length, string unit) = IOPath.GetSize(num);
if (length == 0)
return "0 B";
return $"{length:###,###.##} {unit}";
return d.ToString("C", c1.GetCultureInfo());
}
else if (decimal.TryParse(str, out decimal d))
else if (parameter is CurrencyCode c2)
{
if (parameter is ECurrencyCode c1)
{
return d.ToString("C", c1.GetCultureInfo());
}
else if (parameter is CurrencyCode c2)
{
return d.ToString("C", c2.GetCultureInfo());
}
else if (string.Equals(para, Money, StringComparison.OrdinalIgnoreCase))
{
return d.ToString("C", culture);
}
return d.ToString("C", c2.GetCultureInfo());
}
else
else if (string.Equals(para, Money, StringComparison.OrdinalIgnoreCase))
{
return str.Format(para);
return d.ToString("C", culture);
}
}
else
{
return str.Format(string.Empty);
return str.Format(para);
}
return str;
}

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
else
{
return Format(value, parameter, culture);
return str.Format(string.Empty);
}
return str;
}

public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return Format(value, parameter, culture);
}

public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
var format = values.FirstOrDefault()?.ToString() ?? string.Empty;
if (format == string.Empty || string.Equals("(Unset)", format.ToString(), StringComparison.OrdinalIgnoreCase))
{
return null;
}
if (parameter is not null && values.Count >= 2)
{
var format = values.FirstOrDefault()?.ToString() ?? string.Empty;
if (format == string.Empty || string.Equals("(Unset)", format.ToString(), StringComparison.OrdinalIgnoreCase))
if (string.Equals(parameter.ToString(), Money, StringComparison.OrdinalIgnoreCase))
{
return null;
return Format(values[0], values[1] ?? Money, culture);
}
if (parameter is not null && values.Count >= 2)
else
{
if (string.Equals(parameter.ToString(), Money, StringComparison.OrdinalIgnoreCase))
{
return Format(values[0], values[1] ?? Money, culture);
}
else
{
return Format(values[0], parameter, culture);
}
return Format(values[0], parameter, culture);
}

var stringValues = values.Select(x => x is not string str ? x?.ToString() ?? string.Empty : str);
var args = stringValues.Skip(1).ToArray();
return format.Format(args);
}

var stringValues = values.Select(x => x is not string str ? x?.ToString() ?? string.Empty : str);
var args = stringValues.Skip(1).ToArray();
return format.Format(args);
}
}
24 changes: 1 addition & 23 deletions src/ST.Client.Desktop.Avalonia/ST.Client.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<AvaloniaResource Include="Assets\**" />
<AvaloniaResource Include="Application\UI\Assets\**" />
<None Remove="Application\UI\**" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -58,22 +58,6 @@
<Compile Remove="Extensions\WebViewExtensions.cs" />
</ItemGroup>

<ItemGroup>
<None Remove="Application\UI\Assets\afdian.png" />
<None Remove="Application\UI\Assets\AppResources\Icon\ArchiSteamFarmPlusPageViewModel.png" />
<None Remove="Application\UI\Assets\AppResources\Xbox.png" />
<None Remove="Application\UI\Assets\avalonia-logo.ico" />
<None Remove="Application\UI\Assets\Fonts\WenQuanYiMicroHei-01.ttf" />
<None Remove="Application\UI\Assets\ko-fi.png" />
<None Remove="Application\UI\Assets\movecross.png" />
<None Remove="Application\UI\Assets\pateron.png" />
<None Remove="Application\UI\Styles\Controls\NavigationView.xaml" />
<None Remove="Application\UI\Styles\Controls\ProgressBar.xaml" />
<None Remove="Application\UI\Views\Controls\CustomFilePicker.xaml" />
<None Remove="Application\UI\Views\Controls\OptionsDisplayItem.xaml" />
<None Remove="Application\UI\Views\Controls\UserControl\Badge.xaml" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
Expand Down Expand Up @@ -123,10 +107,4 @@
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<Compile Update="Application\UI\Views\Controls\UserControl\CarouselBanner.axaml.cs">
<DependentUpon>CarouselBanner.axaml</DependentUpon>
</Compile>
</ItemGroup>

</Project>
14 changes: 0 additions & 14 deletions src/ST.Client.Maui.App/App.xaml

This file was deleted.

14 changes: 0 additions & 14 deletions src/ST.Client.Maui.App/App.xaml.cs

This file was deleted.

10 changes: 0 additions & 10 deletions src/ST.Client.Maui.App/AppShell.xaml.cs

This file was deleted.

19 changes: 1 addition & 18 deletions src/ST.Client.Maui.App/ST.Client.Maui.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@
<SupportedOSPlatformVersion>6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
Expand All @@ -82,6 +64,7 @@

<ItemGroup>
<ProjectReference Include="..\Common.CoreLib\Common.CoreLib.csproj" />
<ProjectReference Include="..\ST.Client.Maui\ST.Client.Maui.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 29 additions & 0 deletions src/ST.Client.Maui/ST.Client.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,43 @@
<Compile Include="..\ST.Client.Desktop.Avalonia\Application\Converters\Base\*.cs">
<LinkBase>Converters\Base</LinkBase>
</Compile>
<Compile Include="..\ST.Client.XamarinForms\Converters\*.cs">
<LinkBase>Converters</LinkBase>
</Compile>
<Compile Include="..\ST.Client.XamarinForms\Extensions\*.cs">
<LinkBase>Extensions</LinkBase>
</Compile>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Common.Essentials.Maui\Common.Essentials.Maui.csproj" />
<ProjectReference Include="..\ST.Client\ST.Client.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<MauiXaml Update="UI\*.xaml" />
<MauiXaml Update="UI\**\*.xaml" />

<!-- App Icon -->
<MauiIcon Include="UI\Assets\AppResources\Icon\appicon.svg" ForegroundFile="UI\Assets\AppResources\Icon\appiconfg.svg" Color="#512BD4" />

<!-- Splash Screen -->
<MauiSplashScreen Include="UI\Assets\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

<!-- Images -->
<MauiImage Include="UI\Assets\Images\*" />
<MauiImage Update="UI\Assets\Images\dotnet_bot.svg" BaseSize="168,208" />

<!-- Custom Fonts -->
<MauiFont Include="UI\Assets\Fonts\*" />

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="UI\Assets\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
<MauiAsset Remove="UI\Assets\Raw\AboutAssets.txt" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions src/ST.Client.Maui/UI/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:System.Application.UI"
x:Class="System.Application.UI.App">
<!--<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="UI/Styles/Colors.xaml" />
<ResourceDictionary Source="UI/Styles/Styles.xaml" />
--><!-- ↑ XFC0124 Resource "UI/Styles/Colors.xaml" not found. --><!--
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>-->
</Application>
18 changes: 18 additions & 0 deletions src/ST.Client.Maui/UI/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MauiApplication = Microsoft.Maui.Controls.Application;
using UI_Styles_Colors_xaml = __XamlGeneratedCode__.__TypeD77312341DE78E28;
using UI_Styles_Styles_xaml = __XamlGeneratedCode__.__TypeE0CAB8CC0B793AB6;

namespace System.Application.UI;

public partial class App : MauiApplication
{
public App()
{
InitializeComponent();

Resources.MergedDictionaries.Add(new UI_Styles_Colors_xaml());
Resources.MergedDictionaries.Add(new UI_Styles_Styles_xaml());

MainPage = new AppShell();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:System.Application.UI"
Shell.FlyoutBehavior="Disabled">

<ShellContent
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
Expand Down
9 changes: 9 additions & 0 deletions src/ST.Client.Maui/UI/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace System.Application.UI;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 56951ce

Please sign in to comment.