//pass this an array of shorts with values 0 through 9 public SDBoard(short[] filledArray) { for (int i = 0; i < 9; i++) { NBRows[i] = new NumBox[9]; NBColumns[i] = new NumBox[9]; NBBOX[i] = new NumBox[9]; } //creates every numBox for (short i = 0; i < 81; i++) { short row = (short)(i / 9); short column = (short)(i % 9); short box = (short)((row / 3) * 3 + column / 3); numBoxes[i] = new NumBox(row, column, box, i); NBRows[row][column] = numBoxes[i]; NBColumns[column][row] = numBoxes[i]; NBBOX[box][(row % 3) * 3 + (column % 3)] = numBoxes[i]; //determines numBox position with largeBox //numBoxes[i].setTBText(column.ToString()); //initiates showing numBox position within row //numBoxes[i].setTBText(row.ToString()); //initiates showing numBox position within column //numBoxes[i].setTBText(((row % 3) * 3 + (column % 3)).ToString()); //initiates showing numBox position with largeBox //numBoxes[i].setTBText(box.ToString()); //initiates showing each box association } for (int i = 0; i < 81; i++) //populates boxes { if (filledArray[i] != 0) { insertNum(numBoxes[i], filledArray[i]); //must be done after all boxes initialized } } }
private void PreviewByNewName() { int Num; int NumLen = NumBox.Text.Length; string Suf = SufBox.Text.Trim(); if (!int.TryParse(NumBox.Text, out Num)) { NumBox.Focus(); throw new Exception("请输入正确整数"); } foreach (var fileinfo in FileList) { ResetFileInfo(fileinfo); string NewSuf = string.Empty; if (!string.IsNullOrEmpty(Suf)) { NewSuf = "." + Suf; } else { NewSuf = GetSuf(fileinfo.OldFilename); } var flag = "<>"; if (NewNameBox.Text.IndexOf(flag) >= 0) { fileinfo.NewFilename = string.Format("{0}{1}", NewNameBox.Text, NewSuf).Replace(flag, Num.ToString("D" + NumLen)); } else { fileinfo.NewFilename = string.Format("{0}{1}{2}", NewNameBox.Text, Num.ToString("D" + NumLen), NewSuf); } ++Num; } }
public void Add ( NumBox numericBoxInstance ) { // we check that elements has our numbox instance or not.. // if our instance is not in the elements then find method returns null if (this.Elements.Find( numericBoxInstance ) == null) { this.Elements.Add ( numericBoxInstance ) }
public MainForm(IQuizRepository quizRepository) { InitializeComponent(); _quizRepository = quizRepository; _quiz = new Quiz(_quizRepository.Get20Questions()); Size = new Size(700, 700); FormBorderStyle = FormBorderStyle.FixedSingle; NumBox.Hide(); labelSaisie.Hide(); }
private void NettoieForm() { txtBoxCorrection.Text = ""; textBxNumQuestion.Text = ""; NumBox.Hide(); labelSaisie.Hide(); NumBox.Text = ""; if (lesCheckBoxes != null) { foreach (CheckBox checkbox in lesCheckBoxes) { Controls.Remove(checkbox); } } }
private void RemoveName(object sender, RoutedEventArgs e) { if (players.Remove(NameBox.Text)) { NameBox.Clear(); NumBox.Clear(); } else if (retiredPlayers.Remove(NameBox.Text)) { NameBox.Clear(); NumBox.Clear(); } populateRetired(); populateLists(); }
private void AddName(object sender, RoutedEventArgs e) { int temp = 0; if (NameBox.Text.Length != 0 && !players.ContainsKey(NameBox.Text) && !retiredPlayers.ContainsKey(NameBox.Text)) { if (Int32.TryParse(NumBox.Text, out temp)) { players.Add(NameBox.Text, temp); } if (NumBox.Text.Length == 0) { players.Add(NameBox.Text, 0); } } else if (players.ContainsKey(NameBox.Text) && NumBox.Text.Length != 0) { if (NumBox.Text != players[NameBox.Text].ToString()) { if (Int32.TryParse(NumBox.Text, out temp)) { players[NameBox.Text] = temp; } } } if (retiredPlayers.ContainsKey(NameBox.Text) && NameBox.Text.Length != 0) { if (Int32.TryParse(NumBox.Text, out temp)) { retiredPlayers[NameBox.Text] = temp; } populateRetired(); } NameBox.Clear(); NumBox.Clear(); populateLists(); }
public void SetDisplay(object o) { NumBox.DisplayNumber(o); }
private ErrorLogger insertNum(NumBox NB, short val) { //this value insertion verifies that it is not inserting a conflict value //colors boxes red if a conflict occurs //updates all validNumbers for pertinent boxes ErrorLogger RV = new ErrorLogger(); RV = RV + checkStruct(val, NBRows[NB.getRow()]); //if (RV!= 0) return RV; RV = RV + checkStruct(val, NBColumns[NB.getColumn()]); //if (RV!= 0) return RV; RV = RV + checkStruct(val, NBBOX[NB.getBox()]); //if (RV != 0) return RV; if(NB.getID() == 44) val = val; //if code makes it here, there are no conflicts, add value to box NB.setValue(val); valueArray[NB.getID()] = val; if (NB.getID() == 38) val = val; if (!RV.hasError()) { foreach (NumBox NBt in NBRows[NB.getRow()]) { NBt.removePotentialValue(val); if (NBt.getID() == 44) val = val; } foreach (NumBox NBt in NBColumns[NB.getColumn()]) { NBt.removePotentialValue(val); } foreach (NumBox NBt in NBBOX[NB.getBox()]) { NBt.removePotentialValue(val); } } else { Console.WriteLine("Skipped removing potential vals"); } return RV; }
private ErrorLogger checkStruct(short val, NumBox[] NBStruct) { ErrorLogger RV = new ErrorLogger(); //if a value exists, remove it from the rest of the row foreach (NumBox NBInner in NBStruct) { //checks if attempting to remove a po if (val == NBInner.getValue()) { RV = RV + new ErrorLogger(1, "checkStruct failed: BOXID: " + NBInner.getID()+ " value: " + val); NBInner.setTBcolor(Color.Red); } if (RV.hasError()) break; } return RV; }
//checks for rows where a val can only go to a single box public ErrorLogger checkRCB(NumBox[][] NBstruct,ref bool madeChange) { ErrorLogger RV = new ErrorLogger(); NumBox[] boxArray; bool noChange = false; while (!noChange) { noChange = true; List<short> PVs = new List<short>(); for (int i = 0; i < 9; i++) //does for each row { short[] occuranceCount = new short[9]; for (int j = 0; j < 9; j++) occuranceCount[j] = 0; boxArray = NBstruct[i]; foreach (NumBox NB in boxArray) //counts the occurances of each potential value in the struct { if (NB.getID() == 44) PVs = PVs; PVs.Clear(); PVs.AddRange(NB.getPV()); for (int j = 0; j < PVs.Count; j++) { int T = PVs[j]; occuranceCount[T - 1] = (short)(occuranceCount[T - 1] + 1); } } for (short j = 0; j < 9; j++) { if (occuranceCount[j] == 1) //if there are any instances of a value being possible in only one spot, it is placed { foreach (NumBox NB in boxArray) { if (NB.getID() == 44) PVs = PVs; PVs.Clear(); PVs.AddRange(NB.getPV()); if(PVs.Contains((short)(j+1))) { for (int k = 0; k < PVs.Count; k++) { occuranceCount[j] = (short)(occuranceCount[j] - 1); } RV = RV + insertNum(NB,(short)(j + 1)); Console.WriteLine("RCB Insert: " + NB.getID() + " inserting value: " + (j + 1).ToString()); madeChange = true; noChange = false; } if (RV.hasError()) break; } } if (RV.hasError()) break; } if (RV.hasError()) break; } if (RV.hasError()) break; } return RV; }
public void UpdateElement (int indexNo, NumBox updatedNumBox) { this.Elements[indexNo] = updatedNumBox; }
public void DeleteElement ( NumBox numboxInstance ) { this.Elements.Remove (numboxInstance ); }
private void AfficheQuestion(Question question) { string file; if (question.PieceJointe != null) { file = "../../../DAL/images/" + question.PieceJointe; pictureBox.Image = Image.FromFile(file); } else { file = "../../../DAL/images/ia.jpg"; pictureBox.Image = Image.FromFile(file); } if (question != null) //par précaution on teste si la question est nulle mais normalement elle ne sera jamais nulle { btnValider.Text = "Valider"; txtQuestion.Text = question.Intitule; if (question.Type == Question.TypeQues.QCM)// pour les qcm { if (question.Intitule == "Dijkstra") { btnValider.Enabled = false; btnValider.Text = "Suivant"; d = new Dijkstra(false); d.Show(); compteur++; } else { if (question.Intitule == "A*") { btnValider.Enabled = false; btnValider.Text = "Suivant"; d = new Dijkstra(true); d.Show(); compteur++; } else { CheckBox[] checkBoxes = new CheckBox[question.LesReponses.Count]; lesCheckBoxes = new CheckBox[question.LesReponses.Count]; for (int i = 0; i < question.LesReponses.Count; i++) { checkBoxes[i] = new CheckBox(); checkBoxes[i].Location = new Point(69, 400 + i * 20); checkBoxes[i].Font = new Font("Calibri", 11, FontStyle.Regular, GraphicsUnit.Point, 0); checkBoxes[i].Text = alphabet[i] + ". " + question.LesReponses[i].Intitule; checkBoxes[i].AutoSize = true; Controls.Add(checkBoxes[i]); lesCheckBoxes[i] = checkBoxes[i]; } } } } if (question.Type == Question.TypeQues.saisieNum)// pour la saisie numérique { NumBox.Show(); labelSaisie.Show(); } } }