Skip to content

Commit 928ca47

Browse files
committed
Add preview background in welcome page 2
1 parent 022cad0 commit 928ca47

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
using Flow.Launcher.Infrastructure.Hotkey;
33
using Flow.Launcher.Infrastructure.UserSettings;
44
using System;
5-
using System.Windows;
6-
using System.Windows.Media;
75
using System.Windows.Navigation;
86
using CommunityToolkit.Mvvm.Input;
97
using Flow.Launcher.ViewModel;
8+
using System.IO;
9+
using System.Windows.Media.Imaging;
10+
using System.Windows.Media;
1011

1112
namespace Flow.Launcher.Resources.Pages
1213
{
@@ -29,5 +30,27 @@ private static void SetTogglingHotkey(HotkeyModel hotkey)
2930
{
3031
HotKeyMapper.SetHotkey(hotkey, HotKeyMapper.OnToggleHotkey);
3132
}
33+
34+
public Brush PreviewBackground
35+
{
36+
get
37+
{
38+
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
39+
if (wallpaper is not null && File.Exists(wallpaper))
40+
{
41+
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
42+
var bitmap = new BitmapImage();
43+
bitmap.BeginInit();
44+
bitmap.StreamSource = memStream;
45+
bitmap.DecodePixelWidth = 800;
46+
bitmap.DecodePixelHeight = 600;
47+
bitmap.EndInit();
48+
return new ImageBrush(bitmap) { Stretch = Stretch.UniformToFill };
49+
}
50+
51+
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
52+
return new SolidColorBrush(wallpaperColor);
53+
}
54+
}
3255
}
3356
}

0 commit comments

Comments
 (0)