/// <summary>
        /// Updates the data file tools from the HTML document within the supplied range 
        /// </summary>
        /// <param name="start">beginning tool to save</param>
        /// <param name="count">last tool to update </param>
        public void SaveToolEditor(int start, int count)
        {
            UpdateDocument(new Action(delegate()
            {
                for (int i = start; i <= count; i++)
                {
                    var element = _GuiHost.Document.GetElementById(String.Format("toolname{0}", i));
                    if (element != null)
                    {
                        var tool = InterpreterDataFile.Tools.FirstOrDefault(x => x.Index == i);
                        if (tool == null)
                        {
                            tool = new ToolData { Index = i };
                            InterpreterDataFile.Tools.Add(tool);
                        }
                        double offsetvalue = 0.0;
                        int indexvalue = 0;

                        tool.ToolName = _GuiHost.GetAttribute(String.Format("toolname{0}", i), Attribs.Value);
                        if (_GuiHost.Document.GetElementById(String.Format("toolslot{0}", i)) != null)
                        {
                            if (Int32.TryParse(_GuiHost.GetAttribute(String.Format("toolslot{0}", i), Attribs.Value), out indexvalue))
                            {
                                tool.SlotNumber = indexvalue;
                            }
                        }
                        if (_GuiHost.Document.GetElementById(String.Format("ID{0}", i)) != null)
                        {
                            if (Int32.TryParse(_GuiHost.GetAttribute(String.Format("ID{0}", i), Attribs.Value), out indexvalue))
                            {
                                tool.ID = indexvalue;
                            }
                        }
                        if (_GuiHost.Document.GetElementById(String.Format("toollength{0}", i)) != null)
                        {
                            if (Double.TryParse(_GuiHost.GetAttribute(String.Format("toollength{0}", i), Attribs.Value), out offsetvalue))
                            {
                                tool.LengthOffset = offsetvalue;
                            }
                        }
                        if (_GuiHost.Document.GetElementById(String.Format("tooldiameter{0}", i)) != null)
                        {
                            if (Double.TryParse(_GuiHost.GetAttribute(String.Format("tooldiameter{0}", i), Attribs.Value), out offsetvalue))
                            {
                                tool.DiameterOffset = offsetvalue;
                            }
                        }
                        if (_GuiHost.Document.GetElementById(String.Format("XOffset{0}", i)) != null)
                        {
                            if (Double.TryParse(_GuiHost.GetAttribute(String.Format("XOffset{0}", i), Attribs.Value), out offsetvalue))
                            {
                                tool.XOffset = offsetvalue;
                            }
                        }
                        if (_GuiHost.Document.GetElementById(String.Format("YOffset{0}", i)) != null)
                        {
                            if (Double.TryParse(_GuiHost.GetAttribute(String.Format("YOffset{0}", i), Attribs.Value), out offsetvalue))
                            {
                                tool.YOffset = offsetvalue;
                            }
                        }
                    }
                }
            })); 
        }
 /// <summary>
 /// Transfers tool data from the data file to the HTML within the supplied range of elements
 /// </summary>
 /// <param name="start">beginning tool to load</param>
 /// <param name="count">last tool to load </param>
 public void LoadToolEditor(int start, int count)
 {
     bool needssave = false;
     UpdateDocument(new Action(delegate()
         {
             for (int i = start; i <= count; i++)
             {
                 var element = _GuiHost.Document.GetElementById(String.Format("toolname{0}", i));
                 if (element != null)
                 {
                     var tool = InterpreterDataFile.Tools.FirstOrDefault(x => x.Index == i);
                     if (tool == null)
                     {
                         tool = new ToolData { Index = i };
                         InterpreterDataFile.Tools.Add(tool);
                         needssave = true;
                     }
                     _GuiHost.SetAttribute(String.Format("toolname{0}", i), Attribs.Value, tool.ToolName);
                     _GuiHost.SetAttribute(String.Format("toolslot{0}", i), Attribs.Value, tool.SlotNumber);
                     _GuiHost.SetAttribute(String.Format("ID{0}", i), Attribs.Value, tool.ID);
                     _GuiHost.SetAttribute(String.Format("toollength{0}", i), Attribs.Value, tool.LengthOffset);
                     _GuiHost.SetAttribute(String.Format("tooldiameter{0}", i), Attribs.Value, tool.DiameterOffset);
                     _GuiHost.SetAttribute(String.Format("XOffset{0}", i), Attribs.Value, tool.XOffset);
                     _GuiHost.SetAttribute(String.Format("YOffset{0}", i), Attribs.Value, tool.YOffset);
                 }
             }
         }));
     if (needssave)
     {
         SaveInterpreterData();
     }
 }