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
6 changes: 6 additions & 0 deletions Calculator/Calculator/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
83 changes: 83 additions & 0 deletions Calculator/Calculator/Calculator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4BF9438F-1BDB-41DD-9660-F73946CE1FF0}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Calculator</RootNamespace>
<AssemblyName>Calculator</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>4</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
392 changes: 392 additions & 0 deletions Calculator/Calculator/Form1.Designer.cs

Large diffs are not rendered by default.

253 changes: 253 additions & 0 deletions Calculator/Calculator/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator
{
public partial class Form1 : Form
{
Double result = 0;
String operation ="";
bool ok = false;

//For Making The Form Move
private bool drag_app;
private Point start_point = new Point(0, 0);

public Form1()
{
InitializeComponent();
}

private void Button_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "0") || (ok)) //zero nu poate fi prima litera
textBox1.Clear();
ok = false;
Button b = (Button)sender;
/*
if (b.Text == ",")//daca butonul pe care l.am apasat este ","
{

if (!textBox1.Text.Contains(","))
textBox1.Text = textBox1.Text + b.Text;//punem "," atata timp cat nu mai este altul

}
else*/
textBox1.Text = textBox1.Text + b.Text; //daca nu punem punct continuam cu adaugarea cifrelor

}

private void Operator_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
if (result != 0)
{
egal.PerformClick();
ok = true; //memoram faptul ca o operatie a fost selectata(pentru a nu se adauga noul numar peste celalalt)
operation = b.Text;
label1.Text =result + " " + operation;
result = Double.Parse(textBox1.Text);
}
else
{
operation = b.Text;
result = Double.Parse(textBox1.Text);
ok = true;
label1.Text =result + " " + operation;
}
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text="0";
result = 0;
label1.Text = " ";

}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text = "0";
}

private void egal_Click(object sender, EventArgs e)
{
switch (operation)
{
case "+":
textBox1.Text = (result + Double.Parse(textBox1.Text)).ToString();
break;
case "-":
textBox1.Text = (result - Double.Parse(textBox1.Text)).ToString();
break;
case "*":
textBox1.Text = (result * Double.Parse(textBox1.Text)).ToString();
break;
case "/":
textBox1.Text = (result / Double.Parse(textBox1.Text)).ToString();
break;
default: break;
}

result = Double.Parse(textBox1.Text);//salvez al doilea numar
operation = "";//resetez operatia
// label1.Text = " ";
ok = true;


}

private void button12_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - 1, 1);
else
textBox1.Text = "0";
}

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{

switch (e.KeyChar.ToString())
{
case "1":
button1.PerformClick();
break;
case "2":
button2.PerformClick();
break;
case "3":
button3.PerformClick();
break;
case "4":
button4.PerformClick();
break;
case "5":
button5.PerformClick();
break;
case "6":
button6.PerformClick();
break;
case "7":
button7.PerformClick();
break;
case "8":
button8.PerformClick();
break;
case "9":
button9.PerformClick();
break;
case "0":
button0.PerformClick();
break;
case "+":
plus.PerformClick();
break;
case "-":
minus.PerformClick();
break;
case "*":
inmultire.PerformClick();
break;
case "/":
impartire.PerformClick();
break;
case "=":
egal.PerformClick();
break;
case ",":
punct.PerformClick();
break;
default:
break;
}
}

private void button13_Click(object sender, EventArgs e)
{
double a;
a = Double.Parse(textBox1.Text);
a = a * (-1);
textBox1.Text = a.ToString();
}

private void punct_Click(object sender, EventArgs e)
{
ok = false;

if (!textBox1.Text.Contains(","))
{
textBox1.Text = textBox1.Text + ",";
}
}

private void CloseWindow_Btn_Click(object sender, EventArgs e)
{
//Closes The App
Application.Exit();
}

private void MinimizeWindow_btn_Click(object sender, EventArgs e)
{
//Minimizes The Window
WindowState = FormWindowState.Minimized;
}

private void CloseWindow_Btn_MouseEnter(object sender, EventArgs e)
{
//Changes The Background Colour To red When Mouse Pointer Enters The Close Button Area
CloseWindow_Btn.BackColor = Color.Red;
}

private void CloseWindow_Btn_MouseLeave(object sender, EventArgs e)
{
//Changes The Background Colour To Transparent When Mouse Pointer Leaves The Close Button Area
CloseWindow_Btn.BackColor = Color.Transparent;
}

private void MinimizeWindow_btn_MouseEnter(object sender, EventArgs e)
{
//Changes The Background Colour To Dark Gray When Mouse Pointer Enters The Minimize Button Area
MinimizeWindow_btn.BackColor = Color.DarkGray;
}

private void MinimizeWindow_btn_MouseLeave(object sender, EventArgs e)
{
//Changes The Background Colour To Transparent When Mouse Pointer Leaves The Minimize Button Area
MinimizeWindow_btn.BackColor = Color.Transparent;
}

//Code For Moveing The App With The Mouse Pointer (As I Have Changed The Border Type To None) Starts From Here-

private void TopPanel_MouseDown(object sender, MouseEventArgs e)
{
//Enabling The Move
drag_app = true;
start_point = new Point(e.X, e.Y);
}

private void TopPanel_MouseMove(object sender, MouseEventArgs e)
{
//For Making The App Move With The Pointer
if (drag_app == true)
{
Point p = PointToScreen(e.Location);
Location = new Point(p.X - this.start_point.X, p.Y - this.start_point.Y);
}
}

private void TopPanel_MouseUp(object sender, MouseEventArgs e)
{
//When You Unclick The Mouse, It Will Not Move With The Pointer
drag_app = false;
}

//Code For Moving The App Ends Here

}
}
Loading