From 840ccad5bf0b0be1e61274932c3dbae1ff4b7374 Mon Sep 17 00:00:00 2001 From: Xjph Date: Mon, 13 Sep 2021 10:16:18 -0230 Subject: [PATCH] add scale and timeout notification settings --- ObservatoryCore/Properties/Core.Designer.cs | 24 +++++++++ ObservatoryCore/Properties/Core.settings | 6 +++ ObservatoryCore/UI/Views/BasicUIView.axaml.cs | 50 +++++++++++++++++++ .../UI/Views/NotificationView.axaml | 7 +-- .../UI/Views/NotificationView.axaml.cs | 28 ++++++++--- 5 files changed, 103 insertions(+), 12 deletions(-) diff --git a/ObservatoryCore/Properties/Core.Designer.cs b/ObservatoryCore/Properties/Core.Designer.cs index 4842202..e45a7d1 100644 --- a/ObservatoryCore/Properties/Core.Designer.cs +++ b/ObservatoryCore/Properties/Core.Designer.cs @@ -214,5 +214,29 @@ namespace Observatory.Properties { this["MainWindowPosition"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100")] + public int NativeNotifyScale { + get { + return ((int)(this["NativeNotifyScale"])); + } + set { + this["NativeNotifyScale"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("8000")] + public int NativeNotifyTimeout { + get { + return ((int)(this["NativeNotifyTimeout"])); + } + set { + this["NativeNotifyTimeout"] = value; + } + } } } diff --git a/ObservatoryCore/Properties/Core.settings b/ObservatoryCore/Properties/Core.settings index a055fd9..52f6786 100644 --- a/ObservatoryCore/Properties/Core.settings +++ b/ObservatoryCore/Properties/Core.settings @@ -50,5 +50,11 @@ 100, 100 + + 100 + + + 8000 + \ No newline at end of file diff --git a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs index c5a1301..f50ce07 100644 --- a/ObservatoryCore/UI/Views/BasicUIView.axaml.cs +++ b/ObservatoryCore/UI/Views/BasicUIView.axaml.cs @@ -376,9 +376,59 @@ namespace Observatory.UI.Views } }; + TextBlock scaleLabel = new() + { + Text = "Scale (%): ", + HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, + VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center + }; + + NumericUpDown scaleSpinner = new() + { + Value = Properties.Core.Default.NativeNotifyScale, + AllowSpin = true, + Minimum = 1, + Maximum = 1000, + Increment = 1, + Width = 200, + HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left + }; + + scaleSpinner.ValueChanged += (object sender, NumericUpDownValueChangedEventArgs e) => + { + Properties.Core.Default.NativeNotifyScale = Convert.ToInt32(e.NewValue); + Properties.Core.Default.Save(); + }; + + TextBlock timeoutLabel = new() + { + Text = "Duration (ms): ", + HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, + VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center + }; + + NumericUpDown timeoutSpinner = new() + { + Value = Properties.Core.Default.NativeNotifyTimeout, + AllowSpin = true, + Minimum = 1, + Maximum = 3600000, + Increment = 1, + Width = 200, + HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left + }; + + timeoutSpinner.ValueChanged += (object sender, NumericUpDownValueChangedEventArgs e) => + { + Properties.Core.Default.NativeNotifyTimeout = Convert.ToInt32(e.NewValue); + Properties.Core.Default.Save(); + }; + notificationGridManager.AddSettingWithLabel(monitorLabel, monitorDropDown); notificationGridManager.AddSettingWithLabel(cornerLabel, cornerDropDown); notificationGridManager.AddSettingWithLabel(notifyFontLabel, notifyFontDropDown); + notificationGridManager.AddSettingWithLabel(scaleLabel, scaleSpinner); + notificationGridManager.AddSettingWithLabel(timeoutLabel, timeoutSpinner); notificationGridManager.AddSettingWithLabel(colourLabel, colourPickerButton); notificationGridManager.AddSettingSameLine(notifyTestButton); notificationGridManager.AddSetting(nativeNotifyCheckbox); diff --git a/ObservatoryCore/UI/Views/NotificationView.axaml b/ObservatoryCore/UI/Views/NotificationView.axaml index e665eac..2de1240 100644 --- a/ObservatoryCore/UI/Views/NotificationView.axaml +++ b/ObservatoryCore/UI/Views/NotificationView.axaml @@ -9,16 +9,13 @@ ExtendClientAreaTitleBarHeightHint="-1" Title="Notification" Width="400" Height="150" - MinWidth="400" MinHeight="150" - MaxWidth="400" MaxHeight="150" Topmost="True" - SizeToContent="Height" TransparencyLevelHint="AcrylicBlur" Background="Transparent" Focusable="False"> - - + + ("Title"); + var detailText = this.Find("Detail"); + if (font.Length > 0) { - var titleText = this.Find("Title"); - var detailText = this.Find("Detail"); var fontFamily = new Avalonia.Media.FontFamily(font); titleText.FontFamily = fontFamily; detailText.FontFamily = fontFamily; } + titleText.FontSize *= scale; + detailText.FontSize *= scale; + + var textPanel = this.Find("TextPanel"); + Width *= scale; + Height *= scale; + textPanel.Width *= scale; + textPanel.Height *= scale; + + var textBorder = this.Find("TextBorder"); + textBorder.BorderThickness *= scale; + PixelRect screenBounds; if (screen == -1 || screen > Screens.All.Count) @@ -37,9 +51,9 @@ namespace Observatory.UI.Views else screenBounds = Screens.All[screen - 1].Bounds; - double scale = LayoutHelper.GetLayoutScale(this); - double scaleWidth = Width * scale; - double scaleHeight = Height * scale; + double displayScale = LayoutHelper.GetLayoutScale(this); + double scaleWidth = Width * displayScale; + double scaleHeight = Height * displayScale; switch (corner) { @@ -59,7 +73,7 @@ namespace Observatory.UI.Views var timer = new System.Timers.Timer(); timer.Elapsed += CloseNotification; - timer.Interval = 8000; + timer.Interval = Properties.Core.Default.NativeNotifyTimeout; timer.Start(); #if DEBUG this.AttachDevTools();