mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-20 02:34:09 +02:00
Refactor UserConfig event invocations into a generic method
This commit is contained in:
parent
4f8c778ba0
commit
33d9ba3871
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using TweetDuck.Core.Controls;
|
using TweetDuck.Core.Controls;
|
||||||
@ -95,7 +96,7 @@ static UserConfig(){
|
|||||||
public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty;
|
public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty;
|
||||||
|
|
||||||
public TwitterUtils.ImageQuality TwitterImageQuality => BestImageQuality ? TwitterUtils.ImageQuality.Orig : TwitterUtils.ImageQuality.Default;
|
public TwitterUtils.ImageQuality TwitterImageQuality => BestImageQuality ? TwitterUtils.ImageQuality.Orig : TwitterUtils.ImageQuality.Default;
|
||||||
|
|
||||||
public string NotificationSoundPath{
|
public string NotificationSoundPath{
|
||||||
get => string.IsNullOrEmpty(_notificationSoundPath) ? string.Empty : _notificationSoundPath;
|
get => string.IsNullOrEmpty(_notificationSoundPath) ? string.Empty : _notificationSoundPath;
|
||||||
set => _notificationSoundPath = value;
|
set => _notificationSoundPath = value;
|
||||||
@ -103,35 +104,17 @@ public string NotificationSoundPath{
|
|||||||
|
|
||||||
public bool MuteNotifications{
|
public bool MuteNotifications{
|
||||||
get => _muteNotifications;
|
get => _muteNotifications;
|
||||||
|
set => UpdatePropertyWithEvent(ref _muteNotifications, value, MuteToggled);
|
||||||
set{
|
|
||||||
if (_muteNotifications != value){
|
|
||||||
_muteNotifications = value;
|
|
||||||
MuteToggled?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ZoomLevel{
|
public int ZoomLevel{
|
||||||
get => _zoomLevel;
|
get => _zoomLevel;
|
||||||
|
set => UpdatePropertyWithEvent(ref _zoomLevel, value, ZoomLevelChanged);
|
||||||
set{
|
|
||||||
if (_zoomLevel != value){
|
|
||||||
_zoomLevel = value;
|
|
||||||
ZoomLevelChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TrayIcon.Behavior TrayBehavior{
|
public TrayIcon.Behavior TrayBehavior{
|
||||||
get => _trayBehavior;
|
get => _trayBehavior;
|
||||||
|
set => UpdatePropertyWithEvent(ref _trayBehavior, value, TrayBehaviorChanged);
|
||||||
set{
|
|
||||||
if (_trayBehavior != value){
|
|
||||||
_trayBehavior = value;
|
|
||||||
TrayBehaviorChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EVENTS
|
// EVENTS
|
||||||
@ -148,6 +131,13 @@ private UserConfig(string file){
|
|||||||
this.file = file;
|
this.file = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdatePropertyWithEvent<T>(ref T field, T value, EventHandler eventHandler){
|
||||||
|
if (!EqualityComparer<T>.Default.Equals(field, value)){
|
||||||
|
field = value;
|
||||||
|
eventHandler?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Save(){
|
public void Save(){
|
||||||
try{
|
try{
|
||||||
if (File.Exists(file)){
|
if (File.Exists(file)){
|
||||||
|
Loading…
Reference in New Issue
Block a user