User-Filter Settings now on a per-user basis, saved as a dictionary in user space.
This is for the case of people using the same windows account but with several different BC users.
This commit is contained in:
parent
ac8b6ba491
commit
e03c8dc7df
@ -83,6 +83,9 @@
|
||||
<setting name="W4Top" serializeAs="String">
|
||||
<value>0</value>
|
||||
</setting>
|
||||
<setting name="FilterCriteriaMap" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</BreCalClient.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
@ -143,7 +143,7 @@ namespace BreCalClient
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// serialize filter settings
|
||||
Properties.Settings.Default.FilterCriteria = this.searchFilterControl.SearchFilter.Serialize();
|
||||
Properties.Settings.Default.FilterCriteriaMap = SearchFilterModel.Serialize();
|
||||
Properties.Settings.Default.Save();
|
||||
_tokenSource.Cancel();
|
||||
}
|
||||
@ -405,6 +405,8 @@ namespace BreCalClient
|
||||
|
||||
private async void LoadStaticLists()
|
||||
{
|
||||
if (_loginResult == null) return;
|
||||
|
||||
BreCalLists.InitializeBerths(await _staticApi.BerthsGetAsync());
|
||||
BreCalLists.InitializeShips(await _shipApi.ShipsGetAsync());
|
||||
BreCalLists.InitializeParticipants(await _staticApi.ParticipantsGetAsync());
|
||||
@ -422,16 +424,33 @@ namespace BreCalClient
|
||||
|
||||
this.searchFilterControl.SetAgencies(BreCalLists.Participants_Agent);
|
||||
|
||||
if (!string.IsNullOrEmpty(Properties.Settings.Default.FilterCriteria))
|
||||
if (!string.IsNullOrEmpty(Properties.Settings.Default.FilterCriteriaMap))
|
||||
{
|
||||
SearchFilterModel? sfm = SearchFilterModel.Deserialize(Properties.Settings.Default.FilterCriteria);
|
||||
if (sfm != null)
|
||||
this.searchFilterControl.SetFilterFromModel(sfm);
|
||||
SearchFilterModel.Deserialize(Properties.Settings.Default.FilterCriteriaMap);
|
||||
SearchFilterModel? currentFilter = null;
|
||||
if (SearchFilterModel.filterMap != null)
|
||||
{
|
||||
if((_loginResult != null) && SearchFilterModel.filterMap.ContainsKey(_loginResult.Id))
|
||||
{
|
||||
currentFilter = SearchFilterModel.filterMap[_loginResult.Id];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchFilterModel.filterMap = new();
|
||||
}
|
||||
if (currentFilter == null)
|
||||
{
|
||||
currentFilter = new();
|
||||
if(_loginResult != null)
|
||||
SearchFilterModel.filterMap[_loginResult.Id] = currentFilter;
|
||||
}
|
||||
this.searchFilterControl.SetFilterFromModel(currentFilter);
|
||||
}
|
||||
|
||||
_ = Task.Run(() => RefreshShipcalls());
|
||||
|
||||
_ = Task.Run(() => RefreshShips());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
src/BreCalClient/Properties/Settings.Designer.cs
generated
14
src/BreCalClient/Properties/Settings.Designer.cs
generated
@ -12,7 +12,7 @@ namespace BreCalClient.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@ -214,5 +214,17 @@ namespace BreCalClient.Properties {
|
||||
this["W4Top"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string FilterCriteriaMap {
|
||||
get {
|
||||
return ((string)(this["FilterCriteriaMap"]));
|
||||
}
|
||||
set {
|
||||
this["FilterCriteriaMap"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,5 +53,8 @@
|
||||
<Setting Name="W4Top" Type="System.Double" Scope="User">
|
||||
<Value Profile="(Default)">0</Value>
|
||||
</Setting>
|
||||
<Setting Name="FilterCriteriaMap" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -33,18 +33,21 @@ namespace BreCalClient
|
||||
|
||||
public bool? MineOnly { get; set; }
|
||||
|
||||
public static Dictionary<int, SearchFilterModel>? filterMap = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serialisation
|
||||
|
||||
public static SearchFilterModel? Deserialize(string json)
|
||||
public static bool Deserialize(string json)
|
||||
{
|
||||
return (SearchFilterModel?) JsonConvert.DeserializeObject(json, typeof(SearchFilterModel));
|
||||
filterMap = (Dictionary<int, SearchFilterModel>?) JsonConvert.DeserializeObject(json, typeof(Dictionary<int, SearchFilterModel>));
|
||||
return (filterMap != null);
|
||||
}
|
||||
|
||||
public string Serialize()
|
||||
public static string Serialize()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
return JsonConvert.SerializeObject(filterMap, Formatting.Indented);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
Reference in New Issue
Block a user