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;
}
}
[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">
<Value Profile="(Default)">100, 100</Value>
</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>
</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(cornerLabel, cornerDropDown);
notificationGridManager.AddSettingWithLabel(notifyFontLabel, notifyFontDropDown);
notificationGridManager.AddSettingWithLabel(scaleLabel, scaleSpinner);
notificationGridManager.AddSettingWithLabel(timeoutLabel, timeoutSpinner);
notificationGridManager.AddSettingWithLabel(colourLabel, colourPickerButton);
notificationGridManager.AddSettingSameLine(notifyTestButton);
notificationGridManager.AddSetting(nativeNotifyCheckbox);

View File

@ -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">
<Panel DataContext="{Binding Notification}">
<Border BorderBrush="{Binding Colour}" BorderThickness="4">
<StackPanel Width="400">
<Border Name="TextBorder" BorderBrush="{Binding Colour}" BorderThickness="4">
<StackPanel Name="TextPanel" Width="400">
<TextBlock
Name="Title"
Padding="10"

View File

@ -19,17 +19,31 @@ namespace Observatory.UI.Views
int screen = Properties.Core.Default.NativeNotifyScreen;
int corner = Properties.Core.Default.NativeNotifyCorner;
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)
{
var titleText = this.Find<TextBlock>("Title");
var detailText = this.Find<TextBlock>("Detail");
var fontFamily = new Avalonia.Media.FontFamily(font);
titleText.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;
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();