mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-26 12:18:26 +00:00
Add message list, part 1
This converts the "problem list viewer" tool to a grid that appears below the code list view when non-empty. Not all messages are problems, so it's being renamed to "message list".
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<Window x:Class="SourceGen.Tools.WpfGui.ProblemListViewer"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SourceGen.Tools.WpfGui"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
mc:Ignorable="d"
|
||||
Title="Problems" ShowInTaskbar="True"
|
||||
Height="500" Width="500" ResizeMode="CanResizeWithGrip"
|
||||
Loaded="Window_Loaded">
|
||||
|
||||
<Window.Resources>
|
||||
<system:String x:Key="str_HiddenLabel">Hidden label</system:String>
|
||||
<system:String x:Key="str_UnresolvedWeakRef">Ref'd symbol not found</system:String>
|
||||
<system:String x:Key="str_InvalidOffsetOrLength">Invalid offset or len</system:String>
|
||||
<system:String x:Key="str_InvalidDescriptor">Invalid format desc</system:String>
|
||||
|
||||
<system:String x:Key="str_LabelIgnored">Label ignored</system:String>
|
||||
<system:String x:Key="str_FormatDescriptorIgnored">Format ignored</system:String>
|
||||
</Window.Resources>
|
||||
|
||||
<DockPanel Margin="8">
|
||||
<TextBlock DockPanel.Dock="Top" Text="Problems detected during analysis:"/>
|
||||
|
||||
<DataGrid DockPanel.Dock="Bottom" Name="problemsGrid" Margin="0,4,0,0"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding FormattedProblems}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
SnapsToDevicePixels="True"
|
||||
GridLinesVisibility="Vertical"
|
||||
VerticalGridLinesBrush="#FF7F7F7F"
|
||||
AutoGenerateColumns="False"
|
||||
HeadersVisibility="Column"
|
||||
CanUserReorderColumns="False"
|
||||
SelectionMode="Single">
|
||||
<!-- should probably add ellipsis: https://stackoverflow.com/a/12880111/294248 -->
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Severity" Width="64" Binding="{Binding Severity}"/>
|
||||
<DataGridTextColumn Header="Offset" Width="53" Binding="{Binding Offset}"/>
|
||||
<DataGridTextColumn Header="Type" Width="119" Binding="{Binding Type}"/>
|
||||
<DataGridTextColumn Header="Context" Width="119" Binding="{Binding Context}"/>
|
||||
<DataGridTextColumn Header="Resolution" Width="119" Binding="{Binding Resolution}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
namespace SourceGen.Tools.WpfGui {
|
||||
/// <summary>
|
||||
/// Floating problem list window.
|
||||
/// </summary>
|
||||
public partial class ProblemListViewer : Window, INotifyPropertyChanged {
|
||||
public class ProblemsListItem {
|
||||
public string Severity { get; private set; }
|
||||
public string Offset { get; private set; }
|
||||
public string Type { get; private set; }
|
||||
public string Context { get; private set; }
|
||||
public string Resolution { get; private set; }
|
||||
|
||||
public ProblemsListItem(string severity, string offset, string type, string context,
|
||||
string resolution) {
|
||||
Severity = severity;
|
||||
Offset = offset;
|
||||
Type = type;
|
||||
Context = context;
|
||||
Resolution = resolution;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reference to project.
|
||||
/// </summary>
|
||||
private DisasmProject mProject;
|
||||
|
||||
/// <summary>
|
||||
/// Text formatter.
|
||||
/// </summary>
|
||||
private Asm65.Formatter mFormatter;
|
||||
|
||||
/// <summary>
|
||||
/// ItemsSource for DataGrid.
|
||||
/// </summary>
|
||||
public ObservableCollection<ProblemsListItem> FormattedProblems { get; private set; } =
|
||||
new ObservableCollection<ProblemsListItem>();
|
||||
|
||||
// INotifyPropertyChanged implementation
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
|
||||
public ProblemListViewer(Window owner, DisasmProject project, Asm65.Formatter formatter) {
|
||||
InitializeComponent();
|
||||
Owner = owner;
|
||||
DataContext = this;
|
||||
|
||||
mProject = project;
|
||||
mFormatter = formatter;
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the contents of the DataGrid to the current values in mProject.Problems.
|
||||
/// </summary>
|
||||
public void Update() {
|
||||
FormattedProblems.Clear();
|
||||
|
||||
foreach (ProblemList.ProblemEntry entry in mProject.Problems) {
|
||||
ProblemsListItem newItem = FormatEntry(entry);
|
||||
FormattedProblems.Add(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
private ProblemsListItem FormatEntry(ProblemList.ProblemEntry entry) {
|
||||
string severity = entry.Severity.ToString(); // enum
|
||||
string offset = mFormatter.FormatOffset24(entry.Offset);
|
||||
|
||||
string problem;
|
||||
switch (entry.Problem) {
|
||||
case ProblemList.ProblemEntry.ProblemType.HiddenLabel:
|
||||
problem = (string)FindResource("str_HiddenLabel");
|
||||
break;
|
||||
case ProblemList.ProblemEntry.ProblemType.UnresolvedWeakRef:
|
||||
problem = (string)FindResource("str_UnresolvedWeakRef");
|
||||
break;
|
||||
case ProblemList.ProblemEntry.ProblemType.InvalidOffsetOrLength:
|
||||
problem = (string)FindResource("str_InvalidOffsetOrLength");
|
||||
break;
|
||||
case ProblemList.ProblemEntry.ProblemType.InvalidDescriptor:
|
||||
problem = (string)FindResource("str_InvalidDescriptor");
|
||||
break;
|
||||
default:
|
||||
problem = "???";
|
||||
break;
|
||||
}
|
||||
|
||||
string context = entry.Context.ToString();
|
||||
|
||||
string resolution;
|
||||
switch (entry.Resolution) {
|
||||
case ProblemList.ProblemEntry.ProblemResolution.LabelIgnored:
|
||||
resolution = (string)FindResource("str_LabelIgnored");
|
||||
break;
|
||||
case ProblemList.ProblemEntry.ProblemResolution.FormatDescriptorIgnored:
|
||||
resolution = (string)FindResource("str_FormatDescriptorIgnored");
|
||||
break;
|
||||
default:
|
||||
resolution = "???";
|
||||
break;
|
||||
}
|
||||
|
||||
return new ProblemsListItem(severity, offset, problem, context, resolution);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user