mirror of
https://github.com/ckaczor/WorkIndicator.git
synced 2026-01-14 01:25:45 -05:00
Switch to submodules, support multiple patterns, add options dialog, add license and initial readme
This commit is contained in:
47
WindowPatterns.cs
Normal file
47
WindowPatterns.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using WorkIndicator.Properties;
|
||||
|
||||
namespace WorkIndicator
|
||||
{
|
||||
public class WindowPatterns : ObservableCollection<WindowPattern>
|
||||
{
|
||||
public static event EventHandler Changed;
|
||||
|
||||
public static WindowPatterns Load()
|
||||
{
|
||||
var windowPatterns = Load(Settings.Default.WindowPatterns);
|
||||
|
||||
return windowPatterns;
|
||||
}
|
||||
|
||||
private static WindowPatterns Load(string serializedData)
|
||||
{
|
||||
var windowPatterns = JsonConvert.DeserializeObject<WindowPatterns>(serializedData) ?? new WindowPatterns();
|
||||
|
||||
return windowPatterns;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
Settings.Default.WindowPatterns = Serialize();
|
||||
|
||||
Settings.Default.Save();
|
||||
|
||||
Changed?.Invoke(this, null);
|
||||
}
|
||||
|
||||
private string Serialize()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
public WindowPatterns Clone()
|
||||
{
|
||||
var data = Serialize();
|
||||
|
||||
return Load(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user