forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
907 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/ST.Client.XamarinForms/Converters/LoginOrRegisterChannelBackgroundColorConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Globalization; | ||
#if !__MOBILE__ | ||
using Avalonia.Data.Converters; | ||
#else | ||
using Xamarin.Forms; | ||
#endif | ||
|
||
namespace System.Application.Converters | ||
{ | ||
public class LoginOrRegisterChannelBackgroundColorConverter : IValueConverter | ||
{ | ||
static Color ColorFromHex(string hex) | ||
{ | ||
return Color.FromHex(hex); | ||
} | ||
|
||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
var valueStr = value?.ToString(); | ||
return valueStr switch | ||
{ | ||
nameof(FastLoginChannel.Steam) => ColorFromHex("#145c8f"), | ||
nameof(FastLoginChannel.Xbox) or nameof(FastLoginChannel.Microsoft) => ColorFromHex("#027d00"), | ||
nameof(FastLoginChannel.Apple) => ColorFromHex("#000000"), | ||
nameof(FastLoginChannel.QQ) => ColorFromHex("#12B7F5"), | ||
"Phone" or "PhoneNumber" => ColorFromHex("#2196F3"), | ||
_ => Binding.DoNothing, | ||
}; | ||
} | ||
|
||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/ST.Client.XamarinForms/Converters/LoginOrRegisterChannelTextConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
#if !__MOBILE__ | ||
using Avalonia.Data.Converters; | ||
#else | ||
using Xamarin.Forms; | ||
#endif | ||
|
||
namespace System.Application.Converters | ||
{ | ||
public class LoginOrRegisterChannelTextConverter : IMultiValueConverter | ||
{ | ||
public object? Convert(IList<object?>? values, Type? targetType, object? parameter, CultureInfo? culture) | ||
{ | ||
if (values != null && values.Count >= 3) | ||
{ | ||
var stringValues = values.Select(x => (x is not string str) ? x?.ToString() ?? string.Empty : str).ToArray(); | ||
var args = stringValues.Skip(1).FirstOrDefault(); | ||
switch (args) | ||
{ | ||
case "Xbox": | ||
args = "Xbox Live"; | ||
break; | ||
case "Phone" or "PhoneNumber": | ||
return stringValues[2]; | ||
} | ||
var format = stringValues.FirstOrDefault() ?? string.Empty; | ||
return format.Format(args); | ||
} | ||
return Binding.DoNothing; | ||
} | ||
|
||
public object? Convert(object?[]? values, Type? targetType, object? parameter, CultureInfo? culture) | ||
{ | ||
IList<object?>? values_ = values; | ||
return Convert(values_, targetType, parameter, culture); | ||
} | ||
|
||
public object? ConvertBack(object? value, Type? targetType, object? parameter, CultureInfo? culture) => throw new NotImplementedException(); | ||
|
||
public object[]? ConvertBack(object? value, Type[]? targetTypes, object? parameter, CultureInfo? culture) => throw new NotImplementedException(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/ST.Client.XamarinForms/Converters/PathGeometryConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Globalization; | ||
using Xamarin.Forms; | ||
using XFSPathGeometryConverter = Xamarin.Forms.Shapes.PathGeometryConverter; | ||
|
||
namespace System.Application.Converters | ||
{ | ||
public class PathGeometryConverter : XFSPathGeometryConverter, IValueConverter | ||
{ | ||
internal static object? GetGeometryByPathString(XFSPathGeometryConverter converter, string pathStr) | ||
{ | ||
try | ||
{ | ||
// https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/shapes/path-markup-syntax | ||
var pathData = converter.ConvertFromInvariantString(pathStr); | ||
return pathData; | ||
} | ||
catch | ||
{ | ||
} | ||
return Binding.DoNothing; | ||
} | ||
|
||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
var valueStr = value?.ToString(); | ||
if (!string.IsNullOrWhiteSpace(valueStr)) | ||
{ | ||
var r = GetGeometryByPathString(this, valueStr); | ||
return r; | ||
} | ||
return Binding.DoNothing; | ||
} | ||
|
||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/ST.Client.XamarinForms/Converters/PathIconConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Globalization; | ||
using Xamarin.Forms; | ||
using static System.Application.Converters.PathGeometryConverter; | ||
using static System.Application.Converters.ResourceKeyConverter; | ||
using XFSPathGeometryConverter = Xamarin.Forms.Shapes.PathGeometryConverter; | ||
|
||
namespace System.Application.Converters | ||
{ | ||
public class PathIconConverter : XFSPathGeometryConverter, IValueConverter | ||
{ | ||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
var valueStr = value?.ToString(); | ||
if (!string.IsNullOrWhiteSpace(valueStr)) | ||
{ | ||
var pathStr = GetResourceByKey(valueStr)?.ToString(); | ||
if (!string.IsNullOrWhiteSpace(pathStr)) | ||
{ | ||
var r = GetGeometryByPathString(this, pathStr); | ||
return r; | ||
} | ||
} | ||
return Binding.DoNothing; | ||
} | ||
|
||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/ST.Client.XamarinForms/Converters/ResourceKeyConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Globalization; | ||
using Xamarin.Forms; | ||
using XFApplication = Xamarin.Forms.Application; | ||
|
||
namespace System.Application.Converters | ||
{ | ||
public class ResourceKeyConverter : IValueConverter | ||
{ | ||
const string DrawingSvg = "DrawingSvg"; | ||
|
||
internal static object? GetResourceByKey(string key) | ||
{ | ||
var res = XFApplication.Current.Resources; | ||
if (res.ContainsKey(DrawingSvg)) | ||
{ | ||
var svgRes = res[DrawingSvg]; | ||
if (svgRes is ResourceDictionary drawingSvg) | ||
{ | ||
switch (key) | ||
{ | ||
case "Steam": | ||
key = "SteamDrawing"; | ||
break; | ||
case "PhoneNumber": | ||
key = "Phone"; | ||
break; | ||
} | ||
if (drawingSvg.ContainsKey(key)) | ||
{ | ||
return drawingSvg[key]; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
var valueStr = value?.ToString(); | ||
if (!string.IsNullOrWhiteSpace(valueStr)) | ||
{ | ||
var r = GetResourceByKey(valueStr); | ||
return r; | ||
} | ||
return Binding.DoNothing; | ||
} | ||
|
||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException(); | ||
} | ||
} |
Oops, something went wrong.