1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-26 06:49:19 +00:00

Populate Notes panel

This was pretty easy to do with DataGrid, even with custom background
colors in some cells.  Score one for WPF.
This commit is contained in:
Andy McFadden 2019-06-12 15:54:22 -07:00
parent 9e525d1428
commit 0abc7a7587
3 changed files with 69 additions and 3 deletions

View File

@ -406,6 +406,9 @@ namespace SourceGenWPF {
// Populate the Symbols list.
PopulateSymbolsList();
// Load initial contents of Notes panel.
PopulateNotesList();
mMainWin.ShowCodeListView = true;
mNavStack.Clear();
@ -510,6 +513,9 @@ namespace SourceGenWPF {
mMainWin.SetCodeListTopIndex(topItemIndex);
mReanalysisTimer.EndTask("Restore selection and top position");
// Update the Notes list as well.
PopulateNotesList();
mReanalysisTimer.EndTask("ProjectView.ApplyChanges()");
//mReanalysisTimer.DumpTimes("ProjectView timers:", mGenerationLog);
@ -1386,6 +1392,32 @@ namespace SourceGenWPF {
#endregion References panel
#region Notes panel
private void PopulateNotesList() {
mMainWin.NotesList.Clear();
foreach (KeyValuePair<int, MultiLineComment> kvp in mProject.Notes) {
int offset = kvp.Key;
MultiLineComment mlc = kvp.Value;
// Replace line break with bullet. If there's a single CRLF at the end, strip it.
string nocrlfStr;
if (mlc.Text.EndsWith("\r\n")) {
nocrlfStr = mlc.Text.Substring(0, mlc.Text.Length - 2).Replace("\r\n", " \u2022 ");
} else {
nocrlfStr = mlc.Text.Replace("\r\n", " \u2022 ");
}
MainWindow.NotesListItem nli = new MainWindow.NotesListItem(
mOutputFormatter.FormatOffset24(offset),
nocrlfStr,
mlc.BackgroundColor);
mMainWin.NotesList.Add(nli);
}
}
#endregion Notes panel
#region Symbols panel
private void PopulateSymbolsList() {

View File

@ -256,10 +256,24 @@ limitations under the License.
<GroupBox Grid.Row="2" Header="Notes">
<DataGrid Name="notesList" IsReadOnly="True"
FontFamily="{StaticResource GeneralMonoFont}">
ItemsSource="{Binding NotesList}"
FontFamily="{StaticResource GeneralMonoFont}"
SnapsToDevicePixels="True"
GridLinesVisibility="Vertical"
VerticalGridLinesBrush="#FF7F7F7F"
AutoGenerateColumns="False"
HeadersVisibility="Column"
CanUserReorderColumns="False"
SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="Offset" Binding="{Binding Offset}"/>
<DataGridTextColumn Header="Note" Binding="{Binding Note}"/>
<DataGridTextColumn Header="Note" Binding="{Binding Note}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Background" Value="{Binding BackBrush}"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</GroupBox>

View File

@ -543,7 +543,27 @@ namespace SourceGenWPF.ProjWin {
#region Notes panel
// TODO
public class NotesListItem {
public string Offset { get; private set; }
public string Note { get; private set; }
public SolidColorBrush BackBrush { get; private set; }
public NotesListItem(string offset, string note, Color backColor) {
Offset = offset;
Note = note;
BackBrush = new SolidColorBrush(backColor);
}
public override string ToString() {
return "[NotesListItem: off=" + Offset + " note=" + Note + " brush=" +
BackBrush + "]";
}
}
public ObservableCollection<NotesListItem> NotesList { get; private set; } =
new ObservableCollection<NotesListItem>();
#endregion Notes panel