public bool initCreateStartDemoProject(IDELauncherSetup projectSetup, Project selectedProject, out string errorMsg) { errorMsg = ""; this._setup = projectSetup; string path = Path.Combine(Application.StartupPath, Path.Combine("DemoExample", selectedProject.IDELoader.DirectoryName)); string str2 = Path.Combine(this._setup.projectDirectoyPath, this._setup.projectName); if (!Directory.Exists(str2)) { Directory.CreateDirectory(str2); } if (!Directory.Exists(path)) { errorMsg = "Project source does not exist!"; return false; } DirectoryInfo source = new DirectoryInfo(path); DirectoryInfo target = new DirectoryInfo(str2); CopyAll(source, target); if (this._setup.radioChipHeader != string.Empty) { string str3 = Path.Combine(str2, selectedProject.IDELoader.HeaderLocation); if (str3 == string.Empty) { errorMsg = "Could not find modem_params.h file!"; return false; } File.WriteAllText(str3, this._setup.radioChipHeader); } string str4 = this.getFilePathAndName(target, new string[] { this._setup.toolVendor.ToString() }, ".wsp"); if (str4 == string.Empty) { errorMsg = "Could not find project file!"; return false; } string contents = File.ReadAllText(str4).Replace("<Assembler>", this._setup.assemblerExec).Replace("<AssFlag>", this._setup.assemblerFlags).Replace("<Compiler>", this._setup.compilerExec).Replace("<CompFlag>", this._setup.compilerFlags).Replace("<Linker>", this._setup.linkerExec).Replace("<LinkFlag>", this._setup.linkerFlags); File.WriteAllText(str4, contents); ProcessStartInfo startInfo = new ProcessStartInfo(this._setup.ideExecutable) { Arguments = str4 }; Process.Start(startInfo); return true; }
private bool isValidSetup(out string validationComment) { bool flag = true; if (this._setup == null) { this._setup = new IDELauncherSetup(); } if (this._selectedProject == null) { this._setup.projectName = "Default empty project"; } else { this._setup.projectName = this._selectedProject.IDELoader.DirectoryName; } this._setup.mcu = (IDELauncherSetup.MCU) Enum.Parse(typeof(IDELauncherSetup.MCU), this.cbbMCUSelection.SelectedItem.ToString()); this._setup.toolVendor = (IDELauncherSetup.ToolVendor) Enum.Parse(typeof(IDELauncherSetup.ToolVendor), this.cbbToolVendor.SelectedItem.ToString()); this._setup.assemblerExec = this.txbExecutableAssembler.Text; this._setup.assemblerFlags = this.txbFlagsAssembler.Text; this._setup.compilerExec = this.txbExecutableCompiler.Text; this._setup.compilerFlags = this.txbFlagsCompiler.Text; this._setup.linkerExec = this.txbExecutableLinker.Text; this._setup.linkerFlags = this.txbFlagsLinker.Text; this._setup.ideExecutable = this.txbIDEExecutable.Text; this._setup.includeMCUHeaders = this.chbIncludeMCUHeaders.Checked; this._setup.includeRadioHeaders = this.chbIncludeRadioHeaders.Checked; this._setup.predefinedSourceFileStructure = this.rdbPredefined.Checked; switch (this._setup.toolVendor) { case IDELauncherSetup.ToolVendor.Keil: this._setup.assemblerFormat = "<Executable Name> <Input File(s)> <Flags>"; this._setup.compilerFormat = "<Executable Name> <Input File(s)> <Flags>"; this._setup.linkerFormat = "<Executable Name> <Input File(s)> TO <Output File> <Flags>"; break; case IDELauncherSetup.ToolVendor.Raisonance: this._setup.assemblerFormat = "<Executable Name> <Input File(s)> <Flags>"; this._setup.compilerFormat = "<Executable Name> <Input File(s)> <Flags>"; this._setup.linkerFormat = "<Executable Name> <Input File(s)> TO( <Output File> ) <Flags>"; break; case IDELauncherSetup.ToolVendor.SDCC: this._setup.assemblerFormat = "<Executable Name> <Flags> <Input File(s)>"; this._setup.compilerFormat = "<Executable Name> <Flags> <Input File(s)>"; this._setup.linkerFormat = "<Executable Name> <Flags> -o<Output File> <Input File(s)>"; break; default: this._setup.assemblerFormat = ""; this._setup.compilerFormat = ""; this._setup.linkerFormat = ""; break; } string str = "Checked parameters:\n\n"; if (this.txbLocation.Text.Contains(":")) { this._setup.projectDirectoyPath = this.txbLocation.Text; } else { this._setup.projectDirectoyPath = AppDomain.CurrentDomain.BaseDirectory + @"\" + this.txbLocation.Text; } str = str + "Assembler\t\t\t"; if (!File.Exists(this._setup.assemblerExec)) { str = str + "FAILED\n"; flag = false; } else { str = str + "Passed\n"; } str = str + "Compiler\t\t\t"; if (!File.Exists(this._setup.compilerExec)) { str = str + "FAILED\n"; flag = false; } else { str = str + "Passed\n"; } str = str + "Linker\t\t\t"; if (!File.Exists(this._setup.linkerExec)) { str = str + "FAILED\n"; flag = false; } else { str = str + "Passed\n"; } str = str + "IDE Executable\t\t"; if (!File.Exists(this._setup.ideExecutable)) { str = str + "FAILED\n"; flag = false; } else { str = str + "Passed\n"; } str = str + "Project Directory Path\t"; if (!Directory.Exists(this._setup.projectDirectoyPath)) { if (MessageBox.Show("The Location for new project does not exists!\nDo You want to create it?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { Directory.CreateDirectory(this._setup.projectDirectoyPath); str = str + "Passed\n"; } catch { str = str + "FAILED\n"; flag = false; } } else { str = str + "FAILED\n"; flag = false; } } else { str = str + "Passed\n"; } this._setup.radioChipType = this._radioChipType; this._setup.radioChipRevision = this._radioChipRevision; this._setup.radioChipHeader = this._radioHeaderText; this._setup.radioChipNickname = this._nickname; str = str + "\nPlease correct the path for the FAILED parameters and retry again..."; validationComment = str; return flag; }
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; }