public List <INSTALLED> installeds() { var list = new ListWithDuplicates(); list.Add(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); list.Add(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); list.Add(Registry.LocalMachine, @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"); List <INSTALLED> installeds = new List <INSTALLED>(); foreach (var item in list) { RegistryKey subkey = item.Key.OpenSubKey(item.Value); foreach (string installed in subkey.GetSubKeyNames()) { using (RegistryKey info = subkey.OpenSubKey(installed)) { if (info.GetValue("UninstallString") != null && info.GetValue("DisplayName") != null && !excludePublishers.Any(info.GetValue("DisplayName").ToString().Contains)) { if (info.GetValue("Publisher") == null || !excludePublishers.Contains(info.GetValue("Publisher").ToString())) { INSTALLED soft = new INSTALLED(); soft.name = info.GetValue("DisplayName").ToString(); if (info.GetValue("Publisher") == null) { soft.publisher = null; } else { soft.publisher = info.GetValue("Publisher").ToString(); } string UninstallString = info.GetValue("UninstallString").ToString(); soft.UninstallString = UninstallString; string[] array = UninstallString.Split(new[] { @"\" }, StringSplitOptions.None); string path = UninstallString.Replace(@"\" + array.Last(), ""); soft.path = path; soft.regkey = info.Name; installeds.Add(soft); } } else { continue; } } } } return(installeds); }
public void btn_LoadSettingsFile_Click(object sender, EventArgs e) { //System.Diagnostics.Debug.WriteLine(""); //System.Diagnostics.Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click()"); DataSet returnSettingsData = null; string filePath = string.Empty; string fileExt = string.Empty; settingsFile = null; OpenFileDialog file = new OpenFileDialog(); //open dialog to choose file if (file.ShowDialog() == System.Windows.Forms.DialogResult.OK) //if there is a file choosen by the user { filePath = file.FileName; //get the path and name of the file settingsFile = filePath; /*Debug.WriteLine("settingsFile = " + settingsFile); * Debug.WriteLine("filePath = " + filePath);*/ fileExt = Path.GetExtension(filePath); //get the file extension if (fileExt.CompareTo(".xls") == 0 || fileExt.CompareTo(".xlsx") == 0) { try { //Code to put Excel worksheets in datatables and then 1 dataset alphabetically //Make excel settings file into dataset object returnSettingsData = cCSVSettingsTemplate.Parse(filePath); //Retrieve setttings values in the dataset: Table(worksheet), row and column String parameterSetName = returnSettingsData.Tables[4].Rows[0][1].ToString(); //YM //String parameterSetName = returnSettingsData.Tables[6].Rows[0][1].ToString(); //YM textBoxParameterSet.Text = parameterSetName; outputFolder = returnSettingsData.Tables[4].Rows[2][1].ToString();//YM //outputFolder = returnSettingsData.Tables[6].Rows[2][1].ToString(); //YM textBoxOutputFolder.Text = outputFolder; String landscapeFile = returnSettingsData.Tables[4].Rows[3][1].ToString();//YM //String landscapeFile = returnSettingsData.Tables[6].Rows[3][1].ToString();//YM Char[] delimiters = { '\\', '/' }; String[] landscapeFileItems = landscapeFile.Split(delimiters); String landscapeFileItemsLast = landscapeFileItems.Last(); textBoxLandscapeFile.Text = landscapeFileItemsLast; String growPop = returnSettingsData.Tables[4].Rows[4][1].ToString();//YM //String growPop = returnSettingsData.Tables[6].Rows[4][1].ToString();//YM //Debug.WriteLine("growPop = " + growPop); if (growPop == "TRUE") { textBoxPopulationFile.Text = "No file provided. A population is being grown."; } else { String populationFile = returnSettingsData.Tables[4].Rows[7][1].ToString();//YM //String populationFile = returnSettingsData.Tables[6].Rows[7][1].ToString();//YM //Debug.WriteLine("populationFile = " + populationFile); //Char delimiter = '\\'; String[] populationFileItems = populationFile.Split(delimiters); String populationFileItemsLast = populationFileItems.Last(); //Debug.WriteLine("populationFileItemsLast = " + populationFileItemsLast); textBoxPopulationFile.Text = populationFileItemsLast; } String numbIterations = returnSettingsData.Tables[4].Rows[12][1].ToString();//YM //String numbIterations = returnSettingsData.Tables[6].Rows[12][1].ToString();//YM textBoxNumbIterations.Text = numbIterations; String numbYears = returnSettingsData.Tables[4].Rows[8][1].ToString();//YM //String numbYears = returnSettingsData.Tables[6].Rows[8][1].ToString();//YM textBoxNumbYears.Text = numbYears; //Connect to landscape XML file to get supercell and K information cXMLCellDataSource landscapeXMLFile = new cXMLCellDataSource(true); int totalPathLength = landscapeFile.Length; int landNameLength = landscapeFileItemsLast.Length; string landPath = landscapeFile.Substring(0, totalPathLength - landNameLength); //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): landPath = " + landPath); //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): landscapeFileItemsLast = " + landscapeFileItemsLast); landscapeXMLFile.DataSourcePath = landPath; landscapeXMLFile.DataSourceName = landscapeFileItemsLast; landscapeXMLFile.Connect(); //Getting set up to get supercell values cSuperCellList listSuperCells = new cSuperCellList(); landscapeXMLFile.GetSuperCellData(listSuperCells); int numbSupCells = listSuperCells.Count; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): numbSupCells = " + numbSupCells); string superCellFormEntry; superCellFormEntry = null; //Getting set up to get K values cUniformRandom rand = new cUniformRandom(); cCellList listCells = new cCellList(rand); landscapeXMLFile.GetCellData(listCells, listSuperCells); cCellData CellData = new cCellData(); int numbCells = listCells.Count; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): numbCells = " + numbCells); double mvarK; // Get the supercell and K combinations var superK = new ListWithDuplicates(); for (int i = 0; i < numbCells; i++) { //landscapeKValues[i] = listCells.ToString() //values = listCells.ToString(); mvarK = listCells[i].K; superCellFormEntry = listCells[i].SuperCell.ID; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): i = " + i + " mvarK = " + mvarK + "; supercell = " + superCellFormEntry); superK.Add(superCellFormEntry, mvarK); } // Disconnect from the landscape XML file landscapeXMLFile.Disconnect(); //With the data loaded in, activate the run button btnRun.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } else { MessageBox.Show("Please choose .xls or .xlsx file only.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); //custom messageBox to show error } } }
//*************************************************************************************************************************************** //mothode : Load Files ** for ORM console ** public void LoadSettingsFile(string[] args) { //System.Diagnostics.Debug.WriteLine(""); //System.Diagnostics.Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click()"); pathArg[0] = "."; Debug.WriteLine("settingsFile =++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " + pathArg[0]); DataSet returnSettingsData = null; string filePath = string.Empty; string fileExt = string.Empty; settingsFile = null; //filePath = pathArg[0]; //get the path and name of the file settingsFile = pathArg[0]; /*Debug.WriteLine("settingsFile = " + settingsFile); * Debug.WriteLine("filePath = " + filePath);*/ //fileExt = pathArg[0]; //get the file extension if (pathArg[0] != "") { try { //Code to put Excel worksheets in datatables and then 1 dataset alphabetically //Make excel settings file into dataset object returnSettingsData = cCSVSettingsTemplate.Parse(pathArg[0]); //Retrieve setttings values in the dataset: Table(worksheet), row and column String parameterSetName = returnSettingsData.Tables[4].Rows[0][1].ToString(); // textBoxParameterSet.Text = parameterSetName; outputFolder = returnSettingsData.Tables[4].Rows[2][1].ToString(); // textBoxOutputFolder.Text = outputFolder; Debug.WriteLine(" outputFolder =++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " + outputFolder); String landscapeFile = returnSettingsData.Tables[4].Rows[3][1].ToString(); Char[] delimiters = { '\\', '/' }; String[] landscapeFileItems = landscapeFile.Split(delimiters); String landscapeFileItemsLast = landscapeFileItems.Last(); // textBoxLandscapeFile.Text = landscapeFileItemsLast; String growPop = returnSettingsData.Tables[4].Rows[4][1].ToString(); //Debug.WriteLine("growPop = " + growPop); if (growPop == "TRUE") { // textBoxPopulationFile.Text = "No file provided. A population is being grown."; } else { String populationFile = returnSettingsData.Tables[4].Rows[7][1].ToString(); //Debug.WriteLine("populationFile = " + populationFile); //Char delimiter = '\\'; String[] populationFileItems = populationFile.Split(delimiters); String populationFileItemsLast = populationFileItems.Last(); //Debug.WriteLine("populationFileItemsLast = " + populationFileItemsLast); // textBoxPopulationFile.Text = populationFileItemsLast; } String numbIterations = returnSettingsData.Tables[4].Rows[12][1].ToString(); // textBoxNumbIterations.Text = numbIterations; String numbYears = returnSettingsData.Tables[4].Rows[8][1].ToString(); // textBoxNumbYears.Text = numbYears; //Connect to landscape XML file to get supercell and K information cXMLCellDataSource landscapeXMLFile = new cXMLCellDataSource(true); int totalPathLength = landscapeFile.Length; int landNameLength = landscapeFileItemsLast.Length; string landPath = landscapeFile.Substring(0, totalPathLength - landNameLength); //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): landPath = " + landPath); //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): landscapeFileItemsLast = " + landscapeFileItemsLast); landscapeXMLFile.DataSourcePath = landPath; landscapeXMLFile.DataSourceName = landscapeFileItemsLast; landscapeXMLFile.Connect(); //Getting set up to get supercell values cSuperCellList listSuperCells = new cSuperCellList(); landscapeXMLFile.GetSuperCellData(listSuperCells); int numbSupCells = listSuperCells.Count; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): numbSupCells = " + numbSupCells); string superCellFormEntry; superCellFormEntry = null; //Getting set up to get K values cUniformRandom rand = new cUniformRandom(); cCellList listCells = new cCellList(rand); landscapeXMLFile.GetCellData(listCells, listSuperCells); cCellData CellData = new cCellData(); int numbCells = listCells.Count; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): numbCells = " + numbCells); double mvarK; // Get the supercell and K combinations var superK = new ListWithDuplicates(); for (int i = 0; i < numbCells; i++) { //landscapeKValues[i] = listCells.ToString() //values = listCells.ToString(); mvarK = listCells[i].K; superCellFormEntry = listCells[i].SuperCell.ID; //Debug.WriteLine("Form1.cs: btn_LoadSettingsFile_Click(): i = " + i + " mvarK = " + mvarK + "; supercell = " + superCellFormEntry); superK.Add(superCellFormEntry, mvarK); } // Disconnect from the landscape XML file landscapeXMLFile.Disconnect(); //With the data loaded in, activate the run button // btnRun.Enabled = true; } catch (Exception ex) { Console.Error.WriteLine(ex.Message.ToString()); } } else { Console.Error.WriteLine("Please choose .xls or .xlsx file only."); } }