public bool initCreateStartEmptyProject(IDELauncherSetup projectSetup, out string errorMsg) { errorMsg = ""; this._setup = projectSetup; if (!Directory.Exists(this._setup.projectDirectoyPath)) { Directory.CreateDirectory(this._setup.projectDirectoyPath); } Assembly executingAssembly = Assembly.GetExecutingAssembly(); GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.ProjectDescriptor.xml"), false); bool flag = false; bool flag2 = false; string replacement = ""; int num4 = reader.HowManyChildNode("RadioChip"); string path = ""; string str10 = ""; string str12 = ""; for (int i = 0; (i < num4) && !flag; i++) { reader.NavigateToChild("RadioChip", i); if (this._setup.radioChipType.Contains(reader.GetAttribute("name", false))) { int num3 = reader.HowManyChildNode("MCU"); for (int j = 0; (j < num3) && !flag; j++) { reader.NavigateToChild("MCU", j); reader.GetAttribute("name", false); if (reader.GetAttribute("name", false) == this._setup.mcu.ToString()) { int num2 = reader.HowManyChildNode("Vendor"); for (int k = 0; k < num2; k++) { reader.NavigateToChild("Vendor", k); if (reader.GetAttribute("name", false) == this._setup.toolVendor.ToString()) { reader.NavigateToChild("Project", 0); replacement = reader.GetAttribute("name", false); if (!Directory.Exists(this._setup.projectDirectoyPath + @"\" + replacement)) { Directory.CreateDirectory(this._setup.projectDirectoyPath + @"\" + replacement); } flag = true; break; } reader.NavigateUpOneLevel(); } } else { reader.NavigateUpOneLevel(); } } } else { reader.NavigateUpOneLevel(); } } if (flag) { StreamWriter writer; reader.NavigateToChild("WSP", 0); reader.NavigateToChild("FileName", 0); string str5 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("FilePath", 0); reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("ResourceName", 0); string str6 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); StreamReader reader2 = new StreamReader(executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.IDE_Project_Resources." + str6)); string input = reader2.ReadToEnd(); reader2.Close(); path = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str5; string pattern = "<WorkSpaceName>"; string str2 = path; input = Regex.Replace(input, pattern, str2); pattern = "<Vendor>"; switch (this._setup.toolVendor) { case IDELauncherSetup.ToolVendor.Keil: str2 = "0"; break; case IDELauncherSetup.ToolVendor.Raisonance: str2 = "1"; break; case IDELauncherSetup.ToolVendor.SDCC: str2 = "5"; break; } input = Regex.Replace(input, pattern, str2); pattern = "<Assembler>"; input = Regex.Replace(input, pattern, this._setup.assemblerExec); pattern = "<AssFlag>"; input = Regex.Replace(input, pattern, this._setup.assemblerFlags); pattern = "<AssFormat>"; input = Regex.Replace(input, pattern, this._setup.assemblerFormat); pattern = "<Compiler>"; input = Regex.Replace(input, pattern, this._setup.compilerExec); pattern = "<CompFlag>"; input = Regex.Replace(input, pattern, this._setup.compilerFlags); pattern = "<CompFormat>"; input = Regex.Replace(input, pattern, this._setup.compilerFormat); pattern = "<Linker>"; input = Regex.Replace(input, pattern, this._setup.linkerExec); pattern = "<LinkFlag>"; input = Regex.Replace(input, pattern, this._setup.linkerFlags); pattern = "<LinkFormat>"; input = Regex.Replace(input, pattern, this._setup.linkerFormat); pattern = "<OutputFile>"; input = Regex.Replace(input, pattern, replacement); int num = reader.HowManyChildNode("File"); int num9 = 0; int childNumber = 0; while (childNumber < num) { reader.NavigateToChild("File", childNumber); reader.NavigateToChild("FileName", 0); string str8 = reader.InnerText(); reader.NavigateUpOneLevel(); if (!this._setup.includeMCUHeaders && str8.Contains(this._setup.mcu.ToString())) { reader.NavigateUpOneLevel(); num9++; } else { string str11; reader.NavigateToChild("FilePath", 0); str10 = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("ResourceName", 0); string str9 = reader.InnerText(); reader.NavigateUpOneLevel(); if (this._setup.predefinedSourceFileStructure && (str10 != "")) { if (!Directory.Exists(this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10)) { Directory.CreateDirectory(this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10); } str11 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10 + @"\" + str8; } else { str11 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str8; } Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("NewWDS.Applications.IDE_Launcher.IDE_Project_Resources." + str9); FileStream stream2 = new FileStream(str11, FileMode.OpenOrCreate, FileAccess.Write); for (int m = 0; m < manifestResourceStream.Length; m++) { stream2.WriteByte((byte) manifestResourceStream.ReadByte()); } stream2.Close(); manifestResourceStream.Close(); pattern = "<HeaderFiles>"; str2 = "ptn_Child1=FileName\r\n[WorkState_v1_1.Header Files.FileName"; for (int n = 0; n < (childNumber - num9); n++) { str2 = str2 + ".FileName"; } if ((str10 == "") || !this._setup.predefinedSourceFileStructure) { string str13 = str2; str2 = str13 + "]\r\nFileName=" + str8 + "\r\n" + pattern + "\r\n"; str12 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h"; } else { string str14 = str2; str2 = str14 + "]\r\nFileName=" + str10 + @"\" + str8 + "\r\n" + pattern + "\r\n"; str12 = this._setup.projectDirectoyPath + @"\" + replacement + @"\" + str10 + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h"; } input = Regex.Replace(input, pattern, str2); reader.NavigateUpOneLevel(); } childNumber++; } if (this._setup.includeRadioHeaders) { writer = new StreamWriter(str12); writer.Write(this._setup.radioChipHeader); writer.Close(); pattern = "<HeaderFiles>"; str2 = "ptn_Child1=FileName\r\n[WorkState_v1_1.Header Files.FileName"; for (int num12 = 0; num12 < (childNumber - num9); num12++) { str2 = str2 + ".FileName"; } if (!this._setup.predefinedSourceFileStructure) { string str15 = str2; str2 = str15 + "]\r\nFileName=" + this._setup.projectDirectoyPath + @"\" + replacement + @"\" + this._setup.radioChipType + "_" + this._setup.radioChipNickname + ".h\r\n" + pattern + "\r\n"; } else { string str16 = str2; str2 = str16 + "]\r\nFileName=" + str12 + "\r\n" + pattern + "\r\n"; } input = Regex.Replace(input, pattern, str2); } pattern = "<HeaderFiles>"; str2 = ""; input = Regex.Replace(input, pattern, str2); writer = new StreamWriter(path); writer.Write(input); writer.Close(); flag2 = true; } if (!flag || !flag2) { errorMsg = "The IDE Project was not created!\nCould not find proper project description for your setup!"; return false; } ProcessStartInfo startInfo = new ProcessStartInfo(this._setup.ideExecutable) { Arguments = path }; Process.Start(startInfo); return true; }
private void LoadPreferences(XmlNode _preferencesNode) { try { GlobalPreferences preferences = GlobalPreferences.instance(); GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(_preferencesNode); reader.NavigateToChild("Advanced", 0); reader.NavigateToChild("Language", 0); preferences.advanced.LangIdx = Convert.ToInt32(reader.GetAttribute("idx", false)); preferences.advanced.ShowDevFoundDlg = Convert.ToInt32(reader.GetAttribute("showdevfound", false)); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); reader.NavigateToChild("Logs", 0); reader.NavigateToChild("Option", 0); preferences.logs.SelDelIdx = Convert.ToInt32(reader.GetAttribute("idx", false)); reader.NavigateUpOneLevel(); reader.NavigateToChild("DelAfterDays", 0); preferences.logs.DelAfterDays = Convert.ToInt32(reader.GetAttribute("days", false)); reader.NavigateUpOneLevel(); reader.NavigateToChild("DelAfterNumOfFiles", 0); preferences.logs.DelNumOfFiles = Convert.ToInt32(reader.GetAttribute("numoffiles", false)); preferences.logs.DelIfMoreThan = Convert.ToInt32(reader.GetAttribute("ifmorethan", false)); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); reader.NavigateToChild("Help", 0); preferences.help.EnableContSensHelp = reader.GetAttribute("contSensHelp", false) == "1"; reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); reader.NavigateToChild("SoftwareUpdate", 0); preferences.swUpdate.AutoUpdate = reader.GetAttribute("autoUpdate", false) == "1"; preferences.swUpdate.UpdatePeriod = (PrefSofwareUpdate.UpdatePeriodList)Enum.Parse(typeof(PrefSofwareUpdate.UpdatePeriodList), reader.GetAttribute("updatePeriod", false)); preferences.swUpdate.UseProxyAuth = reader.GetAttribute("useProxyAuth", false) == "1"; preferences.swUpdate.ProxyUser = reader.GetAttribute("proxyUser", false); preferences.swUpdate.ProxyPassword = reader.GetAttribute("proxyPassword", false); preferences.swUpdate.LastUpdate = DateTime.Parse(reader.GetAttribute("lastUpdate", false)); preferences.swUpdate.ExcludedVersion = reader.GetAttribute("excludedVersion", false); } catch { } }
public int restore(XmlNode parentNode, int mainNodeIdx) { try { GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(parentNode); if (mainNodeIdx > -1) { reader.NavigateToChild(mainXmlNodeName(), mainNodeIdx); } reader.NavigateToChild("UniqId", 0); this.UniqId = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateToChild("CDT_Record", 0); reader.NavigateUpOneLevel(); reader.NavigateToChild("IOPortAddress", 0); this._portAddress.restore(reader.IteratorNode); reader.NavigateUpOneLevel(); return 0; } catch (Exception exception) { GlobalServices.ErrMsg("ADTRecord.restore()", "Reading XML failed\n" + exception.Message); return -1; } }
private int getAdtRecIDs(XmlNode appNode, List<int> adtRecIDList) { try { adtRecIDList.Clear(); GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(appNode); int num = reader.HowManyChildNode("ADT_Record_UniqId"); for (int i = 0; i < num; i++) { reader.NavigateToChild("ADT_Record_UniqId", i); adtRecIDList.Add(Convert.ToInt32(reader.InnerText())); reader.NavigateUpOneLevel(); } return 0; } catch { GlobalServices.ErrMsg("getAdtRecIDs()", "XML Format Error"); return -1; } }
public int restore(XmlNode parentNode) { int num; try { GlobalXMLManipulatorReader reader = new GlobalXMLManipulatorReader(parentNode); reader.NavigateToChild("PortType", 0); string attribute = reader.GetAttribute("name", false); if (attribute == null) { goto Label_01C3; } if (!(attribute == "RS232")) { if (attribute == "USB_FTDI") { goto Label_00A5; } if (attribute == "USB_EZLink") { goto Label_0156; } if (attribute == "SIMULATION") { goto Label_01BA; } goto Label_01C3; } this.portType = PortType.RS232; reader.NavigateToChild("COMPortId", 0); this.comAddr.COMPortId = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); goto Label_01D9; Label_00A5: this.portType = PortType.USB_FTDI; reader.NavigateToChild("SerialNo", 0); this.usbFtdiAddr.SerialNo = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateToChild("LocationId", 0); this.usbFtdiAddr.LocationId = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateToChild("DeviceIdx", 0); this.usbFtdiAddr.DeviceIdx = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateToChild("Description", 0); this.usbFtdiAddr.Description = reader.InnerText(); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); goto Label_01D9; Label_0156: this.portType = PortType.USB_EZLink; reader.NavigateToChild("DeviceIndex", 0); this.usbEzLinkAddr.devIdx = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateToChild("FrequencyBand", 0); this.usbEzLinkAddr.freqBand = Convert.ToInt32(reader.InnerText()); reader.NavigateUpOneLevel(); reader.NavigateUpOneLevel(); goto Label_01D9; Label_01BA: this.portType = PortType.SIMULATION; goto Label_01D9; Label_01C3: this.portType = PortType.INVALID; GlobalServices.ErrMsg("IOPortAddress.restore()", "Unexpected portType restored"); Label_01D9: num = 0; } catch { GlobalServices.ErrMsg("IOPortAddress.restore()", "Reading XML failed"); num = -1; } return num; }