apply Rider suggestions
This commit is contained in:
@@ -20,8 +20,8 @@ namespace ntfysh_client
|
|||||||
private System.Windows.Forms.Timer? _updateTimer = null;
|
private System.Windows.Forms.Timer? _updateTimer = null;
|
||||||
private Stopwatch? _shownStopwatch = null;
|
private Stopwatch? _shownStopwatch = null;
|
||||||
|
|
||||||
private BaseTheme _darkModeTheme = new DarkModeTheme();
|
private readonly BaseTheme _darkModeTheme = new DarkModeTheme();
|
||||||
private BaseTheme _defaultTheme = new DefaultTheme();
|
private readonly BaseTheme _defaultTheme = new DefaultTheme();
|
||||||
private BaseTheme? _theme = null;
|
private BaseTheme? _theme = null;
|
||||||
|
|
||||||
public NotificationDialog()
|
public NotificationDialog()
|
||||||
@@ -41,14 +41,7 @@ namespace ntfysh_client
|
|||||||
HandleTimeout(null, null);
|
HandleTimeout(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showInDarkMode)
|
_theme = showInDarkMode ? _darkModeTheme : _defaultTheme;
|
||||||
{
|
|
||||||
_theme = _darkModeTheme;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_theme = _defaultTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyTheme();
|
ApplyTheme();
|
||||||
|
|
||||||
@@ -111,7 +104,7 @@ namespace ntfysh_client
|
|||||||
|
|
||||||
private void ApplyTheme()
|
private void ApplyTheme()
|
||||||
{
|
{
|
||||||
if (_theme is null) _theme = _defaultTheme;
|
_theme ??= _defaultTheme;
|
||||||
|
|
||||||
// back colors
|
// back colors
|
||||||
BackColor = _theme.BackgroundColor;
|
BackColor = _theme.BackgroundColor;
|
||||||
@@ -139,7 +132,7 @@ namespace ntfysh_client
|
|||||||
if (_shownStopwatch is null) return;
|
if (_shownStopwatch is null) return;
|
||||||
|
|
||||||
ProgressBar1.Value = (_timeoutSeconds - _shownStopwatch.Elapsed.Seconds) * 100 / _timeoutSeconds;
|
ProgressBar1.Value = (_timeoutSeconds - _shownStopwatch.Elapsed.Seconds) * 100 / _timeoutSeconds;
|
||||||
LblTimeout.Text = $"{_timeoutSeconds - _shownStopwatch.Elapsed.Seconds}";
|
LblTimeout.Text = $@"{_timeoutSeconds - _shownStopwatch.Elapsed.Seconds}";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetVisibleCore(bool value)
|
protected override void SetVisibleCore(bool value)
|
||||||
@@ -153,7 +146,7 @@ namespace ntfysh_client
|
|||||||
AnimateWindow(
|
AnimateWindow(
|
||||||
Handle,
|
Handle,
|
||||||
time: 250,
|
time: 250,
|
||||||
flags: NFWinUserAnimateWindowConstnats.AW_SLIDE | NFWinUserAnimateWindowConstnats.AW_VER_NEGATIVE
|
flags: NFWinUserAnimateWindowConstants.AW_SLIDE | NFWinUserAnimateWindowConstants.AW_VER_NEGATIVE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,11 +155,11 @@ namespace ntfysh_client
|
|||||||
|
|
||||||
private void SetWindowPosition()
|
private void SetWindowPosition()
|
||||||
{
|
{
|
||||||
int workingtop = Screen.PrimaryScreen.WorkingArea.Height - Height;
|
var workingTop = Screen.PrimaryScreen.WorkingArea.Height - Height;
|
||||||
Top = workingtop - NotificationDialog.ScreenMargin;
|
Top = workingTop - NotificationDialog.ScreenMargin;
|
||||||
|
|
||||||
int workingleft = Screen.PrimaryScreen.WorkingArea.Width - Width;
|
var workingLeft = Screen.PrimaryScreen.WorkingArea.Width - Width;
|
||||||
Left = workingleft - NotificationDialog.ScreenMargin;
|
Left = workingLeft - NotificationDialog.ScreenMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UIThreadAnimatedHideWindow(object? sender, EventArgs? e)
|
private void UIThreadAnimatedHideWindow(object? sender, EventArgs? e)
|
||||||
@@ -175,7 +168,7 @@ namespace ntfysh_client
|
|||||||
AnimateWindow(
|
AnimateWindow(
|
||||||
Handle,
|
Handle,
|
||||||
time: 250,
|
time: 250,
|
||||||
flags: NFWinUserAnimateWindowConstnats.AW_SLIDE | NFWinUserAnimateWindowConstnats.AW_VER_POSITIVE | NFWinUserAnimateWindowConstnats.AW_HIDE
|
flags: NFWinUserAnimateWindowConstants.AW_SLIDE | NFWinUserAnimateWindowConstants.AW_VER_POSITIVE | NFWinUserAnimateWindowConstants.AW_HIDE
|
||||||
);
|
);
|
||||||
|
|
||||||
Visible = false;
|
Visible = false;
|
||||||
@@ -219,7 +212,7 @@ namespace ntfysh_client
|
|||||||
Visible = false;
|
Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NFWinUserAnimateWindowConstnats
|
private class NFWinUserAnimateWindowConstants
|
||||||
{
|
{
|
||||||
public const int AW_HOR_POSITIVE = 0x00000001;
|
public const int AW_HOR_POSITIVE = 0x00000001;
|
||||||
public const int AW_HOR_NEGATIVE = 0x00000002;
|
public const int AW_HOR_NEGATIVE = 0x00000002;
|
||||||
|
@@ -66,7 +66,7 @@ namespace ntfysh_client
|
|||||||
public SettingsDialog()
|
public SettingsDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SetNotificationsUIElements();
|
SetNotificationsUiElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveButton_Click(object sender, EventArgs e)
|
private void saveButton_Click(object sender, EventArgs e)
|
||||||
@@ -79,7 +79,7 @@ namespace ntfysh_client
|
|||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetNotificationsUIElements()
|
private void SetNotificationsUiElements()
|
||||||
{
|
{
|
||||||
groupCustomNotificationSettings.Enabled = useCustomTrayNotifications.Checked;
|
groupCustomNotificationSettings.Enabled = useCustomTrayNotifications.Checked;
|
||||||
timeoutLabel.Text = useCustomTrayNotifications.Checked ? _customNotificationsTimeout : _windowsNotificationsTimeout;
|
timeoutLabel.Text = useCustomTrayNotifications.Checked ? _customNotificationsTimeout : _windowsNotificationsTimeout;
|
||||||
@@ -87,7 +87,7 @@ namespace ntfysh_client
|
|||||||
|
|
||||||
private void UseCustomTrayNotifications_CheckedChanged(object sender, EventArgs e)
|
private void UseCustomTrayNotifications_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SetNotificationsUIElements();
|
SetNotificationsUiElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string _windowsNotificationsTimeout = "Notification Toast Timeout (seconds, may be ignored by OS based on accessibility settings):";
|
private const string _windowsNotificationsTimeout = "Notification Toast Timeout (seconds, may be ignored by OS based on accessibility settings):";
|
||||||
|
Reference in New Issue
Block a user