bool wxExViMacros::Load(wxXmlDocument& doc) { // This test is to prevent showing an error if the macro file does not exist, // as this is not required. if (!GetFileName().FileExists()) { return false; } if (!doc.Load(GetFileName().GetFullPath())) { return false; } return true; }
void MyFrame::LoadConfigFromFile() { if (wxFile::Exists("config/config.xml")) { bool success = config.Load("config/config.xml"); } wxXmlNode* root = config.GetRoot(); if (root == 0) { config.SetRoot(new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "Root")); root = config.GetRoot(); } wxXmlNode* child = root->GetChildren(); if (child == 0) { wxXmlNode* pathInfo = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "LastPath"); pathInfo->AddProperty("LastDatabasePath", ""); pathInfo->AddProperty("LastDatabaseFile", ""); pathInfo->AddProperty("LastCSVPath", ""); root->AddChild(pathInfo); } else { lastDatabasePath = child->GetPropVal("LastDatabasePath", ""); lastDatabaseFile = child->GetPropVal("LastDatabaseFile", ""); lastCSVPath = child->GetPropVal("LastCSVPath", ""); toolPanel->SetCSVPath(lastCSVPath); } if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* pageState = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "PageState"); root->AddChild(pageState); } else { wxXmlNode* nextPage = child->GetChildren(); while (nextPage != 0) { wxString table = nextPage->GetPropVal("Table", ""); wxString itemName = nextPage->GetPropVal("ItemName", ""); if (tcBaseViewer* viewer = FindViewerForTable(table)) { viewer->InitializeDatabaseClass(itemName); } nextPage = nextPage->GetNext(); } } // sonar calculation if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* sonarConfig = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "SonarCalculation"); root->AddChild(sonarConfig); } else { wxXmlNode* sonarConfig = child; tcSonarCalculationControl::Get()->LoadXmlConfig(sonarConfig); } // missile calculation if (child != 0) child = child->GetNext(); if (child == 0) { wxXmlNode* missileConfig = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, "MissileCalculation"); root->AddChild(missileConfig); } else { wxXmlNode* missileConfig = child; tcMissileCalculationControl::Get()->LoadXmlConfig(missileConfig); } }