Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/LabelProvider/ContinuousLabelProvider.cs @ 1688

Last change on this file since 1688 was 1385, checked in by gkragl, 16 years ago

Implemented persistence mechanism for XAxisLabelProvider (#434)

File size: 1.1 KB
Line 
1using System.Globalization;
2using System.Xml;
3
4namespace HeuristicLab.Visualization.LabelProvider {
5  public class ContinuousLabelProvider : ILabelProvider {
6    private readonly string format;
7
8    public ContinuousLabelProvider() {}
9
10    public ContinuousLabelProvider(string format) {
11      this.format = format;
12    }
13
14    public string GetLabel(double value) {
15      return value.ToString(format, CultureInfo.InvariantCulture);
16    }
17
18    public XmlNode GetLabelProviderXmlNode()
19    {
20      XmlDocument Xdoc = new XmlDocument();
21
22      XmlNode lblProvInfo = Xdoc.CreateNode(XmlNodeType.Element, "LabelProvider", null);
23      lblProvInfo.InnerText = "ContinuousLabelProvider";
24
25      XmlAttribute idFormat = Xdoc.CreateAttribute("format");
26      idFormat.Value = this.format;
27
28      lblProvInfo.Attributes.Append(idFormat);
29
30      return lblProvInfo;
31    }
32
33    public ILabelProvider PopulateLabelProviderXmlNode(XmlNode node) {
34      var labelProvider = new ContinuousLabelProvider(node.SelectSingleNode("//LabelProvider").Attributes[0].Value);
35      return labelProvider;
36    }
37  }
38}
Note: See TracBrowser for help on using the repository browser.