public bool SetDCCProgram(CDCCDefinition program) { bool isNotOverride = true; if (DCCPrograms.ContainsKey(program.Name)) { DCCPrograms.Remove(program.Name); isNotOverride = false; } DCCPrograms.Add(program.Name, program); return(isNotOverride); }
private void LoadProgramDefinitions() { XmlTextReader reader = null; try { if (!File.Exists(m_sProgramDefSavePath)) { SaveProgramDefinitions(); } reader = new XmlTextReader(m_sProgramDefSavePath); string currentDef = ""; string currentProg = ""; while (reader.Read()) { reader.MoveToElement(); if (reader.LocalName == "ProgramDef" && reader.AttributeCount > 0) { reader.MoveToNextAttribute(); var def = new CDCCDefinition(); def.Name = reader.Value; SetDCCProgram(def); currentDef = reader.Value; } else if (reader.LocalName == "Program" && reader.AttributeCount > 0) { reader.MoveToNextAttribute(); SDCCProgram program = new SDCCProgram(); program.Name = reader.Value; reader.MoveToNextAttribute(); program.ExecutablePath = reader.Value; GetDCCProgram(currentDef).Programs.Add(program.Name, program); currentProg = program.Name; } else if (reader.LocalName == "File") { SDCCProgram prog = GetDCCProgram(currentDef).GetProgram(currentProg); SStartupFile file = new SStartupFile("", ""); reader.MoveToNextAttribute(); file.Name = reader.Value; reader.MoveToNextAttribute(); file.SetFilePath(reader.Value); reader.MoveToNextAttribute(); bool boolVal; Boolean.TryParse(reader.Value, out boolVal); file.Copy = boolVal; reader.MoveToNextAttribute(); Boolean.TryParse(reader.Value, out boolVal); file.LaunchWithProgram = boolVal; prog.StartupFiles.Add(file.Name, file); } else { } } } catch (Exception e) { if (reader != null) { reader.Close(); } CUserInteractionUtils.ShowErrorMessageBox(e.Message); // TODO: More ionfo pls } }