mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
added possibility to switch/save/reset both languages and some other changes (work still in progress)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1836 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
b0c8e5af12
commit
e4fba2e652
6 changed files with 280 additions and 90 deletions
|
@ -10,13 +10,15 @@
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
</PropertyGroup>
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
<NoStdLib>False</NoStdLib>
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
|
<SourceAnalysisOverrideSettingsFile>C:\Users\jens\AppData\Roaming\ICSharpCode/SharpDevelop4\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DebugSymbols>True</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>Full</DebugType>
|
<DebugType>Full</DebugType>
|
||||||
<Optimize>False</Optimize>
|
<Optimize>False</Optimize>
|
||||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||||
|
@ -30,6 +32,16 @@
|
||||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||||
|
<RegisterForComInterop>False</RegisterForComInterop>
|
||||||
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||||
|
<BaseAddress>4194304</BaseAddress>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<FileAlignment>4096</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="PresentationCore">
|
<Reference Include="PresentationCore">
|
||||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
@ -78,6 +90,19 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
<None Include="icons\cross.png" />
|
||||||
|
<Resource Include="icons\disk-black.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
<LogicalName>icon-save</LogicalName>
|
||||||
|
</Resource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="icons" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="icons\icon.ico">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -29,6 +29,9 @@ namespace GreenshotLanguageEditor {
|
||||||
public string FilePath {
|
public string FilePath {
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
|
}
|
||||||
|
public string FileName {
|
||||||
|
get {return Path.GetFileName(FilePath);}
|
||||||
}
|
}
|
||||||
public string IETF {
|
public string IETF {
|
||||||
get;
|
get;
|
||||||
|
|
|
@ -1,48 +1,144 @@
|
||||||
<Window x:Class="GreenshotLanguageEditor.Window1"
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<Window
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="GreenshotLanguageEditor.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="Language editor" Height="400" Width="600">
|
Width="800"
|
||||||
<Grid>
|
Height="600"
|
||||||
|
Title="Greenshot Language Editor"
|
||||||
|
Icon="icons\icon.ico">
|
||||||
|
<Grid
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Height="Auto">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="250" />
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="50*" />
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="50*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition
|
||||||
<RowDefinition Height="Auto" />
|
Height="Auto" />
|
||||||
|
<RowDefinition
|
||||||
|
Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<DataGrid Grid.Row="0" Grid.Column="0" Name="LanguageGrid" ItemsSource="{Binding View}" AutoGenerateColumns="False" IsReadOnly="False" IsSynchronizedWithCurrentItem="True">
|
<StackPanel
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<ComboBox
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.Row="0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Margin="8,8,0,0"
|
||||||
|
Height="20"
|
||||||
|
Name="language1ComboBox"
|
||||||
|
SelectionChanged="languageComboBoxSelectionChanged"
|
||||||
|
Tag="1"
|
||||||
|
Width="150"></ComboBox>
|
||||||
|
<Button
|
||||||
|
Content="Save"
|
||||||
|
Click="saveButtonClicked"
|
||||||
|
Tag="1"></Button>
|
||||||
|
<Button
|
||||||
|
Content="Reset"
|
||||||
|
Click="cancelButtonClicked"
|
||||||
|
Tag="1" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="2"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<ComboBox
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.Row="0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Margin="8,8,0,0"
|
||||||
|
Height="20"
|
||||||
|
Name="language2ComboBox"
|
||||||
|
SelectionChanged="languageComboBoxSelectionChanged"
|
||||||
|
Tag="2"
|
||||||
|
Width="150"></ComboBox>
|
||||||
|
<Button
|
||||||
|
Content="Save"
|
||||||
|
Click="saveButtonClicked"
|
||||||
|
Tag="2" />
|
||||||
|
<Button
|
||||||
|
Content="Reset"
|
||||||
|
Click="cancelButtonClicked"
|
||||||
|
Tag="2" />
|
||||||
|
</StackPanel>
|
||||||
|
<DataGrid
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="3"
|
||||||
|
Name="LanguageGrid"
|
||||||
|
ItemsSource="{Binding View}"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
IsReadOnly="False"
|
||||||
|
IsSynchronizedWithCurrentItem="True">
|
||||||
<DataGrid.RowStyle>
|
<DataGrid.RowStyle>
|
||||||
<Style TargetType="DataGridRow">
|
<Style
|
||||||
|
TargetType="DataGridRow">
|
||||||
<Style.Setters>
|
<Style.Setters>
|
||||||
<Setter Property="Background" Value="{Binding Path=Background}"></Setter>
|
<Setter
|
||||||
|
Property="Background"
|
||||||
|
Value="{Binding Path=Background}"></Setter>
|
||||||
</Style.Setters>
|
</Style.Setters>
|
||||||
</Style>
|
</Style>
|
||||||
</DataGrid.RowStyle>
|
</DataGrid.RowStyle>
|
||||||
|
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Key" Binding="{Binding Key}" Width="250"/>
|
<DataGridTextColumn
|
||||||
<DataGridTextColumn Header="Language1" Binding="{Binding Entry1}" Width="*">
|
Header="Key"
|
||||||
<DataGridTextColumn.EditingElementStyle>
|
Binding="{Binding Key}"
|
||||||
<Style TargetType="TextBox">
|
Width="250" />
|
||||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
<DataGridTextColumn
|
||||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
Header="Language1"
|
||||||
<Setter Property="MaxHeight" Value="300"/>
|
Binding="{Binding Entry1}"
|
||||||
<Setter Property="AcceptsReturn" Value="true" />
|
Width="*">
|
||||||
</Style>
|
<DataGridTextColumn.EditingElementStyle>
|
||||||
</DataGridTextColumn.EditingElementStyle>
|
<Style
|
||||||
</DataGridTextColumn>
|
TargetType="TextBox">
|
||||||
<DataGridTextColumn Header="Language2" Binding="{Binding Entry2}" Width="*">
|
<Setter
|
||||||
<DataGridTextColumn.EditingElementStyle>
|
Property="ScrollViewer.HorizontalScrollBarVisibility"
|
||||||
<Style TargetType="TextBox">
|
Value="Auto" />
|
||||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
<Setter
|
||||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
Property="ScrollViewer.VerticalScrollBarVisibility"
|
||||||
<Setter Property="MaxHeight" Value="300"/>
|
Value="Auto" />
|
||||||
<Setter Property="AcceptsReturn" Value="true" />
|
<Setter
|
||||||
</Style>
|
Property="MaxHeight"
|
||||||
</DataGridTextColumn.EditingElementStyle>
|
Value="300" />
|
||||||
</DataGridTextColumn>
|
<Setter
|
||||||
</DataGrid.Columns>
|
Property="AcceptsReturn"
|
||||||
|
Value="true" />
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn
|
||||||
|
Header="Language2"
|
||||||
|
Binding="{Binding Entry2}"
|
||||||
|
Width="*">
|
||||||
|
<DataGridTextColumn.EditingElementStyle>
|
||||||
|
<Style
|
||||||
|
TargetType="TextBox">
|
||||||
|
<Setter
|
||||||
|
Property="ScrollViewer.HorizontalScrollBarVisibility"
|
||||||
|
Value="Auto" />
|
||||||
|
<Setter
|
||||||
|
Property="ScrollViewer.VerticalScrollBarVisibility"
|
||||||
|
Value="Auto" />
|
||||||
|
<Setter
|
||||||
|
Property="MaxHeight"
|
||||||
|
Value="300" />
|
||||||
|
<Setter
|
||||||
|
Property="AcceptsReturn"
|
||||||
|
Value="true" />
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.EditingElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
|
||||||
<Button Content="Save" Click="Button_Click"/>
|
|
||||||
<Button Content="Cancel" />
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -35,66 +36,142 @@ namespace GreenshotLanguageEditor {
|
||||||
/// Interaction logic for Window1.xaml
|
/// Interaction logic for Window1.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Window1 : Window {
|
public partial class Window1 : Window {
|
||||||
|
|
||||||
|
IDictionary<string, LanguageEntry> languageResources = new SortedDictionary<string, LanguageEntry>();
|
||||||
|
IList<LanguageFile> languageFiles = new List<LanguageFile>();
|
||||||
|
|
||||||
public ICollectionView View {
|
public ICollectionView View {
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO user should be able to create a new translation file using this app
|
||||||
|
// TODO possibility to edit language file meta data, such as version, languagegroup, description, etc.
|
||||||
|
|
||||||
public Window1() {
|
public Window1() {
|
||||||
var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
||||||
|
// TODO remember last selected location
|
||||||
|
|
||||||
|
/*var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
dialog.ShowNewFolderButton = false;
|
dialog.ShowNewFolderButton = false;
|
||||||
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
||||||
string languagePath;
|
string languagePath;
|
||||||
|
|
||||||
|
|
||||||
if (result == System.Windows.Forms.DialogResult.OK) {
|
if (result == System.Windows.Forms.DialogResult.OK) {
|
||||||
languagePath = dialog.SelectedPath;
|
languagePath = dialog.SelectedPath;
|
||||||
} else {
|
} else {
|
||||||
this.Close();
|
this.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
string languagePath = @"C:\Users\jens\Documents\Sharpdevelop Projects\Greenshot\trunk\Greenshot\Languages\";
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
View = CollectionViewSource.GetDefaultView(LoadResources(languagePath));
|
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
this.Activate();
|
this.Activate();
|
||||||
|
|
||||||
|
this.language1ComboBox.ItemsSource = languageFiles;
|
||||||
|
this.language1ComboBox.DisplayMemberPath = "FileName";
|
||||||
|
this.language2ComboBox.ItemsSource = languageFiles;
|
||||||
|
this.language2ComboBox.DisplayMemberPath = "FileName";
|
||||||
|
|
||||||
|
View = CollectionViewSource.GetDefaultView(LoadResources(languagePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IList<LanguageEntry> LoadResources(string languagePath) {
|
private IList<LanguageEntry> LoadResources(string languagePath) {
|
||||||
IDictionary<string, LanguageEntry> languageResources = new SortedDictionary<string, LanguageEntry>();
|
|
||||||
|
|
||||||
foreach (LanguageFile languageFile in GreenshotLanguage.GetLanguageFiles(languagePath, "language*.xml")) {
|
foreach (LanguageFile languageFile in GreenshotLanguage.GetLanguageFiles(languagePath, "language*.xml")) {
|
||||||
|
languageFiles.Add(languageFile);
|
||||||
|
|
||||||
if ("en-US".Equals(languageFile.IETF)) {
|
if ("en-US".Equals(languageFile.IETF)) {
|
||||||
IDictionary<string, string> enResources = GreenshotLanguage.ReadLanguageFile(languageFile);
|
// we should always start with en-US, so the grid is initialized with the probably most-complete language file as benchmark for translations
|
||||||
foreach(string key in enResources.Keys) {
|
this.language1ComboBox.SelectedItem = languageFile;
|
||||||
LanguageEntry entry;
|
} else if(this.language2ComboBox.SelectedItem == null) {
|
||||||
if (languageResources.ContainsKey(key)) {
|
this.language2ComboBox.SelectedItem = languageFile;
|
||||||
entry = languageResources[key];
|
|
||||||
} else {
|
|
||||||
entry = new LanguageEntry();
|
|
||||||
entry.Key = key;
|
|
||||||
languageResources.Add(key, entry);
|
|
||||||
}
|
|
||||||
entry.Entry1 = enResources[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ("de-DE".Equals(languageFile.IETF)) {
|
|
||||||
IDictionary<string, string> deResources = GreenshotLanguage.ReadLanguageFile(languageFile);
|
|
||||||
foreach(string key in deResources.Keys) {
|
|
||||||
LanguageEntry entry;
|
|
||||||
if (languageResources.ContainsKey(key)) {
|
|
||||||
entry = languageResources[key];
|
|
||||||
} else {
|
|
||||||
entry = new LanguageEntry();
|
|
||||||
entry.Key = key;
|
|
||||||
languageResources.Add(key, entry);
|
|
||||||
}
|
|
||||||
entry.Entry2 = deResources[key];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(this.language1ComboBox.SelectedItem == null) {
|
||||||
|
MessageBox.Show("language-en-US.xml does not exist in the location selected. It is needed as reference for the translation.");
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
return new List<LanguageEntry>(languageResources.Values);
|
return new List<LanguageEntry>(languageResources.Values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateXML(string savePath) {
|
private void PopulateColumn(LanguageFile languageFile, int columnIndex) {
|
||||||
|
ClearColumn(columnIndex);
|
||||||
|
IDictionary<string, string> resources = GreenshotLanguage.ReadLanguageFile(languageFile);
|
||||||
|
foreach(string key in resources.Keys) {
|
||||||
|
LanguageEntry entry = GetOrCreateLanguageEntry(key);
|
||||||
|
if(columnIndex == 1) entry.Entry1 = resources[key];
|
||||||
|
else if (columnIndex == 2) entry.Entry2 = resources[key];
|
||||||
|
else throw new ArgumentOutOfRangeException("Argument columnIndex must be either 1 or 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClearColumn(int columnIndex) {
|
||||||
|
// we do not throw out LanguageEntries that do not exist in selected language,
|
||||||
|
// so that en-US (loaded at startup) is always the benchmark, even when other languages are displayed
|
||||||
|
foreach(LanguageEntry e in languageResources.Values) {
|
||||||
|
if (columnIndex == 1) e.Entry1 = "";
|
||||||
|
else if (columnIndex == 2) e.Entry2 = "";
|
||||||
|
else throw new ArgumentOutOfRangeException("Argument columnIndex must be either 1 or 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private LanguageEntry GetOrCreateLanguageEntry(string key) {
|
||||||
|
LanguageEntry entry;
|
||||||
|
if (languageResources.ContainsKey(key)) {
|
||||||
|
entry = languageResources[key];
|
||||||
|
} else {
|
||||||
|
entry = new LanguageEntry();
|
||||||
|
entry.Key = key;
|
||||||
|
languageResources.Add(key, entry);
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveButtonClicked(object sender, RoutedEventArgs e) {
|
||||||
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
|
LanguageFile editedFile = (LanguageFile) (targetColumn == 1 ? language1ComboBox.SelectedItem : language2ComboBox.SelectedItem);
|
||||||
|
|
||||||
|
var dialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
|
dialog.AutoUpgradeEnabled = true;
|
||||||
|
dialog.DefaultExt = ".xml";
|
||||||
|
dialog.InitialDirectory = Path.GetDirectoryName(editedFile.FilePath);
|
||||||
|
dialog.FileName = editedFile.FileName;
|
||||||
|
dialog.CheckFileExists = true;
|
||||||
|
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
||||||
|
if (result == System.Windows.Forms.DialogResult.OK) {
|
||||||
|
CreateXML(dialog.FileName, targetColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void languageComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||||
|
// TODO let user confirm if there are unsaved changes
|
||||||
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
|
LanguageFile file = (LanguageFile)((ComboBox)sender).SelectedItem;
|
||||||
|
PopulateColumn(file, targetColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelButtonClicked(object sender, RoutedEventArgs e) {
|
||||||
|
// TODO let user confirm if there are unsaved changes
|
||||||
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
|
LanguageFile file = (LanguageFile)(targetColumn == 1 ? language1ComboBox.SelectedItem : language2ComboBox.SelectedItem);
|
||||||
|
PopulateColumn(file, targetColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetTargetColumn(Control control) {
|
||||||
|
object tag = control.Tag;
|
||||||
|
if(tag == null && !tag.Equals("1") && !tag.Equals("2")) {
|
||||||
|
throw new ApplicationException("Please use the control's Tag property to indicate the column to interact with (1 or 2).");
|
||||||
|
} else {
|
||||||
|
return tag.Equals("1") ? 1 : 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateXML(string savePath, int targetColumn) {
|
||||||
|
|
||||||
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
||||||
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
||||||
|
@ -113,7 +190,9 @@ namespace GreenshotLanguageEditor {
|
||||||
foreach(LanguageEntry entry in entries) {
|
foreach(LanguageEntry entry in entries) {
|
||||||
xmlWriter.WriteStartElement("resource");
|
xmlWriter.WriteStartElement("resource");
|
||||||
xmlWriter.WriteAttributeString("name", entry.Key);
|
xmlWriter.WriteAttributeString("name", entry.Key);
|
||||||
xmlWriter.WriteString(entry.Entry1);
|
if(targetColumn == 1) xmlWriter.WriteString(entry.Entry1);
|
||||||
|
else if(targetColumn == 2 ) xmlWriter.WriteString(entry.Entry2);
|
||||||
|
else throw new ArgumentOutOfRangeException("Argument columnIndex must be either 1 or 2");
|
||||||
xmlWriter.WriteEndElement();
|
xmlWriter.WriteEndElement();
|
||||||
}
|
}
|
||||||
xmlWriter.WriteEndElement();
|
xmlWriter.WriteEndElement();
|
||||||
|
@ -122,19 +201,6 @@ namespace GreenshotLanguageEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e) {
|
|
||||||
var dialog = new System.Windows.Forms.SaveFileDialog();
|
|
||||||
dialog.AutoUpgradeEnabled = true;
|
|
||||||
dialog.DefaultExt = ".xml";
|
|
||||||
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
|
|
||||||
if (result == System.Windows.Forms.DialogResult.OK) {
|
|
||||||
CreateXML(dialog.FileName);
|
|
||||||
} else {
|
|
||||||
this.Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LanguageEntry : IEditableObject, INotifyPropertyChanged {
|
public class LanguageEntry : IEditableObject, INotifyPropertyChanged {
|
||||||
|
@ -151,13 +217,13 @@ namespace GreenshotLanguageEditor {
|
||||||
|
|
||||||
public Brush Background {
|
public Brush Background {
|
||||||
get {
|
get {
|
||||||
if (Entry1 == null) {
|
if (String.IsNullOrEmpty(Entry1)) {
|
||||||
return Brushes.Red;
|
return Brushes.Red;
|
||||||
}
|
}
|
||||||
if (Entry2 == null) {
|
if (String.IsNullOrEmpty(Entry2)) {
|
||||||
return Brushes.Red;
|
return Brushes.Red;
|
||||||
}
|
}
|
||||||
return Brushes.Green;
|
return Brushes.White;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string Key {
|
public string Key {
|
||||||
|
|
BIN
GreenshotLanguageEditor/icons/cross.png
Normal file
BIN
GreenshotLanguageEditor/icons/cross.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 476 B |
BIN
GreenshotLanguageEditor/icons/disk-black.png
Normal file
BIN
GreenshotLanguageEditor/icons/disk-black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 433 B |
Loading…
Add table
Add a link
Reference in a new issue