using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
public enum PrecisionType
public class PrecisionChoice
public PrecisionChoice(string value)
NotifyPropertyChanged("Value");
public override string ToString()
public class PrecisionChoices : List<PrecisionChoice>
public PrecisionChoices()
internal PrecisionChoices(string src)
if (string.IsNullOrEmpty(src))
char[] separators = { ';' };
string[] lines = src.Split(separators);
foreach (string line in lines)
if (!string.IsNullOrEmpty(line))
base.Add(new PrecisionChoice(line));
public override string ToString()
foreach (PrecisionChoice item in Items)
if (!string.IsNullOrEmpty(item.Value))
if (string.IsNullOrEmpty(ret))
ret = ret + ";" + item.Value;
public class PrecisionGroup
public override string ToString()
if (!string.IsNullOrEmpty(_nom))
NotifyPropertyChanged("Nom");
private bool _isPrintable = true;
if (_isPrintable != value)
NotifyPropertyChanged("IsPrintable");
private PrecisionItems _precisions;
public PrecisionItems Items
_precisions = new PrecisionItems();
public class PrecisionItems : List<Precision>
public Precision Find(string name)
if (string.IsNullOrEmpty(name))
foreach (Precision item in Items)
if (!string.IsNullOrEmpty(item.Nom) && item.Nom.ToLower() == name.ToLower())
public void AddOrUpdateNotEmpty(string name, string value)
if (string.IsNullOrEmpty(value))
AddOrUpdate(name, value);
public Precision this[string name]
foreach (Precision item in Items)
if (item.Nom.ToLower() == name.ToLower())
Precision newItem = new Precision();
newItem.Value = string.Empty;
newItem.Type = PrecisionType.TextItem;
public void AddOrUpdate(string name, string value)
Precision newItem = null;
foreach (Precision item in Items)
if (item.Nom.ToLower() == name.ToLower())
newItem = new Precision();
newItem.Type = PrecisionType.TextItem;
public void Add(string name, string value)
Precision newItem = new Precision();
newItem.Type = PrecisionType.TextItem;
public override string ToString()
private PrecisionType _type;
public PrecisionType Type
NotifyPropertyChanged("Type");
NotifyPropertyChanged("Nom");
NotifyPropertyChanged("Value");
private PrecisionChoices _choices;
internal string ChoicesForSerialisation
return _choices.ToString();
if (_choices == null || _choices.ToString() != value)
_choices = new PrecisionChoices(value);
NotifyPropertyChanged("Choices");
public PrecisionChoices Choices
_choices = new PrecisionChoices("");
public class PrecisionGroups : List<PrecisionGroup>
public void AddOrUpdateNotEmptyItem(string groupName, string itemName, string value)
if (string.IsNullOrEmpty(value))
this[groupName].Items.AddOrUpdateNotEmpty(itemName, value);
public void DeleteSubItem(string name)
for (int i = Items.Count-1 ; i >= 0 ; i--)
PrecisionGroup group = Items[i];
Precision ret = group.Items.Find(name);
if (group.Items.Count == 0)
public void MoveGroupToEnd(string groupName)
PrecisionGroup gp = Find(groupName);
public void MoveToEnd(PrecisionGroup gp)
public PrecisionGroup Add(string name)
PrecisionGroup newGroup = new PrecisionGroup();
public Precision FindItem(string name)
foreach (PrecisionGroup group in Items)
Precision ret = group.Items.Find(name);
public PrecisionGroup Find(string name)
foreach (PrecisionGroup group in Items)
public PrecisionGroup this[string name]
return AddOrUpdate(name);
public PrecisionGroup AddOrUpdate(string name)
foreach (PrecisionGroup group in Items)
PrecisionGroup newGroup = new PrecisionGroup();
public PrecisionGroups(string src)
if (string.IsNullOrEmpty(src))
PrecisionGroup curGroup = null;
char[] separators = { 'ÿ' };
string[] lines = src.Split(separators);
foreach (string line in lines)
char[] colseparators = { '\t' };
string[] columns = line.Split(colseparators);
Precision prec = new Precision();
for (int col = 0; col < columns.Length; col++)
int.TryParse(columns[col], out type);
prec.Type = (PrecisionType) type;
prec.Nom = columns[col].Trim();
prec.Value = columns[col];
prec.ChoicesForSerialisation = columns[col];
curGroup = new PrecisionGroup();
curGroup.IsPrintable = false;
curGroup.Items.Add(prec);
curGroup = new PrecisionGroup();
curGroup.Items.Add(prec);
public override string ToString()
foreach (PrecisionGroup grp in Items)
if (string.IsNullOrEmpty(ret))
ret = "0\t" + grp.Nom+"\t"+(grp.IsPrintable?"":"1")+"\t";
ret = ret + "ÿ0\t" + grp.Nom + "\t" + (grp.IsPrintable ? "" : "1") + "\t";
foreach (Precision item in grp.Items)
ret = ret + "ÿ" + ((int)item.Type).ToString() + "\t" + item.Nom + "\t" + item.Value + "\t" + item.ChoicesForSerialisation;