public bool LoadData(CompuMethod dat) { currentCM = dat; this.entryName.Text = dat.name; this.entryDescription.Text = dat.description; if (dat is RationalFunction) { currentRF = (RationalFunction)dat; this.notebook1.GetNthPage(0).ShowAll(); this.notebook1.GetNthPage(1).HideAll(); this.entryNumerator.Text = currentRF.Numerators [0].ToString(); this.entryNumerator1.Text = currentRF.Numerators [1].ToString(); this.entryDenominator.Text = currentRF.Denominators [0].ToString(); this.entryDenominator1.Text = currentRF.Denominators [1].ToString(); } else if (dat is VerbalTable) { currentVT = (VerbalTable)dat; this.notebook1.GetNthPage(0).HideAll(); this.notebook1.GetNthPage(1).ShowAll(); lsVT.Clear(); foreach (var item in ((VerbalTable)dat).items) { this.lsVT.AppendValues(item.Key, item.Value); } this.buttonDelete.Sensitive = false; } else { } return(true); }
public CompuMethod SaveData(CompuMethod dat = null) { if (null == dat) { dat = currentCM; } dat.name = this.entryName.Text; dat.description = this.entryDescription.Text; if (dat is RationalFunction) { ((RationalFunction)dat).Numerators [0] = Convert.ToDouble(this.entryNumerator.Text); ((RationalFunction)dat).Numerators [1] = Convert.ToDouble(this.entryNumerator1.Text); ((RationalFunction)dat).Denominators [0] = Convert.ToDouble(this.entryDenominator.Text); ((RationalFunction)dat).Denominators [1] = Convert.ToDouble(this.entryDenominator1.Text); } else if (dat is VerbalTable) { TreeIter ti; lsVT.GetIterFirst(out ti); ((VerbalTable)dat).items.Clear(); for (int i = 0; i < lsVT.IterNChildren(); i++) { ((VerbalTable)dat).items.Add((int)lsVT.GetValue(ti, 0), (string)lsVT.GetValue(ti, 1)); lsVT.IterNext(ref ti); } } else { } return(dat); }
public static CompuMethod ParseFromXml(XmlNode node, CompuMethod ret = null) { switch (node.Name) { case "RationalFunction": return(RationalFunction.ParseFromXml(node, ret)); break; case "VerbalTable": return(VerbalTable.ParseFromXml(node, ret)); break; default: return(ret); break; } }