private void ArgumentChoiceBox1_SelectionChangeCommitted(object sender, EventArgs e) { string selection = ArgumentChoiceBox1.GetItemText(ArgumentChoiceBox1.SelectedItem); SetFunctionButton.Visible = true; if (selection == Nazwy.aX) { StopienBox1.Visible = true; StopienBox1.Text = Nazwy.bPodajStopień; StopienBox1.ForeColor = Color.SlateGray; StopienBox1.Location = new Point(322, 57); //HelpLabel.Text = String.Format("Podaj stopień argumentu, a następnie wszystkie{0}współczynniki oddzielone spacjami. Podaj współczynniki{0}nawet gdy " + // "wynoszą one zero. Póki co bez ułamków, ale już wkrótce!", Environment.NewLine); HelpLabel.Text = Nazwy.iFTrygonometrycznaX; SetFunctionBox.Text = Nazwy.bPrzykład + ": 1 0 3 2 4 0"; SetFunctionBox.ForeColor = Color.SlateGray; SetFunctionButton.Visible = true; } else if (selection == Nazwy.aPI) { StopienBox1.Visible = false; //HelpLabel.Text = String.Format("Funkcja {0}(x) przesunięta o podaną ilość PI, np.{1}{0}(x+0,3). Może zawierać ułamki, ale tylko w postaci dziesiętnej. " + // "Podaj tylko liczbę.", FunctionChoiceBox.GetItemText(FunctionChoiceBox.SelectedItem), Environment.NewLine); HelpLabel.Text = Nazwy.iFTrygonometrycznaPI; SetFunctionBox.Text = Nazwy.bPrzykład + ": 2,78"; SetFunctionBox.ForeColor = Color.SlateGray; SetFunctionButton.Visible = true; } }
private void SetFunctionButton_Click(object sender, EventArgs e) { var typ = FunctionChoiceBox.GetItemText(FunctionChoiceBox.SelectedItem); if (typ == Nazwy.fLosuj) //wylosuj funkcję o danym stopniu { bool sprawdz = ushort.TryParse(StopienBox1.Text, out ushort result); if (sprawdz) { RunAlgorithms.LosujFunkcje(result); MessageBox.Show(Nazwy.eWylosowano, Nazwy.eSukces, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Nazwy.emsgStopieńLosowejFunkcji, Nazwy.eBłąd, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { AlgorytmyZachlanne.Fankszyn = SetFunctionBox.Text; AlgorytmyZachlanne.TypFankszynu = typ; if (ArgumentChoiceBox1.Visible) { if (ArgumentChoiceBox1.GetItemText(ArgumentChoiceBox1.SelectedItem) == Nazwy.aX) { AlgorytmyZachlanne.TypArgumentu = Nazwy.aX; MessageBox.Show(Nazwy.eUstawiono, Nazwy.eSukces, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (ArgumentChoiceBox1.GetItemText(ArgumentChoiceBox1.SelectedItem) == Nazwy.aPI) { AlgorytmyZachlanne.TypArgumentu = Nazwy.aPI; string selection = SetFunctionBox.Text; if (selection.IndexOf('.') > 0) { selection = selection.Replace('.', ','); } bool sprawdz = double.TryParse(selection, out double temp); if (sprawdz) { AlgorytmyZachlanne.IloscPI = temp; MessageBox.Show(Nazwy.eUstawiono, Nazwy.eSukces, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else //gdy użytkownik poda coś swojego zamiast wyboru z listy { MessageBox.Show("Incorrect type of argument! Please choose one from the list, rather than typing something in.", Nazwy.eBłąd, MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (AlgorytmyZachlanne.TypFankszynu == Nazwy.fWielomian) { bool sprawdz = ushort.TryParse(StopienBox1.Text, out ushort temp); if (sprawdz) { AlgorytmyZachlanne.Stopien = temp; MessageBox.Show(Nazwy.eUstawiono, Nazwy.eUstawiono, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Nazwy.emsgNieprawidłowyStopień, Nazwy.eBłądStopnia, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (AlgorytmyZachlanne.TypFankszynu == Nazwy.fWymierna) { bool sprawdz1 = ushort.TryParse(StopienBox1.Text, out ushort temp1); bool sprawdz2 = ushort.TryParse(StopienBox2.Text, out ushort temp2); if (sprawdz1 && sprawdz2) { AlgorytmyZachlanne.stLicz = temp1; AlgorytmyZachlanne.stMian = temp2; MessageBox.Show(Nazwy.eUstawiono, Nazwy.eSukces, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Nazwy.emsgNieprawidłowyStopień, Nazwy.eBłądStopnia, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (AlgorytmyZachlanne.TypFankszynu == Nazwy.fPierwiastek) { bool sprawdz1 = ushort.TryParse(StopienBox1.Text, out ushort temp1); bool sprawdz2 = ushort.TryParse(StopienBox2.Text, out ushort temp2); if (sprawdz1 && sprawdz2) { AlgorytmyZachlanne.stF = temp1; AlgorytmyZachlanne.stPierw = temp2; MessageBox.Show(Nazwy.eUstawiono, Nazwy.eSukces, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Nazwy.emsgNieprawidłowyStopień, Nazwy.eBłądStopnia, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (AlgorytmyZachlanne.TypFankszynu == Nazwy.fSin || AlgorytmyZachlanne.TypFankszynu == Nazwy.fCos || AlgorytmyZachlanne.TypFankszynu == Nazwy.fTg || AlgorytmyZachlanne.TypFankszynu == Nazwy.fCtg) { // } else //gdy użytkownik poda coś swojego zamiast wyboru z listy { MessageBox.Show("Incorrect type of function! Please choose one from the list, rather than typing something in.", Nazwy.eBłąd, MessageBoxButtons.OK, MessageBoxIcon.Error); } } //tutaj }