Show light and charcoal previews in README

This commit is contained in:
Dario P. committed 2026-10-15 22:57:30 +02:00
1 parent 192469c258
commit 8be2445753
4 files changed
+29 -2

No files matched your search

+12
View File
@@ -2,6 +2,18 @@
A portable C# / WPF website launcher for Windows.
[**Download for Windows**](https://github.com/donishki/orbit-shortcuts/releases/latest) · [Features](#features) · [Build from source](#build)
## Screenshots
### Charcoal
![Orbit in charcoal mode, showing website cards and the collection sidebar](docs/screenshots/orbit-dark.png)
### Light
![Orbit in light mode, showing website cards and the collection sidebar](docs/screenshots/orbit-light.png)
## Features
- Website cards with automatic or custom icons
Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

+17 -2
View File
@@ -16,16 +16,26 @@ internal static class ThemeChecks
foreach (var site in new[] { "https://github.com", "https://www.google.com" })
Console.WriteLine("Live icon " + site + ": " + (WebsiteIcons.Fetch(site).GetAwaiter().GetResult() != null ? "loaded" : "fallback"));
var app = new App(); app.InitializeComponent();
var window = new MainWindow();
SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext());
var isolated = Path.Combine(Path.GetTempPath(), "OrbitPreview-" + Guid.NewGuid().ToString("N"));
var window = new MainWindow(new SettingsStore(@"Software\OrbitPreview-" + Guid.NewGuid().ToString("N"), Path.Combine(isolated, "absent.json"), isolated));
var content = (FrameworkElement)window.Content;
window.WindowState = WindowState.Normal;
content.Width = 1100; content.Height = 680;
// Let asynchronous website icons finish without reading or altering the user's library.
var wait = new System.Windows.Threading.DispatcherFrame();
var timer = new System.Windows.Threading.DispatcherTimer { Interval = TimeSpan.FromSeconds(8) };
timer.Tick += (_, _) => { timer.Stop(); wait.Continue = false; };
timer.Start(); System.Windows.Threading.Dispatcher.PushFrame(wait);
var output = Path.Combine(Path.GetTempPath(), "OrbitThemePreview"); Directory.CreateDirectory(output);
foreach (var dark in new[] { false, true, false })
{
Theme.Apply(dark);
SetSwitch(content, dark);
content.Measure(new Size(1100, 680)); content.Arrange(new Rect(0, 0, 1100, 680)); content.UpdateLayout();
if (((SolidColorBrush)window.Background).Color != (Color)ColorConverter.ConvertFromString(dark ? "#202020" : "#FAF9F6")) throw new Exception("Window theme did not update");
var bitmap = new RenderTargetBitmap(1100, 680, 96, 96, PixelFormats.Pbgra32);
var frame = new DrawingVisual(); using (var dc = frame.RenderOpen()) { dc.DrawRectangle(window.Background, null, new Rect(0,0,1100,680)); dc.DrawRectangle(new VisualBrush(content), null, new Rect(0,0,1100,680)); }
var frame = new DrawingVisual(); using (var dc = frame.RenderOpen()) { dc.DrawRectangle(window.Background, null, new Rect(0,0,1100,680)); dc.DrawRectangle(new VisualBrush(content) { ViewboxUnits = BrushMappingMode.Absolute, Viewbox = new Rect(0,0,1100,680) }, null, new Rect(0,0,1100,680)); }
bitmap.Render(frame); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap));
using var file = File.Create(Path.Combine(output, dark ? "dark.png" : "light.png")); encoder.Save(file);
Console.WriteLine("PASS rendered " + (dark ? "dark" : "light") + " theme");
@@ -33,4 +43,9 @@ internal static class ThemeChecks
Console.WriteLine(output);
window.Close(); app.Shutdown();
}
static void SetSwitch(DependencyObject parent, bool dark)
{
if (parent is CheckBox toggle && toggle.Content as string == "Dark mode") toggle.IsChecked = dark;
for (int index = 0; index < VisualTreeHelper.GetChildrenCount(parent); index++) SetSwitch(VisualTreeHelper.GetChild(parent, index), dark);
}
}