https://github.com/anlbora/calculator-wpf-net
This repository contains a simple calculator application built using Windows Forms in C#. The calculator supports basic arithmetic operations and has features for evaluating complex expressions with parentheses and handling square root operations.
https://github.com/anlbora/calculator-wpf-net
application calculator calculator-application csharp desktop-application dotnet wpf
Last synced: 18 days ago
JSON representation
This repository contains a simple calculator application built using Windows Forms in C#. The calculator supports basic arithmetic operations and has features for evaluating complex expressions with parentheses and handling square root operations.
- Host: GitHub
- URL: https://github.com/anlbora/calculator-wpf-net
- Owner: anlbora
- License: mit
- Created: 2024-06-19T20:19:17.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-06-19T20:36:38.000Z (10 months ago)
- Last Synced: 2025-04-08T09:51:25.554Z (18 days ago)
- Topics: application, calculator, calculator-application, csharp, desktop-application, dotnet, wpf
- Language: C#
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Windows Forms Calculator Application
## Overview
This repository contains a simple calculator application built using Windows Forms in C#. The calculator supports basic arithmetic operations and has features for evaluating complex expressions with parentheses and handling square root operations.

## Features
- **Basic Arithmetic**: Supports addition, subtraction, multiplication, and division.
- **Complex Expressions**: Allows for multiple operations and parentheses for operator precedence.
- **Square Root Calculation**: Can compute the square root of the current input or the result displayed.
- **Dynamic Display**: Adjusts the font size dynamically to fit longer expressions in the display.
- **Keyboard Support**: Allows numeric and operation input via the keyboard.
## Components
### Main Form (`mainApp`)
- **Controls**: The form includes buttons for digits (0-9), arithmetic operations (`+`, `-`, `*`, `/`), special functions (square root, parentheses, clear, delete, and toggle sign), and equal for evaluating the expression.
- **Label**: `lbl_answer` displays the current input or result, dynamically adjusting its font size based on the length of the text.### Key Functionalities
1. **Numeric Input**:
- Handled through both button clicks and keyboard input.
- Appended to the current `input` and reflected in the `expression` for display.2. **Operation Handling**:
- Adds operation signs (`+`, `-`, `*`, `/`) to the `expression`.
- Supports continuation of operations after the equal button is pressed.

4. **Expression Evaluation**:
- Uses the `DataTable.Compute` method to evaluate the full expression, considering operator precedence and parentheses.
- Updates the `expression` to display the result after evaluation.5. **Square Root Calculation**:
- Computes the square root of the current input or the displayed result if no new input is provided.
- Updates the `expression` to reflect the square root operation result.6. **Dynamic Font Adjustment**:
- Adjusts the font size of `lbl_answer` based on the length of the text to ensure readability.7. **Keyboard Input Handling**:
- Supports numeric input and operations through keyboard shortcuts.
- Allows users to control the calculator without using the mouse.