Добавлены операци:
SqrtY, Factorial, CubeRoot, Square, Cube, PowY, Log, Ln, Exp, Inv, Pi, Sinh, Sin, Cosh, Cos, Tanh, Tan
This commit is contained in:
parent
dcfd7c6e70
commit
d3836d6cfc
14 changed files with 1072 additions and 798 deletions
54
.gitignore
vendored
54
.gitignore
vendored
|
|
@ -361,3 +361,57 @@ MigrationBackup/
|
||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/*.code-snippets
|
||||||
|
.history/
|
||||||
|
*.vsix
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
/node_modules
|
||||||
|
/wwwroot/node_modules
|
||||||
|
*.tlog
|
||||||
|
*.vbp
|
||||||
|
*.dsw
|
||||||
|
*.dsp
|
||||||
|
.vshistory/
|
||||||
|
*.code-workspace
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
*.sln.iml
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
.idea/**/aws.xml
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
cmake-build-*/
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
*.iws
|
||||||
|
out/
|
||||||
|
.idea_modules/
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
.idea/replstate.xml
|
||||||
|
.idea/sonarlint/
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
.idea/httpRequests
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
|
||||||
6
.idea/.idea.calculator/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.calculator/.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
38
Commands/CalculateCommand.cs
Normal file
38
Commands/CalculateCommand.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
using calculator.Common;
|
||||||
|
using calculator.Model;
|
||||||
|
using calculator.Services;
|
||||||
|
|
||||||
|
namespace calculator.Commands;
|
||||||
|
|
||||||
|
public class CalculateCommand : ICommand
|
||||||
|
{
|
||||||
|
private readonly ICaculator _caculator;
|
||||||
|
private readonly CaculatorData _data;
|
||||||
|
private readonly double? _b;
|
||||||
|
private readonly Operation _operation;
|
||||||
|
private double? _previousValue;
|
||||||
|
|
||||||
|
public CalculateCommand(ICaculator caculator, CaculatorData data)
|
||||||
|
{
|
||||||
|
_caculator = caculator;
|
||||||
|
_data = data;
|
||||||
|
_operation = data.Operation.Value;
|
||||||
|
|
||||||
|
if (double.TryParse(data.Input, out var b))
|
||||||
|
_b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute()
|
||||||
|
{
|
||||||
|
if (_data.Value is null)
|
||||||
|
return;
|
||||||
|
_previousValue = _data.Value;
|
||||||
|
_data.Value = _caculator.Calculate(_operation, _data.Value.Value, _b);
|
||||||
|
_data.Input = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Undo()
|
||||||
|
{
|
||||||
|
_data.Value = _previousValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
7
Commands/ICommand.cs
Normal file
7
Commands/ICommand.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace calculator.Commands;
|
||||||
|
|
||||||
|
public interface ICommand
|
||||||
|
{
|
||||||
|
void Execute();
|
||||||
|
void Undo();
|
||||||
|
}
|
||||||
32
Common/Operation.cs
Normal file
32
Common/Operation.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
namespace calculator.Common;
|
||||||
|
|
||||||
|
public enum Operation
|
||||||
|
{
|
||||||
|
Add,
|
||||||
|
Sub,
|
||||||
|
Mul,
|
||||||
|
Div,
|
||||||
|
Pow,
|
||||||
|
Sqrt,
|
||||||
|
SqrtY,
|
||||||
|
Factorial,
|
||||||
|
CubeRoot,
|
||||||
|
Square,
|
||||||
|
Cube,
|
||||||
|
PowY,
|
||||||
|
Log,
|
||||||
|
Ln,
|
||||||
|
Exp,
|
||||||
|
Inv,
|
||||||
|
Pi,
|
||||||
|
OneDiv,
|
||||||
|
Mod,
|
||||||
|
Neg,
|
||||||
|
Percent,
|
||||||
|
Sinh,
|
||||||
|
Sin,
|
||||||
|
Cosh,
|
||||||
|
Cos,
|
||||||
|
Tanh,
|
||||||
|
Tan
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using calculator.Model;
|
using calculator.Commands;
|
||||||
|
using calculator.Common;
|
||||||
|
using calculator.Model;
|
||||||
using calculator.Services;
|
using calculator.Services;
|
||||||
using calculator.View;
|
using calculator.View;
|
||||||
|
|
||||||
|
|
@ -10,6 +12,7 @@ public class CaculatorController
|
||||||
private readonly IInputService _inputService;
|
private readonly IInputService _inputService;
|
||||||
private readonly ICaculatorView _view;
|
private readonly ICaculatorView _view;
|
||||||
private readonly CaculatorData _data;
|
private readonly CaculatorData _data;
|
||||||
|
private ICommand? _currentCommand;
|
||||||
|
|
||||||
public CaculatorController(ICaculator caculator, IInputService inputService, ICaculatorView view,
|
public CaculatorController(ICaculator caculator, IInputService inputService, ICaculatorView view,
|
||||||
CaculatorData data)
|
CaculatorData data)
|
||||||
|
|
@ -21,30 +24,22 @@ public class CaculatorController
|
||||||
|
|
||||||
_view.OperandPressed += OnOperandPressed;
|
_view.OperandPressed += OnOperandPressed;
|
||||||
_view.OperatorPressed += OnOperatorPressed;
|
_view.OperatorPressed += OnOperatorPressed;
|
||||||
_view.ClearPressed += OnFullClearPressed;
|
_view.ClearPressed += OnClearPressed;
|
||||||
_view.CalculatePressed += OnCalculatePressed;
|
_view.CalculatePressed += OnCalculatePressed;
|
||||||
_view.SingleOperatorPressed += OnSingleOperationPressed;
|
_view.SingleOperatorPressed += OnSingleOperationPressed;
|
||||||
OnFullClearPressed();
|
OnClearPressed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSingleOperationPressed(string obj)
|
private void OnSingleOperationPressed(Operation operation)
|
||||||
{
|
|
||||||
_data.Operation = null;
|
|
||||||
if (_data.Operands.Count == 2 && _data.Caculated == false)
|
|
||||||
{
|
{
|
||||||
|
OnOperatorPressed(operation);
|
||||||
|
_currentCommand = new CalculateCommand(_caculator, _data);
|
||||||
OnCalculatePressed();
|
OnCalculatePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
_data.Caculated = true;
|
private void OnClearPressed(bool full)
|
||||||
_data.SingleOperation = obj;
|
|
||||||
var operand = _data.Operands.Pop();
|
|
||||||
_data.Operands.Push(_caculator.SingleOperation(operand, obj));
|
|
||||||
_view.UpdateView(_data.Operands.Peek());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnFullClearPressed()
|
|
||||||
{
|
{
|
||||||
Clear();
|
Clear(full: full);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCalculatePressed()
|
private void OnCalculatePressed()
|
||||||
|
|
@ -52,83 +47,70 @@ public class CaculatorController
|
||||||
if (_data.Operation is null)
|
if (_data.Operation is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_data.SingleOperation is not null)
|
if (_data.Value is null)
|
||||||
{
|
|
||||||
var singleOperand = _data.Operands.Pop();
|
|
||||||
_data.Operands.Push(_caculator.SingleOperation(singleOperand, _data.SingleOperation));
|
|
||||||
_view.UpdateView(_data.Operands.Peek());
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_data is not { Caculated: true, Input: null } || _currentCommand == null)
|
||||||
|
{
|
||||||
|
_currentCommand = new CalculateCommand(_caculator, _data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data.Operands.Count < 2)
|
_currentCommand?.Execute();
|
||||||
{
|
|
||||||
var (lastOperand, lastOperation) = (_data.LastOperand, _data.Operation);
|
|
||||||
if (lastOperand is not null && lastOperation is not null)
|
|
||||||
{
|
|
||||||
Calculate(_data.Operands.Pop(), lastOperand, lastOperation);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var operand = _data.Operands.Pop();
|
|
||||||
var operand2 = _data.Operands.Pop();
|
|
||||||
Calculate(operand2, operand, _data.Operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Calculate(string operand1, string operand2, string operation)
|
|
||||||
{
|
|
||||||
_data.Caculated = true;
|
_data.Caculated = true;
|
||||||
_data.LastOperand = operand2;
|
UpdateView(_data.Value.Value);
|
||||||
_data.Operands.Push(_caculator.Calculate(operand1, operand2, operation));
|
|
||||||
_view.UpdateView(_data.Operands.Peek());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Clear(string value = "0", bool full = true)
|
private void Clear(string value = "0", bool full = true)
|
||||||
{
|
{
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
_data.Operands.Clear();
|
_data.Value = null;
|
||||||
_data.Operation = null;
|
_data.Operation = null;
|
||||||
_data.SingleOperation = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_data.Operands.TryPop(out _);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_data.Caculated = false;
|
_data.Caculated = false;
|
||||||
_data.LastOperand = null;
|
_data.Input = null;
|
||||||
_data.Operands.Push(value);
|
_view.UpdateView(value);
|
||||||
_view.UpdateView(_data.Operands.Peek());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOperatorPressed(string operation)
|
private void OnOperatorPressed(Operation operation)
|
||||||
{
|
{
|
||||||
_data.SingleOperation = null;
|
if (_data.Input == null && _data.Value == null)
|
||||||
if (_data.LastOperand is not null && _data.Caculated == false)
|
return;
|
||||||
|
|
||||||
|
if (_data is { Caculated: false, Input: not null, Value: not null })
|
||||||
{
|
{
|
||||||
OnCalculatePressed();
|
OnCalculatePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
_data.Operation = operation;
|
_data.Operation = operation;
|
||||||
|
|
||||||
|
if (_data.Input != null)
|
||||||
|
{
|
||||||
|
_data.Value = double.Parse(_data.Input);
|
||||||
|
}
|
||||||
|
|
||||||
|
_data.Input = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOperandPressed(char obj)
|
private void OnOperandPressed(char obj)
|
||||||
{
|
{
|
||||||
|
if (_data.Caculated)
|
||||||
if (_data is { Operands.Count: 1, Operation: not null })
|
|
||||||
{
|
{
|
||||||
_data.Operands.Push("0");
|
Clear(full: false);
|
||||||
}
|
}
|
||||||
else if (_data is { Caculated: true })
|
|
||||||
|
_data.Input = _inputService.TryInput(_data.Input + obj);
|
||||||
|
UpdateView(_data.Input);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateView(double input)
|
||||||
{
|
{
|
||||||
Clear();
|
_view.UpdateView(input.ToString("0.#####"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var operand = _data.Operands.Pop();
|
private void UpdateView(string input)
|
||||||
|
{
|
||||||
|
_view.UpdateView(input);
|
||||||
_data.Operands.Push(_inputService.TryInput(operand + obj));
|
|
||||||
_view.UpdateView(_data.Operands.Peek());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
512
Form1.Designer.cs
generated
512
Form1.Designer.cs
generated
|
|
@ -30,29 +30,29 @@
|
||||||
{
|
{
|
||||||
panel1 = new Panel();
|
panel1 = new Panel();
|
||||||
button49 = new Button();
|
button49 = new Button();
|
||||||
button50=new Button();
|
Log_button = new Button();
|
||||||
button51=new Button();
|
Mod_button = new Button();
|
||||||
button52=new Button();
|
Exp_button = new Button();
|
||||||
button53 = new Button();
|
button53 = new Button();
|
||||||
button44=new Button();
|
CubeRoot_Button = new Button();
|
||||||
button45=new Button();
|
Cube_button = new Button();
|
||||||
button46=new Button();
|
Tan_button = new Button();
|
||||||
button47=new Button();
|
Tanh_button = new Button();
|
||||||
button48=new Button();
|
Pi_button = new Button();
|
||||||
button39=new Button();
|
SqrtY_button = new Button();
|
||||||
button40=new Button();
|
PowY_button = new Button();
|
||||||
button41=new Button();
|
Cos_button = new Button();
|
||||||
button42=new Button();
|
Cosh_button = new Button();
|
||||||
button43=new Button();
|
dms_button = new Button();
|
||||||
button34=new Button();
|
Factorial_button = new Button();
|
||||||
button35=new Button();
|
Square_button = new Button();
|
||||||
button36=new Button();
|
Sin_button = new Button();
|
||||||
button37=new Button();
|
Sinh_button = new Button();
|
||||||
button38=new Button();
|
Int_button = new Button();
|
||||||
button23 = new Button();
|
button23 = new Button();
|
||||||
button30 = new Button();
|
button30 = new Button();
|
||||||
button31=new Button();
|
Ln_button = new Button();
|
||||||
button32=new Button();
|
Inv_button = new Button();
|
||||||
button33 = new Button();
|
button33 = new Button();
|
||||||
InverseButton = new Button();
|
InverseButton = new Button();
|
||||||
MultButton = new Button();
|
MultButton = new Button();
|
||||||
|
|
@ -98,29 +98,29 @@
|
||||||
//
|
//
|
||||||
panel1.BackColor = Color.MediumSlateBlue;
|
panel1.BackColor = Color.MediumSlateBlue;
|
||||||
panel1.Controls.Add(button49);
|
panel1.Controls.Add(button49);
|
||||||
panel1.Controls.Add(button50);
|
panel1.Controls.Add(Log_button);
|
||||||
panel1.Controls.Add(button51);
|
panel1.Controls.Add(Mod_button);
|
||||||
panel1.Controls.Add(button52);
|
panel1.Controls.Add(Exp_button);
|
||||||
panel1.Controls.Add(button53);
|
panel1.Controls.Add(button53);
|
||||||
panel1.Controls.Add(button44);
|
panel1.Controls.Add(CubeRoot_Button);
|
||||||
panel1.Controls.Add(button45);
|
panel1.Controls.Add(Cube_button);
|
||||||
panel1.Controls.Add(button46);
|
panel1.Controls.Add(Tan_button);
|
||||||
panel1.Controls.Add(button47);
|
panel1.Controls.Add(Tanh_button);
|
||||||
panel1.Controls.Add(button48);
|
panel1.Controls.Add(Pi_button);
|
||||||
panel1.Controls.Add(button39);
|
panel1.Controls.Add(SqrtY_button);
|
||||||
panel1.Controls.Add(button40);
|
panel1.Controls.Add(PowY_button);
|
||||||
panel1.Controls.Add(button41);
|
panel1.Controls.Add(Cos_button);
|
||||||
panel1.Controls.Add(button42);
|
panel1.Controls.Add(Cosh_button);
|
||||||
panel1.Controls.Add(button43);
|
panel1.Controls.Add(dms_button);
|
||||||
panel1.Controls.Add(button34);
|
panel1.Controls.Add(Factorial_button);
|
||||||
panel1.Controls.Add(button35);
|
panel1.Controls.Add(Square_button);
|
||||||
panel1.Controls.Add(button36);
|
panel1.Controls.Add(Sin_button);
|
||||||
panel1.Controls.Add(button37);
|
panel1.Controls.Add(Sinh_button);
|
||||||
panel1.Controls.Add(button38);
|
panel1.Controls.Add(Int_button);
|
||||||
panel1.Controls.Add(button23);
|
panel1.Controls.Add(button23);
|
||||||
panel1.Controls.Add(button30);
|
panel1.Controls.Add(button30);
|
||||||
panel1.Controls.Add(button31);
|
panel1.Controls.Add(Ln_button);
|
||||||
panel1.Controls.Add(button32);
|
panel1.Controls.Add(Inv_button);
|
||||||
panel1.Controls.Add(button33);
|
panel1.Controls.Add(button33);
|
||||||
panel1.Controls.Add(InverseButton);
|
panel1.Controls.Add(InverseButton);
|
||||||
panel1.Controls.Add(MultButton);
|
panel1.Controls.Add(MultButton);
|
||||||
|
|
@ -168,38 +168,41 @@
|
||||||
button49.Text = "10ᵜ";
|
button49.Text = "10ᵜ";
|
||||||
button49.UseVisualStyleBackColor = true;
|
button49.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button50
|
// Log_button
|
||||||
//
|
//
|
||||||
button50.FlatStyle=FlatStyle.Flat;
|
Log_button.FlatStyle = FlatStyle.Flat;
|
||||||
button50.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Log_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button50.Location=new Point(175, 296);
|
Log_button.Location = new Point(175, 296);
|
||||||
button50.Name="button50";
|
Log_button.Name = "Log_button";
|
||||||
button50.Size=new Size(51, 37);
|
Log_button.Size = new Size(51, 37);
|
||||||
button50.TabIndex=54;
|
Log_button.TabIndex = 54;
|
||||||
button50.Text="log";
|
Log_button.Text = "log";
|
||||||
button50.UseVisualStyleBackColor=true;
|
Log_button.UseVisualStyleBackColor = true;
|
||||||
|
Log_button.Click += OnLogButtonClick;
|
||||||
//
|
//
|
||||||
// button51
|
// Mod_button
|
||||||
//
|
//
|
||||||
button51.FlatStyle=FlatStyle.Flat;
|
Mod_button.FlatStyle = FlatStyle.Flat;
|
||||||
button51.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Mod_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button51.Location=new Point(118, 296);
|
Mod_button.Location = new Point(118, 296);
|
||||||
button51.Name="button51";
|
Mod_button.Name = "Mod_button";
|
||||||
button51.Size=new Size(51, 37);
|
Mod_button.Size = new Size(51, 37);
|
||||||
button51.TabIndex=53;
|
Mod_button.TabIndex = 53;
|
||||||
button51.Text="Mod";
|
Mod_button.Text = "Mod";
|
||||||
button51.UseVisualStyleBackColor=true;
|
Mod_button.UseVisualStyleBackColor = true;
|
||||||
|
Mod_button.Click += OnModButtonClick;
|
||||||
//
|
//
|
||||||
// button52
|
// Exp_button
|
||||||
//
|
//
|
||||||
button52.FlatStyle=FlatStyle.Flat;
|
Exp_button.FlatStyle = FlatStyle.Flat;
|
||||||
button52.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Exp_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button52.Location=new Point(61, 296);
|
Exp_button.Location = new Point(61, 296);
|
||||||
button52.Name="button52";
|
Exp_button.Name = "Exp_button";
|
||||||
button52.Size=new Size(51, 37);
|
Exp_button.Size = new Size(51, 37);
|
||||||
button52.TabIndex=52;
|
Exp_button.TabIndex = 52;
|
||||||
button52.Text="Exp";
|
Exp_button.Text = "Exp";
|
||||||
button52.UseVisualStyleBackColor=true;
|
Exp_button.UseVisualStyleBackColor = true;
|
||||||
|
Exp_button.Click += OnExpButtonClick;
|
||||||
//
|
//
|
||||||
// button53
|
// button53
|
||||||
//
|
//
|
||||||
|
|
@ -212,171 +215,183 @@
|
||||||
button53.Text = "F-E";
|
button53.Text = "F-E";
|
||||||
button53.UseVisualStyleBackColor = true;
|
button53.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button44
|
// CubeRoot_Button
|
||||||
//
|
//
|
||||||
button44.FlatStyle=FlatStyle.Flat;
|
CubeRoot_Button.FlatStyle = FlatStyle.Flat;
|
||||||
button44.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
CubeRoot_Button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button44.Location=new Point(232, 253);
|
CubeRoot_Button.Location = new Point(232, 253);
|
||||||
button44.Name="button44";
|
CubeRoot_Button.Name = "CubeRoot_Button";
|
||||||
button44.Size=new Size(51, 37);
|
CubeRoot_Button.Size = new Size(51, 37);
|
||||||
button44.TabIndex=50;
|
CubeRoot_Button.TabIndex = 50;
|
||||||
button44.Text="∛x";
|
CubeRoot_Button.Text = "∛x";
|
||||||
button44.UseVisualStyleBackColor=true;
|
CubeRoot_Button.UseVisualStyleBackColor = true;
|
||||||
|
CubeRoot_Button.Click += OnCubeRootButtonClick;
|
||||||
//
|
//
|
||||||
// button45
|
// Cube_button
|
||||||
//
|
//
|
||||||
button45.FlatStyle=FlatStyle.Flat;
|
Cube_button.FlatStyle = FlatStyle.Flat;
|
||||||
button45.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Cube_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button45.Location=new Point(175, 253);
|
Cube_button.Location = new Point(175, 253);
|
||||||
button45.Name="button45";
|
Cube_button.Name = "Cube_button";
|
||||||
button45.Size=new Size(51, 37);
|
Cube_button.Size = new Size(51, 37);
|
||||||
button45.TabIndex=49;
|
Cube_button.TabIndex = 49;
|
||||||
button45.Text="x³";
|
Cube_button.Text = "x³";
|
||||||
button45.UseVisualStyleBackColor=true;
|
Cube_button.UseVisualStyleBackColor = true;
|
||||||
|
Cube_button.Click += OnCubeButtonClick;
|
||||||
//
|
//
|
||||||
// button46
|
// Tan_button
|
||||||
//
|
//
|
||||||
button46.FlatStyle=FlatStyle.Flat;
|
Tan_button.FlatStyle = FlatStyle.Flat;
|
||||||
button46.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Tan_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button46.Location=new Point(118, 253);
|
Tan_button.Location = new Point(118, 253);
|
||||||
button46.Name="button46";
|
Tan_button.Name = "Tan_button";
|
||||||
button46.Size=new Size(51, 37);
|
Tan_button.Size = new Size(51, 37);
|
||||||
button46.TabIndex=48;
|
Tan_button.TabIndex = 48;
|
||||||
button46.Text="tan";
|
Tan_button.Text = "tan";
|
||||||
button46.UseVisualStyleBackColor=true;
|
Tan_button.UseVisualStyleBackColor = true;
|
||||||
|
Tan_button.Click += OnTanButtonClick;
|
||||||
//
|
//
|
||||||
// button47
|
// Tanh_button
|
||||||
//
|
//
|
||||||
button47.FlatStyle=FlatStyle.Flat;
|
Tanh_button.FlatStyle = FlatStyle.Flat;
|
||||||
button47.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Tanh_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button47.Location=new Point(61, 253);
|
Tanh_button.Location = new Point(61, 253);
|
||||||
button47.Name="button47";
|
Tanh_button.Name = "Tanh_button";
|
||||||
button47.Size=new Size(51, 37);
|
Tanh_button.Size = new Size(51, 37);
|
||||||
button47.TabIndex=47;
|
Tanh_button.TabIndex = 47;
|
||||||
button47.Text="tanh";
|
Tanh_button.Text = "tanh";
|
||||||
button47.UseVisualStyleBackColor=true;
|
Tanh_button.UseVisualStyleBackColor = true;
|
||||||
|
Tanh_button.Click += OnTanhButtonClick;
|
||||||
//
|
//
|
||||||
// button48
|
// Pi_button
|
||||||
//
|
//
|
||||||
button48.FlatStyle=FlatStyle.Flat;
|
Pi_button.FlatStyle = FlatStyle.Flat;
|
||||||
button48.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Pi_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button48.Location=new Point(4, 253);
|
Pi_button.Location = new Point(4, 253);
|
||||||
button48.Name="button48";
|
Pi_button.Name = "Pi_button";
|
||||||
button48.Size=new Size(51, 37);
|
Pi_button.Size = new Size(51, 37);
|
||||||
button48.TabIndex=46;
|
Pi_button.TabIndex = 46;
|
||||||
button48.Text="π";
|
Pi_button.Text = "π";
|
||||||
button48.UseVisualStyleBackColor=true;
|
Pi_button.UseVisualStyleBackColor = true;
|
||||||
|
Pi_button.Click += OnPiButtonClick;
|
||||||
//
|
//
|
||||||
// button39
|
// SqrtY_button
|
||||||
//
|
//
|
||||||
button39.FlatStyle=FlatStyle.Flat;
|
SqrtY_button.FlatStyle = FlatStyle.Flat;
|
||||||
button39.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
SqrtY_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button39.Location=new Point(232, 210);
|
SqrtY_button.Location = new Point(232, 210);
|
||||||
button39.Name="button39";
|
SqrtY_button.Name = "SqrtY_button";
|
||||||
button39.Size=new Size(51, 37);
|
SqrtY_button.Size = new Size(51, 37);
|
||||||
button39.TabIndex=45;
|
SqrtY_button.TabIndex = 45;
|
||||||
button39.Text="y√x";
|
SqrtY_button.Text = "y√x";
|
||||||
button39.UseVisualStyleBackColor=true;
|
SqrtY_button.UseVisualStyleBackColor = true;
|
||||||
button39.Click+=button39_Click;
|
SqrtY_button.Click += OnSqrtYButtonClick;
|
||||||
//
|
//
|
||||||
// button40
|
// PowY_button
|
||||||
//
|
//
|
||||||
button40.FlatStyle=FlatStyle.Flat;
|
PowY_button.FlatStyle = FlatStyle.Flat;
|
||||||
button40.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
PowY_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button40.Location=new Point(175, 210);
|
PowY_button.Location = new Point(175, 210);
|
||||||
button40.Name="button40";
|
PowY_button.Name = "PowY_button";
|
||||||
button40.Size=new Size(51, 37);
|
PowY_button.Size = new Size(51, 37);
|
||||||
button40.TabIndex=44;
|
PowY_button.TabIndex = 44;
|
||||||
button40.Text="xᵜ";
|
PowY_button.Text = "xᵜ";
|
||||||
button40.UseVisualStyleBackColor=true;
|
PowY_button.UseVisualStyleBackColor = true;
|
||||||
|
PowY_button.Click += OnPowYButtonClick;
|
||||||
//
|
//
|
||||||
// button41
|
// Cos_button
|
||||||
//
|
//
|
||||||
button41.FlatStyle=FlatStyle.Flat;
|
Cos_button.FlatStyle = FlatStyle.Flat;
|
||||||
button41.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Cos_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button41.Location=new Point(118, 210);
|
Cos_button.Location = new Point(118, 210);
|
||||||
button41.Name="button41";
|
Cos_button.Name = "Cos_button";
|
||||||
button41.Size=new Size(51, 37);
|
Cos_button.Size = new Size(51, 37);
|
||||||
button41.TabIndex=43;
|
Cos_button.TabIndex = 43;
|
||||||
button41.Text="cos";
|
Cos_button.Text = "cos";
|
||||||
button41.UseVisualStyleBackColor=true;
|
Cos_button.UseVisualStyleBackColor = true;
|
||||||
|
Cos_button.Click += OnCosButtonClick;
|
||||||
//
|
//
|
||||||
// button42
|
// Cosh_button
|
||||||
//
|
//
|
||||||
button42.FlatStyle=FlatStyle.Flat;
|
Cosh_button.FlatStyle = FlatStyle.Flat;
|
||||||
button42.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Cosh_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button42.Location=new Point(61, 210);
|
Cosh_button.Location = new Point(61, 210);
|
||||||
button42.Name="button42";
|
Cosh_button.Name = "Cosh_button";
|
||||||
button42.Size=new Size(51, 37);
|
Cosh_button.Size = new Size(51, 37);
|
||||||
button42.TabIndex=42;
|
Cosh_button.TabIndex = 42;
|
||||||
button42.Text="cosh";
|
Cosh_button.Text = "cosh";
|
||||||
button42.UseVisualStyleBackColor=true;
|
Cosh_button.UseVisualStyleBackColor = true;
|
||||||
|
Cosh_button.Click += OnCoshButtonClick;
|
||||||
//
|
//
|
||||||
// button43
|
// dms_button
|
||||||
//
|
//
|
||||||
button43.FlatStyle=FlatStyle.Flat;
|
dms_button.FlatStyle = FlatStyle.Flat;
|
||||||
button43.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
dms_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button43.Location=new Point(4, 210);
|
dms_button.Location = new Point(4, 210);
|
||||||
button43.Name="button43";
|
dms_button.Name = "dms_button";
|
||||||
button43.Size=new Size(51, 37);
|
dms_button.Size = new Size(51, 37);
|
||||||
button43.TabIndex=41;
|
dms_button.TabIndex = 41;
|
||||||
button43.Text="dms";
|
dms_button.Text = "dms";
|
||||||
button43.UseVisualStyleBackColor=true;
|
dms_button.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button34
|
// Factorial_button
|
||||||
//
|
//
|
||||||
button34.FlatStyle=FlatStyle.Flat;
|
Factorial_button.FlatStyle = FlatStyle.Flat;
|
||||||
button34.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Factorial_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button34.Location=new Point(232, 167);
|
Factorial_button.Location = new Point(232, 167);
|
||||||
button34.Name="button34";
|
Factorial_button.Name = "Factorial_button";
|
||||||
button34.Size=new Size(51, 37);
|
Factorial_button.Size = new Size(51, 37);
|
||||||
button34.TabIndex=40;
|
Factorial_button.TabIndex = 40;
|
||||||
button34.Text="n!";
|
Factorial_button.Text = "n!";
|
||||||
button34.UseVisualStyleBackColor=true;
|
Factorial_button.UseVisualStyleBackColor = true;
|
||||||
|
Factorial_button.Click += OnFactorialButtonClick;
|
||||||
//
|
//
|
||||||
// button35
|
// Square_button
|
||||||
//
|
//
|
||||||
button35.FlatStyle=FlatStyle.Flat;
|
Square_button.FlatStyle = FlatStyle.Flat;
|
||||||
button35.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Square_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button35.Location=new Point(175, 167);
|
Square_button.Location = new Point(175, 167);
|
||||||
button35.Name="button35";
|
Square_button.Name = "Square_button";
|
||||||
button35.Size=new Size(51, 37);
|
Square_button.Size = new Size(51, 37);
|
||||||
button35.TabIndex=39;
|
Square_button.TabIndex = 39;
|
||||||
button35.Text="Х²";
|
Square_button.Text = "Х²";
|
||||||
button35.UseVisualStyleBackColor=true;
|
Square_button.UseVisualStyleBackColor = true;
|
||||||
|
Square_button.Click += OnSquareButtonClick;
|
||||||
//
|
//
|
||||||
// button36
|
// Sin_button
|
||||||
//
|
//
|
||||||
button36.FlatStyle=FlatStyle.Flat;
|
Sin_button.FlatStyle = FlatStyle.Flat;
|
||||||
button36.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Sin_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button36.Location=new Point(118, 167);
|
Sin_button.Location = new Point(118, 167);
|
||||||
button36.Name="button36";
|
Sin_button.Name = "Sin_button";
|
||||||
button36.Size=new Size(51, 37);
|
Sin_button.Size = new Size(51, 37);
|
||||||
button36.TabIndex=38;
|
Sin_button.TabIndex = 38;
|
||||||
button36.Text="sin";
|
Sin_button.Text = "sin";
|
||||||
button36.UseVisualStyleBackColor=true;
|
Sin_button.UseVisualStyleBackColor = true;
|
||||||
|
Sin_button.Click += OnSinButtonClick;
|
||||||
//
|
//
|
||||||
// button37
|
// Sinh_button
|
||||||
//
|
//
|
||||||
button37.FlatStyle=FlatStyle.Flat;
|
Sinh_button.FlatStyle = FlatStyle.Flat;
|
||||||
button37.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Sinh_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button37.Location=new Point(61, 167);
|
Sinh_button.Location = new Point(61, 167);
|
||||||
button37.Name="button37";
|
Sinh_button.Name = "Sinh_button";
|
||||||
button37.Size=new Size(51, 37);
|
Sinh_button.Size = new Size(51, 37);
|
||||||
button37.TabIndex=37;
|
Sinh_button.TabIndex = 37;
|
||||||
button37.Text="sinh";
|
Sinh_button.Text = "sinh";
|
||||||
button37.UseVisualStyleBackColor=true;
|
Sinh_button.UseVisualStyleBackColor = true;
|
||||||
|
Sinh_button.Click += OnSinhButtonClick;
|
||||||
//
|
//
|
||||||
// button38
|
// Int_button
|
||||||
//
|
//
|
||||||
button38.FlatStyle=FlatStyle.Flat;
|
Int_button.FlatStyle = FlatStyle.Flat;
|
||||||
button38.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Int_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button38.Location=new Point(4, 167);
|
Int_button.Location = new Point(4, 167);
|
||||||
button38.Name="button38";
|
Int_button.Name = "Int_button";
|
||||||
button38.Size=new Size(51, 37);
|
Int_button.Size = new Size(51, 37);
|
||||||
button38.TabIndex=36;
|
Int_button.TabIndex = 36;
|
||||||
button38.Text="Int";
|
Int_button.Text = "Int";
|
||||||
button38.UseVisualStyleBackColor=true;
|
Int_button.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button23
|
// button23
|
||||||
//
|
//
|
||||||
|
|
@ -400,27 +415,29 @@
|
||||||
button30.Text = "(";
|
button30.Text = "(";
|
||||||
button30.UseVisualStyleBackColor = true;
|
button30.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button31
|
// Ln_button
|
||||||
//
|
//
|
||||||
button31.FlatStyle=FlatStyle.Flat;
|
Ln_button.FlatStyle = FlatStyle.Flat;
|
||||||
button31.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Ln_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button31.Location=new Point(118, 124);
|
Ln_button.Location = new Point(118, 124);
|
||||||
button31.Name="button31";
|
Ln_button.Name = "Ln_button";
|
||||||
button31.Size=new Size(51, 37);
|
Ln_button.Size = new Size(51, 37);
|
||||||
button31.TabIndex=33;
|
Ln_button.TabIndex = 33;
|
||||||
button31.Text="In";
|
Ln_button.Text = "Ln";
|
||||||
button31.UseVisualStyleBackColor=true;
|
Ln_button.UseVisualStyleBackColor = true;
|
||||||
|
Ln_button.Click += OnLnButtonClick;
|
||||||
//
|
//
|
||||||
// button32
|
// Inv_button
|
||||||
//
|
//
|
||||||
button32.FlatStyle=FlatStyle.Flat;
|
Inv_button.FlatStyle = FlatStyle.Flat;
|
||||||
button32.Font=new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
Inv_button.Font = new Font("Segoe UI", 9.75F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
button32.Location=new Point(61, 124);
|
Inv_button.Location = new Point(61, 124);
|
||||||
button32.Name="button32";
|
Inv_button.Name = "Inv_button";
|
||||||
button32.Size=new Size(51, 37);
|
Inv_button.Size = new Size(51, 37);
|
||||||
button32.TabIndex=32;
|
Inv_button.TabIndex = 32;
|
||||||
button32.Text="Inv";
|
Inv_button.Text = "Inv";
|
||||||
button32.UseVisualStyleBackColor=true;
|
Inv_button.UseVisualStyleBackColor = true;
|
||||||
|
Inv_button.Click += OnInvButtonClick;
|
||||||
//
|
//
|
||||||
// button33
|
// button33
|
||||||
//
|
//
|
||||||
|
|
@ -685,6 +702,7 @@
|
||||||
button8.TabIndex = 9;
|
button8.TabIndex = 9;
|
||||||
button8.Text = "C";
|
button8.Text = "C";
|
||||||
button8.UseVisualStyleBackColor = true;
|
button8.UseVisualStyleBackColor = true;
|
||||||
|
button8.Click += CButtonClick;
|
||||||
//
|
//
|
||||||
// CE_button
|
// CE_button
|
||||||
//
|
//
|
||||||
|
|
@ -778,11 +796,11 @@
|
||||||
// radioButton3
|
// radioButton3
|
||||||
//
|
//
|
||||||
radioButton3.AutoSize = true;
|
radioButton3.AutoSize = true;
|
||||||
radioButton3.Font=new Font("Roboto", 11.25F, FontStyle.Bold|FontStyle.Italic, GraphicsUnit.Point);
|
radioButton3.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
|
||||||
radioButton3.ForeColor = Color.FromArgb(255, 192, 255);
|
radioButton3.ForeColor = Color.FromArgb(255, 192, 255);
|
||||||
radioButton3.Location = new Point(197, 13);
|
radioButton3.Location = new Point(197, 13);
|
||||||
radioButton3.Name = "radioButton3";
|
radioButton3.Name = "radioButton3";
|
||||||
radioButton3.Size=new Size(74, 22);
|
radioButton3.Size = new Size(76, 22);
|
||||||
radioButton3.TabIndex = 2;
|
radioButton3.TabIndex = 2;
|
||||||
radioButton3.TabStop = true;
|
radioButton3.TabStop = true;
|
||||||
radioButton3.Text = "Грады";
|
radioButton3.Text = "Грады";
|
||||||
|
|
@ -791,11 +809,11 @@
|
||||||
// radioButton2
|
// radioButton2
|
||||||
//
|
//
|
||||||
radioButton2.AutoSize = true;
|
radioButton2.AutoSize = true;
|
||||||
radioButton2.Font=new Font("Roboto", 11.25F, FontStyle.Bold|FontStyle.Italic, GraphicsUnit.Point);
|
radioButton2.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
|
||||||
radioButton2.ForeColor = Color.FromArgb(255, 192, 255);
|
radioButton2.ForeColor = Color.FromArgb(255, 192, 255);
|
||||||
radioButton2.Location = new Point(98, 13);
|
radioButton2.Location = new Point(98, 13);
|
||||||
radioButton2.Name = "radioButton2";
|
radioButton2.Name = "radioButton2";
|
||||||
radioButton2.Size=new Size(97, 22);
|
radioButton2.Size = new Size(95, 22);
|
||||||
radioButton2.TabIndex = 1;
|
radioButton2.TabIndex = 1;
|
||||||
radioButton2.TabStop = true;
|
radioButton2.TabStop = true;
|
||||||
radioButton2.Text = "Радианы";
|
radioButton2.Text = "Радианы";
|
||||||
|
|
@ -804,11 +822,11 @@
|
||||||
// radioButton1
|
// radioButton1
|
||||||
//
|
//
|
||||||
radioButton1.AutoSize = true;
|
radioButton1.AutoSize = true;
|
||||||
radioButton1.Font=new Font("Roboto", 11.25F, FontStyle.Bold|FontStyle.Italic, GraphicsUnit.Point);
|
radioButton1.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point);
|
||||||
radioButton1.ForeColor = Color.FromArgb(255, 192, 255);
|
radioButton1.ForeColor = Color.FromArgb(255, 192, 255);
|
||||||
radioButton1.Location = new Point(6, 13);
|
radioButton1.Location = new Point(6, 13);
|
||||||
radioButton1.Name = "radioButton1";
|
radioButton1.Name = "radioButton1";
|
||||||
radioButton1.Size=new Size(91, 22);
|
radioButton1.Size = new Size(93, 22);
|
||||||
radioButton1.TabIndex = 0;
|
radioButton1.TabIndex = 0;
|
||||||
radioButton1.TabStop = true;
|
radioButton1.TabStop = true;
|
||||||
radioButton1.Text = "Градусы";
|
radioButton1.Text = "Градусы";
|
||||||
|
|
@ -897,29 +915,29 @@
|
||||||
private LinkLabel linkLabel2;
|
private LinkLabel linkLabel2;
|
||||||
private LinkLabel linkLabel3;
|
private LinkLabel linkLabel3;
|
||||||
private Button button49;
|
private Button button49;
|
||||||
private Button button50;
|
private Button Log_button;
|
||||||
private Button button51;
|
private Button Mod_button;
|
||||||
private Button button52;
|
private Button Exp_button;
|
||||||
private Button button53;
|
private Button button53;
|
||||||
private Button button44;
|
private Button CubeRoot_Button;
|
||||||
private Button button45;
|
private Button Cube_button;
|
||||||
private Button button46;
|
private Button Tan_button;
|
||||||
private Button button47;
|
private Button Tanh_button;
|
||||||
private Button button48;
|
private Button Pi_button;
|
||||||
private Button button39;
|
private Button SqrtY_button;
|
||||||
private Button button40;
|
private Button PowY_button;
|
||||||
private Button button41;
|
private Button Cos_button;
|
||||||
private Button button42;
|
private Button Cosh_button;
|
||||||
private Button button43;
|
private Button dms_button;
|
||||||
private Button button34;
|
private Button Factorial_button;
|
||||||
private Button button35;
|
private Button Square_button;
|
||||||
private Button button36;
|
private Button Sin_button;
|
||||||
private Button button37;
|
private Button Sinh_button;
|
||||||
private Button button38;
|
private Button Int_button;
|
||||||
private Button button23;
|
private Button button23;
|
||||||
private Button button30;
|
private Button button30;
|
||||||
private Button button31;
|
private Button Ln_button;
|
||||||
private Button button32;
|
private Button Inv_button;
|
||||||
private Button button33;
|
private Button button33;
|
||||||
private Button InverseButton;
|
private Button InverseButton;
|
||||||
private Button MultButton;
|
private Button MultButton;
|
||||||
|
|
|
||||||
119
Form1.cs
119
Form1.cs
|
|
@ -1,4 +1,5 @@
|
||||||
using calculator.View;
|
using calculator.Common;
|
||||||
|
using calculator.View;
|
||||||
|
|
||||||
namespace calculator
|
namespace calculator
|
||||||
{
|
{
|
||||||
|
|
@ -10,9 +11,9 @@ namespace calculator
|
||||||
}
|
}
|
||||||
|
|
||||||
public event Action<char>? OperandPressed;
|
public event Action<char>? OperandPressed;
|
||||||
public event Action<string>? OperatorPressed;
|
public event Action<Operation>? OperatorPressed;
|
||||||
public event Action<string>? SingleOperatorPressed;
|
public event Action<Operation>? SingleOperatorPressed;
|
||||||
public event Action? ClearPressed;
|
public event Action<bool>? ClearPressed;
|
||||||
public event Action? CalculatePressed;
|
public event Action? CalculatePressed;
|
||||||
|
|
||||||
public void UpdateView(string input)
|
public void UpdateView(string input)
|
||||||
|
|
@ -22,7 +23,12 @@ namespace calculator
|
||||||
|
|
||||||
private void OnCEButtonClick(object sender, EventArgs e)
|
private void OnCEButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ClearPressed?.Invoke();
|
ClearPressed?.Invoke(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ClearPressed?.Invoke(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnZeroButtonClick(object sender, EventArgs e)
|
private void OnZeroButtonClick(object sender, EventArgs e)
|
||||||
|
|
@ -82,42 +88,77 @@ namespace calculator
|
||||||
|
|
||||||
private void OnNegativeButtonClick(object sender, EventArgs e)
|
private void OnNegativeButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SingleOperatorPressed?.Invoke("-1");
|
SingleOperatorPressed?.Invoke(Operation.Neg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPlusButtonClick(object sender, EventArgs e)
|
private void OnPlusButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OperatorPressed?.Invoke("+");
|
OperatorPressed?.Invoke(Operation.Add);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMinusButtonClick(object sender, EventArgs e)
|
private void OnMinusButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OperatorPressed?.Invoke("-");
|
OperatorPressed?.Invoke(Operation.Sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMultButtonClick(object sender, EventArgs e)
|
private void OnMultButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OperatorPressed?.Invoke("*");
|
OperatorPressed?.Invoke(Operation.Mul);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDivideButtonClick(object sender, EventArgs e)
|
private void OnDivideButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OperatorPressed?.Invoke("/");
|
OperatorPressed?.Invoke(Operation.Div);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSqrtButtonClick(object sender, EventArgs e)
|
private void OnSqrtButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SingleOperatorPressed?.Invoke("√");
|
SingleOperatorPressed?.Invoke(Operation.Sqrt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPercentButtonClick(object sender, EventArgs e)
|
private void OnPercentButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SingleOperatorPressed?.Invoke("%");
|
SingleOperatorPressed?.Invoke(Operation.Percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInverseButtonClick(object sender, EventArgs e)
|
private void OnInverseButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SingleOperatorPressed?.Invoke("1/");
|
SingleOperatorPressed?.Invoke(Operation.OneDiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSinhButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Sinh);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSinButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Sin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCoshButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Cosh);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCosButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Cos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTanhButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Tanh);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTanButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Tan);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSqrtYButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.SqrtY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEqualButtonClick(object sender, EventArgs e)
|
private void OnEqualButtonClick(object sender, EventArgs e)
|
||||||
|
|
@ -125,9 +166,59 @@ namespace calculator
|
||||||
CalculatePressed?.Invoke();
|
CalculatePressed?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button39_Click(object sender, EventArgs e)
|
private void OnFactorialButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Factorial);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnModButtonClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCubeRootButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.CubeRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSquareButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Square);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPowYButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.PowY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCubeButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Cube);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLogButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Log);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnInvButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLnButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Ln);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExpButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Exp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPiButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SingleOperatorPressed?.Invoke(Operation.Pi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
49
Form1.resx
49
Form1.resx
|
|
@ -123,61 +123,61 @@
|
||||||
<metadata name="button49.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="button49.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button50.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Log_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button51.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Mod_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button52.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Exp_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button53.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="button53.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button44.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="CubeRoot_Button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button45.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Cube_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button46.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Tan_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button47.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Tanh_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button48.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Pi_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button39.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="SqrtY_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button40.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="PowY_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button41.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Cos_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button42.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Cosh_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button43.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="dms_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button34.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Factorial_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button35.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Square_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button36.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Sin_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button37.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Sinh_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button38.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Int_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button23.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="button23.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
|
@ -186,10 +186,10 @@
|
||||||
<metadata name="button30.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="button30.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button31.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Ln_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button32.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Inv_button.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="button33.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="button33.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
|
@ -291,6 +291,15 @@
|
||||||
<metadata name="radioButton1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="radioButton1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="radioButton3.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="radioButton2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="radioButton1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="linkLabel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="linkLabel1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
namespace calculator.Model;
|
using calculator.Common;
|
||||||
|
|
||||||
|
namespace calculator.Model;
|
||||||
|
|
||||||
public class CaculatorData
|
public class CaculatorData
|
||||||
{
|
{
|
||||||
public Stack<string> Operands { get; set; } = new();
|
public string? Input { get; set; }
|
||||||
public string? Operation { get; set; }
|
public double? Value { get; set; }
|
||||||
public string? SingleOperation { get; set; }
|
public Operation? Operation { get; set; }
|
||||||
public bool Caculated { get; set; }
|
public bool Caculated { get; set; }
|
||||||
public string? LastOperand { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,57 +1,90 @@
|
||||||
using System.Globalization;
|
using calculator.Common;
|
||||||
|
|
||||||
namespace calculator.Services
|
namespace calculator.Services
|
||||||
{
|
{
|
||||||
internal class Caculyator : ICaculator
|
internal class Caculyator : ICaculator
|
||||||
{
|
{
|
||||||
public string Calculate(string n, string m, string operation)
|
public double Calculate(Operation operation, double a, double? b = null)
|
||||||
{
|
{
|
||||||
if (double.TryParse(n, out var numberone) == false)
|
return b is null
|
||||||
return string.Empty;
|
? ApplyOperator(operation, a)
|
||||||
if (double.TryParse(m, out var numbertwo) == false)
|
: ApplyOperator(operation, a, b.Value);
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
return ApplyOperator(operation, numberone, numbertwo).ToString("0.#####");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SingleOperation(string operand, string operation)
|
private static double ApplyOperator(Operation token, double a, double b)
|
||||||
{
|
|
||||||
if (double.TryParse(operand, out var numberone) == false)
|
|
||||||
return string.Empty;
|
|
||||||
return ApplyOperator(operation, numberone).ToString("0.#####");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double ApplyOperator(string token, double operand1, double operand2)
|
|
||||||
{
|
{
|
||||||
switch (token)
|
switch (token)
|
||||||
{
|
{
|
||||||
case "+":
|
case Operation.Add:
|
||||||
return operand1 + operand2;
|
return a + b;
|
||||||
case "-":
|
case Operation.Sub:
|
||||||
return operand1 - operand2;
|
return a - b;
|
||||||
case "*":
|
case Operation.Mul:
|
||||||
return operand1 * operand2;
|
return a * b;
|
||||||
case "/":
|
case Operation.Div:
|
||||||
return operand1 / operand2;
|
return a / b;
|
||||||
case "^":
|
case Operation.Pow:
|
||||||
return Math.Pow(operand1, operand2);
|
return Math.Pow(a, b);
|
||||||
|
case Operation.SqrtY:
|
||||||
|
return Math.Pow(a, 1 / b);
|
||||||
|
case Operation.PowY:
|
||||||
|
return Math.Pow(a, b);
|
||||||
|
case Operation.Mod:
|
||||||
|
return a % b;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"Invalid operator: {token}");
|
throw new ArgumentException($"Invalid operator: {token}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double ApplyOperator(string token, double operand1)
|
private static double Factorial(double n)
|
||||||
|
{
|
||||||
|
if (n == 0)
|
||||||
|
return 1;
|
||||||
|
return n * Factorial(n - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double ApplyOperator(Operation token, double a)
|
||||||
{
|
{
|
||||||
switch (token)
|
switch (token)
|
||||||
{
|
{
|
||||||
case "1/":
|
case Operation.OneDiv:
|
||||||
return 1 / operand1;
|
return 1 / a;
|
||||||
case "√":
|
case Operation.Sqrt:
|
||||||
return Math.Sqrt(operand1);
|
return Math.Sqrt(a);
|
||||||
case "%":
|
case Operation.Percent:
|
||||||
return operand1 / 100;
|
return a / 100;
|
||||||
case "-1":
|
case Operation.Neg:
|
||||||
return operand1 * -1;
|
return a * -1;
|
||||||
|
case Operation.Sinh:
|
||||||
|
return Math.Sinh(a);
|
||||||
|
case Operation.Sin:
|
||||||
|
return Math.Sin(a);
|
||||||
|
case Operation.Cosh:
|
||||||
|
return Math.Cosh(a);
|
||||||
|
case Operation.Cos:
|
||||||
|
return Math.Cos(a);
|
||||||
|
case Operation.Tanh:
|
||||||
|
return Math.Tanh(a);
|
||||||
|
case Operation.Tan:
|
||||||
|
return Math.Tan(a);
|
||||||
|
case Operation.Factorial:
|
||||||
|
return Factorial(a);
|
||||||
|
case Operation.Square:
|
||||||
|
return Math.Pow(a, 2);
|
||||||
|
case Operation.Cube:
|
||||||
|
return Math.Pow(a, 3);
|
||||||
|
case Operation.CubeRoot:
|
||||||
|
return Math.Pow(a, 1 / 3);
|
||||||
|
case Operation.Log:
|
||||||
|
return Math.Log10(a);
|
||||||
|
case Operation.Ln:
|
||||||
|
return Math.Log(a);
|
||||||
|
case Operation.Exp:
|
||||||
|
return Math.Exp(a);
|
||||||
|
case Operation.Inv:
|
||||||
|
return 1 / a;
|
||||||
|
case Operation.Pi:
|
||||||
|
return Math.PI;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"Invalid operator: {token}");
|
throw new ArgumentException($"Invalid operator: {token}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
namespace calculator.Services;
|
using calculator.Common;
|
||||||
|
|
||||||
|
namespace calculator.Services;
|
||||||
|
|
||||||
public interface ICaculator
|
public interface ICaculator
|
||||||
{
|
{
|
||||||
string Calculate(string op1, string op2, string operation);
|
double Calculate(Operation operation, double a, double? b = null);
|
||||||
string SingleOperation(string operand, string operation);
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
namespace calculator.View;
|
using calculator.Common;
|
||||||
|
|
||||||
|
namespace calculator.View;
|
||||||
|
|
||||||
public interface ICaculatorView
|
public interface ICaculatorView
|
||||||
{
|
{
|
||||||
public event Action<char> OperandPressed;
|
public event Action<char> OperandPressed;
|
||||||
public event Action<string> OperatorPressed;
|
public event Action<Operation> OperatorPressed;
|
||||||
public event Action<string> SingleOperatorPressed;
|
public event Action<bool> ClearPressed;
|
||||||
public event Action ClearPressed;
|
|
||||||
public event Action CalculatePressed;
|
public event Action CalculatePressed;
|
||||||
|
public event Action<Operation> SingleOperatorPressed;
|
||||||
public void UpdateView(string input);
|
public void UpdateView(string input);
|
||||||
}
|
}
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue