diff --git a/SourceGenWPF/MainController.cs b/SourceGenWPF/MainController.cs index 89e2763..386737b 100644 --- a/SourceGenWPF/MainController.cs +++ b/SourceGenWPF/MainController.cs @@ -1355,11 +1355,9 @@ namespace SourceGenWPF { } break; case LineListGen.Line.Type.Note: -#if false - if (editNoteToolStripMenuItem.Enabled) { - EditNote_Click(sender, e); + if (CanEditNote()) { + EditNote(); } -#endif break; case LineListGen.Line.Type.Code: @@ -1592,6 +1590,42 @@ namespace SourceGenWPF { } } + public bool CanEditNote() { + if (SelectionAnalysis.mNumItemsSelected != 1) { + return false; + } + EntityCounts counts = SelectionAnalysis.mEntityCounts; + // Single line, code or data, or a note. + return (counts.mDataLines > 0 || counts.mCodeLines > 0 || + SelectionAnalysis.mLineType == LineListGen.Line.Type.Note); + } + + public void EditNote() { + int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex(); + int offset = CodeLineList[selIndex].FileOffset; + + MultiLineComment oldNote; + if (!mProject.Notes.TryGetValue(offset, out oldNote)) { + oldNote = new MultiLineComment(string.Empty); + } + EditNote dlg = new EditNote(mMainWin, oldNote); + dlg.ShowDialog(); + + if (dlg.DialogResult != true) { + return; + } + + MultiLineComment newNote = dlg.Note; + if (oldNote != newNote) { + Debug.WriteLine("Changing note at +" + offset.ToString("x6")); + + UndoableChange uc = UndoableChange.CreateNoteChange(offset, + oldNote, newNote); + ChangeSet cs = new ChangeSet(uc); + ApplyUndoableChanges(cs); + } + } + public bool CanEditOperand() { if (SelectionAnalysis.mNumItemsSelected == 0) { return false; diff --git a/SourceGenWPF/SourceGenWPF.csproj b/SourceGenWPF/SourceGenWPF.csproj index 3f403ce..7844dac 100644 --- a/SourceGenWPF/SourceGenWPF.csproj +++ b/SourceGenWPF/SourceGenWPF.csproj @@ -103,6 +103,9 @@ EditLongComment.xaml + + EditNote.xaml + EditProjectProperties.xaml @@ -248,6 +251,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/SourceGenWPF/WpfGui/EditLongComment.xaml b/SourceGenWPF/WpfGui/EditLongComment.xaml index da07ba4..542a590 100644 --- a/SourceGenWPF/WpfGui/EditLongComment.xaml +++ b/SourceGenWPF/WpfGui/EditLongComment.xaml @@ -71,7 +71,7 @@ limitations under the License. IsReadOnly="True"/> -