Skip to content

Commit

Permalink
Add a button to provide a visible UI element to allow editing the que…
Browse files Browse the repository at this point in the history
…st name and

URL.
  • Loading branch information
Kinematics committed Apr 17, 2015
1 parent 688da89 commit 9c634ac
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
5 changes: 3 additions & 2 deletions NetTally/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<Canvas x:Name="editDescriptorCanvas" Height="30" Margin="10,10,227,0" VerticalAlignment="Top" Visibility="Hidden">
<TextBlock x:Name="editDescriptor" FontSize="18" Foreground="BlueViolet" Text="Quest Name" Canvas.Top="3" Canvas.Right="4"/>
</Canvas>
<Button x:Name="editNameButton" Content="Edit Name" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Width="125" Click="editNameButton_Click"
IsEnabled="{Binding ElementName=tallyButton, Path=IsEnabled, Converter={StaticResource BoolConverter}, ConverterParameter=Normal, Mode=OneWay}"/>
<TextBox x:Name="startPost" HorizontalAlignment="Left" Height="30" Margin="140,45,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="84"
Text="{Binding Path=CurrentItem.StartPost, ValidatesOnExceptions=True}" GotFocus="textEntry_GotFocus" PreviewMouseDown="textEntry_PreviewMouseDown" MaxLines="1"
IsEnabled="{Binding ElementName=tallyButton, Path=IsEnabled, Converter={StaticResource BoolConverter}, ConverterParameter=Normal, Mode=OneWay}"/>
Expand Down Expand Up @@ -68,8 +70,7 @@
IsEnabled="{Binding ElementName=tallyButton, Path=IsEnabled, Converter={StaticResource BoolConverter}, ConverterParameter=Invert, Mode=OneWay}" Click="cancelTally_Click"/>
<Button x:Name="copyToClipboardButton" Content="Copy to Clipboard" Margin="0,66,10,0" HorizontalAlignment="Right" Width="113"
Click="copyToClipboardButton_Click" Height="30" VerticalAlignment="Top"/>
<TextBox x:Name="resultsWindow" Margin="10,101,10,10" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" IsReadOnly="True" FontSize="13.333"
<TextBox x:Name="resultsWindow" Margin="10,107,10,10" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" IsReadOnly="True" FontSize="13.333"
Text="{Binding Path=TallyResults, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />

</Grid>
</Window>
52 changes: 40 additions & 12 deletions NetTally/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,25 +240,29 @@ private void textEntry_PreviewMouseDown(object sender, MouseButtonEventArgs e)
}
}

/// <summary>
/// Global window key capture for using F2 to edit the quest name and URL.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.F2)
{
if ((editQuestName.Visibility == Visibility.Hidden) && (editQuestThread.Visibility == Visibility.Hidden))
{
EditQuestName();
}
else if (editQuestThread.Visibility == Visibility.Hidden)
{
EditQuestThread();
}
else
{
DoneEditingQuestSite();
}
EditActions();
}
}

/// <summary>
/// Button event handler for editing the quest name and URL.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void editNameButton_Click(object sender, RoutedEventArgs e)
{
EditActions();
}


/// <summary>
/// When modifying the quest name, hitting enter will complete the entry,
Expand Down Expand Up @@ -331,11 +335,32 @@ private void partitionByLine_CheckedChanged(object sender, RoutedEventArgs e)

#region Utility support methods

/// <summary>
/// The sequence of edit actions performed when either hitting F2 or the Edit Name button.
/// </summary>
private void EditActions()
{
if ((editQuestName.Visibility == Visibility.Hidden) && (editQuestThread.Visibility == Visibility.Hidden))
{
EditQuestName();
}
else if (editQuestThread.Visibility == Visibility.Hidden)
{
EditQuestThread();
}
else
{
DoneEditingQuestSite();
}
}


private void EditQuestName()
{
DoneEditingQuestSite();
editingName = ((IQuest)QuestCollectionView.CurrentItem).DisplayName;
editDescriptor.Text = "Name";
editNameButton.Content = "Edit URL";
editQuestName.Visibility = Visibility.Visible;
editDescriptorCanvas.Visibility = Visibility.Visible;
editQuestName.Focus();
Expand All @@ -346,6 +371,7 @@ private void EditQuestThread()
DoneEditingQuestName();
editingName = ((IQuest)QuestCollectionView.CurrentItem).ThreadName;
editDescriptor.Text = "Thread";
editNameButton.Content = "Finish Edit";
editQuestThread.Visibility = Visibility.Visible;
editDescriptorCanvas.Visibility = Visibility.Visible;
editQuestThread.Focus();
Expand All @@ -366,11 +392,13 @@ private void DoneEditingQuestName()

private void DoneEditingQuestSite()
{
editNameButton.Content = "Edit Name";
editQuestThread.Visibility = Visibility.Hidden;
editDescriptorCanvas.Visibility = Visibility.Hidden;
QuestCollectionView.Refresh();
}

#endregion

}
}

0 comments on commit 9c634ac

Please sign in to comment.