-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
f14395a
commit 28c3b04
Showing
9 changed files
with
165 additions
and
77 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NewWorldCompanion.Entities | ||
{ | ||
public class SettingsNWC | ||
{ | ||
// Shape detection | ||
public int EmguAreaLower { get; set; } = 10000; | ||
public int EmguAreaUpper { get; set; } = 15000; | ||
public int EmguHysteresisLower { get; set; } = 10; | ||
public int EmguHysteresisUpper { get; set; } = 400; | ||
|
||
// OCR | ||
public int EmguThresholdMin { get; set; } = 90; | ||
public int EmguThresholdMax { get; set; } = 255; | ||
} | ||
} |
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,16 @@ | ||
using NewWorldCompanion.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NewWorldCompanion.Interfaces | ||
{ | ||
public interface ISettingsManager | ||
{ | ||
public SettingsNWC Settings { get; } | ||
|
||
public void SaveSettings(); | ||
} | ||
} |
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,74 @@ | ||
using NewWorldCompanion.Entities; | ||
using NewWorldCompanion.Interfaces; | ||
using Prism.Events; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace NewWorldCompanion.Services | ||
{ | ||
public class SettingsManager : ISettingsManager | ||
{ | ||
private readonly IEventAggregator _eventAggregator; | ||
|
||
private SettingsNWC _settings = new SettingsNWC(); | ||
|
||
// Start of Constructor region | ||
|
||
#region Constructor | ||
|
||
public SettingsManager(IEventAggregator eventAggregator) | ||
{ | ||
// Init IEventAggregator | ||
_eventAggregator = eventAggregator; | ||
|
||
// Init settings | ||
LoadSettings(); | ||
} | ||
|
||
#endregion | ||
|
||
// Start of Properties region | ||
|
||
#region Properties | ||
|
||
public SettingsNWC Settings { get => _settings; set => _settings = value; } | ||
|
||
#endregion | ||
|
||
// Start of Events region | ||
|
||
#region Events | ||
|
||
#endregion | ||
|
||
// Start of Methods region | ||
#region Methods | ||
|
||
private void LoadSettings() | ||
{ | ||
string fileName = "Settings.json"; | ||
if (File.Exists(fileName)) | ||
{ | ||
using FileStream stream = File.OpenRead(fileName); | ||
_settings = JsonSerializer.Deserialize<SettingsNWC>(stream) ?? new SettingsNWC(); | ||
} | ||
|
||
SaveSettings(); | ||
} | ||
|
||
public void SaveSettings() | ||
{ | ||
string fileName = "Settings.json"; | ||
using FileStream stream = File.Create(fileName); | ||
var options = new JsonSerializerOptions { WriteIndented = true }; | ||
JsonSerializer.Serialize(stream, _settings, options); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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
Oops, something went wrong.