mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-01-14 01:25:38 -05:00
More UI updates
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
using System.IO;
|
||||
|
||||
namespace FeedCenter.Data
|
||||
namespace FeedCenter.Data;
|
||||
|
||||
public static class Database
|
||||
{
|
||||
public static class Database
|
||||
public static string DatabaseFile { get; set; }
|
||||
public static string DatabasePath { get; set; }
|
||||
|
||||
public static FeedCenterEntities Entities { get; set; }
|
||||
|
||||
public static bool Exists => File.Exists(DatabaseFile);
|
||||
|
||||
public static bool Loaded { get; set; }
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
public static string DatabaseFile { get; set; }
|
||||
public static string DatabasePath { get; set; }
|
||||
if (Loaded) return;
|
||||
|
||||
public static FeedCenterEntities Entities { get; set; }
|
||||
Entities = new FeedCenterEntities();
|
||||
|
||||
public static bool Exists => File.Exists(DatabaseFile);
|
||||
|
||||
public static bool Loaded { get; set; }
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
if (Loaded) return;
|
||||
|
||||
Entities = new FeedCenterEntities();
|
||||
|
||||
Loaded = true;
|
||||
}
|
||||
Loaded = true;
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,27 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace FeedCenter.Data
|
||||
namespace FeedCenter.Data;
|
||||
|
||||
public class RealmObservableCollection<T> : ObservableCollection<T> where T : IRealmObject
|
||||
{
|
||||
public class RealmObservableCollection<T> : ObservableCollection<T> where T : IRealmObject
|
||||
private readonly Realm _realm;
|
||||
|
||||
public RealmObservableCollection(Realm realm) : base(realm.All<T>())
|
||||
{
|
||||
private readonly Realm _realm;
|
||||
_realm = realm;
|
||||
}
|
||||
|
||||
public RealmObservableCollection(Realm realm) : base(realm.All<T>())
|
||||
{
|
||||
_realm = realm;
|
||||
}
|
||||
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
foreach (T item in e.OldItems)
|
||||
_realm.Remove(item);
|
||||
|
||||
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.OldItems != null)
|
||||
foreach (T item in e.OldItems)
|
||||
_realm.Remove(item);
|
||||
if (e.NewItems != null)
|
||||
foreach (T item in e.NewItems)
|
||||
_realm.Add(item);
|
||||
|
||||
if (e.NewItems != null)
|
||||
foreach (T item in e.NewItems)
|
||||
_realm.Add(item);
|
||||
|
||||
base.OnCollectionChanged(e);
|
||||
}
|
||||
base.OnCollectionChanged(e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user