예제 #1
0
        public static string GetSettingsXML(KbBimstoreTab tab)
        {
            XmlSerializer xsSubmit = new XmlSerializer(typeof(KbBimstoreTab));

            using (StringWriter stringWriter = new StringWriter())
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings {
                    OmitXmlDeclaration = true
                }))
                {
                    xsSubmit.Serialize(xmlWriter, tab);
                    string xml = stringWriter.ToString();

                    return(xml);
                }
            }
        }
예제 #2
0
        private static void CreateDefaultTabSettings(string path)
        {
            KbBimstoreTab defaultTab = new KbBimstoreTab();

            defaultTab.Name     = defaultTabName;
            defaultTab.Locked   = false;
            defaultTab.Enabled  = true;
            defaultTab.ToolBars = new List <KbBimstoreToolbar>();

            for (int i = 0; i < defaultPanels.Length; i++)
            {
                string panel = defaultPanels[i];

                KbBimstoreToolbar toolbar = new KbBimstoreToolbar();
                toolbar.Name        = panel;
                toolbar.Enabled     = true;
                toolbar.TabIdentity = i;

                defaultTab.ToolBars.Add(toolbar);
            }

            File.WriteAllText(path, GetSettingsXML(defaultTab));
        }
예제 #3
0
        private void importSettingsButton_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.Filter           = "XML Files | *.xml";
            this.openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            DialogResult dr = this.openFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string importPath = this.openFileDialog1.FileName;

                KbBimstoreTab tab = KbBimstoreTab.CreateBimStoreFromSettings(importPath);

                if (tab != null)
                {
                    KbBimstoreApp.MainTab = tab;
                }
                else
                {
                    MessageBox.Show("Error importing settings file. Please try another file", KbBimstoreApp.MainTab.Name);
                }
            }
        }