Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CalculatorApp/CalculatorApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CalculatorApp", "CalculatorApp\CalculatorApp.csproj", "{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestsForCalculator", "TestsForCalculator\TestsForCalculator.csproj", "{5F17A030-E207-46F7-88E5-534F89878F08}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31E65DB4-A6C8-4C0F-BB79-2E251A62686D}.Release|Any CPU.Build.0 = Release|Any CPU
{5F17A030-E207-46F7-88E5-534F89878F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F17A030-E207-46F7-88E5-534F89878F08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F17A030-E207-46F7-88E5-534F89878F08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F17A030-E207-46F7-88E5-534F89878F08}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A28D84EF-25A1-486C-AAC0-E0C30FF24335}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions CalculatorApp/CalculatorApp/CalculatorApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
8 changes: 8 additions & 0 deletions CalculatorApp/CalculatorApp/CalculatorApp.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="Form1.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>
500 changes: 500 additions & 0 deletions CalculatorApp/CalculatorApp/Form1.Designer.cs

Large diffs are not rendered by default.

260 changes: 260 additions & 0 deletions CalculatorApp/CalculatorApp/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
namespace CalculatorApp;

public enum ConditionCalculator
{
start,
firstNumber,
signFirstNumber,
operation,
secondNumber,
signSecondNumber
}

public partial class Calculator : Form
{

TableLayoutPanel tableLayoutPanel;
private ConditionCalculator conditionCalculator = ConditionCalculator.start;
private string firstNumber = "";
private string secondNumber = "";

public Calculator()
{
InitializeComponent();

tableLayoutPanel = new TableLayoutPanel
{
Parent = this,
CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset,
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink
};
}

private void Form1_Load(object sender, EventArgs e) {}

private bool IsInfinity()
{
if (firstNumber == "∞" || firstNumber == "-∞" || secondNumber == "∞" || secondNumber == "-∞")
{
ErrorLabel.Text = "Error";
firstNumber = "";
secondNumber = "";
MainOutputLabel.Text = "0";
BackOutputLabel.Text = "";
conditionCalculator = ConditionCalculator.start;
return true;
}
return false;
}

private void SignButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.SignButtonClick(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
}

private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e) {}


private void DeleteButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.DeleteButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
}

private void CommaButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.CommaButton(ref conditionCalculator, ref firstNumber, ref secondNumber, ref MainOutputLabel, false);
}

private void ResetButton_Click(object sender, EventArgs e)
{
var functional = new Functional();
functional.ResetButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
ref ErrorLabel, false);
}

private void CEButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.CEButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, false);
}

private void WorkWithOperations(char symbol)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.WorkWithOperations(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
ref ErrorLabel, false, symbol);
}

private void OperationButton_Click(object sender, EventArgs e)
{
WorkWithOperations((sender as Button)?.Text[0] ?? throw new Exception());
}

private void EqualButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.EqualButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
ref ErrorLabel, false);
}

private void WorkWithNumbers(char number)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.WorkWithNumber(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel,
false, number);
}

private void OneButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('1');
}

private void TwoButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('2');
}

private void ThreeButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('3');
}

private void FourButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('4');
}

private void FiveButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('5');
}

private void SixButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('6');
}

private void SevenButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('7');
}

private void EightButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('8');
}

private void NineButton_Click(object sender, EventArgs e)
{
WorkWithNumbers('9');
}

private void ZeroButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.ZeroButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel,
false);
}
private void ProcentButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.ProcentButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel,
false);
}

private void SquaringButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
ErrorLabel.Text = "";
var functional = new Functional();
functional.SquaringButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel,
false);
}

private void TakeRootButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.TakeRootButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
ref ErrorLabel, false);
}

private void UnitDividedByNumberButton_Click(object sender, EventArgs e)
{
if (IsInfinity())
{
return;
}
ErrorLabel.Text = "";
var functional = new Functional();
functional.UnitDividedByNumberButton(ref conditionCalculator, ref firstNumber,
ref secondNumber, ref MainOutputLabel, ref BackOutputLabel,
ref ErrorLabel, false);
}
}
60 changes: 60 additions & 0 deletions CalculatorApp/CalculatorApp/Form1.resx
Original file line number Diff line number Diff line change
@@ -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>
Loading