Skip to content

Commit

Permalink
Add option for automatic fill in of folder name when pressing right o…
Browse files Browse the repository at this point in the history
…r tab on the phrase cell
  • Loading branch information
CaffeineAU committed Aug 21, 2016
1 parent d494bcd commit a1bb82e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
File renamed without changes.
34 changes: 32 additions & 2 deletions Translator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,11 @@ private void WordsListView_PreviewKeyDown(object sender, KeyEventArgs e)
}
}
}
if (e.Key == Key.Right && !((DependencyObject)e.OriginalSource is TextBox))
if ((e.Key == Key.Right || e.Key == Key.Tab )&& !((DependencyObject)e.OriginalSource is TextBox))
{
DependencyObject dep = (DependencyObject)e.OriginalSource;
DependencyObject currentRow = dep;
DependencyObject nextRow = dep;
DataGridCell cell = dep as DataGridCell;
cell.IsSelected = false;
DependencyObject nextRowCell;
Expand All @@ -810,14 +812,42 @@ private void WordsListView_PreviewKeyDown(object sender, KeyEventArgs e)
if (nextRowCell == null || (nextRowCell as DataGridCell).Column.Header.ToString() == "Play")
{
nextRowCell = cell.PredictFocus(FocusNavigationDirection.Left);
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Down);

while ((nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left) != null)
{
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);
}
while ((currentRow != null) && !(currentRow is DataGridRow) && !(currentRow is System.Windows.Controls.Primitives.DataGridColumnHeader))
{
currentRow = VisualTreeHelper.GetParent(currentRow);
}

nextRowCell = cell.PredictFocus(FocusNavigationDirection.Down);
nextRow = VisualTreeHelper.GetParent(nextRowCell);
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Left);
while ((nextRow != null) && !(nextRow is DataGridRow) && !(nextRow is System.Windows.Controls.Primitives.DataGridColumnHeader))
{
nextRow = VisualTreeHelper.GetParent(nextRow);
}

SelectedRowCount = WordsListView.SelectedItems.Count;
if (Properties.Settings.Default.CopyFolderWhenSelectingEmptyRow && String.IsNullOrEmpty(((nextRow as DataGridRow).Item as PhraseItem).Folder))
{
nextRowCell = (nextRowCell as DataGridCell).PredictFocus(FocusNavigationDirection.Right);
int rowselected = PhraseItems.IndexOf(((nextRow as DataGridRow).Item as PhraseItem) as PhraseItem);
while (String.IsNullOrEmpty(PhraseItems[rowselected].Folder) && rowselected >= 0) { rowselected--; } // traverse upwards
if (rowselected >= 0)
{
(((nextRow as DataGridRow).Item as PhraseItem) as PhraseItem).Folder = PhraseItems[rowselected].Folder;
NeedToSave = true;
}
}

WordsListView.CurrentCell = new DataGridCellInfo(nextRowCell as DataGridCell);
(nextRowCell as DataGridCell).IsSelected = true;


e.Handled = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Translator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.3.0")]
[assembly: AssemblyFileVersion("2.1.3.0")]
[assembly: AssemblyVersion("2.1.4.0")]
[assembly: AssemblyFileVersion("2.1.4.0")]

0 comments on commit a1bb82e

Please sign in to comment.