Example #1
0
void ProjectManagerXML::writeHeader(wxXmlDocument &doc)
{
    wxXmlNode *root;

    doc.SetFileEncoding("UTF-8");
    doc.SetVersion("1.0");

    root = new wxXmlNode(wxXML_ELEMENT_NODE, ROOT_STR);
    root->AddAttribute(ATTRIBUTE_VERSION_STR, wxString::Format("%.4d", PROJECT_FILE_VERSION));
    doc.SetRoot(root);
}
Example #2
0
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);
	}

}