Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/21/09 10:07:16 (16 years ago)
Author:
gkragl
Message:

Implemented persistence mechanism for XAxisLabelProvider (#434)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/LabelProvider/StringLabelProvider.cs

    r1194 r1385  
    22using System.Collections.Generic;
    33using HeuristicLab.Visualization.LabelProvider;
     4using System.Xml;
    45
    56namespace HeuristicLab.Visualization.LabelProvider {
     
    2627        return string.Empty;
    2728    }
     29
     30    public XmlNode GetLabelProviderXmlNode() {
     31      XmlDocument Xdoc = new XmlDocument();
     32
     33      XmlNode lblProvInfo = Xdoc.CreateNode(XmlNodeType.Element, "LabelProvider", null);
     34      lblProvInfo.InnerText = "StringLabelProvider";
     35
     36      foreach (KeyValuePair<int, string> pair in labels)
     37      {
     38        XmlNode strLbl = Xdoc.CreateNode(XmlNodeType.Element, "String", null);
     39
     40        XmlAttribute idStrLbl = Xdoc.CreateAttribute("id");
     41        idStrLbl.Value = pair.Key.ToString();
     42        strLbl.Attributes.Append(idStrLbl);
     43
     44        strLbl.InnerText = pair.Value;
     45        lblProvInfo.AppendChild(strLbl);
     46      }
     47      return lblProvInfo;
     48    }
     49
     50    public ILabelProvider PopulateLabelProviderXmlNode(XmlNode node) {
     51      var labelProvider = new StringLabelProvider();
     52
     53      foreach (XmlNode strLbl in node.SelectNodes("//String"))
     54      {
     55        labelProvider.SetLabel(int.Parse(strLbl.Attributes[0].Value), strLbl.InnerText);
     56      }
     57      return labelProvider;
     58    }
    2859  }
    2960}
Note: See TracChangeset for help on using the changeset viewer.