mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
added possibility to edit language properties and to create new language files. also some cosmetics, e.g. icons
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1859 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
608ab69082
commit
3e371d5d03
9 changed files with 770 additions and 466 deletions
|
@ -1,7 +1,7 @@
|
||||||
<Application x:Class="GreenshotLanguageEditor.App"
|
<Application x:Class="GreenshotLanguageEditor.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
StartupUri="Window1.xaml">
|
StartupUri="EntriesEditorWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Window
|
<Window
|
||||||
x:Class="GreenshotLanguageEditor.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="GreenshotLanguageEditor.EntriesEditorWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Width="800"
|
Width="850"
|
||||||
Height="600"
|
Height="600"
|
||||||
Title="Greenshot Language Editor"
|
Title="Greenshot Language Editor"
|
||||||
Icon="icons\icon.ico">
|
Icon="icons\icon.ico">
|
||||||
|
@ -31,23 +31,63 @@
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Margin="8,8,0,0"
|
|
||||||
Height="20"
|
|
||||||
Name="language1ComboBox"
|
Name="language1ComboBox"
|
||||||
SelectionChanged="languageComboBoxSelectionChanged"
|
SelectionChanged="languageComboBoxSelectionChanged"
|
||||||
Tag="1"
|
Tag="1"
|
||||||
Width="150"
|
Width="150"
|
||||||
ItemsSource="{Binding LanguageFiles}"
|
ItemsSource="{Binding LanguageFiles, Mode=OneWay}"
|
||||||
DisplayMemberPath="FileName"
|
DisplayMemberPath="FileName"
|
||||||
SelectedItem="{Binding LanguageFile1, Mode=OneWay}"></ComboBox>
|
SelectedItem="{Binding LanguageFile1, Mode=OneWay}"
|
||||||
|
Margin="5,5,5,5"
|
||||||
|
Height="26"></ComboBox>
|
||||||
|
<Button
|
||||||
|
Click="metaButtonClicked"
|
||||||
|
Tag="1"
|
||||||
|
ToolTip="Edit language properties"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\property.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Content="Save"
|
|
||||||
Click="saveButtonClicked"
|
Click="saveButtonClicked"
|
||||||
Tag="1"></Button>
|
Tag="1"
|
||||||
|
ToolTip="Save to file"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Width="16"
|
||||||
|
Height="16"
|
||||||
|
Source="icons\disk-black.png" />
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Content="Reset"
|
|
||||||
Click="cancelButtonClicked"
|
Click="cancelButtonClicked"
|
||||||
Tag="1" />
|
Tag="1"
|
||||||
|
ToolTip="Reset (reload from file)"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\cross.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Click="newButtonClicked"
|
||||||
|
Tag="1"
|
||||||
|
ToolTip="Create new file"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\new.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
@ -58,23 +98,61 @@
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Margin="8,8,0,0"
|
|
||||||
Height="20"
|
|
||||||
Name="language2ComboBox"
|
Name="language2ComboBox"
|
||||||
SelectionChanged="languageComboBoxSelectionChanged"
|
SelectionChanged="languageComboBoxSelectionChanged"
|
||||||
Tag="2"
|
Tag="2"
|
||||||
Width="150"
|
Width="150"
|
||||||
ItemsSource="{Binding LanguageFiles}"
|
ItemsSource="{Binding LanguageFiles, Mode=OneWay}"
|
||||||
DisplayMemberPath="FileName"
|
DisplayMemberPath="FileName"
|
||||||
SelectedItem="{Binding LanguageFile2, Mode=OneWay}"></ComboBox>
|
SelectedItem="{Binding LanguageFile2, Mode=OneWay}"
|
||||||
|
Margin="5,5,5,5"
|
||||||
|
Height="26"></ComboBox>
|
||||||
|
<Button
|
||||||
|
Click="metaButtonClicked"
|
||||||
|
Tag="2"
|
||||||
|
ToolTip="Edit language properties"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\property.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Content="Save"
|
|
||||||
Click="saveButtonClicked"
|
Click="saveButtonClicked"
|
||||||
Tag="2" />
|
Tag="2"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\disk-black.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
Content="Reset"
|
|
||||||
Click="cancelButtonClicked"
|
Click="cancelButtonClicked"
|
||||||
Tag="2" />
|
Tag="2"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\cross.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
Click="newButtonClicked"
|
||||||
|
Tag="2"
|
||||||
|
ToolTip="Create new file"
|
||||||
|
Width="26"
|
||||||
|
Height="26"
|
||||||
|
Margin="0,5,5,5">
|
||||||
|
<Image
|
||||||
|
Source="icons\new.png"
|
||||||
|
Width="16"
|
||||||
|
Height="16" />
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<DataGrid
|
<DataGrid
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
|
@ -21,6 +21,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -28,20 +29,33 @@ using System.Windows.Data;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace GreenshotLanguageEditor {
|
namespace GreenshotLanguageEditor {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for Window1.xaml
|
/// Interaction logic for EntriesEditorWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Window1 : Window {
|
public partial class EntriesEditorWindow : Window, INotifyPropertyChanged {
|
||||||
|
|
||||||
|
private string languagePath;
|
||||||
IDictionary<string, LanguageEntry> languageResources = new SortedDictionary<string, LanguageEntry>();
|
IDictionary<string, LanguageEntry> languageResources = new SortedDictionary<string, LanguageEntry>();
|
||||||
|
|
||||||
|
IList<LanguageFile> languageFiles;
|
||||||
public IList<LanguageFile> LanguageFiles {
|
public IList<LanguageFile> LanguageFiles {
|
||||||
get;
|
get {return languageFiles;}
|
||||||
set;
|
set {languageFiles = value; NotifyPropertyChanged("languageFiles");}
|
||||||
}
|
}
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
private void NotifyPropertyChanged(String info) {
|
||||||
|
if (PropertyChanged != null) {
|
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs(info));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// maybe refactor this encapsulating column related info
|
// maybe refactor this encapsulating column related info
|
||||||
bool unsavedChangesInLanguage1 = false;
|
bool unsavedChangesInLanguage1 = false;
|
||||||
bool unsavedChangesInLanguage2 = false;
|
bool unsavedChangesInLanguage2 = false;
|
||||||
|
@ -59,12 +73,7 @@ namespace GreenshotLanguageEditor {
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO user should be able to create a new translation file using this app
|
public EntriesEditorWindow() {
|
||||||
// TODO possibility to edit language file meta data, such as version, languagegroup, description, etc.
|
|
||||||
|
|
||||||
public Window1() {
|
|
||||||
|
|
||||||
// TODO remember last selected location
|
|
||||||
|
|
||||||
/*var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
/*var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||||
dialog.ShowNewFolderButton = false;
|
dialog.ShowNewFolderButton = false;
|
||||||
|
@ -79,17 +88,17 @@ namespace GreenshotLanguageEditor {
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
languagePath = @"C:\Users\jens\Documents\Sharpdevelop Projects\Greenshot\trunk\Greenshot\Languages\";
|
||||||
string languagePath = @"C:\Users\jens\Documents\Sharpdevelop Projects\Greenshot\trunk\Greenshot\Languages\";
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
this.Activate();
|
this.Activate();
|
||||||
|
|
||||||
View = CollectionViewSource.GetDefaultView(LoadResources(languagePath));
|
View = CollectionViewSource.GetDefaultView(LoadResources(languagePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IList<LanguageEntry> LoadResources(string languagePath) {
|
private IList<LanguageEntry> LoadResources(string languagePath) {
|
||||||
LanguageFiles = new List<LanguageFile>();
|
LanguageFiles = new BindingList<LanguageFile>();
|
||||||
foreach (LanguageFile languageFile in GreenshotLanguage.GetLanguageFiles(languagePath, "language*.xml")) {
|
foreach (LanguageFile languageFile in GreenshotLanguage.GetLanguageFiles(languagePath, "language*.xml")) {
|
||||||
LanguageFiles.Add(languageFile);
|
LanguageFiles.Add(languageFile);
|
||||||
|
|
||||||
|
@ -148,16 +157,7 @@ namespace GreenshotLanguageEditor {
|
||||||
int targetColumn = GetTargetColumn((Control)sender);
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
LanguageFile editedFile = (LanguageFile) (targetColumn == 1 ? language1ComboBox.SelectedItem : language2ComboBox.SelectedItem);
|
LanguageFile editedFile = (LanguageFile) (targetColumn == 1 ? language1ComboBox.SelectedItem : language2ComboBox.SelectedItem);
|
||||||
|
|
||||||
var dialog = new System.Windows.Forms.SaveFileDialog();
|
CreateXML(editedFile.FilePath, targetColumn);
|
||||||
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) {
|
private void languageComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||||
|
@ -191,6 +191,40 @@ namespace GreenshotLanguageEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void newButtonClicked(object sender, RoutedEventArgs e) {
|
||||||
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
|
if((targetColumn == 1 && unsavedChangesInLanguage1) || (targetColumn == 2 && unsavedChangesInLanguage2)) {
|
||||||
|
MessageBoxResult res = MessageBox.Show("Do you really want to discard this column? Unsaved changes will be lost.", "Confirm new language file creation", MessageBoxButton.OKCancel, MessageBoxImage.Warning,MessageBoxResult.Cancel,MessageBoxOptions.None);
|
||||||
|
if(res != MessageBoxResult.OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LanguageFile newLang = new LanguageFile();
|
||||||
|
newLang.FilePath = languagePath;
|
||||||
|
new MetaEditorWindow(newLang).ShowDialog();
|
||||||
|
if(newLang.FileName != null && newLang.FileName.Length > 0) {
|
||||||
|
ClearColumn(targetColumn);
|
||||||
|
CreateXML(newLang.FilePath,targetColumn);
|
||||||
|
LanguageFiles.Add(newLang);
|
||||||
|
|
||||||
|
LanguageFiles = LanguageFiles.OrderBy(f => f.FileName).ToList();
|
||||||
|
if(targetColumn == 1) {
|
||||||
|
LanguageFile1 = newLang;
|
||||||
|
language1ComboBox.SelectedItem = newLang;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LanguageFile2 = newLang;
|
||||||
|
language2ComboBox.SelectedItem = newLang;
|
||||||
|
}
|
||||||
|
PopulateColumn(newLang, targetColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void metaButtonClicked(object sender, RoutedEventArgs e) {
|
||||||
|
int targetColumn = GetTargetColumn((Control)sender);
|
||||||
|
new MetaEditorWindow(targetColumn == 1 ? LanguageFile1 : LanguageFile2).ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
private int GetTargetColumn(Control control) {
|
private int GetTargetColumn(Control control) {
|
||||||
object tag = control.Tag;
|
object tag = control.Tag;
|
||||||
if(tag == null && !tag.Equals("1") && !tag.Equals("2")) {
|
if(tag == null && !tag.Equals("1") && !tag.Equals("2")) {
|
||||||
|
@ -207,34 +241,38 @@ namespace GreenshotLanguageEditor {
|
||||||
|
|
||||||
public void CreateXML(string savePath, int targetColumn) {
|
public void CreateXML(string savePath, int targetColumn) {
|
||||||
|
|
||||||
|
LanguageFile langfile = targetColumn == 1 ? LanguageFile1 : LanguageFile2;
|
||||||
|
|
||||||
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
||||||
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
||||||
|
|
||||||
using (XmlTextWriter xmlWriter = new XmlTextWriter(savePath, Encoding.UTF8)) {
|
using (XmlTextWriter xmlWriter = new XmlTextWriter(savePath, Encoding.UTF8)) {
|
||||||
xmlWriter.Formatting = Formatting.Indented;
|
xmlWriter.Formatting = Formatting.Indented;
|
||||||
xmlWriter.Indentation = 1;
|
xmlWriter.Indentation = 1;
|
||||||
xmlWriter.IndentChar = '\t';
|
xmlWriter.IndentChar = '\t';
|
||||||
xmlWriter.WriteStartDocument();
|
xmlWriter.WriteStartDocument();
|
||||||
xmlWriter.WriteStartElement("language");
|
xmlWriter.WriteStartElement("language");
|
||||||
xmlWriter.WriteAttributeString("description", "testdescription");
|
xmlWriter.WriteAttributeString("description", langfile.Description);
|
||||||
xmlWriter.WriteAttributeString("ietf", "testietf");
|
xmlWriter.WriteAttributeString("ietf", langfile.IETF);
|
||||||
xmlWriter.WriteAttributeString("version", "testversion");
|
xmlWriter.WriteAttributeString("version", langfile.Version);
|
||||||
xmlWriter.WriteAttributeString("languagegroup", "testlanguagegroup");
|
xmlWriter.WriteAttributeString("languagegroup", langfile.Languagegroup);
|
||||||
xmlWriter.WriteStartElement("resources");
|
xmlWriter.WriteStartElement("resources");
|
||||||
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);
|
||||||
if(targetColumn == 1) xmlWriter.WriteString(entry.Entry1);
|
if(targetColumn == 1) xmlWriter.WriteString(entry.Entry1);
|
||||||
else if(targetColumn == 2 ) xmlWriter.WriteString(entry.Entry2);
|
else if(targetColumn == 2 ) xmlWriter.WriteString(entry.Entry2);
|
||||||
else throw new ArgumentOutOfRangeException("Argument columnIndex must be either 1 or 2");
|
else throw new ArgumentOutOfRangeException("Argument columnIndex must be either 1 or 2");
|
||||||
xmlWriter.WriteEndElement();
|
xmlWriter.WriteEndElement();
|
||||||
}
|
}
|
||||||
xmlWriter.WriteEndElement();
|
xmlWriter.WriteEndElement();
|
||||||
xmlWriter.WriteEndElement();
|
xmlWriter.WriteEndElement();
|
||||||
xmlWriter.WriteEndDocument();
|
xmlWriter.WriteEndDocument();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LanguageEntry : IEditableObject, INotifyPropertyChanged {
|
public class LanguageEntry : IEditableObject, INotifyPropertyChanged {
|
|
@ -78,23 +78,36 @@
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Language.cs" />
|
<Compile Include="Language.cs" />
|
||||||
|
<Compile Include="MetaEditorWindow.xaml.cs">
|
||||||
|
<DependentUpon>MetaEditorWindow.xaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Properties\WPFAssemblyInfo.cs" />
|
<Compile Include="Properties\WPFAssemblyInfo.cs" />
|
||||||
<Compile Include="Window1.xaml.cs">
|
<Compile Include="EntriesEditorWindow.xaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
<DependentUpon>Window1.xaml</DependentUpon>
|
<DependentUpon>EntriesEditorWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="Window1.xaml" />
|
<Page Include="MetaEditorWindow.xaml" />
|
||||||
|
<Page Include="EntriesEditorWindow.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
<None Include="icons\cross.png" />
|
<Resource Include="icons\cross.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
<Resource Include="icons\disk-black.png">
|
<Resource Include="icons\disk-black.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
<LogicalName>icon-save</LogicalName>
|
<LogicalName>icon-save</LogicalName>
|
||||||
</Resource>
|
</Resource>
|
||||||
|
<Resource Include="icons\new.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
|
<Resource Include="icons\property.png">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="icons" />
|
<Folder Include="icons" />
|
||||||
|
|
|
@ -27,11 +27,19 @@ using System.Xml.Linq;
|
||||||
namespace GreenshotLanguageEditor {
|
namespace GreenshotLanguageEditor {
|
||||||
public class LanguageFile {
|
public class LanguageFile {
|
||||||
public string FilePath {
|
public string FilePath {
|
||||||
get;
|
get {return Path.Combine(FileDir,FileName);}
|
||||||
set;
|
set {
|
||||||
|
FileDir = Path.GetDirectoryName(value);
|
||||||
|
FileName = Path.GetFileName(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
public string FileDir {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
public string FileName {
|
public string FileName {
|
||||||
get {return Path.GetFileName(FilePath);}
|
get;
|
||||||
|
set;
|
||||||
}
|
}
|
||||||
public string IETF {
|
public string IETF {
|
||||||
get;
|
get;
|
||||||
|
|
102
GreenshotLanguageEditor/MetaEditorWindow.xaml
Normal file
102
GreenshotLanguageEditor/MetaEditorWindow.xaml
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Window
|
||||||
|
x:Class="GreenshotLanguageEditor.MetaEditorWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="GreenshotLanguageEditor"
|
||||||
|
Width="320"
|
||||||
|
Height="243"
|
||||||
|
Icon="icons\icon.ico">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition
|
||||||
|
Height="Auto"></RowDefinition>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition
|
||||||
|
Width="Auto"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="22"
|
||||||
|
Padding="2"
|
||||||
|
Margin="5">Filename</Label>
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Height="22"
|
||||||
|
Margin="5"
|
||||||
|
Width="150"
|
||||||
|
Text="{Binding Path=LangFile.FileName, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=TwoWay}"></TextBox>
|
||||||
|
<Label
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="22"
|
||||||
|
Padding="2"
|
||||||
|
Margin="5">Description</Label>
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Height="22"
|
||||||
|
Margin="5"
|
||||||
|
Width="150"
|
||||||
|
Text="{Binding Path=LangFile.Description, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=TwoWay}"></TextBox>
|
||||||
|
<Label
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="22"
|
||||||
|
Padding="2"
|
||||||
|
Margin="5">IETF</Label>
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="2"
|
||||||
|
Grid.Column="1"
|
||||||
|
Height="22"
|
||||||
|
Margin="5"
|
||||||
|
Width="150"
|
||||||
|
Text="{Binding Path=LangFile.IETF, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=TwoWay}"></TextBox>
|
||||||
|
<Label
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="22"
|
||||||
|
Padding="2"
|
||||||
|
Margin="5">Language group</Label>
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
Height="22"
|
||||||
|
Margin="5"
|
||||||
|
Width="150"
|
||||||
|
Text="{Binding Path=LangFile.Languagegroup, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=TwoWay}"></TextBox>
|
||||||
|
<Label
|
||||||
|
Grid.Row="4"
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="22"
|
||||||
|
Padding="2"
|
||||||
|
Margin="5">Version</Label>
|
||||||
|
<TextBox
|
||||||
|
Grid.Row="4"
|
||||||
|
Grid.Column="1"
|
||||||
|
Height="22"
|
||||||
|
Margin="5"
|
||||||
|
Width="150"
|
||||||
|
Text="{Binding Path=LangFile.Version, RelativeSource={RelativeSource AncestorType={x:Type Window}}, Mode=TwoWay}"></TextBox>
|
||||||
|
<Button
|
||||||
|
Grid.Row="5"
|
||||||
|
Grid.Column="1"
|
||||||
|
Content="Close"
|
||||||
|
Margin="5,10,5,5"
|
||||||
|
Name="button1"
|
||||||
|
Click="button1_Click"></Button>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
65
GreenshotLanguageEditor/MetaEditorWindow.xaml.cs
Normal file
65
GreenshotLanguageEditor/MetaEditorWindow.xaml.cs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Greenshot - a free and open source screenshot tool
|
||||||
|
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
|
*
|
||||||
|
* For more information see: http://getgreenshot.org/
|
||||||
|
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 1 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace GreenshotLanguageEditor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for LanguageMetaEditor.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MetaEditorWindow : Window {
|
||||||
|
|
||||||
|
private static Regex FILENAME_PATTERN = new Regex(@"[a-z]+\-[a-z]{2}\-[A-Z]{2}.xml");
|
||||||
|
private LanguageFile langFile = new LanguageFile();
|
||||||
|
|
||||||
|
|
||||||
|
public LanguageFile LangFile {
|
||||||
|
get {return langFile;}
|
||||||
|
set {langFile = value;}
|
||||||
|
}
|
||||||
|
public MetaEditorWindow(LanguageFile langFile) {
|
||||||
|
InitializeComponent();
|
||||||
|
this.LangFile = langFile;
|
||||||
|
this.Closing += new System.ComponentModel.CancelEventHandler(OnClosing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||||
|
if(langFile.FileName != null && langFile.FileName.Length != 0 && !FILENAME_PATTERN.IsMatch(langFile.FileName)) {
|
||||||
|
MessageBox.Show("The filename is not valid, please use a file name like language-en-US.xml","Filename not valid", MessageBoxButton.OK, MessageBoxImage.Stop);
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void button1_Click(object sender, RoutedEventArgs e) {
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
GreenshotLanguageEditor/icons/new.png
Normal file
BIN
GreenshotLanguageEditor/icons/new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
BIN
GreenshotLanguageEditor/icons/property.png
Normal file
BIN
GreenshotLanguageEditor/icons/property.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 769 B |
Loading…
Add table
Add a link
Reference in a new issue