/// <summary>
        /// Costructor used to read the needed values from
        /// the O37 element to locate the macrobox position
        /// in the project and compare the current values with
        /// thoes to set.
        /// </summary>
        /// <param name="o37"></param>
        public MacroBox(XmlElement o37, string _pageName)
        {
            //TODO: maybe extract methodes from regions
            #region Set Name
            try
            {
                this.Name = o37.SelectSingleNode("P11/@P23001").Value;
            }
            catch (NullReferenceException)
            {
                this.Name = "";
            }
            #endregion

            #region Set Variant
            this.Variant = o37.GetAttribute("A690");
            #endregion

            #region Set DocumentType
            this.RepresentationType = o37.GetAttribute("A689");
            #endregion

            #region Set Description
            try
            {
                this.Description = EplanScriptHelper.GetMuLanStringToDisplay(o37.SelectSingleNode("P11/@P23004").Value);
            }
            catch (NullReferenceException)
            {
                this.Description = "";
            }
            #endregion

            #region Set X and Y
            try
            {
                string location = o37.SelectSingleNode("S40x1201/@A762").Value;
                this.X = location.Split('/')[0];
                this.Y = location.Split('/')[1];
            }
            catch (NullReferenceException)
            {
                this.X = "";
                this.Y = "";
            }
            #endregion

            this.PageName = _pageName;
        }
        /// <summary>
        /// Costructor used to read the needed values from
        /// the O4 element for setting page dependent properties
        /// of the macroboxes located on a page.
        /// </summary>
        public Page(XmlTextReader reader, List <StructureSegments> StructureSegmentOrder)
        {
            XmlDocument document = new XmlDocument();

            document.LoadXml(reader.ReadOuterXml());

            //TODO: maybe extract methodes from regions
            #region Set PageStructureSements
            this.PageStructureSegments = new Dictionary <StructureSegments, string>();
            XmlNode p49 = document.SelectSingleNode("O4/P49");
            foreach (XmlAttribute attr in p49.Attributes)
            {
                int id = Convert.ToInt32(attr.Name.Remove(0, 1));
                PageStructureSegments.Add((StructureSegments)id, attr.Value);
            }
            #endregion

            #region Set Description
            try
            {
                this.Description = EplanScriptHelper.GetMuLanStringToDisplay(document.SelectSingleNode("O4/P11/@P11011").Value);
            }
            catch (NullReferenceException)
            {
                this.Description = "";
            }
            #endregion

            #region Set DocumentType
            this.DocumentType = ((XmlElement)document.SelectSingleNode("O4")).GetAttribute("A47");
            #endregion

            //How is this solved in entity frameworks?
            _StructureSegmentOrder = StructureSegmentOrder;

            SetFullPageName();

            #region Set MacroBoxList
            this.MacroBoxList = new List <MacroBox>();
            foreach (XmlNode o37 in document.SelectNodes("O4/O37"))
            {
                this.MacroBoxList.Add(new MacroBox((XmlElement)o37, this.FullPageName));
            }
            #endregion

            SetMacroBoxNewNames();
            SetMacroBoxNewRepresentationTypes();
        }