mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
LanguageEditor now saves html snippet for homepage when saving a language_website_*.xml file
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2071 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
63e738118e
commit
11501b8152
3 changed files with 55 additions and 8 deletions
|
@ -31,6 +31,7 @@ using System.Windows.Input;
|
|||
using System.Windows.Media;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
||||
|
@ -50,11 +51,11 @@ namespace GreenshotLanguageEditor {
|
|||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void NotifyPropertyChanged(String info) {
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(info));
|
||||
}
|
||||
}
|
||||
private void NotifyPropertyChanged(String info) {
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(info));
|
||||
}
|
||||
}
|
||||
|
||||
// maybe refactor this encapsulating column related info
|
||||
bool unsavedChangesInLanguage1 = false;
|
||||
|
@ -172,6 +173,10 @@ namespace GreenshotLanguageEditor {
|
|||
|
||||
CreateXML(editedFile.FilePath, targetColumn);
|
||||
|
||||
if(editedFile.FileName.Contains("website")) {
|
||||
CreateHTML(editedFile.FilePath, targetColumn);
|
||||
}
|
||||
|
||||
if(targetColumn == 1) unsavedChangesInLanguage1 = false;
|
||||
else if(targetColumn == 2) unsavedChangesInLanguage2 = false;
|
||||
}
|
||||
|
@ -257,12 +262,9 @@ 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;
|
||||
|
||||
List<LanguageEntry> sortList = new List<LanguageEntry>(entries);
|
||||
sortList.Sort(compareEntryKeys);
|
||||
|
||||
|
@ -292,6 +294,28 @@ namespace GreenshotLanguageEditor {
|
|||
}
|
||||
}
|
||||
|
||||
public void CreateHTML(string savePath, int targetColumn) {
|
||||
LanguageFile langfile = targetColumn == 1 ? LanguageFile1 : LanguageFile2;
|
||||
ICollectionView view = (ICollectionView)LanguageGrid.ItemsSource;
|
||||
IList<LanguageEntry> entries = (IList<LanguageEntry>)view.SourceCollection;
|
||||
|
||||
string tmp;
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("GreenshotLanguageEditor.template-homepage.html.part")) {
|
||||
using (StreamReader reader = new StreamReader(stream)) {
|
||||
tmp = reader.ReadToEnd();
|
||||
foreach(LanguageEntry e in entries) {
|
||||
string entryString = targetColumn == 1 ? e.Entry1 : e.Entry2;
|
||||
tmp = tmp.Replace("${"+e.Key+"}", entryString);
|
||||
}
|
||||
}
|
||||
}
|
||||
FileInfo fi = new FileInfo(savePath.Replace("xml","html.part"));
|
||||
FileStream fs = fi.Open(FileMode.OpenOrCreate);
|
||||
byte[] barr = Encoding.GetEncoding("UTF-8").GetBytes(tmp);
|
||||
fs.Write(barr,0, barr.Length);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
private int compareEntryKeys(LanguageEntry a, LanguageEntry b) {
|
||||
return a.Key.CompareTo(b.Key);
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<EmbeddedResource Include="template-homepage.html.part" />
|
||||
<Resource Include="icons\cross.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
|
|
22
GreenshotLanguageEditor/template-homepage.html.part
Normal file
22
GreenshotLanguageEditor/template-homepage.html.part
Normal file
|
@ -0,0 +1,22 @@
|
|||
<div class="two-col left-box">
|
||||
|
||||
<h2>${home_whatis}</h2>
|
||||
<p>${home_whatis_intro}</p>
|
||||
<p class="ul">
|
||||
<span class="li">${home_whatis_create}</span> <span class="li">${home_whatis_edit}</span> <span class="li">${home_whatis_send}</span> <span class="li">${home_whatis_more}</li>
|
||||
</p>
|
||||
<p>${home_whatis_usage}</p>
|
||||
|
||||
</div>
|
||||
<div class="two-col right-box">
|
||||
|
||||
<h2>${home_seemore}</h2>
|
||||
<p>${home_seemore_screenshots}</p>
|
||||
|
||||
<a class="button" href="/downloads/">${home_downloads}</a>
|
||||
|
||||
<h2>${home_opensource}</h2>
|
||||
<p>${home_opensource_gpl}</p>
|
||||
<p>${home_opensource_donate}</p>
|
||||
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue