More changes to translation window

This commit is contained in:
Tim Young 2017-10-03 15:57:12 -05:00
parent 50452f4ea2
commit 240671304c
5 changed files with 70 additions and 4 deletions

View File

@ -154,6 +154,26 @@ namespace EduNetworkBuilder
return "";
}
public void ChangeText(string language, string NewText)
{
bool done = false;
//Find the matching language
foreach (LanguageString LS in TheStrings)
{
if (LS.language == language)
{
LS.text = NewText;
done = true;
}
}
if(!done)
{
LanguageString oneString = new LanguageString(language, NewText, tag);
TheStrings.Add(oneString);
}
}
public string GetText()
{
NBSettings oursettings = NB.GetSettings();

View File

@ -332,7 +332,10 @@ namespace EduNetworkBuilder
public void Save()
{
Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.enbx"));
if (NetworkFilename == "")
Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.enbx"));
else
Save(NetworkFilename);
}
public void Save(string filename)

View File

@ -440,7 +440,8 @@ namespace EduNetworkBuilder
{
//ctrl-click -- open translators window
TranslationWindow TW = new TranslationWindow(myNet);
TW.Show();
TW.ShowDialog();
LoadValuesFromNetwork();
}
}
}

View File

@ -34,6 +34,7 @@
this.cb2Language = new System.Windows.Forms.ComboBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.lblStatus = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// cb1Language
@ -90,12 +91,23 @@
this.btnSave.TabIndex = 14;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(139, 459);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(48, 17);
this.lblStatus.TabIndex = 15;
this.lblStatus.Text = "Status";
//
// TranslationWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(433, 491);
this.Controls.Add(this.lblStatus);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.tb2Message);
@ -119,5 +131,6 @@
private System.Windows.Forms.ComboBox cb2Language;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Label lblStatus;
}
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace EduNetworkBuilder
{
@ -44,6 +45,7 @@ namespace EduNetworkBuilder
if (cb1Language.SelectedIndex == -1) cb1Language.SelectedIndex = 0;
if (cb2Language.SelectedIndex == -1) cb2Language.SelectedIndex = 0;
Icon = Properties.Resources.NBIco;
lblStatus.Text = "";
}
private void ClosingStuff()
@ -90,7 +92,12 @@ namespace EduNetworkBuilder
private void Save()
{
Console.WriteLine("Saved");
if (File.Exists(myNet.NetworkFilename))
{
myNet.Save();
//Console.WriteLine("Saved");
lblStatus.Text = NB.Translate("_Saved");
}
}
private void TranslationWindow_KeyDown(object sender, KeyEventArgs e)
@ -125,14 +132,36 @@ namespace EduNetworkBuilder
}
}
void RefreshContents()
{
cb1Language_SelectedIndexChanged(null, EventArgs.Empty);
cb2Language_SelectedIndexChanged(null, EventArgs.Empty);
lblStatus.Text = "";
}
private void tb1Message_Leave(object sender, EventArgs e)
{
string What = CodeFromLang(cb1Language.Text);
if (What != "")
{
myNet.NetMessage.ChangeText(What,tb1Message.Text);
}
RefreshContents();
}
private void tb2Message_Leave(object sender, EventArgs e)
{
string What = CodeFromLang(cb2Language.Text);
if (What != "")
{
myNet.NetMessage.ChangeText(What, tb2Message.Text);
}
RefreshContents();
}
private void btnSave_Click(object sender, EventArgs e)
{
Save();
}
}
}