Skip to content
Permalink
Browse files

Reloading the settings for the chat master control on setting changed

  • Loading branch information...
COM8 committed Aug 12, 2019
1 parent 4515a24 commit cb44ed72d470a11ad7305c4932f924fc54e546e4
@@ -1,4 +1,5 @@
using Microsoft.Toolkit.Uwp.Helpers;
using System.ComponentModel;
using Microsoft.Toolkit.Uwp.Helpers;

namespace Data_Manager2.Classes
{
@@ -8,6 +9,8 @@ public static class Settings
#region --Attributes--
public static readonly LocalObjectStorageHelper LOCAL_OBJECT_STORAGE_HELPER = new LocalObjectStorageHelper();

public static event PropertyChangedEventHandler SettingChanged;

#endregion
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\
#region --Constructors--
@@ -24,6 +27,7 @@ public static class Settings
public static void setSetting(string token, object value)
{
Windows.Storage.ApplicationData.Current.LocalSettings.Values[token] = value;
SettingChanged?.Invoke(value, new PropertyChangedEventArgs(token));
}

/// <summary>
@@ -271,6 +271,27 @@ private void InvokeOnError(string titel, string message)
OnError?.Invoke(this, new OnErrorEventArgs(titel, message));
}

private void LoadSettings()
{
int show = Settings.getSettingInt(SettingsConsts.CHAT_SHOW_ACCOUNT_COLOR);
switch (show)
{
case 1:
MODEL.ShowAccountColor = true;
break;

case 2:
MODEL.ShowAccountColor = false;
break;

default:
MODEL.ShowAccountColor = ConnectionHandler.INSTANCE.getClients().Count > 1;
break;
}

Settings.SettingChanged += Settings_SettingChanged;
}

#endregion

#region --Misc Methods (Protected)--
@@ -304,21 +325,12 @@ private void Chat_ChatMessageChanged(ChatDataTemplate chat, Data_Manager2.Classe
MODEL.UpdateUnreadCount(chat.Chat);
}

private void LoadSettings()
private void Settings_SettingChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
int show = Settings.getSettingInt(SettingsConsts.CHAT_SHOW_ACCOUNT_COLOR);
switch (show)
switch (e.PropertyName)
{
case 1:
MODEL.ShowAccountColor = true;
break;

case 2:
MODEL.ShowAccountColor = false;
break;

default:
MODEL.ShowAccountColor = ConnectionHandler.INSTANCE.getClients().Count > 1;
case SettingsConsts.CHAT_SHOW_ACCOUNT_COLOR:
LoadSettings();
break;
}
}

0 comments on commit cb44ed7

Please sign in to comment.
You can’t perform that action at this time.