otify other Objects when Settings are changed.
This commit is contained in:
parent
c5ff258793
commit
1e4c2db716
@ -14,6 +14,8 @@ using LitJson;
|
||||
namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin {
|
||||
class AdminModel {
|
||||
public delegate void AdminEvent(Object sender, EventArgs e);
|
||||
|
||||
//Supress never used warning (cause of reflection)
|
||||
#pragma warning disable 0067
|
||||
public event AdminEvent NamesUpdate;
|
||||
public event AdminEvent GeoUpdate;
|
||||
|
@ -12,6 +12,8 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Position {
|
||||
private readonly SortedDictionary<DateTime, Double[]> _history = new SortedDictionary<DateTime, Double[]>();
|
||||
private String _lastHash = "";
|
||||
private Boolean _isdublicate = false;
|
||||
private Double _historycounter = 0;
|
||||
private readonly Object lockHistory = new Object();
|
||||
|
||||
public Double Rssi { get; private set; }
|
||||
public Double Snr { get; private set; }
|
||||
@ -35,6 +37,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Position {
|
||||
public PositionItem(LoraData data, NamesModel marker) {
|
||||
this.Update(data);
|
||||
this.UpdateMarker(marker, data.Name);
|
||||
Settings.Instance.SettingsUpdate += this.UpdateSettings;
|
||||
}
|
||||
|
||||
public void UpdateMarker(NamesModel marker, String id) {
|
||||
@ -104,6 +107,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Position {
|
||||
}
|
||||
|
||||
private void StoreHistory() {
|
||||
lock(this.lockHistory) {
|
||||
if(Settings.Instance.Internal.History.Enabled) {
|
||||
if(Settings.Instance.Internal.History.Amount != 0 && this._history.Count > Settings.Instance.Internal.History.Amount) {
|
||||
_ = this._history.Remove(this._history.Keys.ToList().First());
|
||||
@ -123,11 +127,18 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Position {
|
||||
}
|
||||
}
|
||||
if(!this._history.ContainsKey(this.Recievedtime)) {
|
||||
this._history.Add(this.Recievedtime, new Double[] { this.Latitude, this.Longitude });
|
||||
this._history.Add(this.Recievedtime, new Double[] { this.Latitude, this.Longitude, this._historycounter++ });
|
||||
}
|
||||
} else {
|
||||
this._history.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSettings(Object sender, EventArgs e) {
|
||||
lock(this.lockHistory) {
|
||||
this._history.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ using System.IO;
|
||||
|
||||
namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
||||
public class Settings : OwnSingeton<Settings> {
|
||||
|
||||
private Int32 gridradius;
|
||||
|
||||
public delegate void SettingsEvent(Object sender, EventArgs e);
|
||||
public event SettingsEvent SettingsUpdate;
|
||||
|
||||
|
||||
public PublicSettings External {
|
||||
get; set;
|
||||
}
|
||||
@ -139,6 +142,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
||||
this.gridradius = json.ContainsKey("GridRadius") && json["GridRadius"].IsInt && this.External.Startloclat != 0 && this.External.Startloclon != 0 ? (Int32)json["GridRadius"] : 0;
|
||||
this.GenerateGrid();
|
||||
this.FindMapLayer();
|
||||
this.SettingsUpdate?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
private void ParseGeoJson() {
|
||||
|
Loading…
Reference in New Issue
Block a user