DHaromszog/haromszogek/Derékszögű Háromszögek.cs

60 lines
1.7 KiB
C#
Raw Normal View History

2024-01-04 11:57:00 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
2024-01-11 13:57:36 +00:00
using System.IO;
2024-01-04 11:57:00 +00:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace haromszogek
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
2024-01-11 13:57:36 +00:00
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
string[] sorok = File.ReadAllLines(openFileDialog1.FileName);
List<DHaromszog> derekszoguek = new List<DHaromszog>();
for (int i = 0; i < sorok.Length; i++)
{
try
{
DHaromszog dh = new DHaromszog(sorok[i], i + 1);
derekszoguek.Add(dh);
}
catch (Exception hiba)
{
2024-01-11 11:37:44 +00:00
2024-01-11 13:57:36 +00:00
listBox1.Items.Add(hiba.Message);
}
}
listBox2.Items.AddRange(derekszoguek.ToArray());
}
}
2024-01-11 11:37:44 +00:00
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
2024-01-04 11:57:00 +00:00
}
2024-01-11 13:57:36 +00:00
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
listBox3.Items.Clear();
DHaromszog kivalasztott = listBox2.SelectedItem as DHaromszog;
listBox3.Items.Add("Kerület= " + kivalasztott.Kerület);
listBox3.Items.Add("Terület= " + kivalasztott.Terület);
}
2024-01-04 11:57:00 +00:00
}
}