forked from msarilar/EDEngineer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlueprintIngredient.cs
66 lines (56 loc) · 1.81 KB
/
BlueprintIngredient.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
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Newtonsoft.Json;
namespace EDEngineer.Models
{
public class BlueprintIngredient : INotifyPropertyChanged
{
private bool shoppingListHighlighted;
public Entry Entry { get; }
public BlueprintIngredient(Entry entry, int size)
{
Entry = entry;
Size = size;
}
public int Size { get; }
[JsonIgnore]
public bool ShoppingListHighlighted
{
get => shoppingListHighlighted;
set
{
if (value == shoppingListHighlighted)
return;
shoppingListHighlighted = value;
OnPropertyChanged();
}
}
public override string ToString()
{
return $"{Entry.Data.Kind} : {Entry.Data.Name} ({Entry.Count} / {Size})";
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected bool Equals(BlueprintIngredient other)
{
return Equals(Entry, other.Entry) && Size == other.Size;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((BlueprintIngredient)obj);
}
public override int GetHashCode()
{
unchecked
{
return ((Entry != null ? Entry.GetHashCode() : 0) * 397) ^ Size;
}
}
}
}