#pragma once
namespace Taschenrechner {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Zusammenfassung für Form1
///
/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
/// die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
/// das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
/// Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
/// arbeiten, die diesem Formular zugewiesen sind.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Konstruktorcode hier hinzufügen.
//
oper;
zahl1 = 0;
zahl2 = 0;
ergebniss = 0;
}
protected:
/// <summary>
/// Verwendete Ressourcen bereinigen.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ btnEins;
protected:
private: System::Windows::Forms::Button^ btnZwei;
private: System::Windows::Forms::Button^ btnDrei;
private: System::Windows::Forms::Button^ btnVier;
private: System::Windows::Forms::Button^ btnFünf;
private: System::Windows::Forms::Button^ btnSechs;
private: System::Windows::Forms::Button^ btnSieben;
private: System::Windows::Forms::Button^ btnAcht;
private: System::Windows::Forms::Button^ btnNeun;
private: System::Windows::Forms::Button^ btnKom;
private: System::Windows::Forms::Button^ btnNul;
private: System::Windows::Forms::TextBox^ tbxAusgabe;
private: System::Windows::Forms::Label^ lblAngabe;
private: System::Windows::Forms::Button^ btnEnde;
private: System::Windows::Forms::Button^ btnLoschen;
private: System::Windows::Forms::Button^ btnTeilen;
private: System::Windows::Forms::Button^ btnMal;
private: System::Windows::Forms::Button^ btnMinus;
private: System::Windows::Forms::Button^ btnPlus;
private: System::Windows::Forms::Button^ btnGleich;
private: char oper;
private: double zahl1;
private: double zahl2;
private: double ergebniss;
private:
/// <summary>
/// Erforderliche Designervariable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
/// </summary>
void InitializeComponent(void)
{
this->btnEins = (gcnew System::Windows::Forms::Button());
this->btnZwei = (gcnew System::Windows::Forms::Button());
this->btnDrei = (gcnew System::Windows::Forms::Button());
this->btnVier = (gcnew System::Windows::Forms::Button());
this->btnFünf = (gcnew System::Windows::Forms::Button());
this->btnSechs = (gcnew System::Windows::Forms::Button());
this->btnSieben = (gcnew System::Windows::Forms::Button());
this->btnAcht = (gcnew System::Windows::Forms::Button());
this->btnNeun = (gcnew System::Windows::Forms::Button());
this->btnKom = (gcnew System::Windows::Forms::Button());
this->btnNul = (gcnew System::Windows::Forms::Button());
this->tbxAusgabe = (gcnew System::Windows::Forms::TextBox());
this->lblAngabe = (gcnew System::Windows::Forms::Label());
this->btnEnde = (gcnew System::Windows::Forms::Button());
this->btnLoschen = (gcnew System::Windows::Forms::Button());
this->btnTeilen = (gcnew System::Windows::Forms::Button());
this->btnMal = (gcnew System::Windows::Forms::Button());
this->btnMinus = (gcnew System::Windows::Forms::Button());
this->btnPlus = (gcnew System::Windows::Forms::Button());
this->btnGleich = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// btnEins
//
this->btnEins->Location = System::Drawing::Point(12, 163);
this->btnEins->Name = L"btnEins";
this->btnEins->Size = System::Drawing::Size(28, 25);
this->btnEins->TabIndex = 0;
this->btnEins->Text = L"1";
this->btnEins->UseVisualStyleBackColor = true;
this->btnEins->Click += gcnew System::EventHandler(this, &Form1::btnEins_Click);
//
// btnZwei
//
this->btnZwei->Location = System::Drawing::Point(46, 163);
this->btnZwei->Name = L"btnZwei";
this->btnZwei->Size = System::Drawing::Size(28, 25);
this->btnZwei->TabIndex = 1;
this->btnZwei->Text = L"2";
this->btnZwei->UseVisualStyleBackColor = true;
this->btnZwei->Click += gcnew System::EventHandler(this, &Form1::btnZwei_Click);
//
// btnDrei
//
this->btnDrei->Location = System::Drawing::Point(80, 163);
this->btnDrei->Name = L"btnDrei";
this->btnDrei->Size = System::Drawing::Size(28, 25);
this->btnDrei->TabIndex = 2;
this->btnDrei->Text = L"3";
this->btnDrei->UseVisualStyleBackColor = true;
this->btnDrei->Click += gcnew System::EventHandler(this, &Form1::btnDrei_Click);
//
// btnVier
//
this->btnVier->Location = System::Drawing::Point(12, 132);
this->btnVier->Name = L"btnVier";
this->btnVier->Size = System::Drawing::Size(28, 25);
this->btnVier->TabIndex = 3;
this->btnVier->Text = L"4";
this->btnVier->UseVisualStyleBackColor = true;
this->btnVier->Click += gcnew System::EventHandler(this, &Form1::btnVier_Click);
//
// btnFünf
//
this->btnFünf->Location = System::Drawing::Point(46, 132);
this->btnFünf->Name = L"btnFünf";
this->btnFünf->Size = System::Drawing::Size(28, 25);
this->btnFünf->TabIndex = 4;
this->btnFünf->Text = L"5";
this->btnFünf->UseVisualStyleBackColor = true;
this->btnFünf->Click += gcnew System::EventHandler(this, &Form1::btnFünf_Click);
//
// btnSechs
//
this->btnSechs->Location = System::Drawing::Point(80, 132);
this->btnSechs->Name = L"btnSechs";
this->btnSechs->Size = System::Drawing::Size(28, 25);
this->btnSechs->TabIndex = 5;
this->btnSechs->Text = L"6";
this->btnSechs->UseVisualStyleBackColor = true;
this->btnSechs->Click += gcnew System::EventHandler(this, &Form1::btnSechs_Click);
//
// btnSieben
//
this->btnSieben->Location = System::Drawing::Point(12, 101);
this->btnSieben->Name = L"btnSieben";
this->btnSieben->Size = System::Drawing::Size(28, 25);
this->btnSieben->TabIndex = 6;
this->btnSieben->Text = L"7";
this->btnSieben->UseVisualStyleBackColor = true;
this->btnSieben->Click += gcnew System::EventHandler(this, &Form1::btnSieben_Click);
//
// btnAcht
//
this->btnAcht->Location = System::Drawing::Point(46, 101);
this->btnAcht->Name = L"btnAcht";
this->btnAcht->Size = System::Drawing::Size(28, 25);
this->btnAcht->TabIndex = 7;
this->btnAcht->Text = L"8";
this->btnAcht->UseVisualStyleBackColor = true;
this->btnAcht->Click += gcnew System::EventHandler(this, &Form1::btnAcht_Click);
//
// btnNeun
//
this->btnNeun->Location = System::Drawing::Point(80, 101);
this->btnNeun->Name = L"btnNeun";
this->btnNeun->Size = System::Drawing::Size(28, 25);
this->btnNeun->TabIndex = 8;
this->btnNeun->Text = L"9";
this->btnNeun->UseVisualStyleBackColor = true;
this->btnNeun->Click += gcnew System::EventHandler(this, &Form1::btnNeun_Click);
//
// btnKom
//
this->btnKom->Location = System::Drawing::Point(114, 163);
this->btnKom->Name = L"btnKom";
this->btnKom->Size = System::Drawing::Size(28, 25);
this->btnKom->TabIndex = 9;
this->btnKom->Text = L",";
this->btnKom->UseVisualStyleBackColor = true;
this->btnKom->Click += gcnew System::EventHandler(this, &Form1::btnKom_Click);
//
// btnNul
//
this->btnNul->Location = System::Drawing::Point(12, 194);
this->btnNul->Name = L"btnNul";
this->btnNul->Size = System::Drawing::Size(28, 25);
this->btnNul->TabIndex = 10;
this->btnNul->Text = L"0";
this->btnNul->UseVisualStyleBackColor = true;
this->btnNul->Click += gcnew System::EventHandler(this, &Form1::btnNul_Click);
//
// tbxAusgabe
//
this->tbxAusgabe->Location = System::Drawing::Point(12, 22);
this->tbxAusgabe->Name = L"tbxAusgabe";
this->tbxAusgabe->Size = System::Drawing::Size(268, 20);
this->tbxAusgabe->TabIndex = 11;
this->tbxAusgabe->TextChanged += gcnew System::EventHandler(this, &Form1::tbxAusgabe_TextChanged);
//
// lblAngabe
//
this->lblAngabe->AutoSize = true;
this->lblAngabe->Location = System::Drawing::Point(12, 6);
this->lblAngabe->Name = L"lblAngabe";
this->lblAngabe->Size = System::Drawing::Size(91, 13);
this->lblAngabe->TabIndex = 12;
this->lblAngabe->Text = L"Ein- und Ausgabe";
this->lblAngabe->Click += gcnew System::EventHandler(this, &Form1::lblAngabe_Click);
//
// btnEnde
//
this->btnEnde->BackColor = System::Drawing::Color::Red;
this->btnEnde->Location = System::Drawing::Point(80, 231);
this->btnEnde->Name = L"btnEnde";
this->btnEnde->Size = System::Drawing::Size(128, 23);
this->btnEnde->TabIndex = 13;
this->btnEnde->Text = L"Ende";
this->btnEnde->UseVisualStyleBackColor = false;
this->btnEnde->Click += gcnew System::EventHandler(this, &Form1::btnEnde_Click);
//
// btnLoschen
//
this->btnLoschen->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->btnLoschen->Location = System::Drawing::Point(12, 48);
this->btnLoschen->Name = L"btnLoschen";
this->btnLoschen->Size = System::Drawing::Size(91, 23);
this->btnLoschen->TabIndex = 14;
this->btnLoschen->Text = L"Clear";
this->btnLoschen->UseVisualStyleBackColor = false;
this->btnLoschen->Click += gcnew System::EventHandler(this, &Form1::btnLoschen_Click);
//
// btnTeilen
//
this->btnTeilen->Location = System::Drawing::Point(252, 84);
this->btnTeilen->Name = L"btnTeilen";
this->btnTeilen->Size = System::Drawing::Size(28, 25);
this->btnTeilen->TabIndex = 15;
this->btnTeilen->Text = L"/";
this->btnTeilen->UseVisualStyleBackColor = true;
this->btnTeilen->Click += gcnew System::EventHandler(this, &Form1::btnTeilen_Click);
//
// btnMal
//
this->btnMal->Location = System::Drawing::Point(252, 115);
this->btnMal->Name = L"btnMal";
this->btnMal->Size = System::Drawing::Size(28, 25);
this->btnMal->TabIndex = 16;
this->btnMal->Text = L"*";
this->btnMal->UseVisualStyleBackColor = true;
this->btnMal->Click += gcnew System::EventHandler(this, &Form1::btnMal_Click);
//
// btnMinus
//
this->btnMinus->Location = System::Drawing::Point(252, 146);
this->btnMinus->Name = L"btnMinus";
this->btnMinus->Size = System::Drawing::Size(28, 25);
this->btnMinus->TabIndex = 17;
this->btnMinus->Text = L"-";
this->btnMinus->UseVisualStyleBackColor = true;
this->btnMinus->Click += gcnew System::EventHandler(this, &Form1::btnMinus_Click);
//
// btnPlus
//
this->btnPlus->Location = System::Drawing::Point(252, 177);
this->btnPlus->Name = L"btnPlus";
this->btnPlus->Size = System::Drawing::Size(28, 25);
this->btnPlus->TabIndex = 18;
this->btnPlus->Text = L"+";
this->btnPlus->UseVisualStyleBackColor = true;
this->btnPlus->Click += gcnew System::EventHandler(this, &Form1::btnPlus_Click);
//
// btnGleich
//
this->btnGleich->BackColor = System::Drawing::SystemColors::ActiveBorder;
this->btnGleich->Location = System::Drawing::Point(189, 48);
this->btnGleich->Name = L"btnGleich";
this->btnGleich->Size = System::Drawing::Size(91, 23);
this->btnGleich->TabIndex = 19;
this->btnGleich->Text = L"=";
this->btnGleich->UseVisualStyleBackColor = false;
this->btnGleich->Click += gcnew System::EventHandler(this, &Form1::btnGleich_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->btnGleich);
this->Controls->Add(this->btnPlus);
this->Controls->Add(this->btnMinus);
this->Controls->Add(this->btnMal);
this->Controls->Add(this->btnTeilen);
this->Controls->Add(this->btnLoschen);
this->Controls->Add(this->btnEnde);
this->Controls->Add(this->lblAngabe);
this->Controls->Add(this->tbxAusgabe);
this->Controls->Add(this->btnNul);
this->Controls->Add(this->btnKom);
this->Controls->Add(this->btnNeun);
this->Controls->Add(this->btnAcht);
this->Controls->Add(this->btnSieben);
this->Controls->Add(this->btnSechs);
this->Controls->Add(this->btnFünf);
this->Controls->Add(this->btnVier);
this->Controls->Add(this->btnDrei);
this->Controls->Add(this->btnZwei);
this->Controls->Add(this->btnEins);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Focus();
}
private: System::Void lblAngabe_Click(System::Object^ sender, System::EventArgs^ e)
{
}
private: System::Void btnEnde_Click(System::Object^ sender, System::EventArgs^ e)
{
this -> Close();
}
private: System::Void tbxAusgabe_TextChanged(System::Object^ sender, System::EventArgs^ e)
{
}
private: System::Void btnLoschen_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = "";
oper = 0;
zahl1 = 0;
zahl2 = 0;
ergebniss = 0;
}
private: System::Void btnNul_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "0");
}
private: System::Void btnEins_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "1");
}
private: System::Void btnZwei_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "2");
}
private: System::Void btnDrei_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "3");
}
private: System::Void btnVier_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "4");
}
private: System::Void btnFünf_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "5");
}
private: System::Void btnSechs_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "6");
}
private: System::Void btnSieben_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "7");
}
private: System::Void btnAcht_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "8");
}
private: System::Void btnNeun_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, "9");
}
private: System::Void btnKom_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = String::Concat(tbxAusgabe -> Text, ",");
}
private: System::Void btnPlus_Click(System::Object^ sender, System::EventArgs^ e)
{
zahl1 = Convert::ToDouble(tbxAusgabe -> Text);
tbxAusgabe -> Text = "";
oper = '+';
tbxAusgabe -> Focus();
zahl2 = Convert::ToDouble(tbxAusgabe -> Text);
}
private: System::Void btnMinus_Click(System::Object^ sender, System::EventArgs^ e)
{
zahl1 = Convert::ToDouble(tbxAusgabe -> Text);
tbxAusgabe -> Text = "";
oper = '-';
tbxAusgabe -> Focus();
zahl2 = Convert::ToDouble(tbxAusgabe -> Text);
}
private: System::Void btnMal_Click(System::Object^ sender, System::EventArgs^ e)
{
zahl1 = Convert::ToDouble(tbxAusgabe -> Text);
tbxAusgabe -> Text = "";
oper = '*';
tbxAusgabe -> Focus();
zahl2 = Convert::ToDouble(tbxAusgabe -> Text);
}
private: System::Void btnTeilen_Click(System::Object^ sender, System::EventArgs^ e)
{
zahl1 = Convert::ToDouble(tbxAusgabe -> Text);
tbxAusgabe -> Text = "";
oper = '/';
tbxAusgabe -> Focus();
zahl2 = Convert::ToDouble(tbxAusgabe -> Text);
}
private: System::Void btnGleich_Click(System::Object^ sender, System::EventArgs^ e)
{
tbxAusgabe -> Text = "";
switch(oper)
{
case '+': ergebniss = zahl1 + zahl2;
tbxAusgabe -> Text = Convert::ToString(ergebniss);break;
case '-':ergebniss = zahl1 - zahl2;
tbxAusgabe -> Text = Convert::ToString(ergebniss);break;
case '*':ergebniss = zahl1 * zahl2;
tbxAusgabe -> Text = Convert::ToString(ergebniss);break;
case '/':ergebniss = zahl1 * zahl2;
tbxAusgabe -> Text = Convert::ToString(ergebniss);break;
}
}
};
}