Skip to content

Commit

Permalink
Updated UI. Added row double click handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirmir committed Feb 24, 2015
1 parent 3064d96 commit 7f466a3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
13 changes: 10 additions & 3 deletions ResxTranslationTool/Models/Translation.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
namespace ResxTranslationTool.Models
using Microsoft.Practices.Prism.Mvvm;

namespace ResxTranslationTool.Models
{
public sealed class Translation
public sealed class Translation : BindableBase
{
private string _translatedText;
public string Id { get; set; }

public string FileName { get; set; }

public string OriginalText { get; set; }

public string TranslatedText { get; set; }
public string TranslatedText
{
get { return _translatedText; }
set { SetProperty(ref _translatedText, value); }
}

public string Comment { get; set; }
}
Expand Down
31 changes: 17 additions & 14 deletions ResxTranslationTool/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Style TargetType="{x:Type TextBox}">
<Style.Setters>
<Setter Property="Height" Value="24" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style.Setters>
</Style>
<Style TargetType="{x:Type Button}">
Expand Down Expand Up @@ -55,8 +56,7 @@
</TextBlock>
<TextBox Grid.Row="0"
Grid.Column="2"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding TranslationFileName}" />

Expand Down Expand Up @@ -99,8 +99,7 @@
</TextBlock>
<TextBox Grid.Row="0"
Grid.Column="2"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding SolutionFileName}" />

Expand Down Expand Up @@ -155,8 +154,7 @@
<TextBox Grid.Row="0"
Grid.Column="2"
Grid.ColumnSpan="5"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding SolutionFileName}" />

Expand All @@ -176,7 +174,6 @@
</TextBlock>
<TextBox Grid.Row="2"
Grid.Column="2"
VerticalContentAlignment="Center"
Text="{Binding ResourceFileMask}" />

<TextBlock Grid.Row="2"
Expand All @@ -186,7 +183,6 @@
</TextBlock>
<TextBox Grid.Row="2"
Grid.Column="6"
VerticalContentAlignment="Center"
Text="{Binding Tag}" />

<!-- Scan -->
Expand All @@ -208,8 +204,7 @@
<TextBox Grid.Row="6"
Grid.Column="2"
Grid.ColumnSpan="5"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding TranslationFileName}" />

Expand Down Expand Up @@ -248,8 +243,7 @@
</TextBlock>
<TextBox Grid.Row="0"
Grid.Column="2"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding SolutionFileName}" />

Expand All @@ -269,8 +263,7 @@
</TextBlock>
<TextBox Grid.Row="2"
Grid.Column="2"
VerticalContentAlignment="Center"
Background="LightGray"
Background="Gainsboro"
IsReadOnly="True"
Text="{Binding TranslationFileName}" />

Expand Down Expand Up @@ -300,16 +293,26 @@
<DataGrid Grid.Row="2"
AlternatingRowBackground="GhostWhite"
AutoGenerateColumns="False"
CanUserAddRows="False"
HeadersVisibility="Column"
HorizontalGridLinesBrush="Gainsboro"
ItemsSource="{Binding Translations}"
VerticalGridLinesBrush="Gainsboro">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="TranslationRow_DoubleClick" />
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="0" />
</Trigger>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="Background" Value="Gainsboro" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
Expand Down
14 changes: 14 additions & 0 deletions ResxTranslationTool/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using ResxTranslationTool.Models;
using ResxTranslationTool.ViewModels;

namespace ResxTranslationTool.Views
Expand All @@ -21,5 +24,16 @@ private void homePageRequestNavigate(object sender, RequestNavigateEventArgs e)
Process.Start(e.Uri.AbsoluteUri);
e.Handled = true;
}

private void TranslationRow_DoubleClick(object sender, MouseButtonEventArgs e)
{
var row = (DataGridRow)sender;
var translation = (Translation)row.DataContext;

if (string.IsNullOrEmpty(translation.TranslatedText))
{
translation.TranslatedText = translation.OriginalText;
}
}
}
}

0 comments on commit 7f466a3

Please sign in to comment.