Skip to content

Commit 6eba060

Browse files
committed
Copy as colored HTML: improved synchronization with application theme
1 parent 5a8bdb2 commit 6eba060

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/CodeSnip/MainWindow.xaml.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using CodeSnip.Services.Exporters;
44
using CodeSnip.Views.HighlightingEditorView;
55
using CodeSnip.Views.SnippetView;
6+
using ControlzEx.Theming;
67
using ICSharpCode.AvalonEdit;
78
using ICSharpCode.AvalonEdit.Document;
89
using ICSharpCode.AvalonEdit.Folding;
@@ -574,7 +575,17 @@ private void CopyAsHtmlColored_Click(object sender, RoutedEventArgs e)
574575
var htmlOptions = new ICSharpCode.AvalonEdit.Highlighting.HtmlOptions();
575576
string fragment = selection.CreateHtmlFragment(htmlOptions);
576577

577-
string wrappedHtml = $"<div>{fragment}</div>";
578+
var theme = ThemeManager.Current.DetectTheme(Application.Current);
579+
string backgroundColor = "white";
580+
string foregroundColor = "black";
581+
582+
if (theme != null && theme.BaseColorScheme.Equals("Dark", StringComparison.OrdinalIgnoreCase))
583+
{
584+
backgroundColor = "#252525";
585+
foregroundColor = "white";
586+
}
587+
588+
string wrappedHtml = $"<div style=\"background-color: {backgroundColor}; color: {foregroundColor};\">{fragment}</div>";
578589

579590
try
580591
{

0 commit comments

Comments
 (0)