diff --git a/README.md b/README.md index 121f982..9995c8c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/screenshots/orbit-dark.png b/docs/screenshots/orbit-dark.png new file mode 100644 index 0000000..afbc0f1 Binary files /dev/null and b/docs/screenshots/orbit-dark.png differ diff --git a/docs/screenshots/orbit-light.png b/docs/screenshots/orbit-light.png new file mode 100644 index 0000000..44599c7 Binary files /dev/null and b/docs/screenshots/orbit-light.png differ diff --git a/tests/ThemeChecks.cs b/tests/ThemeChecks.cs index 119269f..bba2007 100644 --- a/tests/ThemeChecks.cs +++ b/tests/ThemeChecks.cs @@ -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); + } }