Skip to content

Commit 6fcddbb

Browse files
committed
Add props to WPF, Avalonia UIs for easily skipping bg color
#467
1 parent 0561653 commit 6fcddbb

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

src/NetSparkle.UI.Avalonia/UIFactory.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public UIFactory()
2828
HideReleaseNotes = false;
2929
HideRemindMeLaterButton = false;
3030
HideSkipButton = false;
31+
UseStaticUpdateWindowBackgroundColor = true;
3132
UpdateWindowGridBackgroundBrush = (IBrush)new BrushConverter().ConvertFrom("#EEEEEE");
3233
}
3334

@@ -64,7 +65,13 @@ public UIFactory(WindowIcon applicationIcon, string releaseNotesSeparatorTemplat
6465
public string AdditionalReleaseNotesHeaderHTML { get; set; }
6566

6667
/// <summary>
67-
/// Brush for the background of the main grid on the update (changelog) window
68+
/// Whether or not a hardcoded window background color is set on the updates window.
69+
/// Defaults to true.
70+
/// </summary>
71+
public bool UseStaticUpdateWindowBackgroundColor { get; set; }
72+
73+
/// <summary>
74+
/// Brush for the background of the main grid on the update (change log) window
6875
/// </summary>
6976
public IBrush UpdateWindowGridBackgroundBrush { get; set; }
7077

@@ -99,7 +106,10 @@ public virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater spark
99106
{
100107
Icon = _applicationIcon
101108
};
102-
window.ChangeMainGridBackgroundColor(UpdateWindowGridBackgroundBrush);
109+
if (UseStaticUpdateWindowBackgroundColor)
110+
{
111+
window.ChangeMainGridBackgroundColor(UpdateWindowGridBackgroundBrush);
112+
}
103113
if (HideReleaseNotes)
104114
{
105115
(window as IUpdateAvailable).HideReleaseNotes();

src/NetSparkle.UI.WPF/UIFactory.cs

+18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public UIFactory()
2727
HideSkipButton = false;
2828
ReleaseNotesHTMLTemplate = "";
2929
AdditionalReleaseNotesHeaderHTML = "";
30+
UseStaticUpdateWindowBackgroundColor = true;
31+
UpdateWindowGridBackgroundBrush = (System.Windows.Media.Brush)new BrushConverter().ConvertFrom("#EEEEEE");
32+
UpdateWindowGridBackgroundBrush.Freeze();
3033
}
3134

3235
/// <summary>
@@ -74,6 +77,17 @@ public UIFactory(ImageSource applicationIcon) : this()
7477
/// </summary>
7578
public ReleaseNotesGrabber ReleaseNotesGrabberOverride { get; set; } = null;
7679

80+
/// <summary>
81+
/// Whether or not a hardcoded window background color is set on the updates window.
82+
/// Defaults to true.
83+
/// </summary>
84+
public bool UseStaticUpdateWindowBackgroundColor { get; set; }
85+
86+
/// <summary>
87+
/// Brush for the background of the main grid on the update (change log) window
88+
/// </summary>
89+
public System.Windows.Media.Brush UpdateWindowGridBackgroundBrush { get; set; }
90+
7791
/// <inheritdoc/>
7892
public virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater sparkle, List<AppCastItem> updates, bool isUpdateAlreadyDownloaded = false)
7993
{
@@ -82,6 +96,10 @@ public virtual IUpdateAvailable CreateUpdateAvailableWindow(SparkleUpdater spark
8296
{
8397
Icon = _applicationIcon
8498
};
99+
if (UseStaticUpdateWindowBackgroundColor)
100+
{
101+
window.ChangeMainGridBackgroundColor(UpdateWindowGridBackgroundBrush);
102+
}
85103
if (HideReleaseNotes)
86104
{
87105
(window as IUpdateAvailable).HideReleaseNotes();

src/NetSparkle.UI.WPF/UpdateAvailableWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<cont:BaseWindow.Resources>
1717
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
1818
</cont:BaseWindow.Resources>
19-
<Grid Background="#EEEEEE">
19+
<Grid Name="MainGrid">
2020
<Grid.ColumnDefinitions>
2121
<ColumnDefinition Width="Auto" />
2222
<ColumnDefinition Width="*" />

src/NetSparkle.UI.WPF/UpdateAvailableWindow.xaml.cs

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using NetSparkleUpdater.UI.WPF.ViewModels;
77
using System;
88
using System.Collections.Generic;
9+
using System.Drawing;
910
using System.Linq;
1011
using System.Text;
1112
using System.Threading;
@@ -143,6 +144,18 @@ public void UserRespondedToUpdateCheck(UpdateAvailableResult response)
143144
}
144145
}
145146

147+
/// <summary>
148+
/// Change the main grid's background color. Use new SolidColorBrush(Colors.Transparent) or null to clear.
149+
/// </summary>
150+
/// <param name="brush">Brush to use as the main grid's background color</param>
151+
public void ChangeMainGridBackgroundColor(System.Windows.Media.Brush brush)
152+
{
153+
if (MainGrid != null)
154+
{
155+
MainGrid.Background = brush;
156+
}
157+
}
158+
146159
/// <summary>
147160
/// Show the release notes to the end user. Release notes should be in HTML.
148161
///

0 commit comments

Comments
 (0)