1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Implement long-comment editing

We can now Edit Long Comment and Edit Header Comment.

Changing the number of lines in a long comment exposed a bug in the
display list update.  Fixed.

Running the WinForms version trashed the column widths, which exposed
the fact that the default column widths were set too narrow.  Fixed.

On an unrelated note, hitting undo/redo quickly will sometimes leave
you scrolled to the bottom of the code list.  Some sort of command-
handling race in the WPF framework?  (Not fixed.)
This commit is contained in:
Andy McFadden 2019-07-07 16:18:46 -07:00
parent 1685e37c02
commit 99b484df4c
9 changed files with 408 additions and 72 deletions

View File

@ -23,7 +23,8 @@ limitations under the License.
mc:Ignorable="d"
Title="Generate and Assemble"
Width="800" Height="700" MinWidth="600" MinHeight="600" ResizeMode="CanResizeWithGrip"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Loaded="Window_Loaded">
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>

View File

@ -277,12 +277,12 @@ namespace SourceGenWPF {
mList.Add(null);
}
SelectedIndices = new DisplayListSelection(size);
// send one big notification at the end; "reset" means "forget everything you knew"
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerName);
OnCollectionReset();
SelectedIndices = new DisplayListSelection(size);
}
/// <summary>
@ -294,7 +294,7 @@ namespace SourceGenWPF {
/// <param name="newCount">Number of new lines. May be zero.</param>
public void ClearListSegment(int startIndex, int oldCount, int newCount) {
Debug.WriteLine("ClearListSegment start=" + startIndex + " old=" + oldCount +
" new=" + newCount);
" new=" + newCount + " (mList.Count=" + mList.Count + ")");
Debug.Assert(startIndex >= 0 && startIndex < mList.Count);
Debug.Assert(oldCount > 0 && startIndex + oldCount < mList.Count);
@ -307,6 +307,11 @@ namespace SourceGenWPF {
mList.Insert(startIndex, null);
}
// TODO: can we null out existing entries, and just insert/remove when counts differ?
if (oldCount != newCount) {
SelectedIndices = new DisplayListSelection(mList.Count);
}
OnPropertyChanged(CountString);
OnPropertyChanged(IndexerName);
OnCollectionReset();

View File

@ -576,7 +576,9 @@ namespace SourceGenWPF {
/// </summary>
public void GenerateAll() {
mLineList.Clear();
GenerateHeaderLines(mProject, mFormatter, mPseudoOpNames, mLineList);
List<Line> headerLines = GenerateHeaderLines(mProject, mFormatter, mPseudoOpNames);
mLineList.InsertRange(0, headerLines);
GenerateLineList(mProject, mFormatter, mPseudoOpNames,
0, mProject.FileData.Length - 1, mLineList);
@ -594,10 +596,22 @@ namespace SourceGenWPF {
/// <param name="endOffset">End offset (inclusive).</param>
public void GenerateRange(int startOffset, int endOffset) {
if (startOffset < 0) {
ClearHeaderLines();
GenerateHeaderLines(mProject, mFormatter, mPseudoOpNames, mLineList);
// Clear existing header lines. Find the first non-header item.
int headerEndIndex = FindLineByOffset(mLineList, 0);
if (headerEndIndex == 0) {
// no header lines present
Debug.WriteLine("No header lines found");
} else {
Debug.WriteLine("Removing " + headerEndIndex + " header lines");
mLineList.RemoveRange(0, headerEndIndex);
}
List<Line> headerLines = GenerateHeaderLines(mProject, mFormatter, mPseudoOpNames);
mLineList.InsertRange(0, headerLines);
mDisplayList.ClearListSegment(0, headerEndIndex, headerLines.Count);
if (endOffset < 0) {
// nothing else to do
// nothing else to do -- header-only change
return;
}
// do the rest
@ -708,21 +722,20 @@ namespace SourceGenWPF {
return true;
}
/// <summary>
/// Removes all header lines from the display list.
/// </summary>
private void ClearHeaderLines() {
// Find the first non-header item.
int endIndex = FindLineByOffset(mLineList, 0);
if (endIndex == 0) {
// no header lines present
Debug.WriteLine("No header lines found");
return;
}
Debug.WriteLine("Removing " + endIndex + " header lines");
mLineList.RemoveRange(0, endIndex);
mDisplayList.ClearListSegment(0, endIndex, 0);
}
///// <summary>
///// Removes all header lines from the line list.
///// </summary>
//private void ClearHeaderLines() {
// // Find the first non-header item.
// int endIndex = FindLineByOffset(mLineList, 0);
// if (endIndex == 0) {
// // no header lines present
// Debug.WriteLine("No header lines found");
// return;
// }
// Debug.WriteLine("Removing " + endIndex + " header lines");
// mLineList.RemoveRange(0, endIndex);
//}
/// <summary>
/// Generates a synthetic offset for the FileOffset field from an index value. The
@ -745,18 +758,14 @@ namespace SourceGenWPF {
}
/// <summary>
/// Generates the header lines (header comment, EQU directives), and inserts them at
/// the top of the list.
///
/// This does not currently do incremental generation. Call ClearHeaderLines() before
/// calling here if you're not starting with an empty list.
/// Generates the header lines (header comment, EQU directives).
/// </summary>
/// <param name="proj">Project reference.</param>
/// <param name="formatter">Output formatter.</param>
/// <param name="opNames">Pseudo-op names.</param>
/// <param name="fullLines">List to add output lines to.</param>
private static void GenerateHeaderLines(DisasmProject proj, Formatter formatter,
PseudoOp.PseudoOpNames opNames, List<Line> fullLines) {
/// <returns>List with header lines.</returns>
private static List<Line> GenerateHeaderLines(DisasmProject proj, Formatter formatter,
PseudoOp.PseudoOpNames opNames) {
List<Line> tmpLines = new List<Line>();
Line line;
FormattedParts parts;
@ -793,7 +802,7 @@ namespace SourceGenWPF {
tmpLines.Add(line);
}
fullLines.InsertRange(0, tmpLines);
return tmpLines;
}
/// <summary>

View File

@ -212,6 +212,9 @@ namespace SourceGenWPF {
mMainWin.UpdateRecentLinks();
ProcessCommandLine();
// Create an initial value.
SelectionAnalysis = UpdateSelectionState();
}
private void ProcessCommandLine() {
@ -1210,11 +1213,9 @@ namespace SourceGenWPF {
}
break;
case LineListGen.Line.Type.LongComment:
#if false
if (editLongCommentToolStripMenuItem.Enabled) {
EditLongComment_Click(sender, e);
if (CanEditLongComment()) {
EditLongComment();
}
#endif
break;
case LineListGen.Line.Type.Note:
#if false
@ -1355,6 +1356,10 @@ namespace SourceGenWPF {
}
}
public void EditHeaderComment() {
EditLongComment(LineListGen.Line.HEADER_COMMENT_OFFSET);
}
public bool CanEditLabel() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
@ -1395,12 +1400,48 @@ namespace SourceGenWPF {
}
}
public bool CanEditLongComment() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
}
EntityCounts counts = SelectionAnalysis.mEntityCounts;
// Single line, code or data, or a long comment.
return (counts.mDataLines > 0 || counts.mCodeLines > 0 ||
SelectionAnalysis.mLineType == LineListGen.Line.Type.LongComment);
}
public void EditLongComment() {
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
int offset = CodeLineList[selIndex].FileOffset;
EditLongComment(offset);
}
private void EditLongComment(int offset) {
EditLongComment dlg = new EditLongComment(mMainWin, mOutputFormatter);
if (mProject.LongComments.TryGetValue(offset, out MultiLineComment oldComment)) {
dlg.LongComment = oldComment;
}
dlg.ShowDialog();
if (dlg.DialogResult == true) {
MultiLineComment newComment = dlg.LongComment;
if (oldComment != newComment) {
Debug.WriteLine("Changing long comment at +" + offset.ToString("x6"));
UndoableChange uc = UndoableChange.CreateLongCommentChange(offset,
oldComment, newComment);
ChangeSet cs = new ChangeSet(uc);
ApplyUndoableChanges(cs);
}
}
}
public bool CanEditStatusFlags() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
}
EntityCounts counts = SelectionAnalysis.mEntityCounts;
// Line must be code, or a RegWidth directive.
// Single line, must be code or a RegWidth directive.
return (SelectionAnalysis.mLineType == LineListGen.Line.Type.Code ||
SelectionAnalysis.mLineType == LineListGen.Line.Type.RegWidthDirective);
}

View File

@ -90,6 +90,9 @@
<Compile Include="WpfGui\EditLabel.xaml.cs">
<DependentUpon>EditLabel.xaml</DependentUpon>
</Compile>
<Compile Include="WpfGui\EditLongComment.xaml.cs">
<DependentUpon>EditLongComment.xaml</DependentUpon>
</Compile>
<Compile Include="WpfGui\EditProjectProperties.xaml.cs">
<DependentUpon>EditProjectProperties.xaml</DependentUpon>
</Compile>
@ -213,6 +216,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WpfGui\EditLongComment.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WpfGui\EditProjectProperties.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,78 @@
<!--
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="SourceGenWPF.WpfGui.EditLongComment"
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:SourceGenWPF.WpfGui"
mc:Ignorable="d"
Title="Edit Long Comment"
Width="584" Height="700" MinWidth="584" MinHeight="600" ResizeMode="CanResizeWithGrip"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
Closing="Window_Closing">
<Window.Resources>
<RoutedUICommand x:Key="CloseCmd">
<RoutedUICommand.InputGestures>
<KeyGesture>Ctrl+Enter</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="{StaticResource CloseCmd}" Executed="CloseCmd_Executed"/>
</Window.CommandBindings>
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Enter comment text:"/>
<TextBox Name="entryTextBox" Grid.Row="1"
Text="{Binding UserInput, UpdateSourceTrigger=PropertyChanged,
FallbackValue=01234567890123456789012345678901234567890123456789012345678901234567890123456789}"
FontFamily="{StaticResource GeneralMonoFont}" VerticalScrollBarVisibility="Visible"
AcceptsReturn="True" TextWrapping="Wrap"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,20,0,0">
<TextBlock Text="Maximum line width:"/>
<ComboBox Name="maxWidthComboBox" Width="75" Margin="8,0,0,0"
ItemsSource="{Binding LineWidthItems}" SelectionChanged="MaxWidthComboBox_SelectionChanged"/>
<CheckBox Content="Render in box" Margin="40,1,0,0" IsChecked="{Binding RenderInBox}"/>
</StackPanel>
<TextBlock Grid.Row="3" Text="Expected output:" Margin="0,20,0,0"/>
<TextBox Name="displayTextBox" Grid.Row="4"
Text="{Binding TextOutput,
FallbackValue=01234567890123456789012345678901234567890123456789012345678901234567890123456789}"
FontFamily="{StaticResource GeneralMonoFont}" VerticalScrollBarVisibility="Visible"
IsReadOnly="True"/>
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0">
<Button Content="OK" IsDefault="True" Width="70" Click="OkButton_Clicked"/>
<Button Content="Cancel" IsCancel="True" Width="70" Margin="4,0,0,0"/>
</StackPanel>
</Grid>
</Window>

View File

@ -0,0 +1,177 @@
/*
* 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.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace SourceGenWPF.WpfGui {
/// <summary>
/// Long comment editor.
/// </summary>
public partial class EditLongComment : Window, INotifyPropertyChanged {
/// <summary>
/// Get or set the multi-line comment object. On exit, will be set to null if
/// the user wants to delete the comment.
/// </summary>
public MultiLineComment LongComment { get; set; }
private Asm65.Formatter mFormatter;
public bool RenderInBox {
get { return mRenderInBox; }
set {
mRenderInBox = value;
OnPropertyChanged();
FormatInput();
}
}
private bool mRenderInBox;
/// <summary>
/// Text input by user. This is bound to the input TextBox.
/// </summary>
public string UserInput {
get { return mUserInput; }
set {
mUserInput = value;
OnPropertyChanged();
FormatInput();
}
}
private string mUserInput;
/// <summary>
/// Generated text output. This is bound to the output TextBox.
/// </summary>
public string TextOutput {
get { return mTextOutput; }
set {
mTextOutput = value;
OnPropertyChanged();
}
}
private string mTextOutput;
// INotifyPropertyChanged implementation
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
/// <summary>
/// ItemsSource for line width combo box.
/// </summary>
public int[] LineWidthItems { get; } = new int[] { 30, 40, 64, 80 };
public EditLongComment(Window owner, Asm65.Formatter formatter) {
InitializeComponent();
Owner = owner;
DataContext = this;
mFormatter = formatter;
LongComment = new MultiLineComment(string.Empty);
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
Debug.Assert(LongComment != null);
UserInput = LongComment.Text;
RenderInBox = LongComment.BoxMode;
// Try to find a match for the max width specified in the MLC.
maxWidthComboBox.SelectedIndex = 0;
for (int i = 0; i < maxWidthComboBox.Items.Count; i++) {
if ((int)maxWidthComboBox.Items[i] == LongComment.MaxWidth) {
maxWidthComboBox.SelectedIndex = i;
break;
}
}
FormatInput();
entryTextBox.Focus();
}
private void OkButton_Clicked(object sender, RoutedEventArgs e) {
DialogResult = true;
}
// Handle Ctrl+Enter as a way to close the dialog, since plain Enter just
// moves to a new line.
private void CloseCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
DialogResult = true;
}
private void Window_Closing(object sender, CancelEventArgs e) {
if (string.IsNullOrEmpty(UserInput)) {
LongComment = null;
} else {
LongComment = CreateMLC();
}
}
private void MaxWidthComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
FormatInput();
}
/// <summary>
/// Formats entryTextBox.Text into displayTextBox.Text.
/// </summary>
private void FormatInput() {
if (!IsLoaded) {
return;
}
MultiLineComment mlc = CreateMLC();
if (mlc == null) {
return;
}
List<string> lines = mlc.FormatText(mFormatter, string.Empty);
StringBuilder sb = new StringBuilder(UserInput.Length + lines.Count * 2);
//sb.AppendFormat("### got {0} lines\r\n", lines.Count);
bool first = true;
foreach (string line in lines) {
if (first) {
first = false;
} else {
sb.Append("\r\n");
}
sb.Append(line);
}
TextOutput = sb.ToString();
}
/// <summary>
/// Creates a MultiLineComment from the current state of the dialog.
/// </summary>
/// <returns>New MultiLineComment object. Returns null if the dialog is still
/// in the process of initializing.</returns>
private MultiLineComment CreateMLC() {
if (maxWidthComboBox.SelectedItem == null) {
return null; // still initializing
}
return new MultiLineComment(UserInput, RenderInBox,
(int)maxWidthComboBox.SelectedItem);
}
}
}

View File

@ -57,11 +57,17 @@ limitations under the License.
<RoutedUICommand x:Key="DebugSourceGenerationTestsCmd" Text="Source Generation Tests..."/>
<RoutedUICommand x:Key="EditAddressCmd" Text="Set Address..."/>
<RoutedUICommand x:Key="EditAppSettingsCmd" Text="Settings..."/>
<RoutedUICommand x:Key="EditHeaderCommentCmd" Text="Edit Header Comment..."/>
<RoutedUICommand x:Key="EditLabelCmd" Text="Edit Label...">
<RoutedUICommand.InputGestures>
<KeyGesture>Ctrl+L</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
<RoutedUICommand x:Key="EditLongCommentCmd" Text="Edit Long Comment...">
<RoutedUICommand.InputGestures>
<KeyGesture>Ctrl+M</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
<RoutedUICommand x:Key="EditStatusFlagsCmd" Text="Override Status Flags..."/>
<RoutedUICommand x:Key="ExitCmd" Text="Exit"/>
<RoutedUICommand x:Key="FindNextCmd" Text="Find Next">
@ -128,8 +134,12 @@ limitations under the License.
Executed="DebugSourceGenerationTestsCmd_Executed"/>
<CommandBinding Command="{StaticResource EditAddressCmd}"
CanExecute="CanEditAddress" Executed="EditAddressCmd_Executed"/>
<CommandBinding Command="{StaticResource EditHeaderCommentCmd}"
CanExecute="IsProjectOpen" Executed="EditHeaderCommentCmd_Executed"/>
<CommandBinding Command="{StaticResource EditLabelCmd}"
CanExecute="CanEditLabel" Executed="EditLabelCmd_Executed"/>
<CommandBinding Command="{StaticResource EditLongCommentCmd}"
CanExecute="CanEditLongComment" Executed="EditLongCommentCmd_Executed"/>
<CommandBinding Command="{StaticResource EditStatusFlagsCmd}"
CanExecute="CanEditStatusFlags" Executed="EditStatusFlagsCmd_Executed"/>
<CommandBinding Command="{StaticResource ExitCmd}"
@ -204,7 +214,7 @@ limitations under the License.
<MenuItem Command="{StaticResource FindNextCmd}"/>
<MenuItem Command="{StaticResource GotoCmd}"/>
<Separator/>
<MenuItem Header="Edit Header Comment..."/>
<MenuItem Command="{StaticResource EditHeaderCommentCmd}"/>
<MenuItem Command="Properties" Header="Project Properties..."/>
<MenuItem Header="Toggle Data Scan"/> <!-- Ctrl+D -->
<Separator/>
@ -216,7 +226,7 @@ limitations under the License.
<MenuItem Command="{StaticResource EditLabelCmd}"/>
<MenuItem Header="Edit Operand..."/> <!-- Ctrl+O -->
<MenuItem Header="Edit Comment..."/> <!-- Ctrl+; -->
<MenuItem Header="Edit Long Comment..."/> <!-- Ctrl+M -->
<MenuItem Command="{StaticResource EditLongCommentCmd}"/>
<MenuItem Header="Edit Note..."/> <!-- Ctrl+N -->
<MenuItem Header="Edit Project Symbol..."/>
<Separator/>
@ -428,23 +438,23 @@ limitations under the License.
</ListView.Resources>
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="Offset" Width="58"
<GridViewColumn Header="Offset" Width="60"
DisplayMemberBinding="{Binding Offset}"/>
<GridViewColumn Header="Addr" Width="58"
<GridViewColumn Header="Addr" Width="60"
CellTemplate="{StaticResource addrHighlightTemplate}"/>
<GridViewColumn Header="Bytes" Width="85"
<GridViewColumn Header="Bytes" Width="93"
DisplayMemberBinding="{Binding Bytes}"/>
<GridViewColumn Header="Flags" Width="78"
<GridViewColumn Header="Flags" Width="80"
DisplayMemberBinding="{Binding Flags}"/>
<GridViewColumn Header="Attr" Width="52"
<GridViewColumn Header="Attr" Width="54"
DisplayMemberBinding="{Binding Attr}"/>
<GridViewColumn Header="Label" Width="71"
<GridViewColumn Header="Label" Width="73"
CellTemplate="{StaticResource labelHighlightTemplate}"/>
<GridViewColumn Header="Opcode" Width="58"
<GridViewColumn Header="Opcode" Width="60"
DisplayMemberBinding="{Binding Opcode}"/>
<GridViewColumn Header="Operand" Width="98"
<GridViewColumn Header="Operand" Width="100"
DisplayMemberBinding="{Binding Operand}"/>
<GridViewColumn Header="Comment" Width="342"
<GridViewColumn Header="Comment" Width="344"
DisplayMemberBinding="{Binding Comment}"/>
</GridView>
</ListView.View>

View File

@ -730,39 +730,39 @@ namespace SourceGenWPF.WpfGui {
#region Can-execute handlers
/// <summary>
/// Returns true if the project is open.
/// </summary>
/// <returns></returns>
private bool IsProjectOpen() {
return mMainCtrl != null && mMainCtrl.IsProjectOpen();
}
/// <summary>
/// Returns true if the project is open. Intended for use in XAML CommandBindings.
/// </summary>
private void IsProjectOpen(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mMainCtrl != null && mMainCtrl.IsProjectOpen();
e.CanExecute = IsProjectOpen();
}
private void CanEditAddress(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
e.CanExecute = false;
return;
}
e.CanExecute = mMainCtrl.CanEditAddress();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditAddress();
}
private void CanEditLabel(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
e.CanExecute = false;
return;
}
e.CanExecute = mMainCtrl.CanEditLabel();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLabel();
}
private void CanEditLongComment(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLongComment();
}
private void CanEditStatusFlags(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
e.CanExecute = false;
return;
}
e.CanExecute = mMainCtrl.CanEditStatusFlags();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditStatusFlags();
}
private void CanHintAsCodeEntryPoint(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
if (!IsProjectOpen()) {
e.CanExecute = false;
return;
}
@ -771,7 +771,7 @@ namespace SourceGenWPF.WpfGui {
(counts.mDataHints != 0 || counts.mInlineDataHints != 0 || counts.mNoHints != 0);
}
private void CanHintAsDataStart(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
if (!IsProjectOpen()) {
e.CanExecute = false;
return;
}
@ -780,7 +780,7 @@ namespace SourceGenWPF.WpfGui {
(counts.mCodeHints != 0 || counts.mInlineDataHints != 0 || counts.mNoHints != 0);
}
private void CanHintAsInlineData(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
if (!IsProjectOpen()) {
e.CanExecute = false;
return;
}
@ -789,7 +789,7 @@ namespace SourceGenWPF.WpfGui {
(counts.mCodeHints != 0 || counts.mDataHints != 0 || counts.mNoHints != 0);
}
private void CanRemoveHints(object sender, CanExecuteRoutedEventArgs e) {
if (mMainCtrl == null || !mMainCtrl.IsProjectOpen()) {
if (!IsProjectOpen()) {
e.CanExecute = false;
return;
}
@ -799,17 +799,17 @@ namespace SourceGenWPF.WpfGui {
}
private void CanNavigateBackward(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mMainCtrl != null && mMainCtrl.CanNavigateBackward();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanNavigateBackward();
}
private void CanNavigateForward(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mMainCtrl != null && mMainCtrl.CanNavigateForward();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanNavigateForward();
}
private void CanRedo(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mMainCtrl != null && mMainCtrl.CanRedo();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanRedo();
}
private void CanUndo(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = mMainCtrl != null && mMainCtrl.CanUndo();
e.CanExecute = IsProjectOpen() && mMainCtrl.CanUndo();
}
#endregion Can-execute handlers
@ -844,10 +844,18 @@ namespace SourceGenWPF.WpfGui {
mMainCtrl.EditAppSettings();
}
private void EditHeaderCommentCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditHeaderComment();
}
private void EditLabelCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditLabel();
}
private void EditLongCommentCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditLongComment();
}
private void EditStatusFlagsCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditStatusFlags();
}