A modern calculator built with WPF and C#, featuring state machine architecture and full keyboard support.
โจ Features
โ
Basic Operations - Add, Subtract, Multiply, Divide
โ
Operation Chaining - 5 + 3 + 2 = evaluates left-to-right
โ
Large Numbers - Supports up to 9.2 quintillion (64-bit long)
๐น Keyboard Support - Full keyboard + mouse input
๐ State Machine - Prevents input bugs, clean UX flow
๐ก๏ธ Error Handling - Division by zero protection with MessageBox alerts
๐ฆ Modular Design - Separate UI and logic layers
Prerequisites Visual Studio 2019+, .NET Framework 4.7.2+
git clone https://github.com/fahmimee03/wpf-calculator.git
cd wpf-calculator
#Open Learning.sln in Visual Studio
#Press F5 to run
Learning/
โโโ Calculator/ # WPF UI Project
โ โโโ MainWindow.xaml # UI Layout
โ โโโ MainWindow.xaml.cs # UI Logic + State Machine
โ
โโโ Learning/ # Class Library
----โโโ BasicCalculator.cs # Core logic
----โโโ ScientificCalculator.cs
----โโโ ProgrammerCalculator.cs
----โโโ NumberConverter.cs # Binary/Hex/Octal
EnteringFirstNumber โ OperationSelected โ EnteringSecondNumber โ ResultDisplayed
โ----------------------------------------------------------------------------------------โ
โโโโโโโโโโโโโโโโโโโ (New Calculation) โโโโโโโโโโโโโโโโโโโโ
Why?
Prevents bugs like displaying "53" when user types 5 + 3 (should show "3").
- State Pattern - Manages calculator input flow
- Inheritance - Scientific/Programmer extend BasicCalculator
- Separation of Concerns - UI (WPF) โ Logic (DLL)
- Event-Driven - Single event handler for multiple buttons
Contributions welcome! Areas for improvement:
๐ฌ Scientific mode UI (logic exists)
๐ป Programmer mode UI (Binary/Hex/Octal display)
๐ Calculation history panel
๐พ Memory functions (M+, M-, MR, MC)
๐จ Themes/skins support
Please:
Fork the repository
Create feature branch (git checkout -b feature/amazing)
Commit changes (git commit -m 'Add amazing feature')
Push to branch (git push origin feature/amazing)
Open Pull Request
Design inspired by Windows Calculator
Built as part of C# WPF learning journey
State machine pattern from software engineering best practices