mirror of
https://github.com/DarthAffe/RGBSyncPlus
synced 2026-11-11 21:16:28 +00:00
Initial implementation
This commit is contained in:
1 parent
278e22020e
commit
fd662dcf34
63 files changed
+4881
No files matched your search
@@ -0,0 +1,48 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using Newtonsoft.Json;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
|
||||
namespace RGBSyncPlus.Model
|
||||
{
|
||||
public class SyncGroup : AbstractBindable
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public string DisplayName => string.IsNullOrWhiteSpace(Name) ? "(unnamed)" : Name;
|
||||
|
||||
private string _name;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _name, value))
|
||||
OnPropertyChanged(nameof(DisplayName));
|
||||
}
|
||||
}
|
||||
|
||||
private SyncLed _syncLed;
|
||||
public SyncLed SyncLed
|
||||
{
|
||||
get => _syncLed;
|
||||
set => SetProperty(ref _syncLed, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<SyncLed> _leds = new ObservableCollection<SyncLed>();
|
||||
public ObservableCollection<SyncLed> Leds
|
||||
{
|
||||
get => _leds;
|
||||
set => SetProperty(ref _leds, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ListLedGroup LedGroup { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public NotifyCollectionChangedEventHandler LedsChangedEventHandler { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using Newtonsoft.Json;
|
||||
using RGB.NET.Core;
|
||||
using RGBSyncPlus.Helper;
|
||||
|
||||
namespace RGBSyncPlus.Model
|
||||
{
|
||||
public class SyncLed : AbstractBindable
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private string _device;
|
||||
public string Device
|
||||
{
|
||||
get => _device;
|
||||
set => SetProperty(ref _device, value);
|
||||
}
|
||||
|
||||
private LedId _ledId;
|
||||
public LedId LedId
|
||||
{
|
||||
get => _ledId;
|
||||
set => SetProperty(ref _ledId, value);
|
||||
}
|
||||
|
||||
private Led _led;
|
||||
[JsonIgnore]
|
||||
public Led Led
|
||||
{
|
||||
get => _led;
|
||||
set => SetProperty(ref _led, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public SyncLed()
|
||||
{ }
|
||||
|
||||
public SyncLed(string device, LedId ledId)
|
||||
{
|
||||
this.Device = device;
|
||||
this.LedId = ledId;
|
||||
}
|
||||
|
||||
public SyncLed(Led led)
|
||||
{
|
||||
this.Device = led.Device.GetDeviceName();
|
||||
this.LedId = led.Id;
|
||||
this.Led = led;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
protected bool Equals(SyncLed other) => string.Equals(_device, other._device) && (_ledId == other._ledId);
|
||||
|
||||
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((SyncLed)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((_device != null ? _device.GetHashCode() : 0) * 397) ^ (int)_ledId;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(SyncLed left, SyncLed right) => Equals(left, right);
|
||||
public static bool operator !=(SyncLed left, SyncLed right) => !Equals(left, right);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user