43 | This project has adopted the Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.
44 |
45 |
46 |
Known Issues
47 |
48 |
Menu button and Calculator Type Changes don't work for now.
49 |
More than 1 can be pressed the Dot(.) button.
50 |
Delete (⌫) don't working for now.
51 |
More than 1 can be pressed the Negative/Pozitive(±) button.
52 |
When a number is divided by zero the result is infinite(∞)
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/dotNETCalculator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace dotNETCalculator.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dotNETCalculator.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet-desktop.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 |
6 | # This workflow will build, test, sign and package a WPF or Windows Forms desktop application
7 | # built on .NET Core.
8 | # To learn how to migrate your existing application to .NET Core,
9 | # refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
10 | #
11 | # To configure this workflow:
12 | #
13 | # 1. Configure environment variables
14 | # GitHub sets default environment variables for every workflow run.
15 | # Replace the variables relative to your project in the "env" section below.
16 | #
17 | # 2. Signing
18 | # Generate a signing certificate in the Windows Application
19 | # Packaging Project or add an existing signing certificate to the project.
20 | # Next, use PowerShell to encode the .pfx file using Base64 encoding
21 | # by running the following Powershell script to generate the output string:
22 | #
23 | # $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
24 | # [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
25 | #
26 | # Open the output file, SigningCertificate_Encoded.txt, and copy the
27 | # string inside. Then, add the string to the repo as a GitHub secret
28 | # and name it "Base64_Encoded_Pfx."
29 | # For more information on how to configure your signing certificate for
30 | # this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
31 | #
32 | # Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
33 | # See "Build the Windows Application Packaging project" below to see how the secret is used.
34 | #
35 | # For more information on GitHub Actions, refer to https://github.com/features/actions
36 | # For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
37 | # refer to https://github.com/microsoft/github-actions-for-desktop-apps
38 |
39 | name: .NET Core Desktop
40 |
41 | on:
42 | push:
43 | branches: [ "master" ]
44 | pull_request:
45 | branches: [ "master" ]
46 |
47 | jobs:
48 |
49 | build:
50 |
51 | strategy:
52 | matrix:
53 | configuration: [Debug]
54 |
55 | runs-on: windows-latest # For a list of available runner types, refer to
56 | # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
57 |
58 | env:
59 | Solution_Name: dotNETCalculator.sln # Replace with your solution name, i.e. MyWpfApp.sln.
60 |
61 | steps:
62 | - name: Checkout
63 | uses: actions/checkout@v3
64 | with:
65 | fetch-depth: 0
66 |
67 | # Install the .NET Core workload
68 | - name: Install .NET Core
69 | uses: actions/setup-dotnet@v3
70 | with:
71 | dotnet-version: 6.0.x
72 |
73 | # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
74 | - name: Setup MSBuild.exe
75 | uses: microsoft/setup-msbuild@v1.0.2
76 |
77 | # Execute all unit tests in the solution
78 | - name: Execute unit tests
79 | run: dotnet test
80 |
81 | # Restore the application to populate the obj folder with RuntimeIdentifiers
82 | - name: Restore the application
83 | run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
84 | env:
85 | Configuration: ${{ matrix.configuration }
86 |
--------------------------------------------------------------------------------
/dotNETCalculator/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | text/microsoft-resx
91 |
92 |
93 | 1.3
94 |
95 |
96 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
97 |
98 |
99 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
100 |
101 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | alperakca79@outlook.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/dotNETCalculator/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
44 |
48 |
53 |
54 |
59 |
60 |
65 |
66 |
69 |
72 |
75 |
78 |
79 |
82 |
85 |
89 |
92 |
93 |
97 |
101 |
105 |
109 |
110 |
113 |
116 |
119 |
122 |
123 |
126 |
129 |
132 |
135 |
136 |
139 |
142 |
145 |
148 |
149 |
--------------------------------------------------------------------------------
/dotNETCalculator/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace WindowsCalculator
6 | {
7 | ///
8 | /// Interaction logic for MainWindow.xaml
9 | ///
10 | public partial class MainWindow : Window
11 | {
12 | string output = "";
13 |
14 | double temp = 0;
15 |
16 | string operation = "";
17 |
18 |
19 | public MainWindow()
20 | {
21 | InitializeComponent();
22 | }
23 |
24 | // Number Button
25 | private void NumberButton_Click(object sender, RoutedEventArgs e)
26 | {
27 | string name = ((Button)sender).Name;
28 |
29 | switch(name)
30 | {
31 | case "buttonOne":
32 | output += "1";
33 | Output.Text = output;
34 | break;
35 |
36 | case "buttonTwo":
37 | output += "2";
38 | Output.Text = output;
39 | break;
40 |
41 | case "buttonThree":
42 | output += "3";
43 | Output.Text = output;
44 | break;
45 |
46 | case "buttonFour":
47 | output += "4";
48 | Output.Text = output;
49 | break;
50 |
51 | case "buttonFive":
52 | output += "5";
53 | Output.Text = output;
54 | break;
55 |
56 | case "buttonSix":
57 | output += "6";
58 | Output.Text = output;
59 | break;
60 |
61 | case "buttonSeven":
62 | output += "7";
63 | Output.Text = output;
64 | break;
65 |
66 | case "buttonEight":
67 | output += "8";
68 | Output.Text = output;
69 | break;
70 |
71 | case "buttonNine":
72 | output += "9";
73 | Output.Text = output;
74 | break;
75 |
76 | case "buttonZero":
77 | output += "0";
78 | Output.Text = output;
79 | break;
80 | }
81 | }
82 |
83 | // Subtraction Button
84 | private void buttonSubtraction_Click(object sender, RoutedEventArgs e)
85 | {
86 | if (output != "")
87 | {
88 | temp = double.Parse(output);
89 |
90 | output = "";
91 |
92 | operation = "-";
93 | }
94 | PreviewOutput.Text = (temp.ToString() + " " + operation);
95 | }
96 |
97 | // Addition Button
98 | private void buttonAddition_Click(object sender, RoutedEventArgs e)
99 | {
100 | if (output != "")
101 | {
102 | temp = double.Parse(output);
103 |
104 | output = "";
105 |
106 | operation = "+";
107 | }
108 | PreviewOutput.Text = (temp.ToString() + " " + operation);
109 | }
110 |
111 | // Multiply Button
112 | private void buttonMultiply_Click(object sender, RoutedEventArgs e)
113 | {
114 | if (output != "")
115 | {
116 | temp = double.Parse(output);
117 |
118 | output = "";
119 |
120 | operation = "*";
121 | }
122 | PreviewOutput.Text = (temp.ToString() + " " + operation);
123 | }
124 |
125 | // Division Button
126 | private void buttonDivision_Click(object sender, RoutedEventArgs e)
127 | {
128 | if (output != "")
129 | {
130 | temp = double.Parse(output);
131 |
132 | output = "";
133 |
134 | operation = "/";
135 | }
136 | PreviewOutput.Text = (temp.ToString() + " " + operation);
137 | }
138 |
139 | // Sqr Button
140 | private void buttonSqr_Click(object sender, RoutedEventArgs e)
141 | {
142 | if (output != "")
143 | {
144 | temp = double.Parse(output);
145 |
146 | output = "";
147 |
148 | operation = "sqr";
149 | }
150 |
151 | switch (operation)
152 | {
153 | case "sqr":
154 | double outputTempSqr = temp * temp;
155 | output = outputTempSqr.ToString();
156 | Output.Text = output;
157 | break;
158 | }
159 | PreviewOutput.Text = operation + "( " + temp + " )";
160 | }
161 |
162 | // 1/x Button
163 | private void buttonOneX_Click(object sender, RoutedEventArgs e)
164 | {
165 | if (output != "")
166 | {
167 | temp = double.Parse(output);
168 |
169 | output = "";
170 |
171 | operation = "1/x";
172 | }
173 |
174 | switch (operation)
175 | {
176 | case "1/x":
177 | double outputTempSqr = (1) / temp;
178 | output = outputTempSqr.ToString();
179 | Output.Text = output;
180 | break;
181 | }
182 | PreviewOutput.Text = "1/" + "( " +temp + " )";
183 | }
184 |
185 | // Equals Button
186 | private void buttonEquals_Click(object sender, RoutedEventArgs e)
187 | {
188 | if (string.IsNullOrWhiteSpace(output))
189 | output = temp.ToString();
190 |
191 | PreviewOutput.Text = (temp.ToString() + " " + operation + " " + double.Parse(output) + " " + "=");
192 |
193 | switch (operation)
194 | {
195 | case "-":
196 | double outputTempSub = temp - double.Parse(output);
197 | output = outputTempSub.ToString();
198 | Output.Text = output;
199 | break;
200 |
201 | case "+":
202 | double outputTempAdd = temp + double.Parse(output);
203 | output = outputTempAdd.ToString();
204 | Output.Text = output;
205 | break;
206 |
207 | case "*":
208 | double outputTempMul = temp * double.Parse(output);
209 | output = outputTempMul.ToString();
210 | Output.Text = output;
211 | break;
212 |
213 | case "/":
214 | double outputTempDiv = temp / double.Parse(output);
215 | output = outputTempDiv.ToString();
216 | Output.Text = output;
217 | break;
218 |
219 | case "%":
220 | double outputTempPer = (temp * double.Parse(output)) / 100;
221 | output = outputTempPer.ToString();
222 | Output.Text = output;
223 | break;
224 | }
225 | }
226 |
227 |
228 | // Clear All Button
229 | private void buttonClearAll_Click(object sender, RoutedEventArgs e)
230 | {
231 | Output.Clear();
232 | Output.Text = "0";
233 | output = "";
234 | PreviewOutput.Clear();
235 | PreviewOutput.Text = "";
236 | temp = 0;
237 | }
238 |
239 | // Delete Button
240 | private void buttonDelete_Click(object sender, RoutedEventArgs e)
241 | {
242 |
243 | }
244 |
245 | // Clear Button
246 | private void buttonClear_Click(object sender, RoutedEventArgs e)
247 | {
248 | if (operation == "")
249 | {
250 | Output.Clear();
251 | Output.Text = "0";
252 | output = "";
253 | PreviewOutput.Clear();
254 | PreviewOutput.Text = "";
255 | temp = 0;
256 | }
257 | else
258 | {
259 | Output.Clear();
260 | Output.Text = "0";
261 | output = "";
262 | }
263 |
264 | // Function for Concluded
265 | if (PreviewOutput.Text.EndsWith("="))
266 | {
267 | Output.Clear();
268 | Output.Text = "0";
269 | output = "";
270 | PreviewOutput.Clear();
271 | PreviewOutput.Text = "";
272 | temp = 0;
273 | }
274 | }
275 |
276 | // Percentage Button
277 | private void buttonPercent_Click(object sender, RoutedEventArgs e)
278 | {
279 | if (output != "")
280 | {
281 | temp = double.Parse(output);
282 |
283 | output = "";
284 |
285 | operation = "%";
286 | }
287 | PreviewOutput.Text = (temp.ToString() + " " + operation);
288 | }
289 |
290 | // Copy Button
291 | private void CopyButton_Click(object sender, RoutedEventArgs e)
292 | {
293 | Output.SelectAll();
294 | Output.Copy();
295 | }
296 |
297 | // Square Root Button
298 | private void buttonSquareRoot_Click(object sender, RoutedEventArgs e)
299 | {
300 | if (output != "")
301 | {
302 | temp = double.Parse(output);
303 |
304 | output = "";
305 |
306 | operation = "√";
307 | }
308 |
309 | switch (operation)
310 | {
311 | case "√":
312 | double outputTempSqrt = Math.Sqrt(temp);
313 | output = outputTempSqrt.ToString();
314 | Output.Text = output;
315 | break;
316 | }
317 | PreviewOutput.Text = operation + "( " + temp + " )";
318 | }
319 |
320 | // Pozitive(+) - Negative(-)
321 | private void buttonPoNe_Click(object sender, RoutedEventArgs e)
322 | {
323 | string name = ((Button)sender).Name;
324 |
325 | switch (name)
326 | {
327 | case "buttonPoNe":
328 | output += "-";
329 | Output.Text = output;
330 | break;
331 | }
332 | }
333 |
334 | // Dot(.)
335 | private void buttonDot_Click(object sender, RoutedEventArgs e)
336 | {
337 | string name = ((Button)sender).Name;
338 |
339 | switch (name)
340 | {
341 | case "buttonDot":
342 | output += ".";
343 | Output.Text = output;
344 | break;
345 | }
346 | }
347 | }
348 | }
--------------------------------------------------------------------------------