Add project files.

This commit is contained in:
István Priskin 2022-04-26 19:27:50 +02:00
parent e43a78f6f8
commit ac44bb6c29
7 changed files with 451 additions and 0 deletions

25
Haromszogek.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31624.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Haromszogek", "Haromszogek\Haromszogek.csproj", "{9454D6F1-840C-4A42-A93B-B3577071F869}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9454D6F1-840C-4A42-A93B-B3577071F869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9454D6F1-840C-4A42-A93B-B3577071F869}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9454D6F1-840C-4A42-A93B-B3577071F869}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9454D6F1-840C-4A42-A93B-B3577071F869}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1E99C38F-296D-4CD6-9F71-F8F57E3A3CDB}
EndGlobalSection
EndGlobal

129
Haromszogek/DHaromszog.cs Normal file
View File

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Haromszogek
{
class DHaromszog
{
private double aOldal;
private double bOldal;
private double cOldal;
public double a
{
get
{
return aOldal;
}
set
{
if(value>0)
{
aOldal = value;
} else
{
throw new Exception("Az a oldal nem lehet nulla vagy negatív!");
}
}
}
public double b
{
get
{
return bOldal;
}
set
{
if (value > 0)
{
bOldal = value;
}
else
{
throw new Exception("A b oldal nem lehet nulla vagy negatív!");
}
}
}
public double c
{
get
{
return cOldal;
}
set
{
if (value > 0)
{
cOldal = value;
}
else
{
throw new Exception("A c oldal nem lehet nulla vagy negatív!");
}
}
}
public int SorSzama { get; set; }
private bool EllNovekvoSorrend
{
get
{
return (a <= b) && (b <= c);
}
}
private bool EllMegszerkesztheto
{
get
{
return (a + b) > c;
}
}
private bool EllDerekszogu
{
get
{
return a*a + b*b == c*c;
}
}
public double Kerulet
{
get { return a + b + c; }
}
public double Terulet
{
get { return a * b / 2; }
}
public DHaromszog(string sor, int sorSzama)
{
this.SorSzama = sorSzama;
string[] t = sor.Split(' ');
double a = double.Parse(t[0]);
double b = double.Parse(t[1]);
double c = double.Parse(t[2]);
this.a = a;
this.b = b;
this.c = c;
if (!EllNovekvoSorrend) throw new Exception("Az adatok nincsenek növekvő rendben!");
if (!EllMegszerkesztheto) throw new Exception("A háromszöget nem lehet megszerkeszteni!");
if (!EllDerekszogu) throw new Exception("A háromszög nem derékszögű!");
}
public override string ToString()
{
return $"{SorSzama}.sor a={a} b={b} c={c}";
}
}
}

145
Haromszogek/Form1.Designer.cs generated Normal file
View File

@ -0,0 +1,145 @@

namespace Haromszogek
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.listBox3 = new System.Windows.Forms.ListBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.button1.Location = new System.Drawing.Point(27, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(163, 36);
this.button1.TabIndex = 0;
this.button1.Text = "Adatok betöltése";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.listBox1);
this.groupBox1.Location = new System.Drawing.Point(27, 76);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(628, 157);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Hibák a kiválasztott állományban";
//
// listBox1
//
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 15;
this.listBox1.Location = new System.Drawing.Point(3, 19);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(622, 135);
this.listBox1.TabIndex = 0;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.listBox2);
this.groupBox2.Location = new System.Drawing.Point(24, 239);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(212, 177);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Derékszögű háromszögek";
//
// listBox2
//
this.listBox2.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox2.FormattingEnabled = true;
this.listBox2.ItemHeight = 15;
this.listBox2.Location = new System.Drawing.Point(3, 19);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(206, 155);
this.listBox2.TabIndex = 0;
this.listBox2.SelectedIndexChanged += new System.EventHandler(this.listBox2_SelectedIndexChanged);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.listBox3);
this.groupBox3.Location = new System.Drawing.Point(272, 239);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(380, 174);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "A kiválasztott derékszögű háromszög adatai";
//
// listBox3
//
this.listBox3.Dock = System.Windows.Forms.DockStyle.Fill;
this.listBox3.FormattingEnabled = true;
this.listBox3.ItemHeight = 15;
this.listBox3.Location = new System.Drawing.Point(3, 19);
this.listBox3.Name = "listBox3";
this.listBox3.Size = new System.Drawing.Size(374, 152);
this.listBox3.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(685, 450);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.ListBox listBox3;
}
}

60
Haromszogek/Form1.cs Normal file
View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
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)
{
OpenFileDialog of = new OpenFileDialog();
if (of.ShowDialog()==DialogResult.OK)
{
listBox1.Items.Clear();
listBox2.Items.Clear();
listBox3.Items.Clear();
string fajlnev = of.FileName;
string[] sorok = File.ReadAllLines(fajlnev);
for (int i = 0; i < sorok.Length; i++)
{
try
{
DHaromszog dh = new DHaromszog(sorok[i], i + 1);
listBox2.Items.Add(dh);
}
catch (Exception hiba)
{
listBox1.Items.Add($"{i+1}. sor: {hiba.Message}");
}
}
}
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox2.SelectedIndex>=0)
{
DHaromszog dh = (DHaromszog)listBox2.SelectedItem;
listBox3.Items.Clear();
listBox3.Items.Add("Kerület= " + dh.Kerulet.ToString("F2"));
listBox3.Items.Add("Terület= " + dh.Terulet.ToString("F2"));
}
}
}
}

60
Haromszogek/Form1.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>

23
Haromszogek/Program.cs Normal file
View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Haromszogek
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}