2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-05 17:39:39 -04:00

add scale and timeout notification settings

This commit is contained in:
Xjph 2021-09-13 10:16:18 -02:30
parent 2e235bc939
commit 840ccad5bf
5 changed files with 103 additions and 12 deletions

View File

@ -214,5 +214,29 @@ namespace Observatory.Properties {
this["MainWindowPosition"] = value; 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;
}
}
} }
} }

View File

@ -50,5 +50,11 @@
<Setting Name="MainWindowPosition" Type="System.Drawing.Point" Scope="User"> <Setting Name="MainWindowPosition" Type="System.Drawing.Point" Scope="User">
<Value Profile="(Default)">100, 100</Value> <Value Profile="(Default)">100, 100</Value>
</Setting> </Setting>
<Setting Name="NativeNotifyScale" Type="System.Int32" Scope="User">
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="NativeNotifyTimeout" Type="System.Int32" Scope="User">
<Value Profile="(Default)">8000</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -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(monitorLabel, monitorDropDown);
notificationGridManager.AddSettingWithLabel(cornerLabel, cornerDropDown); notificationGridManager.AddSettingWithLabel(cornerLabel, cornerDropDown);
notificationGridManager.AddSettingWithLabel(notifyFontLabel, notifyFontDropDown); notificationGridManager.AddSettingWithLabel(notifyFontLabel, notifyFontDropDown);
notificationGridManager.AddSettingWithLabel(scaleLabel, scaleSpinner);
notificationGridManager.AddSettingWithLabel(timeoutLabel, timeoutSpinner);
notificationGridManager.AddSettingWithLabel(colourLabel, colourPickerButton); notificationGridManager.AddSettingWithLabel(colourLabel, colourPickerButton);
notificationGridManager.AddSettingSameLine(notifyTestButton); notificationGridManager.AddSettingSameLine(notifyTestButton);
notificationGridManager.AddSetting(nativeNotifyCheckbox); notificationGridManager.AddSetting(nativeNotifyCheckbox);

View File

@ -9,16 +9,13 @@
ExtendClientAreaTitleBarHeightHint="-1" ExtendClientAreaTitleBarHeightHint="-1"
Title="Notification" Title="Notification"
Width="400" Height="150" Width="400" Height="150"
MinWidth="400" MinHeight="150"
MaxWidth="400" MaxHeight="150"
Topmost="True" Topmost="True"
SizeToContent="Height"
TransparencyLevelHint="AcrylicBlur" TransparencyLevelHint="AcrylicBlur"
Background="Transparent" Background="Transparent"
Focusable="False"> Focusable="False">
<Panel DataContext="{Binding Notification}"> <Panel DataContext="{Binding Notification}">
<Border BorderBrush="{Binding Colour}" BorderThickness="4"> <Border Name="TextBorder" BorderBrush="{Binding Colour}" BorderThickness="4">
<StackPanel Width="400"> <StackPanel Name="TextPanel" Width="400">
<TextBlock <TextBlock
Name="Title" Name="Title"
Padding="10" Padding="10"

View File

@ -19,17 +19,31 @@ namespace Observatory.UI.Views
int screen = Properties.Core.Default.NativeNotifyScreen; int screen = Properties.Core.Default.NativeNotifyScreen;
int corner = Properties.Core.Default.NativeNotifyCorner; int corner = Properties.Core.Default.NativeNotifyCorner;
string font = Properties.Core.Default.NativeNotifyFont; string font = Properties.Core.Default.NativeNotifyFont;
double scale = Properties.Core.Default.NativeNotifyScale / 100.0;
var titleText = this.Find<TextBlock>("Title");
var detailText = this.Find<TextBlock>("Detail");
if (font.Length > 0) if (font.Length > 0)
{ {
var titleText = this.Find<TextBlock>("Title");
var detailText = this.Find<TextBlock>("Detail");
var fontFamily = new Avalonia.Media.FontFamily(font); var fontFamily = new Avalonia.Media.FontFamily(font);
titleText.FontFamily = fontFamily; titleText.FontFamily = fontFamily;
detailText.FontFamily = fontFamily; detailText.FontFamily = fontFamily;
} }
titleText.FontSize *= scale;
detailText.FontSize *= scale;
var textPanel = this.Find<StackPanel>("TextPanel");
Width *= scale;
Height *= scale;
textPanel.Width *= scale;
textPanel.Height *= scale;
var textBorder = this.Find<Border>("TextBorder");
textBorder.BorderThickness *= scale;
PixelRect screenBounds; PixelRect screenBounds;
if (screen == -1 || screen > Screens.All.Count) if (screen == -1 || screen > Screens.All.Count)
@ -37,9 +51,9 @@ namespace Observatory.UI.Views
else else
screenBounds = Screens.All[screen - 1].Bounds; screenBounds = Screens.All[screen - 1].Bounds;
double scale = LayoutHelper.GetLayoutScale(this); double displayScale = LayoutHelper.GetLayoutScale(this);
double scaleWidth = Width * scale; double scaleWidth = Width * displayScale;
double scaleHeight = Height * scale; double scaleHeight = Height * displayScale;
switch (corner) switch (corner)
{ {
@ -59,7 +73,7 @@ namespace Observatory.UI.Views
var timer = new System.Timers.Timer(); var timer = new System.Timers.Timer();
timer.Elapsed += CloseNotification; timer.Elapsed += CloseNotification;
timer.Interval = 8000; timer.Interval = Properties.Core.Default.NativeNotifyTimeout;
timer.Start(); timer.Start();
#if DEBUG #if DEBUG
this.AttachDevTools(); this.AttachDevTools();