-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gizeta
committed
Jun 5, 2017
1 parent
22ae493
commit b938cca
Showing
7 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace ShadowWatcher | ||
{ | ||
public static class Settings | ||
{ | ||
public const int SHOW_SUMMON_CARD = 1; | ||
|
||
public static bool ShowSummonCard { get; set; } = false; | ||
|
||
public static void Parse(string data) | ||
{ | ||
int flag = int.Parse(data); | ||
ShowSummonCard = (flag & SHOW_SUMMON_CARD) > 0; | ||
} | ||
|
||
public static new string ToString() | ||
{ | ||
int flag = 0; | ||
flag |= ShowSummonCard ? SHOW_SUMMON_CARD : 0; | ||
return flag.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using ShadowWatcher.Socket; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.IO.IsolatedStorage; | ||
|
||
namespace ShadowWatcher | ||
{ | ||
public class SettingModel : INotifyPropertyChanged | ||
{ | ||
private IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForAssembly(); | ||
|
||
public SettingModel() | ||
{ | ||
if (!storage.FileExists("setting")) | ||
{ | ||
Save(); | ||
} | ||
else | ||
{ | ||
var reader = new StreamReader(new IsolatedStorageFileStream("setting", FileMode.Open, storage)); | ||
Settings.Parse(reader.ReadLine()); | ||
} | ||
} | ||
|
||
public bool ShowSummonCard | ||
{ | ||
get => Settings.ShowSummonCard; | ||
set | ||
{ | ||
if (Settings.ShowSummonCard != value) | ||
{ | ||
Settings.ShowSummonCard = value; | ||
Save(); | ||
NotifyPropertyChanged("ShowSummonCard"); | ||
} | ||
} | ||
} | ||
|
||
public void Save() | ||
{ | ||
var writer = new StreamWriter(new IsolatedStorageFileStream("setting", FileMode.Create, storage)); | ||
writer.Write(Settings.ToString()); | ||
writer.Close(); | ||
|
||
Sender.Send($"Setting:{Settings.ToString()}"); | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
private void NotifyPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters