private bool ValidateInput() { if (_pruferCode.GetText().Equals("Empty")) { return(true); } var values = _pruferCode.GetText().Split(" "); int elementsAmount = values.Length; if (elementsAmount == 0 || elementsAmount > 25) { return(false); } foreach (string value in values) { if (!Int32.TryParse(value, out int number)) { return(false); } if (number < 1 || number > elementsAmount + 2) { return(false); } } return(true); }
private bool ValidateInput() { if (!Int32.TryParse(_edgesAmount.GetText(), out int edges)) { return(false); } return(edges >= 1 && edges <= _vertices); }
private void OnCheckButtonClick(IItem sender, MouseArgs args) { if (ValidateInput()) { var eventArgs = new GotCorrectCheckPathEventArgs { FirstVertex = Int32.Parse(_firstVertex.GetText()), SecondVertex = Int32.Parse(_secondVertex.GetText()) }; _output.SetText(string.Empty); OnGotCorrectInput(eventArgs); } else { _output.SetText("Incorrect Input"); _output.SetHeight(50); } }
private bool ValidateInput() { if (!(Int32.TryParse(_verticesAmount.GetText(), out int vertices) && Double.TryParse(_density.GetText(), out double density) && Int32.TryParse(_minWeight.GetText(), out int minWeight) && Int32.TryParse(_maxWeight.GetText(), out int maxWeight))) { return(false); } return(vertices >= 2 && vertices <= _maxVertices && density >= 0 && density <= 1 && minWeight >= -100 && minWeight <= 100 && maxWeight >= -100 && maxWeight <= 100 && minWeight <= maxWeight); }
private void OnButtonClick(bool dijkstra, bool bellmanFord, bool floyd) { if (ValidateInput()) { var eventArgs = new GotCorrectFindPathEventArgs { FirstVertex = Int32.Parse(_firstVertex.GetText()), SecondVertex = Int32.Parse(_secondVertex.GetText()), Dijkstra = dijkstra, BellmanFord = bellmanFord, Floyd = floyd }; _output.SetText(string.Empty); OnGotCorrectInput(eventArgs); } else { _output.SetText("Incorrect Input"); _output.SetHeight(50); } }