1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-25 14:34:27 +00:00

SourceGen After Dark

Most of SourceGen uses standard WPF controls, which get their default
style from the system theme.  The main disassembly list uses a
custom style, and always looks like the Windows default theme.

Some people greatly prefer white text on a black background, so we
now provide a way to get that.  This also requires muting the colors
used for Notes, since those were chosen to contrast with black text.

This does not affect anything other than the ListView used for
code, because everything else can be set through the Windows
"personalization" interface.  We might want to change the way the
Notes window looks though, to avoid having glowing bookmarks on
the side.
This commit is contained in:
Andy McFadden 2019-10-12 17:23:32 -07:00
parent 547ecd2173
commit df2f3803f4
12 changed files with 238 additions and 35 deletions

View File

@ -69,9 +69,10 @@ namespace SourceGen {
public const string CLIP_LINE_FORMAT = "clip-line-format"; public const string CLIP_LINE_FORMAT = "clip-line-format";
// Main project view settings.
public const string PRVW_RECENT_PROJECT_LIST = "prvw-recent-project-list"; public const string PRVW_RECENT_PROJECT_LIST = "prvw-recent-project-list";
public const string SKIN_DARK_COLOR_SCHEME = "skin-dark-color-scheme";
// Symbol-list window options. // Symbol-list window options.
public const string SYMWIN_SHOW_USER = "symwin-show-user"; public const string SYMWIN_SHOW_USER = "symwin-show-user";
public const string SYMWIN_SHOW_AUTO = "symwin-show-auto"; public const string SYMWIN_SHOW_AUTO = "symwin-show-auto";

View File

@ -28,6 +28,11 @@ namespace SourceGen {
/// Converts file data and Anattrib contents into a series of strings and format metadata. /// Converts file data and Anattrib contents into a series of strings and format metadata.
/// </summary> /// </summary>
public class LineListGen { public class LineListGen {
/// <summary>
/// Color multiplier for Notes.
/// </summary>
public float NoteColorMultiplier { get; set; } = 1.0f;
/// <summary> /// <summary>
/// List of display lines. /// List of display lines.
/// </summary> /// </summary>
@ -815,7 +820,7 @@ namespace SourceGen {
out MultiLineComment headerComment)) { out MultiLineComment headerComment)) {
List<string> formatted = headerComment.FormatText(formatter, string.Empty); List<string> formatted = headerComment.FormatText(formatter, string.Empty);
StringListToLines(formatted, Line.HEADER_COMMENT_OFFSET, Line.Type.LongComment, StringListToLines(formatted, Line.HEADER_COMMENT_OFFSET, Line.Type.LongComment,
CommonWPF.Helper.ZeroColor, tmpLines); CommonWPF.Helper.ZeroColor, 1.0f, tmpLines);
} }
// Format symbols. // Format symbols.
@ -920,12 +925,12 @@ namespace SourceGen {
if (mProject.Notes.TryGetValue(offset, out MultiLineComment noteData)) { if (mProject.Notes.TryGetValue(offset, out MultiLineComment noteData)) {
List<string> formatted = noteData.FormatText(mFormatter, "NOTE: "); List<string> formatted = noteData.FormatText(mFormatter, "NOTE: ");
StringListToLines(formatted, offset, Line.Type.Note, StringListToLines(formatted, offset, Line.Type.Note,
noteData.BackgroundColor, lines); noteData.BackgroundColor, NoteColorMultiplier, lines);
} }
if (mProject.LongComments.TryGetValue(offset, out MultiLineComment longComment)) { if (mProject.LongComments.TryGetValue(offset, out MultiLineComment longComment)) {
List<string> formatted = longComment.FormatText(mFormatter, string.Empty); List<string> formatted = longComment.FormatText(mFormatter, string.Empty);
StringListToLines(formatted, offset, Line.Type.LongComment, StringListToLines(formatted, offset, Line.Type.LongComment,
longComment.BackgroundColor, lines); longComment.BackgroundColor, NoteColorMultiplier, lines);
} }
// Local variable tables come next. Defer rendering. // Local variable tables come next. Defer rendering.
@ -1115,10 +1120,11 @@ namespace SourceGen {
/// <param name="color">Background color (for Notes).</param> /// <param name="color">Background color (for Notes).</param>
/// <param name="lines">Line list to add data to.</param> /// <param name="lines">Line list to add data to.</param>
private static void StringListToLines(List<string> list, int offset, Line.Type lineType, private static void StringListToLines(List<string> list, int offset, Line.Type lineType,
Color color, List<Line> lines) { Color color, float mult, List<Line> lines) {
foreach (string str in list) { foreach (string str in list) {
Line line = new Line(offset, 0, lineType); Line line = new Line(offset, 0, lineType);
FormattedParts parts = FormattedParts.CreateNote(str, color); FormattedParts parts = FormattedParts.CreateNote(str,
Color.Multiply(color, mult));
line.Parts = parts; line.Parts = parts;
line.BackgroundColor = color; line.BackgroundColor = color;
lines.Add(line); lines.Add(line);

View File

@ -162,6 +162,11 @@ namespace SourceGen {
/// </summary> /// </summary>
private int mTargetHighlightIndex = -1; private int mTargetHighlightIndex = -1;
/// <summary>
/// Code list color scheme.
/// </summary>
private MainWindow.ColorScheme mColorScheme = MainWindow.ColorScheme.Light;
/// <summary> /// <summary>
/// CPU definition used when the Formatter was created. If the CPU choice or /// CPU definition used when the Formatter was created. If the CPU choice or
/// inclusion of undocumented opcodes changes, we need to wipe the formatter. /// inclusion of undocumented opcodes changes, we need to wipe the formatter.
@ -517,6 +522,18 @@ namespace SourceGen {
// Unpack the recent-project list. // Unpack the recent-project list.
UnpackRecentProjectList(); UnpackRecentProjectList();
// Set the color scheme.
bool useDark = settings.GetBool(AppSettings.SKIN_DARK_COLOR_SCHEME, false);
if (useDark) {
mColorScheme = MainWindow.ColorScheme.Dark;
} else {
mColorScheme = MainWindow.ColorScheme.Light;
}
mMainWin.SetColorScheme(mColorScheme);
if (CodeLineList != null) {
SetCodeLineListColorMultiplier();
}
// Enable the DEBUG menu if configured. // Enable the DEBUG menu if configured.
mMainWin.ShowDebugMenu = mMainWin.ShowDebugMenu =
AppSettings.Global.GetBool(AppSettings.DEBUG_MENU_ENABLED, false); AppSettings.Global.GetBool(AppSettings.DEBUG_MENU_ENABLED, false);
@ -531,6 +548,14 @@ namespace SourceGen {
} }
} }
private void SetCodeLineListColorMultiplier() {
if (mColorScheme == MainWindow.ColorScheme.Dark) {
CodeLineList.NoteColorMultiplier = 0.6f;
} else {
CodeLineList.NoteColorMultiplier = 1.0f;
}
}
private void UnpackRecentProjectList() { private void UnpackRecentProjectList() {
RecentProjectPaths.Clear(); RecentProjectPaths.Clear();
@ -670,6 +695,7 @@ namespace SourceGen {
private void FinishPrep() { private void FinishPrep() {
CodeLineList = new LineListGen(mProject, mMainWin.CodeDisplayList, CodeLineList = new LineListGen(mProject, mMainWin.CodeDisplayList,
mOutputFormatter, mPseudoOpNames); mOutputFormatter, mPseudoOpNames);
SetCodeLineListColorMultiplier();
string messages = mProject.LoadExternalFiles(); string messages = mProject.LoadExternalFiles();
if (messages.Length != 0) { if (messages.Length != 0) {

View File

@ -0,0 +1,51 @@
<!--
Copyright 2019 faddenSoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SourceGen.Res">
<!-- colors for ListView and ListViewItem (see CodeListItemStyle.xaml) -->
<SolidColorBrush x:Key="Brush_ListViewForeground" Color="White"/>
<SolidColorBrush x:Key="Brush_ListViewBackground" Color="Black"/>
<Color x:Key="Color_HoverFill0">#FF787D7F</Color>
<Color x:Key="Color_HoverFill1">#FF6A787F</Color>
<Color x:Key="Color_SelectedFill0">#FF6C7A7F</Color>
<Color x:Key="Color_SelectedFill1">#FF4D6E7D</Color>
<Color x:Key="Color_SelectedInactiveFill0">#FF777777</Color>
<Color x:Key="Color_SelectedInactiveFill1">#FF6E6E6E</Color>
<Color x:Key="Color_SelectedHoverFill0">#FF757C7F</Color>
<Color x:Key="Color_SelectedHoverFill1">#FF64767E</Color>
<Color x:Key="Color_HighlightedCellFill0">#FF6C7F7A</Color>
<Color x:Key="Color_HighlightedCellFill1">#FF4D7D6E</Color>
<!-- I think the selection borders need to stay bright; otherwise it's hard to see
when you've selected highlighted notes. Dim them a little with alpha. -->
<SolidColorBrush x:Key="Brush_MouseOverBorder" Color="#7FCCF0FF"/>
<SolidColorBrush x:Key="Brush_SelectedBorder" Color="#7F98DDFB"/>
<SolidColorBrush x:Key="Brush_SelectedActiveBorder" Color="#7FCFCFCF"/>
<SolidColorBrush x:Key="Brush_SelectedMouseOverBorder" Color="#7F98DDFB"/>
<!--<SolidColorBrush x:Key="Brush_MouseOverBorder" Color="#FF66787F"/>
<SolidColorBrush x:Key="Brush_SelectedBorder" Color="#FF4C6E7D"/>
<SolidColorBrush x:Key="Brush_SelectedActiveBorder" Color="#FF676767"/>
<SolidColorBrush x:Key="Brush_SelectedMouseOverBorder" Color="#FF4C6E7D"/>-->
<SolidColorBrush x:Key="Brush_UpperHighlight" Color="#757F7F7F"/>
<SolidColorBrush x:Key="Brush_SelectedUpperHighlight" Color="#407F7F7F"/>
</ResourceDictionary>

View File

@ -0,0 +1,44 @@
<!--
Copyright 2019 faddenSoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SourceGen.Res">
<!-- colors for ListView and ListViewItem (see CodeListItemStyle.xaml) -->
<SolidColorBrush x:Key="Brush_ListViewForeground" Color="Black"/>
<SolidColorBrush x:Key="Brush_ListViewBackground" Color="White"/>
<Color x:Key="Color_HoverFill0">#FFF1FBFF</Color>
<Color x:Key="Color_HoverFill1">#FFD5F1FE</Color>
<Color x:Key="Color_SelectedFill0">#FFD9F4FF</Color>
<Color x:Key="Color_SelectedFill1">#FF9BDDFB</Color>
<Color x:Key="Color_SelectedInactiveFill0">#FFEEEDED</Color>
<Color x:Key="Color_SelectedInactiveFill1">#FFDDDDDD</Color>
<Color x:Key="Color_SelectedHoverFill0">#FFEAF9FF</Color>
<Color x:Key="Color_SelectedHoverFill1">#FFC9EDFD</Color>
<Color x:Key="Color_HighlightedCellFill0">#FFD9FFF4</Color>
<Color x:Key="Color_HighlightedCellFill1">#FF9BFBDD</Color>
<SolidColorBrush x:Key="Brush_MouseOverBorder" Color="#FFCCF0FF"/>
<SolidColorBrush x:Key="Brush_SelectedBorder" Color="#FF98DDFB"/> <!-- Color_SelectedFill1? -->
<SolidColorBrush x:Key="Brush_SelectedActiveBorder" Color="#FFCFCFCF"/>
<SolidColorBrush x:Key="Brush_SelectedMouseOverBorder" Color="#FF98DDFB"/> <!-- Color_SelectedFill1? -->
<SolidColorBrush x:Key="Brush_UpperHighlight" Color="#75FFFFFF"/>
<SolidColorBrush x:Key="Brush_SelectedUpperHighlight" Color="#40FFFFFF"/>
</ResourceDictionary>

View File

@ -65,6 +65,14 @@ hex data in the code list "bytes" column from dense (<code>20edfd</code>)
to spaced (<code>20 ed fd</code>). This also affects the format of to spaced (<code>20 ed fd</code>). This also affects the format of
clipboard copies and exports.</p> clipboard copies and exports.</p>
<p>Check "use 'dark' color scheme" to change the main disassembly list
to use white text on a black background, and mute the Note highlight
colors.
(Most of the GUI uses standard Windows controls that take their colors
from the system theme, but the disassembly list uses a custom style. You
can change the rest of the UI from the Windows display "personalization"
controls.)</p>
<h3><a name="appset-textdelim">Text Delimiters</a></h3> <h3><a name="appset-textdelim">Text Delimiters</a></h3>

View File

@ -237,6 +237,14 @@
<Resource Include="Res\Logo.png" /> <Resource Include="Res\Logo.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Res\Theme_Dark.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Res\Theme_Light.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Tests\WpfGui\GenTestRunner.xaml"> <Page Include="Tests\WpfGui\GenTestRunner.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -15,8 +15,8 @@ limitations under the License.
--> -->
<!-- <!--
ListViewItem control template and style. This is used for the main code ListView. The ListView/ListViewItem control template and style. This is used for the main code ListView.
most significant consideration is getting long comments and notes into the 5th column and The most significant consideration is getting long comments and notes into the 5th column and
having them span multiple columns. Most of this came from the default style (WPF 4.5 on having them span multiple columns. Most of this came from the default style (WPF 4.5 on
Win10, default theme). Win10, default theme).
@ -29,23 +29,23 @@ See also https://github.com/fadden/DisasmUiTest
<!-- some brushes, extracted from the default style --> <!-- some brushes, extracted from the default style -->
<LinearGradientBrush x:Key="ListItemHoverFill" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="ListItemHoverFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF1FBFF" Offset="0"/> <GradientStop Color="{DynamicResource Color_HoverFill0}" Offset="0"/>
<GradientStop Color="#FFD5F1FE" Offset="1"/> <GradientStop Color="{DynamicResource Color_HoverFill1}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
<LinearGradientBrush x:Key="ListItemSelectedFill" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="ListItemSelectedFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFD9F4FF" Offset="0"/> <GradientStop Color="{DynamicResource Color_SelectedFill0}" Offset="0"/>
<GradientStop Color="#FF9BDDFB" Offset="1"/> <GradientStop Color="{DynamicResource Color_SelectedFill1}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
<LinearGradientBrush x:Key="ListItemSelectedInactiveFill" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="ListItemSelectedInactiveFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFEEEDED" Offset="0"/> <GradientStop Color="{DynamicResource Color_SelectedInactiveFill0}" Offset="0"/>
<GradientStop Color="#FFDDDDDD" Offset="1"/> <GradientStop Color="{DynamicResource Color_SelectedInactiveFill1}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
<LinearGradientBrush x:Key="ListItemSelectedHoverFill" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="ListItemSelectedHoverFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFEAF9FF" Offset="0"/> <GradientStop Color="{DynamicResource Color_SelectedHoverFill0}" Offset="0"/>
<GradientStop Color="#FFC9EDFD" Offset="1"/> <GradientStop Color="{DynamicResource Color_SelectedHoverFill1}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
<!-- Column set for the long-comment lines. The first five columns will be empty, but <!-- Column set for the long-comment lines. The first five columns will be empty, but
@ -91,7 +91,7 @@ See also https://github.com/fadden/DisasmUiTest
<RowDefinition MaxHeight="11"/> <RowDefinition MaxHeight="11"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Rectangle x:Name="UpperHighlight" Fill="#75FFFFFF" Visibility="Collapsed"/> <Rectangle x:Name="UpperHighlight" Fill="{DynamicResource Brush_SelectedUpperHighlight}" Visibility="Collapsed"/>
<GridViewRowPresenter Grid.RowSpan="2" <GridViewRowPresenter Grid.RowSpan="2"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
@ -104,15 +104,15 @@ See also https://github.com/fadden/DisasmUiTest
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true"> <Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{StaticResource ListItemHoverFill}"/> <Setter Property="Background" Value="{StaticResource ListItemHoverFill}"/>
<Setter Property="BorderBrush" Value="#FFCCF0FF"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_MouseOverBorder}"/>
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
</Trigger> </Trigger>
<Trigger Property="IsSelected" Value="true"> <Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{StaticResource ListItemSelectedFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedFill}"/>
<Setter Property="BorderBrush" Value="#FF98DDFB"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedBorder}"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/> <Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
<Setter Property="Fill" TargetName="UpperHighlight" Value="#40FFFFFF"/> <Setter Property="Fill" TargetName="UpperHighlight" Value="{DynamicResource Brush_SelectedUpperHighlight}"/>
</Trigger> </Trigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
@ -120,7 +120,7 @@ See also https://github.com/fadden/DisasmUiTest
<Condition Property="Selector.IsSelectionActive" Value="false"/> <Condition Property="Selector.IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource ListItemSelectedInactiveFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedInactiveFill}"/>
<Setter Property="BorderBrush" Value="#FFCFCFCF"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedActiveBorder}"/>
</MultiTrigger> </MultiTrigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
@ -128,7 +128,7 @@ See also https://github.com/fadden/DisasmUiTest
<Condition Property="IsMouseOver" Value="true"/> <Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource ListItemSelectedHoverFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedHoverFill}"/>
<Setter Property="BorderBrush" Value="#FF98DDFB"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedMouseOverBorder}"/>
</MultiTrigger> </MultiTrigger>
<Trigger Property="IsEnabled" Value="false"> <Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
@ -167,12 +167,12 @@ See also https://github.com/fadden/DisasmUiTest
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true"> <Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="{StaticResource ListItemHoverFill}"/> <Setter Property="Background" Value="{StaticResource ListItemHoverFill}"/>
<Setter Property="BorderBrush" Value="#FFCCF0FF"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_MouseOverBorder}"/>
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
</Trigger> </Trigger>
<Trigger Property="IsSelected" Value="true"> <Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="{StaticResource ListItemSelectedFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedFill}"/>
<Setter Property="BorderBrush" Value="#FF98DDFB"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedBorder}"/>
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/> <Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/>
<Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/> <Setter Property="Visibility" TargetName="UpperHighlight" Value="Visible"/>
<Setter Property="Fill" TargetName="UpperHighlight" Value="#40FFFFFF"/> <Setter Property="Fill" TargetName="UpperHighlight" Value="#40FFFFFF"/>
@ -183,7 +183,7 @@ See also https://github.com/fadden/DisasmUiTest
<Condition Property="Selector.IsSelectionActive" Value="false"/> <Condition Property="Selector.IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource ListItemSelectedInactiveFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedInactiveFill}"/>
<Setter Property="BorderBrush" Value="#FFCFCFCF"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedActiveBorder}"/>
</MultiTrigger> </MultiTrigger>
<MultiTrigger> <MultiTrigger>
<MultiTrigger.Conditions> <MultiTrigger.Conditions>
@ -191,7 +191,7 @@ See also https://github.com/fadden/DisasmUiTest
<Condition Property="IsMouseOver" Value="true"/> <Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions> </MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource ListItemSelectedHoverFill}"/> <Setter Property="Background" Value="{StaticResource ListItemSelectedHoverFill}"/>
<Setter Property="BorderBrush" Value="#FF98DDFB"/> <Setter Property="BorderBrush" Value="{DynamicResource Brush_SelectedMouseOverBorder}"/>
</MultiTrigger> </MultiTrigger>
<Trigger Property="IsEnabled" Value="false"> <Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
@ -202,8 +202,8 @@ See also https://github.com/fadden/DisasmUiTest
<!-- ListView style. We have to override the general foreground/background colors to <!-- ListView style. We have to override the general foreground/background colors to
avoid making the whole thing look freakish. --> avoid making the whole thing look freakish. -->
<Style x:Key="codeListStyle" TargetType="{x:Type ListView}"> <Style x:Key="codeListStyle" TargetType="{x:Type ListView}">
<Setter Property="Background" Value="White"/> <Setter Property="Foreground" Value="{DynamicResource Brush_ListViewForeground}"/>
<Setter Property="Foreground" Value="Black"/> <Setter Property="Background" Value="{DynamicResource Brush_ListViewBackground}"/>
</Style> </Style>
<Style x:Key="codeListItemStyle" TargetType="{x:Type ListViewItem}"> <Style x:Key="codeListItemStyle" TargetType="{x:Type ListViewItem}">
@ -233,8 +233,8 @@ See also https://github.com/fadden/DisasmUiTest
<!-- Highlighting for individual cells. --> <!-- Highlighting for individual cells. -->
<LinearGradientBrush x:Key="HighlightedCellFill" EndPoint="0,1" StartPoint="0,0"> <LinearGradientBrush x:Key="HighlightedCellFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFD9Fff4" Offset="0"/> <GradientStop Color="{DynamicResource Color_HighlightedCellFill0}" Offset="0"/>
<GradientStop Color="#FF9Bfbdd" Offset="1"/> <GradientStop Color="{DynamicResource Color_HighlightedCellFill1}" Offset="1"/>
</LinearGradientBrush> </LinearGradientBrush>
<DataTemplate x:Key="addrHighlightTemplate"> <DataTemplate x:Key="addrHighlightTemplate">
@ -245,7 +245,7 @@ See also https://github.com/fadden/DisasmUiTest
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding Path=HasAddrLabelHighlight}" Value="True"> <DataTrigger Binding="{Binding Path=HasAddrLabelHighlight}" Value="True">
<Setter Property="TextBlock.Background" Value="{StaticResource HighlightedCellFill}"/> <Setter Property="TextBlock.Background" Value="{StaticResource HighlightedCellFill}"/>
<Setter Property="TextBlock.Foreground" Value="Black"/> <Setter Property="TextBlock.Foreground" Value="{DynamicResource Brush_ListViewForeground}"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
@ -263,7 +263,7 @@ See also https://github.com/fadden/DisasmUiTest
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding Path=HasAddrLabelHighlight}" Value="True"> <DataTrigger Binding="{Binding Path=HasAddrLabelHighlight}" Value="True">
<Setter Property="TextBlock.Background" Value="{StaticResource HighlightedCellFill}"/> <Setter Property="TextBlock.Background" Value="{StaticResource HighlightedCellFill}"/>
<Setter Property="TextBlock.Foreground" Value="Black"/> <Setter Property="TextBlock.Foreground" Value="{DynamicResource Brush_ListViewForeground}"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>

View File

@ -129,8 +129,10 @@ limitations under the License.
<GroupBox Grid.Column="2" Grid.Row="1" Header="Miscellaneous" <GroupBox Grid.Column="2" Grid.Row="1" Header="Miscellaneous"
Margin="10,0,0,0" Padding="2,4"> Margin="10,0,0,0" Padding="2,4">
<StackPanel> <StackPanel>
<CheckBox Content="Add spaces in bytes column" <CheckBox Content="Add spaces in bytes column" Margin="0,4"
IsChecked="{Binding SpacesBetweenBytes}"/> IsChecked="{Binding SpacesBetweenBytes}"/>
<CheckBox Content="Use &quot;dark&quot; color scheme" Margin="0,4"
IsChecked="{Binding DarkColorScheme}"/>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>

View File

@ -414,6 +414,15 @@ namespace SourceGen.WpfGui {
} }
} }
public bool DarkColorScheme {
get { return mSettings.GetBool(AppSettings.SKIN_DARK_COLOR_SCHEME, false); }
set {
mSettings.SetBool(AppSettings.SKIN_DARK_COLOR_SCHEME, value);
OnPropertyChanged();
IsDirty = true;
}
}
public bool EnableDebugMenu { public bool EnableDebugMenu {
get { return mSettings.GetBool(AppSettings.DEBUG_MENU_ENABLED, false); } get { return mSettings.GetBool(AppSettings.DEBUG_MENU_ENABLED, false); }
set { set {

View File

@ -33,10 +33,10 @@ limitations under the License.
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
<!-- style and control templates for main code ListView items -->
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CodeListItemStyle.xaml"/> <ResourceDictionary Source="CodeListItemStyle.xaml"/>
<ResourceDictionary Source="../Res/CommandIcons.xaml"/> <ResourceDictionary Source="/Res/CommandIcons.xaml"/>
<!--<ResourceDictionary Source="/Res/Theme_Light.xaml"/>-->
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<BooleanToVisibilityConverter x:Key="BoolToVis"/> <BooleanToVisibilityConverter x:Key="BoolToVis"/>

View File

@ -157,6 +157,12 @@ namespace SourceGen.WpfGui {
// Handle to protected ListView.SetSelectedItems() method // Handle to protected ListView.SetSelectedItems() method
private MethodInfo listViewSetSelectedItems; private MethodInfo listViewSetSelectedItems;
// Color theme.
public enum ColorScheme { Unknown = 0, Light, Dark };
private ColorScheme mColorScheme;
private ResourceDictionary mLightTheme;
private ResourceDictionary mDarkTheme;
public MainWindow() { public MainWindow() {
Debug.WriteLine("START at " + DateTime.Now.ToLocalTime()); Debug.WriteLine("START at " + DateTime.Now.ToLocalTime());
@ -173,6 +179,16 @@ namespace SourceGen.WpfGui {
this.DataContext = this; this.DataContext = this;
mLightTheme = new ResourceDictionary() {
Source = new Uri("/Res/Theme_Light.xaml", UriKind.Relative)
};
mDarkTheme = new ResourceDictionary() {
Source = new Uri("/Res/Theme_Dark.xaml", UriKind.Relative)
};
Resources.MergedDictionaries.Add(mLightTheme);
mColorScheme = ColorScheme.Light;
CodeDisplayList = new DisplayList(); CodeDisplayList = new DisplayList();
codeListView.ItemsSource = CodeDisplayList; codeListView.ItemsSource = CodeDisplayList;
// https://dlaa.me/blog/post/9425496 to re-auto-size after data added (this may // https://dlaa.me/blog/post/9425496 to re-auto-size after data added (this may
@ -421,6 +437,38 @@ namespace SourceGen.WpfGui {
} }
} }
/// <summary>
/// Sets the primary color scheme.
/// </summary>
/// <remarks>
/// H/T http://www.markodevcic.com/post/changing_wpf_themes_dynamically
/// </remarks>
public void SetColorScheme(ColorScheme newScheme) {
if (mColorScheme == newScheme) {
// nothing to do
return;
}
ResourceDictionary oldDict, newDict;
if (mColorScheme == ColorScheme.Light) {
oldDict = mLightTheme;
} else {
oldDict = mDarkTheme;
}
if (newScheme == ColorScheme.Light) {
newDict = mLightTheme;
} else {
newDict = mDarkTheme;
}
Debug.WriteLine("Changing color scheme from " + mColorScheme + " to " + newScheme +
" (dict count=" + Resources.MergedDictionaries.Count + ")");
Resources.MergedDictionaries.Remove(oldDict);
Resources.MergedDictionaries.Add(newDict);
mColorScheme = newScheme;
}
#region Window placement #region Window placement
// //