SAuvegarde SeqMaitre

This commit is contained in:
tzim 2013-10-02 18:04:16 +00:00
parent 351fed02de
commit c4aad3552c
4 changed files with 67 additions and 14 deletions

View file

@ -122,6 +122,15 @@ namespace DMX2
} }
} }
public Sequenceur GetSeqByID (int i)
{
foreach(Sequenceur seq in sequenceurs)
if(seq.ID == i)
return seq;
return null;
}
public List<UniversDMX> Patches { public List<UniversDMX> Patches {
get { get {
return univers; return univers;
@ -248,9 +257,19 @@ namespace DMX2
foreach (var xs in root["Sequenceurs"].ChildNodes) { foreach (var xs in root["Sequenceurs"].ChildNodes) {
Sequenceur s = Sequenceur.Load (this, xs as XmlElement); Sequenceur s = Sequenceur.Load (this, xs as XmlElement);
if(s!=null)sequenceurs.Add (s); if (s != null)
sequenceurs.Add (s);
} }
univers.Clear();
foreach (var xu in root["ListeUnivers"].ChildNodes) {
UniversDMX u = UniversDMX.Load(this,xu as XmlElement);
if(u!=null)
univers.Add(u);
}
seqmaitre = SequenceurMaitre.Load(this,root["SequenceurMaitre"]);
} }

View file

@ -70,8 +70,8 @@ namespace DMX2
System.Xml.XmlElement xmlVal; System.Xml.XmlElement xmlVal;
parent.AppendChild (el); parent.AppendChild (el);
el.SetAttribute("nom",_nom); el.SetAttribute("nom",_nom);
el.SetAttribute ("duree", _duree.TotalMilliseconds.ToString ()); el.SetAttribute ("duree", _duree.ToString ());
el.SetAttribute ("transition", _transition.TotalMilliseconds.ToString ()); el.SetAttribute ("transition", _transition.ToString ());
foreach (var valeur in _valeurs) { foreach (var valeur in _valeurs) {
xmlVal = parent.OwnerDocument.CreateElement("Valeur"); xmlVal = parent.OwnerDocument.CreateElement("Valeur");
el.AppendChild(xmlVal); el.AppendChild(xmlVal);
@ -90,8 +90,8 @@ namespace DMX2
); );
} }
return new Effet( el.GetAttribute("nom"),valeurs, return new Effet( el.GetAttribute("nom"),valeurs,
TimeSpan.FromMilliseconds(Double.Parse(el.GetAttribute("duree"))), TimeSpan.Parse(el.GetAttribute("duree")),
TimeSpan.FromMilliseconds(Double.Parse(el.GetAttribute("transition"))) TimeSpan.Parse(el.GetAttribute("transition"))
); );
} }

View file

@ -51,7 +51,7 @@ namespace DMX2
parent.AppendChild (el); parent.AppendChild (el);
el.SetAttribute ("nom", nom); el.SetAttribute ("nom", nom);
el.SetAttribute ("duree", duree.TotalMilliseconds.ToString ()); el.SetAttribute ("duree", duree.ToString ());
XmlElement xmlSeq; XmlElement xmlSeq;
foreach (var val in data) { foreach (var val in data) {
@ -61,6 +61,21 @@ namespace DMX2
} }
} }
public static Ligne Load (Conduite c, XmlElement el)
{
Ligne l = new Ligne();
l.nom = el.GetAttribute ("nom");
l.duree = TimeSpan.Parse(el.GetAttribute("duree"));
foreach (var xv in el.GetElementsByTagName("data")) {
XmlElement xmlSeq = xv as XmlElement;
Sequenceur seq = c.GetSeqByID(int.Parse(xmlSeq.GetAttribute("seq")));
l[seq]= xmlSeq.GetAttribute ("val");
}
return l;
}
} }
List<Ligne> lignes = new List<Ligne>(); List<Ligne> lignes = new List<Ligne>();
@ -89,9 +104,15 @@ namespace DMX2
} }
public static SequenceurMaitre Load (XmlElement doc) public static SequenceurMaitre Load (Conduite c, XmlElement el)
{ {
return null; SequenceurMaitre seq = new SequenceurMaitre ();
foreach (var xl in el.GetElementsByTagName("Ligne")) {
seq.Lignes.Add(Ligne.Load(c,xl as XmlElement));
}
return seq;
} }
} }
} }

View file

@ -106,12 +106,25 @@ namespace DMX2
} }
} }
public static UniversDMX Load (XmlElement doc) public static UniversDMX Load (Conduite c, XmlElement el)
{ {
return null; if (el.Name != "UniversDMX")
throw new ErreurLectureFichier ("<UniversDMX> attendu.");
UniversDMX univ = new UniversDMX ();
univ.Nom = el.GetAttribute("nom");
XmlElement xmlDim; Dimmer dim;
foreach (var xd in el.GetElementsByTagName("Dimmer")) {
xmlDim = xd as XmlElement;
dim.circuitAssocié = c.GetCircuitByID(int.Parse(xmlDim.GetAttribute("circuit")));
FTransfer.TryParse(xmlDim.GetAttribute("ft"),out dim.fonctionTransfert);
dim.param1 = float.Parse(xmlDim.GetAttribute("param1"));
dim.param2 = float.Parse(xmlDim.GetAttribute("param2"));
univ.Dimmers[int.Parse(xmlDim.GetAttribute("num"))] = dim;
}
return univ;
} }
} }
} }