using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace NSD { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); listBox1.Items.Clear(); } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if(!((e.KeyChar >= 48 && e.KeyChar <= 57) || (e.KeyChar == 8))) { e.KeyChar = Convert.ToChar(0); } } private void textBox2_KeyPress(object sender, KeyPressEventArgs e) { if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || (e.KeyChar == 8))) { e.KeyChar = Convert.ToChar(0); } } private void button_vymaz_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } private void button_close_Click(object sender, EventArgs e) { this.Close(); } private void pictureBox1_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("https://cs.wikipedia.org/wiki/Eukleid%C5%AFv_algoritmus"); } private void button_vypocet_Click(object sender, EventArgs e) { uint c1, c2, zb, nsd; string nsd_vystup; if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Musíte zadat číslo!", "Varování", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { try { c1 = Convert.ToUInt32(textBox1.Text); c2 = Convert.ToUInt32(textBox2.Text); } catch(OverflowException) { MessageBox.Show("Zadejte menší číslo!", "Chyba", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); return; } if (c1 == 0 || c2 == 0) { MessageBox.Show("Pro nulu nemá smysl!", "Informace", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { zb = 1; while (zb != 0) { zb = c1 % c2; c1 = c2; c2 = zb; } nsd = c1; nsd_vystup = Convert.ToString(nsd); listBox1.Items.Add(" NSD (" + textBox1.Text + " , " + textBox2.Text + ") = " + nsd_vystup); listBox1.Items.Add(""); } } } } }