1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +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. // Populate the Symbols list.
PopulateSymbolsList(); PopulateSymbolsList();
// Load initial contents of Notes panel.
PopulateNotesList();
mMainWin.ShowCodeListView = true; mMainWin.ShowCodeListView = true;
mNavStack.Clear(); mNavStack.Clear();
@ -510,6 +513,9 @@ namespace SourceGenWPF {
mMainWin.SetCodeListTopIndex(topItemIndex); mMainWin.SetCodeListTopIndex(topItemIndex);
mReanalysisTimer.EndTask("Restore selection and top position"); mReanalysisTimer.EndTask("Restore selection and top position");
// Update the Notes list as well.
PopulateNotesList();
mReanalysisTimer.EndTask("ProjectView.ApplyChanges()"); mReanalysisTimer.EndTask("ProjectView.ApplyChanges()");
//mReanalysisTimer.DumpTimes("ProjectView timers:", mGenerationLog); //mReanalysisTimer.DumpTimes("ProjectView timers:", mGenerationLog);
@ -1386,6 +1392,32 @@ namespace SourceGenWPF {
#endregion References panel #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 #region Symbols panel
private void PopulateSymbolsList() { private void PopulateSymbolsList() {

View File

@ -256,10 +256,24 @@ limitations under the License.
<GroupBox Grid.Row="2" Header="Notes"> <GroupBox Grid.Row="2" Header="Notes">
<DataGrid Name="notesList" IsReadOnly="True" <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> <DataGrid.Columns>
<DataGridTextColumn Header="Offset" Binding="{Binding Offset}"/> <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.Columns>
</DataGrid> </DataGrid>
</GroupBox> </GroupBox>

View File

@ -543,7 +543,27 @@ namespace SourceGenWPF.ProjWin {
#region Notes panel #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 #endregion Notes panel