switch to sqlite
This commit is contained in:
@ -205,7 +205,7 @@ namespace Billing.UI
|
||||
{
|
||||
if (!int.TryParse(key, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int i))
|
||||
{
|
||||
return ImageSource.FromFile(BaseModel.ICON_DEFAULT);
|
||||
return ImageSource.FromFile(Definition.DefaultIcon);
|
||||
}
|
||||
glyph = char.ConvertFromUtf32(i);
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Billing.Languages;
|
||||
using Billing.Models;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Billing.UI
|
||||
{
|
||||
public static partial class Definition
|
||||
{
|
||||
public static string PrimaryColorKey = "PrimaryColor";
|
||||
public const string PrimaryColorKey = "PrimaryColor";
|
||||
public const string DefaultIcon = "ic_default";
|
||||
|
||||
public static partial (string main, long build) GetVersion();
|
||||
public static partial string GetRegularFontFamily();
|
||||
public static partial string GetSemiBoldFontFamily();
|
||||
@ -98,50 +96,33 @@ namespace Billing.UI
|
||||
// add 23:59:59.999...
|
||||
return date.AddTicks(863999999999);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModelExtensionHelper
|
||||
{
|
||||
public static List<T> FromStream<T>(Stream stream) where T : IModel, new()
|
||||
public static bool IsTransparent(this long color)
|
||||
{
|
||||
XDocument doc = XDocument.Load(stream);
|
||||
var root = doc.Root;
|
||||
var list = new List<T>();
|
||||
foreach (XElement ele in root.Elements("item"))
|
||||
{
|
||||
if (ele.Attribute("null")?.Value == "1")
|
||||
{
|
||||
list.Add(default);
|
||||
}
|
||||
else
|
||||
{
|
||||
T value = new();
|
||||
value.OnXmlDeserialize(ele);
|
||||
list.Add(value);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return (color & 0xff000000L) == 0x00000000L;
|
||||
}
|
||||
|
||||
public static void ToStream<T>(this IEnumerable<T> list, Stream stream) where T : IModel
|
||||
public static Color ToColor(this long color)
|
||||
{
|
||||
XElement root = new("root");
|
||||
foreach (var t in list)
|
||||
{
|
||||
XElement item = new("item");
|
||||
if (t == null)
|
||||
{
|
||||
item.Add(new XAttribute("null", 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
t.OnXmlSerialize(item);
|
||||
}
|
||||
root.Add(item);
|
||||
}
|
||||
ulong c = (ulong)color;
|
||||
int r = (int)(c & 0xff);
|
||||
c >>= 8;
|
||||
int g = (int)(c & 0xff);
|
||||
c >>= 8;
|
||||
int b = (int)(c & 0xff);
|
||||
c >>= 8;
|
||||
int a = (int)(c & 0xff);
|
||||
return Color.FromRgba(r, g, b, a);
|
||||
}
|
||||
|
||||
XDocument doc = new(new XDeclaration("1.0", "utf-8", "yes"), root);
|
||||
doc.Save(stream, SaveOptions.DisableFormatting);
|
||||
public static long ToLong(this Color color)
|
||||
{
|
||||
long l =
|
||||
(uint)(color.A * 255) << 24 |
|
||||
(uint)(color.B * 255) << 16 |
|
||||
(uint)(color.G * 255) << 8 |
|
||||
(uint)(color.R * 255);
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user