diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp
index 701fb21c8..45124aa2d 100644
--- a/src/CalcManager/CEngine/scicomm.cpp
+++ b/src/CalcManager/CEngine/scicomm.cpp
@@ -780,6 +780,11 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
DisplayNum();
break;
+ case IDC_ENG:
+ m_nFE = NumberFormat::Engineering;
+ DisplayNum();
+ break;
+
case IDC_EXP:
if (m_bRecord && !m_fIntegerMode && m_input.TryBeginExponent())
{
diff --git a/src/CalcManager/Command.h b/src/CalcManager/Command.h
index 8d27dc799..c6f2b46c8 100644
--- a/src/CalcManager/Command.h
+++ b/src/CalcManager/Command.h
@@ -66,6 +66,7 @@ namespace CalculationManager
CommandGRAD = 323,
CommandDegrees = 324,
CommandHYP = 325,
+ CommandENG = 326,
CommandNULL = 0,
diff --git a/src/CalcManager/Header Files/CCommand.h b/src/CalcManager/Header Files/CCommand.h
index 2696181a5..a56c77577 100644
--- a/src/CalcManager/Header Files/CCommand.h
+++ b/src/CalcManager/Header Files/CCommand.h
@@ -29,6 +29,7 @@
#define IDM_RAD 322
#define IDM_GRAD 323
#define IDM_DEGREES 324
+#define IDC_ENG 326
#define IDC_HEX IDM_HEX
#define IDC_DEC IDM_DEC
diff --git a/src/CalcManager/Ratpack/conv.cpp b/src/CalcManager/Ratpack/conv.cpp
index 4f7609de0..893da9318 100644
--- a/src/CalcManager/Ratpack/conv.cpp
+++ b/src/CalcManager/Ratpack/conv.cpp
@@ -1171,7 +1171,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, NumberFormat format, uint32_t radi
{
if (format == NumberFormat::Engineering)
{
- exponent = (eout % 3);
+ exponent = (3 + (eout % 3)) % 3;
eout -= exponent;
exponent++;
diff --git a/src/CalcViewModel/Common/CalculatorButtonUser.h b/src/CalcViewModel/Common/CalculatorButtonUser.h
index 4885e4887..1c64eac64 100644
--- a/src/CalcViewModel/Common/CalculatorButtonUser.h
+++ b/src/CalcViewModel/Common/CalculatorButtonUser.h
@@ -38,6 +38,7 @@ namespace CalculatorApp::ViewModel::Common
Radians = (int)CM::Command::CommandRAD,
Grads = (int)CM::Command::CommandGRAD,
Degrees = (int)CM::Command::CommandDegrees,
+ Engineering = (int)CM::Command::CommandENG,
OpenParenthesis = (int)CM::Command::CommandOPENP,
CloseParenthesis = (int)CM::Command::CommandCLOSEP,
Pi = (int)CM::Command::CommandPI,
diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp
index 22554ca65..736497bdf 100644
--- a/src/CalcViewModel/StandardCalculatorViewModel.cpp
+++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp
@@ -448,6 +448,12 @@ void StandardCalculatorViewModel::FtoEButtonToggled()
OnButtonPressed(NumbersAndOperatorsEnum::FToE);
}
+void StandardCalculatorViewModel::EngButton()
+{
+ OnButtonPressed(NumbersAndOperatorsEnum::Engineering);
+}
+
+
void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
{
DisplayExpressionToken ^ displayExpressionToken = ExpressionTokens->GetAt(m_TokenPosition);
diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h
index 0af82478e..187b2bf23 100644
--- a/src/CalcViewModel/StandardCalculatorViewModel.h
+++ b/src/CalcViewModel/StandardCalculatorViewModel.h
@@ -258,6 +258,7 @@ namespace CalculatorApp
void SetOpenParenthesisCountNarratorAnnouncement();
void SwitchAngleType(CalculatorApp::ViewModel::Common::NumbersAndOperatorsEnum num);
void FtoEButtonToggled();
+ void EngButton();
internal:
void OnPaste(Platform::String ^ pastedString);
diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml
index ca30815cc..ba3fe1ec4 100644
--- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml
+++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml
@@ -98,21 +98,32 @@
CommandParameter="2"
Content="GRAD"
Visibility="Collapsed"/>
-
-
- FToE
-
-
+
+
+
+
diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cs b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cs
index 464c9ce89..2ea4b4c67 100644
--- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cs
+++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml.cs
@@ -17,10 +17,10 @@ namespace CalculatorApp
[Windows.Foundation.Metadata.WebHostHidden]
public sealed partial class CalculatorScientificAngleButtons
{
- public CalculatorScientificAngleButtons()
+ public CalculatorScientificAngleButtons()
{
m_isErrorVisualState = false;
- InitializeComponent();
+ InitializeComponent();
}
public StandardCalculatorViewModel Model => (StandardCalculatorViewModel)this.DataContext;
@@ -84,10 +84,49 @@ private void OnAngleButtonPressed(object commandParameter)
}
}
- private void FToEButton_Toggled(object sender, RoutedEventArgs e)
+ public System.Windows.Input.ICommand NotationPressed
{
- var viewModel = (StandardCalculatorViewModel)this.DataContext;
- viewModel.FtoEButtonToggled();
+ get
+ {
+ if (donotuse_NotationPressed == null)
+ {
+ donotuse_NotationPressed = DelegateCommandUtils.MakeDelegateCommand(this,
+ (that, param) =>
+ {
+ that.OnNotationButtonPressed(param);
+ });
+ }
+ return donotuse_NotationPressed;
+ }
+ }
+ private System.Windows.Input.ICommand donotuse_NotationPressed;
+
+ private void OnNotationButtonPressed(object commandParameter)
+ {
+ string buttonId = (string)commandParameter;
+
+ AutoButton.Visibility = Visibility.Collapsed;
+ SciButton.Visibility = Visibility.Collapsed;
+ EngButton.Visibility = Visibility.Collapsed;
+
+ if (buttonId == "0")
+ {
+ Model.FtoEButtonToggled();
+ SciButton.Visibility = Visibility.Visible;
+ SciButton.Focus(FocusState.Programmatic);
+ }
+ else if (buttonId == "1")
+ {
+ Model.EngButton();
+ EngButton.Visibility = Visibility.Visible;
+ EngButton.Focus(FocusState.Programmatic);
+ }
+ else if (buttonId == "2")
+ {
+ Model.FtoEButtonToggled();
+ AutoButton.Visibility = Visibility.Visible;
+ AutoButton.Focus(FocusState.Programmatic);
+ }
}
private bool m_isErrorVisualState;
diff --git a/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs b/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs
index 22154f4f7..e514ec16c 100644
--- a/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs
+++ b/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs
@@ -17,8 +17,9 @@ public enum AngleOperatorState
public enum FEButtonState
{
- Normal,
- Exponential
+ Auto,
+ Scientific,
+ Engineering
}
///
@@ -78,11 +79,14 @@ public class ScientificOperatorsPanel
public WindowsElement RandButton => this.session.TryFindElementByAccessibilityId("randButton");
public WindowsElement DmsButton => this.session.TryFindElementByAccessibilityId("dmsButton");
public WindowsElement DegreesButton => this.session.TryFindElementByAccessibilityId("degreesButton");
- public WindowsElement FixedToExponentialButton => this.session.TryFindElementByAccessibilityId("ftoeButton");
+ public WindowsElement AutoButton => this.session.TryFindElementByAccessibilityId("autoButton");
+ public WindowsElement SciButton => this.session.TryFindElementByAccessibilityId("sciButton");
+ public WindowsElement EngButton => this.session.TryFindElementByAccessibilityId("engButton");
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
public WindowsElement ShiftButton => this.session.TryFindElementByAccessibilityId("shiftButton");
public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout");
public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss");
+ private WindowsElement AutoSciEngButton => GetNumberFormatButton();
private WindowsElement DegRadGradButton => GetAngleOperatorButton();
private WindowsElement GetAngleOperatorButton()
{
@@ -103,6 +107,25 @@ private WindowsElement GetAngleOperatorButton()
throw new NotFoundException("Could not find deg, rad or grad button in page source");
}
+ private WindowsElement GetNumberFormatButton()
+ {
+ string source = this.session.PageSource;
+ if (source.Contains("autoButton"))
+ {
+ return AutoButton;
+ }
+ else if (source.Contains("sciButton"))
+ {
+ return SciButton;
+ }
+ else if (source.Contains("engButton"))
+ {
+ return EngButton;
+ }
+
+ throw new NotFoundException("Could not find auto, sci, or eng button in page source");
+ }
+
///
/// Set the state of the degrees, radians and gradians buttons.
///
@@ -122,11 +145,19 @@ public void SetAngleOperator(AngleOperatorState value)
}
}
- public void ResetFEButton(FEButtonState value)
+ public void SetNumberFormat(FEButtonState value)
{
- if (this.FixedToExponentialButton.GetAttribute("Toggle.ToggleState") != "0")
+ //set the desired string value for the button
+ string desiredId = value switch
+ {
+ FEButtonState.Auto => "autoButton",
+ FEButtonState.Scientific => "sciButton",
+ FEButtonState.Engineering => "engButton",
+ _ => throw new NotImplementedException()
+ };
+ while (this.AutoSciEngButton.GetAttribute("AutomationId") != desiredId)
{
- FixedToExponentialButton.Click();
+ this.AutoSciEngButton.Click();
}
}
diff --git a/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs
index e1d8cc419..5c2724fce 100644
--- a/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs
+++ b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs
@@ -3,6 +3,7 @@
using CalculatorUITestFramework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
namespace CalculatorUITests
{
diff --git a/src/CalculatorUITests/ScientificModeFunctionalTests.cs b/src/CalculatorUITests/ScientificModeFunctionalTests.cs
index 21e43f0b3..b377c9381 100644
--- a/src/CalculatorUITests/ScientificModeFunctionalTests.cs
+++ b/src/CalculatorUITests/ScientificModeFunctionalTests.cs
@@ -51,7 +51,7 @@ public void TestInit()
}
CalculatorApp.EnsureCalculatorHasFocus();
page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees);
- page.ScientificOperators.ResetFEButton(FEButtonState.Normal);
+ page.ScientificOperators.SetNumberFormat(FEButtonState.Auto);
}
[TestCleanup]
@@ -161,11 +161,22 @@ public void SmokeTest_GradianAngleOperator()
[TestMethod]
[Priority(0)]
- public void SmokeTest_FixedToExponential()
+ public void SmokeTest_ScientificFormat()
{
- page.ScientificOperators.FixedToExponentialButton.Click();
+ page.ScientificOperators.SetNumberFormat(FEButtonState.Scientific);
+ page.StandardOperators.NumberPad.Input(0.123);
page.StandardOperators.EqualButton.Click();
- Assert.AreEqual("0.e+0", page.CalculatorResults.GetCalculatorResultText());
+ Assert.AreEqual("1.23e-1", page.CalculatorResults.GetCalculatorResultText());
+ }
+
+ [TestMethod]
+ [Priority(0)]
+ public void SmokeTest_EngineeringFormat()
+ {
+ page.ScientificOperators.SetNumberFormat(FEButtonState.Engineering);
+ page.StandardOperators.NumberPad.Input(0.123);
+ page.StandardOperators.EqualButton.Click();
+ Assert.AreEqual("123.e-3", page.CalculatorResults.GetCalculatorResultText());
}
#endregion