add start to form translation. Dir choice dialog

This commit is contained in:
Tim Young 2017-10-30 16:47:06 -05:00
parent 83ac52e5dc
commit 93f0ee18d7
7 changed files with 209 additions and 2 deletions

View File

@ -46,6 +46,9 @@
<setting name="LastTrans2Lang" serializeAs="String"> <setting name="LastTrans2Lang" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="FormTransLastDir" serializeAs="String">
<value />
</setting>
</EduNetworkBuilder.Properties.Settings> </EduNetworkBuilder.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -28,7 +28,7 @@
<PublisherName>Tim Young</PublisherName> <PublisherName>Tim Young</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage> <WebPage>publish.htm</WebPage>
<ApplicationRevision>44</ApplicationRevision> <ApplicationRevision>45</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -35,6 +35,7 @@ namespace EduNetworkBuilder
public bool AutoDHCPAllMachinesAtNetworkLoad = false; //Mainly for teachers public bool AutoDHCPAllMachinesAtNetworkLoad = false; //Mainly for teachers
public string LastTrans1Lang = ""; public string LastTrans1Lang = "";
public string LastTrans2Lang = ""; public string LastTrans2Lang = "";
public string FormLastTransDir = "";
public NBSettings() public NBSettings()
{ {
@ -67,6 +68,7 @@ namespace EduNetworkBuilder
ToClass.MainWindowWidth = FromClass.MainWindowWidth; ToClass.MainWindowWidth = FromClass.MainWindowWidth;
ToClass.BelongsToUser = FromClass.BelongsToUser; ToClass.BelongsToUser = FromClass.BelongsToUser;
ToClass.AutoDHCPAllMachinesAtNetworkLoad = FromClass.AutoDHCPAllMachinesAtNetworkLoad; ToClass.AutoDHCPAllMachinesAtNetworkLoad = FromClass.AutoDHCPAllMachinesAtNetworkLoad;
ToClass.FormLastTransDir = FromClass.FormLastTransDir;
foreach (string one in FromClass.ScoreList) foreach (string one in FromClass.ScoreList)
{ {
@ -121,6 +123,7 @@ namespace EduNetworkBuilder
AutoDHCPAllMachinesAtNetworkLoad = Properties.Settings.Default.AutoDHCP; AutoDHCPAllMachinesAtNetworkLoad = Properties.Settings.Default.AutoDHCP;
LastTrans1Lang = Properties.Settings.Default.LastTrans1Lang; LastTrans1Lang = Properties.Settings.Default.LastTrans1Lang;
LastTrans2Lang = Properties.Settings.Default.LastTrans2Lang; LastTrans2Lang = Properties.Settings.Default.LastTrans2Lang;
FormLastTransDir = Properties.Settings.Default.FormTransLastDir;
foreach (string one in Properties.Settings.Default.ScoreList) foreach (string one in Properties.Settings.Default.ScoreList)
{ {
@ -253,6 +256,7 @@ namespace EduNetworkBuilder
Properties.Settings.Default.AutoDHCP = AutoDHCPAllMachinesAtNetworkLoad; Properties.Settings.Default.AutoDHCP = AutoDHCPAllMachinesAtNetworkLoad;
Properties.Settings.Default.LastTrans1Lang = LastTrans1Lang; Properties.Settings.Default.LastTrans1Lang = LastTrans1Lang;
Properties.Settings.Default.LastTrans2Lang = LastTrans2Lang; Properties.Settings.Default.LastTrans2Lang = LastTrans2Lang;
Properties.Settings.Default.FormTransLastDir = FormLastTransDir;
Properties.Settings.Default.ScoreList.Clear(); Properties.Settings.Default.ScoreList.Clear();
foreach(string One in ScoreList) foreach(string One in ScoreList)

View File

@ -188,5 +188,17 @@ namespace EduNetworkBuilder.Properties {
this["LastTrans2Lang"] = value; this["LastTrans2Lang"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string FormTransLastDir {
get {
return ((string)(this["FormTransLastDir"]));
}
set {
this["FormTransLastDir"] = value;
}
}
} }
} }

View File

@ -44,5 +44,8 @@
<Setting Name="LastTrans2Lang" Type="System.String" Scope="User"> <Setting Name="LastTrans2Lang" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="FormTransLastDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -42,8 +42,19 @@
this.tpFormStuff = new System.Windows.Forms.TabPage(); this.tpFormStuff = new System.Windows.Forms.TabPage();
this.tb2URL = new System.Windows.Forms.TextBox(); this.tb2URL = new System.Windows.Forms.TextBox();
this.tb1URL = new System.Windows.Forms.TextBox(); this.tb1URL = new System.Windows.Forms.TextBox();
this.btnChooseDir = new System.Windows.Forms.Button();
this.lblFormDir = new System.Windows.Forms.Label();
this.panelTranslateFormItems = new System.Windows.Forms.Panel();
this.cbFormLang1Choice = new System.Windows.Forms.ComboBox();
this.cbFormLang2Choice = new System.Windows.Forms.ComboBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.lblFormItem = new System.Windows.Forms.Label();
this.tbFormItem1 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.tcTabPages.SuspendLayout(); this.tcTabPages.SuspendLayout();
this.tpMessageTitle.SuspendLayout(); this.tpMessageTitle.SuspendLayout();
this.tpFormStuff.SuspendLayout();
this.panelTranslateFormItems.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// cb1Language // cb1Language
@ -172,10 +183,13 @@
// //
// tpFormStuff // tpFormStuff
// //
this.tpFormStuff.Controls.Add(this.panelTranslateFormItems);
this.tpFormStuff.Controls.Add(this.lblFormDir);
this.tpFormStuff.Controls.Add(this.btnChooseDir);
this.tpFormStuff.Location = new System.Drawing.Point(4, 25); this.tpFormStuff.Location = new System.Drawing.Point(4, 25);
this.tpFormStuff.Name = "tpFormStuff"; this.tpFormStuff.Name = "tpFormStuff";
this.tpFormStuff.Padding = new System.Windows.Forms.Padding(3); this.tpFormStuff.Padding = new System.Windows.Forms.Padding(3);
this.tpFormStuff.Size = new System.Drawing.Size(428, 434); this.tpFormStuff.Size = new System.Drawing.Size(450, 438);
this.tpFormStuff.TabIndex = 1; this.tpFormStuff.TabIndex = 1;
this.tpFormStuff.Text = "Forms"; this.tpFormStuff.Text = "Forms";
this.tpFormStuff.UseVisualStyleBackColor = true; this.tpFormStuff.UseVisualStyleBackColor = true;
@ -196,6 +210,93 @@
this.tb1URL.TabIndex = 19; this.tb1URL.TabIndex = 19;
this.tb1URL.Leave += new System.EventHandler(this.tb1URL_Leave); this.tb1URL.Leave += new System.EventHandler(this.tb1URL_Leave);
// //
// btnChooseDir
//
this.btnChooseDir.Location = new System.Drawing.Point(28, 20);
this.btnChooseDir.Name = "btnChooseDir";
this.btnChooseDir.Size = new System.Drawing.Size(75, 23);
this.btnChooseDir.TabIndex = 0;
this.btnChooseDir.Text = "...";
this.btnChooseDir.UseVisualStyleBackColor = true;
this.btnChooseDir.Click += new System.EventHandler(this.btnChooseDir_Click);
//
// lblFormDir
//
this.lblFormDir.AutoSize = true;
this.lblFormDir.Location = new System.Drawing.Point(109, 23);
this.lblFormDir.Name = "lblFormDir";
this.lblFormDir.Size = new System.Drawing.Size(117, 17);
this.lblFormDir.TabIndex = 1;
this.lblFormDir.Text = "Choose Directory";
//
// panelTranslateFormItems
//
this.panelTranslateFormItems.Controls.Add(this.textBox1);
this.panelTranslateFormItems.Controls.Add(this.tbFormItem1);
this.panelTranslateFormItems.Controls.Add(this.lblFormItem);
this.panelTranslateFormItems.Controls.Add(this.comboBox1);
this.panelTranslateFormItems.Controls.Add(this.cbFormLang2Choice);
this.panelTranslateFormItems.Controls.Add(this.cbFormLang1Choice);
this.panelTranslateFormItems.Location = new System.Drawing.Point(6, 88);
this.panelTranslateFormItems.Name = "panelTranslateFormItems";
this.panelTranslateFormItems.Size = new System.Drawing.Size(434, 338);
this.panelTranslateFormItems.TabIndex = 2;
//
// cbFormLang1Choice
//
this.cbFormLang1Choice.FormattingEnabled = true;
this.cbFormLang1Choice.Location = new System.Drawing.Point(28, 89);
this.cbFormLang1Choice.Name = "cbFormLang1Choice";
this.cbFormLang1Choice.Size = new System.Drawing.Size(121, 24);
this.cbFormLang1Choice.TabIndex = 0;
//
// cbFormLang2Choice
//
this.cbFormLang2Choice.FormattingEnabled = true;
this.cbFormLang2Choice.Location = new System.Drawing.Point(28, 227);
this.cbFormLang2Choice.Name = "cbFormLang2Choice";
this.cbFormLang2Choice.Size = new System.Drawing.Size(121, 24);
this.cbFormLang2Choice.TabIndex = 1;
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(106, 3);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(306, 24);
this.comboBox1.TabIndex = 3;
//
// lblFormItem
//
this.lblFormItem.AutoSize = true;
this.lblFormItem.Location = new System.Drawing.Point(21, 6);
this.lblFormItem.Name = "lblFormItem";
this.lblFormItem.Size = new System.Drawing.Size(34, 17);
this.lblFormItem.TabIndex = 4;
this.lblFormItem.Text = "Item";
//
// tbFormItem1
//
this.tbFormItem1.AcceptsReturn = true;
this.tbFormItem1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tbFormItem1.Location = new System.Drawing.Point(28, 119);
this.tbFormItem1.Multiline = true;
this.tbFormItem1.Name = "tbFormItem1";
this.tbFormItem1.Size = new System.Drawing.Size(384, 72);
this.tbFormItem1.TabIndex = 5;
//
// textBox1
//
this.textBox1.AcceptsReturn = true;
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(28, 257);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(384, 72);
this.textBox1.TabIndex = 6;
//
// TranslationWindow // TranslationWindow
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -212,6 +313,10 @@
this.tcTabPages.ResumeLayout(false); this.tcTabPages.ResumeLayout(false);
this.tpMessageTitle.ResumeLayout(false); this.tpMessageTitle.ResumeLayout(false);
this.tpMessageTitle.PerformLayout(); this.tpMessageTitle.PerformLayout();
this.tpFormStuff.ResumeLayout(false);
this.tpFormStuff.PerformLayout();
this.panelTranslateFormItems.ResumeLayout(false);
this.panelTranslateFormItems.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -233,5 +338,14 @@
private System.Windows.Forms.TabPage tpFormStuff; private System.Windows.Forms.TabPage tpFormStuff;
private System.Windows.Forms.TextBox tb1URL; private System.Windows.Forms.TextBox tb1URL;
private System.Windows.Forms.TextBox tb2URL; private System.Windows.Forms.TextBox tb2URL;
private System.Windows.Forms.Panel panelTranslateFormItems;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox tbFormItem1;
private System.Windows.Forms.Label lblFormItem;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ComboBox cbFormLang2Choice;
private System.Windows.Forms.ComboBox cbFormLang1Choice;
private System.Windows.Forms.Label lblFormDir;
private System.Windows.Forms.Button btnChooseDir;
} }
} }

View File

@ -15,6 +15,7 @@ namespace EduNetworkBuilder
{ {
Network myNet = null; Network myNet = null;
string[,] LanguageChoices = { { NB.Translate("NB_NBEn"), "en" }, { NB.Translate("NB_NBFr"), "fr" } }; string[,] LanguageChoices = { { NB.Translate("NB_NBEn"), "en" }, { NB.Translate("NB_NBFr"), "fr" } };
string FormChosenDir = "";
public TranslationWindow(Network ToEdit) public TranslationWindow(Network ToEdit)
{ {
@ -29,7 +30,16 @@ namespace EduNetworkBuilder
{ {
cb1Language.Items.Clear(); cb1Language.Items.Clear();
cb2Language.Items.Clear(); cb2Language.Items.Clear();
panelTranslateFormItems.Enabled = false;
NBSettings mySettings = NB.GetSettings(); NBSettings mySettings = NB.GetSettings();
//See if the file we are editing has the right folder. If so, we do not need to choose one
FormChosenDir = mySettings.FormLastTransDir;
if (!TryToChooseFormDir(FormChosenDir))
TryToChooseFormDir(Path.GetDirectoryName(myNet.NetworkFilename));
for (int i = 0; i < LanguageChoices.GetLength(0); i++) for (int i = 0; i < LanguageChoices.GetLength(0); i++)
{ {
cb1Language.Items.Add(LanguageChoices[i, 0]); cb1Language.Items.Add(LanguageChoices[i, 0]);
@ -72,6 +82,7 @@ namespace EduNetworkBuilder
{ {
mySettings.LastTrans2Lang = LanguageChoices[i, 1]; mySettings.LastTrans2Lang = LanguageChoices[i, 1];
} }
mySettings.FormLastTransDir = FormChosenDir;
} }
mySettings.Save(); mySettings.Save();
} }
@ -216,5 +227,65 @@ namespace EduNetworkBuilder
} }
RefreshContents(); RefreshContents();
} }
//**********************************************************************//
//******************* Form Translation Things **************************//
//**********************************************************************//
bool TryToChooseFormDir(string Choice)
{
string targetfile = "edustrings.resx";
if (Choice == null || Choice == "") return false;
//We want to have a file named edustrings.resx there
//There may be other files: edustrings.fr.resx
//If these exist, we are OK. Otherwise, see if there is a "languages" dir and try that if it does exist
string toCheck = Path.GetFileName(Choice).ToLower();
if (File.Exists(Choice))
if (toCheck == targetfile)
{
FormChosenDir = Path.GetDirectoryName(Choice);
panelTranslateFormItems.Enabled = true;
lblFormDir.Text = "Dir: " + FormChosenDir;
lblFormDir.AutoSize = true;
lblFormDir.MaximumSize = new Size(250, 200);
return true;
}
if(Directory.Exists(Choice))
{
//It is a directory. See if it has the correct file in it.
if (TryToChooseFormDir(Path.Combine(Choice, targetfile)))
{
return true; //It was successful
}
//If we get here, it did not have the file. See if there is a "languages" directory
if (TryToChooseFormDir(Path.Combine(Choice, "languages", targetfile)))
{
return true; //It was successful
}
}
return false;
}
private void btnChooseDir_Click(object sender, EventArgs e)
{
string startingDir = FormChosenDir;
if (FormChosenDir == "" && File.Exists(myNet.NetworkFilename))
startingDir = Path.GetDirectoryName(myNet.NetworkFilename);
//Prompt for a directory.
OpenFileDialog ofd = NB.SelectDirectoryDialog("Directory with language files", startingDir);
if(ofd.FileName != "")
{
//try to see if the chosen filename has appropriate files. We need the English, at least
if(!TryToChooseFormDir(Path.GetDirectoryName(ofd.FileName)))
{
MessageBox.Show("Invalid Directory.");
}
}
}
} }
} }