fyiReporting.RdlDesign.RdlDesigner.SaveStartupState C# (CSharp) Method

SaveStartupState() private method

private SaveStartupState ( ) : void
return void
        private void SaveStartupState()
        {
            try
            {
                int[] colors = GetCustomColors();		// get custom colors

                XmlDocument xDoc = new XmlDocument();
                XmlProcessingInstruction xPI;
                xPI = xDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xDoc.AppendChild(xPI);

                XmlNode xDS = xDoc.CreateElement("designerstate");
                xDoc.AppendChild(xDS);

                XmlNode xN;
                // Loop thru the current files
                XmlNode xFiles = xDoc.CreateElement("CurrentFiles");
                xDS.AppendChild(xFiles);
                foreach (MDIChild mc in this.MdiChildren)
                {
                    Uri file = mc.SourceFile;
                    if (file == null)
                    {
                        continue;
                    }
                    xN = xDoc.CreateElement("file");
                    xN.InnerText = file.LocalPath;
                    xFiles.AppendChild(xN);
                }

                // Recent File Count
                XmlNode rfc = xDoc.CreateElement("RecentFilesMax");
                xDS.AppendChild(rfc);
                rfc.InnerText = this._RecentFilesMax.ToString();

                // Loop thru recent files list
                xFiles = xDoc.CreateElement("RecentFiles");
                xDS.AppendChild(xFiles);
                foreach (string f in _RecentFiles.Values)
                {
                    xN = xDoc.CreateElement("file");
                    xN.InnerText = f;
                    xFiles.AppendChild(xN);
                }

                // Help File URL
                XmlNode hfu = xDoc.CreateElement("Help");
                xDS.AppendChild(hfu);
                hfu.InnerText = this._HelpUrl;

                // Map chart subtypes
                XmlNode hmap = xDoc.CreateElement("MapSubtypes");
                xDS.AppendChild(hmap);
                StringBuilder maps = new StringBuilder();
                for (int mi = 0; mi < MapSubtypes.Length; mi++)
                {
                    maps.Append(MapSubtypes[mi]);
                    if (mi + 1 < MapSubtypes.Length)
                        maps.Append(',');
                }
                hmap.InnerText = maps.ToString();

                // Show Line numbers
                XmlNode bln = xDoc.CreateElement("EditLines");
                xDS.AppendChild(bln);
                bln.InnerText = this._ShowEditLines ? "true" : "false";

                // Show Preview Wait dialog
                XmlNode pwd = xDoc.CreateElement("ShowPreviewWaitDialog");
                xDS.AppendChild(pwd);
                pwd.InnerText = this.ShowPreviewWaitDialog ? "true" : "false";

                // Outline reportitems
                XmlNode ori = xDoc.CreateElement("OutlineReportItems");
                xDS.AppendChild(ori);
                ori.InnerText = this.ShowReportItemOutline ? "true" : "false";

                // ShowTabbedInterface
                XmlNode sti = xDoc.CreateElement("ShowTabbedInterface");
                xDS.AppendChild(sti);
                sti.InnerText = this._ShowTabbedInterface ? "true" : "false";

                // PropertiesAutoHide
                XmlNode pah = xDoc.CreateElement("PropertiesAutoHide");
                xDS.AppendChild(pah);
                pah.InnerText = this._PropertiesAutoHide ? "true" : "false";

                // PropertiesLocation
                string loc = "right";
                switch (_PropertiesLocation)
                {
                    case DockStyle.Left:
                        loc = "left";
                        break;
                    case DockStyle.Top:
                        loc = "top";
                        break;
                    case DockStyle.Bottom:
                        loc = "bottom";
                        break;
                }
                XmlNode pl = xDoc.CreateElement("PropertiesLocation");
                xDS.AppendChild(pl);
                pl.InnerText = loc;

                // Save the toolbar items
                XmlNode xTB = xDoc.CreateElement("Toolbar");
                xDS.AppendChild(xTB);
                foreach (string t in _Toolbar)
                {
                    xN = xDoc.CreateElement("item");
                    xN.InnerText = t;
                    xTB.AppendChild(xN);
                }

                // Save the custom colors
                StringBuilder sb = new StringBuilder();
                foreach (int c in colors)
                {
                    sb.Append(c.ToString());
                    sb.Append(",");
                }
                sb.Remove(sb.Length - 1, 1);	// remove last ","

                xN = xDoc.CreateElement("CustomColors");
                xN.InnerText = sb.ToString();
                xDS.AppendChild(xN);

                // Save the file
                string optFileName = AppDomain.CurrentDomain.BaseDirectory + "designerstate.xml";

                xDoc.Save(optFileName);
            }
            catch { }		// still want to leave even on error

            return;
        }
RdlDesigner