public Bitmap Render(Element?[] elements)
 {
     Bitmap output = new Bitmap(elements.Length * (options.ElementWidth + 1), options.ElementHeight);
       Graphics g = Graphics.FromImage(output);
       StringFormat symbolFormat = new StringFormat();
       symbolFormat.Alignment = symbolFormat.LineAlignment = StringAlignment.Center;
       for (int i = 0; i < elements.Length; i++)
     if (elements[i].HasValue)
     {
       Rectangle currentRectangle = new Rectangle(i * (options.ElementWidth + 1), 0, options.ElementWidth - 1, options.ElementHeight - 1);
       g.TextRenderingHint = options.ForceAntiAlias ? TextRenderingHint.AntiAlias : TextRenderingHint.SystemDefault;
       g.DrawRectangle(options.LinePen, currentRectangle);
       g.DrawString(elements[i].Value.Symbol, new Font(options.Font, 20), options.SymbolBrush, new Rectangle(currentRectangle.X, currentRectangle.Y, currentRectangle.Width, currentRectangle.Height), symbolFormat);
       g.DrawString(elements[i].Value.Atomic.ToString(), new Font(options.Font, 8), options.SymbolBrush, new Rectangle(currentRectangle.X + (options.ElementWidth - 18), currentRectangle.Y, 16, 16), symbolFormat);
       g.DrawString(elements[i].Value.Name, new Font(options.Font, 6), options.SymbolBrush, new Rectangle(currentRectangle.X, options.ElementHeight - 16, options.ElementWidth, 16), symbolFormat);
     }
       return output;
 }
 public void Init(string periodicData, HandleProgress progress)
 {
     progress(0, "Searching for cached table...");
       if (File.Exists(periodicData))
       {
     Stream file = File.Open(periodicData, FileMode.OpenOrCreate);
     this.elements = (Element[])serializer.Deserialize(file);
       }
       else
       {
     List<Element> elements = new List<Element>();
     XmlDocument resolver = new XmlDocument();
     resolver.LoadXml(table.GetAtoms());
     XmlNodeList nodes = resolver.GetElementsByTagName("ElementName");
     int i = 0;
     foreach (XmlNode tag in nodes)
     {
       Element element = new Element() { Name = tag.InnerXml };
       resolver.LoadXml(table.GetAtomicNumber(element.Name));
       element.Symbol = resolver.GetElementsByTagName("Symbol")[0].InnerXml;
       element.Atomic = int.Parse(resolver.GetElementsByTagName("AtomicNumber")[0].InnerXml);
       elements.Add(element);
       progress((double)i++ / (double)nodes.Count, "Downloaded " + tag.InnerXml);
     }
     this.elements = elements.OrderByDescending(e => e.Symbol.Length).ToArray();
     Stream file = File.Open(periodicData, FileMode.OpenOrCreate);
     serializer.Serialize(file, this.elements);
     progress(1, "Complete");
     IsInit = true;
       }
 }