103 lines
2.8 KiB
C#
103 lines
2.8 KiB
C#
///
|
|
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Statistics
|
|
{
|
|
/// <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("Statistics")]
|
|
public class LocalSettings
|
|
{
|
|
/// <summary>
|
|
/// User interface language (used as CultureInfo(..) constructor argument).
|
|
/// </summary>
|
|
public string Language;
|
|
|
|
/// Names of servers.
|
|
public string Bench1;
|
|
public string Bench2;
|
|
public string Bench3;
|
|
public string Bench4;
|
|
public string Bench5;
|
|
public string Bench6;
|
|
|
|
/// Database settings of servers.
|
|
public string ConnectionString1;
|
|
public string ConnectionString2;
|
|
public string ConnectionString3;
|
|
public string ConnectionString4;
|
|
public string ConnectionString5;
|
|
public string ConnectionString6;
|
|
|
|
public string TimePeriodFormat;
|
|
|
|
/// Statistics options
|
|
public bool TwoDim;
|
|
|
|
/// MainWnd
|
|
public int MainWndLeft;
|
|
public int MainWndTop;
|
|
public int MainWndWidth;
|
|
public int MainWndHeight;
|
|
public bool ManiWndMaximized;
|
|
public int SplitterDistance;
|
|
|
|
/// Last configuration file name
|
|
public string LastConfigFileName;
|
|
|
|
|
|
public LocalSettings()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load public fields of this class from the XML file.
|
|
/// </summary>
|
|
public static LocalSettings Load(string fileName)
|
|
{
|
|
try
|
|
{
|
|
using (TextReader reader = new StreamReader(fileName))
|
|
{
|
|
LocalSettings ls = (new XmlSerializer(typeof(LocalSettings))).Deserialize(reader) as LocalSettings;
|
|
// Copy the settings just in case De-serialize() completes OK
|
|
return ls;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
string msg = e.Message;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
}
|
|
}
|