117 lines
3.0 KiB
C#
117 lines
3.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace WorkflowConfigurator
|
|
{
|
|
/// <summary>
|
|
/// Class to be serialized to an XML file...
|
|
/// </summary>
|
|
[XmlRootAttribute("WorkflowConfigurator")]
|
|
public class LocalSettings
|
|
{
|
|
static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0];
|
|
|
|
/// Common
|
|
public string ConnectionString;
|
|
public string UsersDBConnString;
|
|
public string Language;
|
|
|
|
/// MainWnd
|
|
public int MWndLeft;
|
|
public int MWndTop;
|
|
public int MWndWidth;
|
|
public int MWndHeight;
|
|
public bool MWndMaximized;
|
|
|
|
/// Overview
|
|
public bool OverviewCB6;
|
|
public bool OverviewCB7;
|
|
public bool OverviewCB8;
|
|
public bool OverviewCB9;
|
|
|
|
public string OverviewNameContains;
|
|
public float SplDst1;
|
|
public float SplDst2;
|
|
|
|
public int ColWid1;
|
|
public int ColWid2;
|
|
public int ColWid3;
|
|
public int ColWid4;
|
|
public int ColWid5;
|
|
public int ColWid6;
|
|
public int ColWid7;
|
|
public int ColWid8;
|
|
|
|
public string LastWorkstep;
|
|
|
|
public LocalSettings()
|
|
{
|
|
}
|
|
|
|
public LocalSettings(bool createNew)
|
|
: this()
|
|
{
|
|
/// Default settings
|
|
|
|
/// Common
|
|
ConnectionString = "SERVER=10.42.128.24; DATABASE=sledovanie2019; UID=vyroba2019; PASSWORD=qwerty; CHARSET=utf8";
|
|
UsersDBConnString = "SERVER=10.42.128.24; DATABASE=st_wr_shared_config; UID=u9305784; PASSWORD=p89344390; CHARSET=utf8;";
|
|
Language = "sk";
|
|
|
|
/// MainWnd
|
|
MWndLeft = 20;
|
|
MWndTop = 20;
|
|
MWndWidth = 1250;
|
|
MWndHeight = 750;
|
|
MWndMaximized = false;
|
|
|
|
/// Overview
|
|
OverviewCB6 = true;
|
|
OverviewCB7 = true;
|
|
OverviewCB8 = true;
|
|
OverviewCB9 = true;
|
|
SplDst1 = 600;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load public fields of this class from the XML file.
|
|
/// </summary>
|
|
/// <returns>LocalSettings object or null when Load() fails</returns>
|
|
public static LocalSettings Load(string fileName)
|
|
{
|
|
try
|
|
{
|
|
using (TextReader reader = new StreamReader(fileName))
|
|
{
|
|
return serializer.Deserialize(reader) as LocalSettings;
|
|
}
|
|
}
|
|
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))
|
|
{
|
|
serializer.Serialize(writer, this);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
string msg = e.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|