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"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml">
|
||||
StartupUri="EntriesEditorWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window
|
||||
x:Class="GreenshotLanguageEditor.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Width="800"
|
||||
x:Class="GreenshotLanguageEditor.EntriesEditorWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Width="850"
|
||||
Height="600"
|
||||
Title="Greenshot Language Editor"
|
||||
Icon="icons\icon.ico">
|
||||
|
@ -31,23 +31,63 @@
|
|||
Grid.Row="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Margin="8,8,0,0"
|
||||
Height="20"
|
||||
Name="language1ComboBox"
|
||||
SelectionChanged="languageComboBoxSelectionChanged"
|
||||
Tag="1"
|
||||
Width="150"
|
||||
ItemsSource="{Binding LanguageFiles}"
|
||||
ItemsSource="{Binding LanguageFiles, Mode=OneWay}"
|
||||
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
|
||||
Content="Save"
|
||||
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
|
||||
Content="Reset"
|
||||
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
|
||||
Grid.Row="0"
|
||||
|
@ -58,23 +98,61 @@
|
|||
Grid.Row="0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Margin="8,8,0,0"
|
||||
Height="20"
|
||||
Name="language2ComboBox"
|
||||
SelectionChanged="languageComboBoxSelectionChanged"
|
||||
Tag="2"
|
||||
Width="150"
|
||||
ItemsSource="{Binding LanguageFiles}"
|
||||
ItemsSource="{Binding LanguageFiles, Mode=OneWay}"
|
||||
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
|
||||
Content="Save"
|
||||
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
|
||||
Content="Reset"
|
||||
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>
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
|
@ -21,6 +21,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
@ -28,20 +29,33 @@ using System.Windows.Data;
|
|||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
namespace GreenshotLanguageEditor {
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// Interaction logic for EntriesEditorWindow.xaml
|
||||
/// </summary>
|
||||
public partial class Window1 : Window {
|
||||
public partial class EntriesEditorWindow : Window, INotifyPropertyChanged {
|
||||
|
||||
private string languagePath;
|
||||
IDictionary<string, LanguageEntry> languageResources = new SortedDictionary<string, LanguageEntry>();
|
||||
|
||||
IList<LanguageFile> languageFiles;
|
||||
public IList<LanguageFile> LanguageFiles {
|
||||
get;
|
||||
set;
|
||||
get {return languageFiles;}
|
||||
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
|
||||
bool unsavedChangesInLanguage1 = false;
|
||||
bool unsavedChangesInLanguage2 = false;
|
||||
|
@ -59,12 +73,7 @@ namespace GreenshotLanguageEditor {
|
|||
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() {
|
||||
|
||||
// TODO remember last selected location
|
||||
public EntriesEditorWindow() {
|
||||
|
||||
/*var dialog = new System.Windows.Forms.FolderBrowserDialog();
|
||||
dialog.ShowNewFolderButton = false;
|
||||
|
@ -79,17 +88,17 @@ namespace GreenshotLanguageEditor {
|
|||
return;
|
||||
}*/
|
||||
|
||||
|
||||
string languagePath = @"C:\Users\jens\Documents\Sharpdevelop Projects\Greenshot\trunk\Greenshot\Languages\";
|
||||
languagePath = @"C:\Users\jens\Documents\Sharpdevelop Projects\Greenshot\trunk\Greenshot\Languages\";
|
||||
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
this.Activate();
|
||||
|
||||
View = CollectionViewSource.GetDefaultView(LoadResources(languagePath));
|
||||
}
|
||||
|
||||
private IList<LanguageEntry> LoadResources(string languagePath) {
|
||||
LanguageFiles = new List<LanguageFile>();
|
||||
LanguageFiles = new BindingList<LanguageFile>();
|
||||
foreach (LanguageFile languageFile in GreenshotLanguage.GetLanguageFiles(languagePath, "language*.xml")) {
|
||||
LanguageFiles.Add(languageFile);
|
||||
|
||||
|
@ -148,16 +157,7 @@ namespace GreenshotLanguageEditor {
|
|||
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);
|
||||
}
|
||||
CreateXML(editedFile.FilePath, targetColumn);
|
||||
}
|
||||
|
||||
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) {
|
||||
object tag = control.Tag;
|
||||
if(tag == null && !tag.Equals("1") && !tag.Equals("2")) {
|
||||
|
@ -207,6 +241,8 @@ namespace GreenshotLanguageEditor {
|
|||
|
||||
public void CreateXML(string savePath, int targetColumn) {
|
||||
|
||||
LanguageFile langfile = targetColumn == 1 ? LanguageFile1 : LanguageFile2;
|
||||
|
||||
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
||||
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
||||
|
||||
|
@ -216,10 +252,10 @@ namespace GreenshotLanguageEditor {
|
|||
xmlWriter.IndentChar = '\t';
|
||||
xmlWriter.WriteStartDocument();
|
||||
xmlWriter.WriteStartElement("language");
|
||||
xmlWriter.WriteAttributeString("description", "testdescription");
|
||||
xmlWriter.WriteAttributeString("ietf", "testietf");
|
||||
xmlWriter.WriteAttributeString("version", "testversion");
|
||||
xmlWriter.WriteAttributeString("languagegroup", "testlanguagegroup");
|
||||
xmlWriter.WriteAttributeString("description", langfile.Description);
|
||||
xmlWriter.WriteAttributeString("ietf", langfile.IETF);
|
||||
xmlWriter.WriteAttributeString("version", langfile.Version);
|
||||
xmlWriter.WriteAttributeString("languagegroup", langfile.Languagegroup);
|
||||
xmlWriter.WriteStartElement("resources");
|
||||
foreach(LanguageEntry entry in entries) {
|
||||
xmlWriter.WriteStartElement("resource");
|
||||
|
@ -235,6 +271,8 @@ namespace GreenshotLanguageEditor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class LanguageEntry : IEditableObject, INotifyPropertyChanged {
|
|
@ -78,23 +78,36 @@
|
|||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<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\WPFAssemblyInfo.cs" />
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<Compile Include="EntriesEditorWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<DependentUpon>EntriesEditorWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Window1.xaml" />
|
||||
<Page Include="MetaEditorWindow.xaml" />
|
||||
<Page Include="EntriesEditorWindow.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="icons\cross.png" />
|
||||
<Resource Include="icons\cross.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Resource Include="icons\disk-black.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<LogicalName>icon-save</LogicalName>
|
||||
</Resource>
|
||||
<Resource Include="icons\new.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Resource Include="icons\property.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="icons" />
|
||||
|
|
|
@ -27,11 +27,19 @@ using System.Xml.Linq;
|
|||
namespace GreenshotLanguageEditor {
|
||||
public class LanguageFile {
|
||||
public string FilePath {
|
||||
get {return Path.Combine(FileDir,FileName);}
|
||||
set {
|
||||
FileDir = Path.GetDirectoryName(value);
|
||||
FileName = Path.GetFileName(value);
|
||||
}
|
||||
}
|
||||
public string FileDir {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string FileName {
|
||||
get {return Path.GetFileName(FilePath);}
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string IETF {
|
||||
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