private void generateButton_Click(object sender, System.EventArgs e) { do { smallBoardsListView.Clear(); if (!validateBoardGeneration()) { break; } int selectedRectangleWidth = int.Parse(rectangleWidthTextBox.Text.Replace("Correction: ", "")); selectedRectangleWidth = FibonnaciStore.getInstance().correctNumber(selectedRectangleWidth); rectangleWidthTextBox.Text = "Correction: " + selectedRectangleWidth; List <int> fibonacciEntries = FibonnaciStore.getInstance().getRespectiveFibonnaciSeries(selectedRectangleWidth); if (fibonacciEntries == null || fibonacciEntries.Count == 0) { MetroSetMessageBox.Show(this, "No results found, please try another value" + Constants.MAX_NUMBER_ALLOWED); break; } foreach (int entry in fibonacciEntries) { smallBoardsListView.AddItem(entry.ToString()); } } while (false); }
private void addBoxButton_Click(object sender, System.EventArgs e) { do { if (!validateBoxSize()) { break; } int boxSize = int.Parse(boxSizeTextBox.Text); int respectiveFibonnaciNumber = FibonnaciStore.getInstance().correctNumber(boxSize); string toAdd = respectiveFibonnaciNumber.ToString(); if (!FibonnaciStore.getInstance().isValidFibonnaciNumber(boxSize)) { toAdd = "Correction: " + toAdd; } if (boxSize != 1 && isDuplicateInput(toAdd)) { MetroSetMessageBox.Show(this, "Already Added"); boxSizeTextBox.Text = string.Empty; break; } inputListBox.AddItem(toAdd); boxSizeTextBox.Text = string.Empty; } while (false); }
static void Main() { FibonnaciStore.getInstance(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new HomeForm()); }
private void generateSolutionButton_Click(object sender, EventArgs e) { List <int> inputList = new List <int>(); List <int> outputList = null; do { outputListBox.Clear(); rectangleSizeTextBox.Text = string.Empty; if (inputListBox.Items == null || inputListBox.Items.Count == 0) { MetroSetMessageBox.Show(this, "Invalid Operation, Empty input list"); break; } int startFrom = 1; int target = 0; foreach (string entry in inputListBox.Items) { int entryRepresentation = int.Parse(entry.Replace("Correction:", "")); //if (entryRepresentation < startFrom) // startFrom = entryRepresentation; if (target < entryRepresentation) { target = entryRepresentation; } inputList.Add(entryRepresentation); } outputList = FibonnaciStore.getInstance().getRespectiveFibonnaciSeries(target, startFrom, true); foreach (int entry in outputList) { string toAdd = entry.ToString(); if (!inputList.Contains(entry)) { toAdd = "Missing: " + toAdd; } outputListBox.AddItem(toAdd); } int rectangleSize = outputList[outputList.Count - 1]; if (outputList.Count > 1) { rectangleSize += outputList[outputList.Count - 2]; } rectangleSizeTextBox.Text = rectangleSize.ToString(); rectangleSizeTextBox.ReadOnly = true; } while (false); }