Idk, dev work goin on

This commit is contained in:
2026-09-09 16:19:45 +03:00 Unverified
parent b0d8bcd742
commit 17a0a9f7a6
318 changed files with 11908 additions and 81 deletions
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
namespace WinWARP.Ui.Converters;
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
public partial class BoolToVisibilityConverter : MarkupExtension, IValueConverter
{
public bool IsInverted { get; set; } = false;
// IValueConverter implementation
public object Convert(object value, Type targetType, object parameter, string language)
{
bool flag = false;
if (value is bool boolValue)
{
flag = boolValue;
}
if (IsInverted)
{
flag = !flag;
}
return flag ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
bool result = (visibility == Visibility.Visible);
return IsInverted ? !result : result;
}
return false;
}
// MarkupExtension override returning self as the instance
protected override object ProvideValue()
{
return this;
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
namespace WinWARP.Ui.Converters;
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
public class CountryCodeToUriConverter : MarkupExtension, IValueConverter
{
protected override object ProvideValue() => this;
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is string countryCode)
{
if (!string.IsNullOrWhiteSpace(countryCode))
{
return new Uri($"ms-appx:///Assets/Flags/{countryCode.ToLower()}.svg");
}
else
{
return new Uri("ms-appx:///Assets/Flags/xx.svg");
}
}
else return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException();
}
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Markup;
using Microsoft.Windows.AI.Text;
using WinWARP.Core.Services.Interfaces;
using WinWARP.Ui.Helpers;
namespace WinWARP.Ui.Converters;
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
public class UpdateIntervalToTextConverter : MarkupExtension, IValueConverter
{
private ILocalizationService _localizationService;
protected override object ProvideValue()
{
_localizationService ??= App.Services.GetRequiredService<ILocalizationService>();
return this;
}
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is double interval)
{
interval = Math.Truncate(interval);
return interval switch
{
-1 => _localizationService.GetString("UpdateInterval_never"),
0 => _localizationService.GetString("UpdateInterval_auto"),
_ => NumberToTranslatedString(interval)
};
}
return "Unknown";
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
private string NumberToTranslatedString(double value)
{
var category = PluralCategory.GetCategory(value, new CultureInfo(_localizationService.GetCurrentLanguage()));
var resourceKey = $"UpdateInterval_{category}";
var localizedTemplate = _localizationService.GetString(resourceKey);
if (string.IsNullOrEmpty(localizedTemplate))
{
// Fallback to a default template if the localized string is not found
localizedTemplate = "Every {0} hours";
}
return string.Format(localizedTemplate, value);
}
}