private void CreatingNewButtons(string studentCfgFileName, string powerSchoolSheet) { int userNameCol = 1; int displayNameCol = 0; int sheetIDCol = 2; //need to create function //read section from CfgSheet IList <IList <Object> > studentConfigData = Utils.GetSpreadData(spreadsheetId, studentCfgFileName, "A1", "C"); //fix range IList <IList <Object> > powerSchoolRowData = Utils.GetSpreadData(spreadsheetId, powerSchoolSheet, "E" + powerSchoolStartRow, "E"); //fix range IList <IList <Object> > canvasRowData = Utils.GetSpreadData(spreadsheetId, "CanvasGrades", "B" + canvasStartRow, "B"); //fix range if (studentConfigData != null && studentConfigData.Count > 0) { int rowNum = powerSchoolStartRow; /* foreach (var row in powerSchoolRowData) * { * try * { * studentDictionary[(string)row[0]].powerSchoolRow = rowNum; //add try catch to handle student not found. * } * catch (Exception ex) { } * rowNum++; * } * rowNum = canvasStartRow; * foreach (var row in canvasRowData) * { * try * { * studentDictionary[(string)row[0]].canvasRow = rowNum; * } * catch (Exception ex) { } //ignore and move on if not found * rowNum++; * }*/ rowNum = 0;//skip header row foreach (var row in studentConfigData) { rowNum++; if (rowNum == 1) { continue; } //skip first row //check if tab exists, if not add tab, create sheet and share //create new student and add in information. Add student to studentDictionary if (row.Count == 2) { userNameList.Add((string)row[userNameCol]); studentDictionary.Add((string)row[userNameCol], new Student((string)row[userNameCol], (string)row[displayNameCol], courseName + suffix, spreadsheetId)); //write new sheet ID to cell Utils.WriteCellData(spreadsheetId, studentDictionary[(string)row[userNameCol]].getSheetID(), studentCfgFileName, "C" + rowNum); //create new tab Utils.AddTabToSpreadSheet(spreadsheetId, studentDictionary[(string)row[userNameCol]].getSheetName()); //fill in header information List <object> cellDataList = new List <object> { "dateTime", "username", "observer", "observation", "comments", "ontask(0 for offtask)", "countable" }; Utils.WriteData(spreadsheetId, cellDataList, studentDictionary[(string)row[userNameCol]].getSheetName(), "A1", "G1"); } else if (row.Count == 3) { userNameList.Add((string)row[userNameCol]); if (row[userNameCol].Equals("x")) { continue; } studentDictionary.Add((string)row[userNameCol], new Student((string)row[userNameCol], (string)row[displayNameCol], courseName + suffix, (string)row[sheetIDCol], spreadsheetId)); } else { Console.WriteLine("could not find username and display name for student on row." + rowNum); //Console.ReadKey(); } } } else { Console.WriteLine("No data found."); } int horizotal = 30; int vertical = 70; int rowSize = 5; int seatsLeftAisle = 8; int seatsRightAisle = 8; //System.Windows.SystemParameters.PrimaryScreenWidth //System.Windows.SystemParameters.PrimaryScreenHeight //clear out existing information foreach (EnhancedButton btnToRemove in buttonList) { this.Controls.Remove(btnToRemove); } buttonList.Clear(); int i = 0; foreach (String userName in userNameList) { EnhancedButton myButton = new EnhancedButton(userName); myButton.Size = new Size(85, 85); myButton.Location = new Point(horizotal, vertical); myButton.Text = "x"; if (!userName.Equals("x")) { myButton.Text = studentDictionary[userName].getDisplayName(); } myButton.Click += new EventHandler(button_Click); horizotal += 90; if ((i % rowSize) == seatsLeftAisle - 1) { horizotal += 20; } if ((i % rowSize) == seatsRightAisle - 1) { horizotal += 20; } if ((i % rowSize) == rowSize - 1) { horizotal = 30; vertical += 100; } this.Controls.Add(myButton); buttonList.Add(myButton); i++; } }