2014-07-28 07:54:35 +00:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace TBF
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class to be serialized to an XML file...
|
|
|
|
|
/// Public members are local settings.
|
|
|
|
|
/// These settings are modified by dialogs invoked by menu items
|
|
|
|
|
/// Edit->Preferences ... PreferencesDlg ... S1.1(language, etc. local settings), and
|
|
|
|
|
/// Edit->Advanced settings ... AdvancedSettingsDlg ... S1.2(spec. where bench settings are stored)
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlRootAttribute("TestBenchFramework")]
|
|
|
|
|
public class LocalSettings
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Available languages.
|
|
|
|
|
/// Method ToString should give a supported culture info string:
|
|
|
|
|
/// ("en","de","fr","es","it","cn", etc.).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum Languages
|
|
|
|
|
{
|
|
|
|
|
en,
|
|
|
|
|
de,
|
|
|
|
|
sk,
|
|
|
|
|
Count,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// User interface language ("en","de","fr","es","it","cn", etc.).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Language = "en";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Names and database settings of test benches.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlArrayAttribute("TestBenches")]
|
|
|
|
|
public DatabaseSettings[] testBenches;
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public DatabaseSettings[] TestBenches { get { return testBenches; } }
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
2014-09-03 11:42:46 +00:00
|
|
|
public int BenchesCount { get { return (testBenches != null) ? testBenches.GetLength(0) : 0; } }
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Currently selected bench name (local or remote) or null (= no selection done).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlElementAttribute("LastBench")]
|
|
|
|
|
public string LastBenchName;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Currently selected procedure name or null (= no selection done yet).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[XmlElementAttribute("LastProcedure")]
|
|
|
|
|
public string LastProcedureName;
|
|
|
|
|
|
|
|
|
|
public int RightPaneHorizSplitterDistance;
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
/// MainWnd
|
|
|
|
|
public int MainWndLeft;
|
|
|
|
|
public int MainWndTop;
|
|
|
|
|
public int MainWndWidth;
|
|
|
|
|
public int MainWndHeight;
|
|
|
|
|
public bool ManiWndMaximized;
|
|
|
|
|
|
2014-09-07 07:34:28 +00:00
|
|
|
/// Components
|
|
|
|
|
public int ComponentsDlgLeft;
|
|
|
|
|
public int ComponentsDlgTop;
|
|
|
|
|
public int ComponentsDlgWidth;
|
|
|
|
|
public int ComponentsDlgHeight;
|
|
|
|
|
|
|
|
|
|
/// Paths
|
|
|
|
|
public int PathsDlgLeft;
|
|
|
|
|
public int PathsDlgTop;
|
|
|
|
|
public int PathsDlgWidth;
|
|
|
|
|
public int PathsDlgHeight;
|
|
|
|
|
|
2014-09-03 11:42:46 +00:00
|
|
|
[XmlArrayAttribute("FeedingColumnWidths")]
|
|
|
|
|
public int[] FeedingColumnWidths;
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public int FeedingColumnCount { get { return (FeedingColumnWidths != null) ? FeedingColumnWidths.Length : 0; } }
|
|
|
|
|
|
|
|
|
|
[XmlArrayAttribute("BenchColumnWidths")]
|
|
|
|
|
public int[] BenchColumnWidths;
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public int BenchColumnCount { get { return (BenchColumnWidths != null) ? BenchColumnWidths.Length : 0; } }
|
|
|
|
|
|
|
|
|
|
[XmlArrayAttribute("OutputColumnWidths")]
|
|
|
|
|
public int[] OutputColumnWidths;
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public int OutputColumnCount { get { return (OutputColumnWidths != null) ? OutputColumnWidths.Length : 0; } }
|
|
|
|
|
|
|
|
|
|
[XmlArrayAttribute("MetersColumnWidths")]
|
|
|
|
|
public int[] MetersColumnWidths;
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public int MetersColumnCount { get { return (MetersColumnWidths != null) ? MetersColumnWidths.Length : 0; } }
|
|
|
|
|
|
2014-09-07 07:34:28 +00:00
|
|
|
/// Transitions
|
|
|
|
|
public int TransitionsDlgLeft;
|
|
|
|
|
public int TransitionsDlgTop;
|
|
|
|
|
public int TransitionsDlgWidth;
|
|
|
|
|
public int TransitionsDlgHeight;
|
|
|
|
|
|
|
|
|
|
[XmlArrayAttribute("TransitionsColumnWidths")]
|
|
|
|
|
public int[] TransitionsColumnWidths;
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public int TransitionsColumnCount { get { return (TransitionsColumnWidths != null) ? TransitionsColumnWidths.Length : 0; } }
|
|
|
|
|
|
|
|
|
|
/// Metrology
|
|
|
|
|
public int MetrologyDlgLeft;
|
|
|
|
|
public int MetrologyDlgTop;
|
|
|
|
|
public int MetrologyDlgWidth;
|
|
|
|
|
public int MetrologyDlgHeight;
|
|
|
|
|
|
|
|
|
|
/// Procedures
|
|
|
|
|
public int ProceduresDlgLeft;
|
|
|
|
|
public int ProceduresDlgTop;
|
|
|
|
|
public int ProceduresDlgWidth;
|
|
|
|
|
public int ProceduresDlgHeight;
|
|
|
|
|
|
|
|
|
|
/// OneProcedure
|
|
|
|
|
public int OneProcedureDlgLeft;
|
|
|
|
|
public int OneProcedureDlgTop;
|
|
|
|
|
public int OneProcedureDlgWidth;
|
|
|
|
|
public int OneProcedureDlgHeight;
|
|
|
|
|
|
2015-01-12 14:09:09 +00:00
|
|
|
/// Configuration of results
|
2014-09-03 11:42:46 +00:00
|
|
|
public Forms.ResultsConfig.Meters ResultsConfigMeters;
|
2014-07-28 07:54:35 +00:00
|
|
|
public Forms.ResultsConfig.TestsAre ResultsConfigTests;
|
2015-01-13 04:00:59 +00:00
|
|
|
public string[] RsltItems_Screen_SingleWM;
|
|
|
|
|
public string[] RsltItems_Screen_CombinedWM;
|
|
|
|
|
public string[] RsltItems_Printer_SingleWM;
|
|
|
|
|
public string[] RsltItems_Printer_CombinedWM;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Copy public fields from a LocalSettings object to this object.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ls">Origin</param>
|
|
|
|
|
public void Assign(LocalSettings ls)
|
|
|
|
|
{
|
|
|
|
|
if (ls != null)
|
|
|
|
|
{
|
|
|
|
|
Language = ls.Language;
|
2014-09-07 10:36:40 +00:00
|
|
|
|
2014-09-03 11:42:46 +00:00
|
|
|
testBenches = new DatabaseSettings[ls.BenchesCount];
|
2014-09-07 07:34:28 +00:00
|
|
|
for (int i = 0; i < BenchesCount; i++)
|
|
|
|
|
testBenches[i] = ls.testBenches[i];
|
2014-07-28 07:54:35 +00:00
|
|
|
LastBenchName = ls.LastBenchName;
|
|
|
|
|
LastProcedureName = ls.LastProcedureName;
|
2014-09-07 10:36:40 +00:00
|
|
|
|
|
|
|
|
MainWndLeft = ls.MainWndLeft;
|
|
|
|
|
MainWndTop = ls.MainWndTop;
|
|
|
|
|
MainWndWidth = ls.MainWndWidth;
|
|
|
|
|
MainWndHeight = ls.MainWndHeight;
|
|
|
|
|
ManiWndMaximized = ls.ManiWndMaximized;
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
RightPaneHorizSplitterDistance = ls.RightPaneHorizSplitterDistance;
|
2014-09-03 11:42:46 +00:00
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
ComponentsDlgLeft = ls.ComponentsDlgLeft;
|
|
|
|
|
ComponentsDlgTop = ls.ComponentsDlgTop;
|
|
|
|
|
ComponentsDlgWidth = ls.ComponentsDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
ComponentsDlgHeight = ls.ComponentsDlgHeight;
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
PathsDlgLeft = ls.PathsDlgLeft;
|
|
|
|
|
PathsDlgTop = ls.PathsDlgTop;
|
|
|
|
|
PathsDlgWidth = ls.PathsDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
PathsDlgHeight = ls.PathsDlgHeight;
|
2014-09-07 10:36:40 +00:00
|
|
|
|
2014-09-03 11:42:46 +00:00
|
|
|
FeedingColumnWidths = new int[ls.FeedingColumnCount];
|
2014-09-07 07:34:28 +00:00
|
|
|
for (int i = 0; i < FeedingColumnCount; i++)
|
|
|
|
|
FeedingColumnWidths[i] = ls.FeedingColumnWidths[i];
|
2014-09-03 11:42:46 +00:00
|
|
|
BenchColumnWidths = new int[ls.BenchColumnCount];
|
2014-09-07 07:34:28 +00:00
|
|
|
for (int i = 0; i < BenchColumnCount; i++)
|
|
|
|
|
BenchColumnWidths[i] = ls.BenchColumnWidths[i];
|
2014-09-03 11:42:46 +00:00
|
|
|
OutputColumnWidths = new int[ls.OutputColumnCount];
|
2014-09-07 07:34:28 +00:00
|
|
|
for (int i = 0; i < OutputColumnCount; i++)
|
|
|
|
|
OutputColumnWidths[i] = ls.OutputColumnWidths[i];
|
2014-09-03 11:42:46 +00:00
|
|
|
MetersColumnWidths = new int[ls.MetersColumnCount];
|
2014-09-07 07:34:28 +00:00
|
|
|
for (int i = 0; i < MetersColumnCount; i++)
|
|
|
|
|
MetersColumnWidths[i] = ls.MetersColumnWidths[i];
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
TransitionsDlgLeft = ls.TransitionsDlgLeft;
|
|
|
|
|
TransitionsDlgTop = ls.TransitionsDlgTop;
|
|
|
|
|
TransitionsDlgWidth = ls.TransitionsDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
TransitionsDlgHeight = ls.TransitionsDlgHeight;
|
2014-09-07 10:36:40 +00:00
|
|
|
|
2014-09-07 07:34:28 +00:00
|
|
|
TransitionsColumnWidths = new int[ls.TransitionsColumnCount];
|
|
|
|
|
for (int i = 0; i < TransitionsColumnCount; i++)
|
|
|
|
|
TransitionsColumnWidths[i] = ls.TransitionsColumnWidths[i];
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
MetrologyDlgLeft = ls.MetrologyDlgLeft;
|
|
|
|
|
MetrologyDlgTop = ls.MetrologyDlgTop;
|
|
|
|
|
MetrologyDlgWidth = ls.MetrologyDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
MetrologyDlgHeight = ls.MetrologyDlgHeight;
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
ProceduresDlgLeft = ls.ProceduresDlgLeft;
|
|
|
|
|
ProceduresDlgTop = ls.ProceduresDlgTop;
|
|
|
|
|
ProceduresDlgWidth = ls.ProceduresDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
ProceduresDlgHeight = ls.ProceduresDlgHeight;
|
|
|
|
|
|
2014-09-07 10:36:40 +00:00
|
|
|
OneProcedureDlgLeft = ls.OneProcedureDlgLeft;
|
|
|
|
|
OneProcedureDlgTop = ls.OneProcedureDlgTop;
|
|
|
|
|
OneProcedureDlgWidth = ls.OneProcedureDlgWidth;
|
2014-09-07 07:34:28 +00:00
|
|
|
OneProcedureDlgHeight = ls.OneProcedureDlgHeight;
|
2014-09-03 11:42:46 +00:00
|
|
|
|
|
|
|
|
ResultsConfigMeters = ls.ResultsConfigMeters;
|
2014-07-28 07:54:35 +00:00
|
|
|
ResultsConfigTests = ls.ResultsConfigTests;
|
2015-01-12 14:09:09 +00:00
|
|
|
|
2015-01-13 04:00:59 +00:00
|
|
|
int count = (ls.RsltItems_Screen_SingleWM != null) ? ls.RsltItems_Screen_SingleWM.Length : 0;
|
|
|
|
|
RsltItems_Screen_SingleWM = new string[count];
|
|
|
|
|
for (int i = 0; i < count; i++) RsltItems_Screen_SingleWM[i] = ls.RsltItems_Screen_SingleWM[i];
|
2015-01-12 14:09:09 +00:00
|
|
|
|
2015-01-13 04:00:59 +00:00
|
|
|
count = (ls.RsltItems_Screen_CombinedWM != null) ? ls.RsltItems_Screen_CombinedWM.Length : 0;
|
|
|
|
|
RsltItems_Screen_CombinedWM = new string[count];
|
|
|
|
|
for (int i = 0; i < count; i++) RsltItems_Screen_CombinedWM[i] = ls.RsltItems_Screen_CombinedWM[i];
|
|
|
|
|
|
|
|
|
|
count = (ls.RsltItems_Printer_SingleWM != null) ? ls.RsltItems_Printer_SingleWM.Length : 0;
|
|
|
|
|
RsltItems_Printer_SingleWM = new string[count];
|
|
|
|
|
for (int i = 0; i < count; i++) RsltItems_Printer_SingleWM[i] = ls.RsltItems_Printer_SingleWM[i];
|
|
|
|
|
|
|
|
|
|
count = (ls.RsltItems_Printer_CombinedWM != null) ? ls.RsltItems_Printer_CombinedWM.Length : 0;
|
|
|
|
|
RsltItems_Printer_CombinedWM = new string[count];
|
|
|
|
|
for (int i = 0; i < count; i++) RsltItems_Printer_CombinedWM[i] = ls.RsltItems_Printer_CombinedWM[i];
|
2015-01-12 14:09:09 +00:00
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public readonly bool AlwaysAskPasswdWhenUnlocking;
|
|
|
|
|
|
|
|
|
|
[XmlIgnore]
|
|
|
|
|
public readonly bool RestoreUserWhenLeavingDialog;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LocalSettings()
|
|
|
|
|
{
|
|
|
|
|
AlwaysAskPasswdWhenUnlocking = false;
|
|
|
|
|
RestoreUserWhenLeavingDialog = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Load public fields of this class from the XML file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Load()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (TextReader reader = new StreamReader(Program.LocalSettingsFileName))
|
|
|
|
|
{
|
|
|
|
|
LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings;
|
|
|
|
|
// Copy the settings just in case De-serialize() completes OK
|
|
|
|
|
this.Assign(ls);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
string msg = e.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Save public fields of this class to the XML file.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (TextWriter writer = new StreamWriter(Program.LocalSettingsFileName))
|
|
|
|
|
{
|
|
|
|
|
(new XmlSerializer(typeof(LocalSettings))).Serialize(writer, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
string msg = e.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|