-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDlc.cs
106 lines (87 loc) · 4.16 KB
/
Dlc.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using CommonPluginsShared;
using CommonPluginsShared.Extensions;
using Playnite.SDK.Data;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Windows.Media.Imaging;
using System.Drawing.Imaging;
using CheckDlc.Services;
namespace CheckDlc.Models
{
public class Dlc : ObservableObject
{
private CheckDlcDatabase PluginDatabase => CheckDlc.PluginDatabase;
[DontSerialize]
public string Id => DlcId + "##" + Name;
public string DlcId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public string Link { get; set; }
private bool _isOwned;
public bool IsOwned
{
get => IsManualOwned || _isOwned;
set => _isOwned = value;
}
[DontSerialize]
public bool IsHidden => PluginDatabase.PluginSettings.Settings.IgnoredList.Contains(Id);
[DontSerialize]
public bool IsManualOwned => PluginDatabase.PluginSettings.Settings.ManuallyOwneds.Contains(Id);
public string Price { get; set; }
public string PriceBase { get; set; }
[DontSerialize]
public double PriceNumeric
{
get
{
if (Price.IsNullOrEmpty())
{
return 0;
}
// Symbol is after
string temp = Price.Replace(",--", string.Empty).Replace(".--", string.Empty).Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "--", string.Empty);
temp = Regex.Split(temp, @"\s+").Where(s => s != string.Empty).First();
temp = temp.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator).Replace(",", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
temp = Regex.Replace(temp, @"[^\d" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "-]", "");
_ = double.TryParse(temp, out double dPrice);
// Try symbol before
if (dPrice == 0)
{
temp = Price.Replace(",--", string.Empty).Replace(".--", string.Empty).Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "--", string.Empty);
temp = Regex.Split(temp, @"\s+").Where(s => s != string.Empty).Last();
temp = temp.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator).Replace(",", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
temp = Regex.Replace(temp, @"[^\d" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "-]", "");
_ = double.TryParse(temp, out dPrice);
}
return dPrice;
}
}
[DontSerialize]
public double PriceBaseNumeric
{
get
{
if (PriceBase.IsNullOrEmpty())
{
return 0;
}
string temp = PriceBase.Replace(",--", string.Empty).Replace(".--", string.Empty).Replace(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "--", string.Empty);
temp = Regex.Split(temp, @"\s+").Where(s => s != string.Empty).First();
temp = temp.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator).Replace(",", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator);
temp = Regex.Replace(temp, @"[^\d" + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + "-]", "");
_ = double.TryParse(temp, out double dPrice);
return dPrice;
}
}
[DontSerialize]
public bool IsFree => !Price.IsNullOrEmpty() && PriceNumeric == 0;
[DontSerialize]
public bool IsDiscount => !Price.IsEqual(PriceBase);
[DontSerialize]
public BitmapImage ImagePath => ImageSourceManagerPlugin.GetImage(Image, false, new BitmapLoadProperties(200, 200));
}
}