Merge branch 'main' into xuid

This commit is contained in:
Matt Cooley 2023-05-11 14:01:47 -06:00
commit 9a27ec1649
43 changed files with 216 additions and 304 deletions

View file

@ -22,7 +22,7 @@ Calculator ships regularly with new features and bug fixes. You can get the late
## Getting started ## Getting started
Prerequisites: Prerequisites:
- Your computer must be running Windows 10, version 1809 or newer. Windows 11 is recommended. - Your computer must be running Windows 11, build 22000 or newer.
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient). - Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
- Install the "Universal Windows Platform Development" workload. - Install the "Universal Windows Platform Development" workload.
- Install the optional "C++ Universal Windows Platform tools" component. - Install the optional "C++ Universal Windows Platform tools" component.

View file

@ -9,7 +9,7 @@ pr: none
variables: variables:
versionMajor: 11 versionMajor: 11
versionMinor: 2209 versionMinor: 2301
versionBuild: $[counter(format('{0}.{1}.*', variables['versionMajor'], variables['versionMinor']), 0)] versionBuild: $[counter(format('{0}.{1}.*', variables['versionMajor'], variables['versionMinor']), 0)]
versionPatch: 0 versionPatch: 0

View file

@ -81,7 +81,7 @@ jobs:
pathToPublish: $(Build.ArtifactStagingDirectory)\msixBundle pathToPublish: $(Build.ArtifactStagingDirectory)\msixBundle
- ${{ if eq(parameters.signBundle, true) }}: - ${{ if eq(parameters.signBundle, true) }}:
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - task: EsrpCodeSigning@2
displayName: Send msixbundle to code signing service displayName: Send msixbundle to code signing service
inputs: inputs:
ConnectedServiceName: Essential Experiences Codesign ConnectedServiceName: Essential Experiences Codesign

View file

@ -143,14 +143,14 @@ void CHistoryCollector::AddBinOpToHistory(int nOpCode, bool isIntegerMode, bool
// This is expected to be called when a binary op in the last say 1+2+ is changing to another one say 1+2* (+ changed to *) // This is expected to be called when a binary op in the last say 1+2+ is changing to another one say 1+2* (+ changed to *)
// It needs to know by this change a Precedence inversion happened. i.e. previous op was lower or equal to its previous op, but the new // It needs to know by this change a Precedence inversion happened. i.e. previous op was lower or equal to its previous op, but the new
// one isn't. (Eg. 1*2* to 1*2^). It can add explicit brackets to ensure the precedence is inverted. (Eg. (1*2) ^) // one isn't. (Eg. 1*2* to 1*2^). It can add explicit brackets to ensure the precedence is inverted. (Eg. (1*2) ^)
void CHistoryCollector::ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntgerMode) void CHistoryCollector::ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntegerMode)
{ {
TruncateEquationSzFromIch(m_lastBinOpStartIndex); TruncateEquationSzFromIch(m_lastBinOpStartIndex);
if (fPrecInvToHigher) if (fPrecInvToHigher)
{ {
EnclosePrecInversionBrackets(); EnclosePrecInversionBrackets();
} }
AddBinOpToHistory(nOpCode, isIntgerMode); AddBinOpToHistory(nOpCode, isIntegerMode);
} }
void CHistoryCollector::PushLastOpndStart(int ichOpndStart) void CHistoryCollector::PushLastOpndStart(int ichOpndStart)

View file

@ -22,10 +22,9 @@ namespace CalcEngine
Number::Number(PNUMBER p) noexcept Number::Number(PNUMBER p) noexcept
: m_sign{ p->sign } : m_sign{ p->sign }
, m_exp{ p->exp } , m_exp{ p->exp }
, m_mantissa{}
{ {
m_mantissa.reserve(p->cdigit); m_mantissa.reserve(p->cdigit);
copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa)); copy_n(p->mant, p->cdigit, back_inserter(m_mantissa));
} }
PNUMBER Number::ToPNUMBER() const PNUMBER Number::ToPNUMBER() const

View file

@ -101,7 +101,7 @@ CCalcEngine::CCalcEngine(
{ {
InitChopNumbers(); InitChopNumbers();
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(m_numwidth); m_dwWordBitWidth = DwWordBitWidthFromNumWidth(m_numwidth);
m_maxTrigonometricNum = RationalMath::Pow(10, 100); m_maxTrigonometricNum = RationalMath::Pow(10, 100);

View file

@ -30,17 +30,31 @@ namespace
// 0 is returned. Higher the number, higher the precedence of the operator. // 0 is returned. Higher the number, higher the precedence of the operator.
int NPrecedenceOfOp(int nopCode) int NPrecedenceOfOp(int nopCode)
{ {
static uint16_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_NAND, 1, IDC_NOR, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF, 3, switch (nopCode)
IDC_LSHF, 3, IDC_RSHFL, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4, IDC_LOGBASEY, 4 };
for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2)
{ {
if (nopCode == rgbPrec[iPrec]) default:
{ case IDC_OR:
return rgbPrec[iPrec + 1]; case IDC_XOR:
}
}
return 0; return 0;
case IDC_AND:
case IDC_NAND:
case IDC_NOR:
return 1;
case IDC_ADD:
case IDC_SUB:
return 2;
case IDC_LSHF:
case IDC_RSHF:
case IDC_RSHFL:
case IDC_MOD:
case IDC_DIV:
case IDC_MUL:
return 3;
case IDC_PWR:
case IDC_ROOT:
case IDC_LOGBASEY:
return 4;
}
} }
} }
@ -762,7 +776,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
break; break;
case IDC_FE: case IDC_FE:
// Toggle exponential notation display. // Toggle exponential notation display.
m_nFE = NumberFormat(!(int)m_nFE); m_nFE = m_nFE == NumberFormat::Float ? NumberFormat::Scientific : NumberFormat::Float;
DisplayNum(); DisplayNum();
break; break;

View file

@ -39,7 +39,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
if (numwidth >= NUM_WIDTH::QWORD_WIDTH && numwidth <= NUM_WIDTH::BYTE_WIDTH) if (numwidth >= NUM_WIDTH::QWORD_WIDTH && numwidth <= NUM_WIDTH::BYTE_WIDTH)
{ {
m_numwidth = numwidth; m_numwidth = numwidth;
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth); m_dwWordBitWidth = DwWordBitWidthFromNumWidth(numwidth);
} }
// inform ratpak that a change in base or precision has occurred // inform ratpak that a change in base or precision has occurred
@ -50,7 +50,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
DisplayNum(); DisplayNum();
} }
int32_t CCalcEngine::DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth) int32_t CCalcEngine::DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth)
{ {
switch (numwidth) switch (numwidth)
{ {
@ -85,7 +85,7 @@ uint32_t CCalcEngine::NRadixFromRadixType(RadixType radixtype)
// Toggles a given bit into the number representation. returns true if it changed it actually. // Toggles a given bit into the number representation. returns true if it changed it actually.
bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno) bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno)
{ {
uint32_t wmax = DwWordBitWidthFromeNumWidth(m_numwidth); uint32_t wmax = DwWordBitWidthFromNumWidth(m_numwidth);
if (wbitno >= wmax) if (wbitno >= wmax)
{ {
return false; // ignore error cant happen return false; // ignore error cant happen

View file

@ -179,7 +179,7 @@ private:
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op); CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs); CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
void SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidth); void SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidth);
int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth); int32_t DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth);
uint32_t NRadixFromRadixType(RadixType radixtype); uint32_t NRadixFromRadixType(RadixType radixtype);
double GenerateRandomNumber(); double GenerateRandomNumber();

View file

@ -21,8 +21,8 @@ public:
~CHistoryCollector(); ~CHistoryCollector();
void AddOpndToHistory(std::wstring_view numStr, CalcEngine::Rational const& rat, bool fRepetition = false); void AddOpndToHistory(std::wstring_view numStr, CalcEngine::Rational const& rat, bool fRepetition = false);
void RemoveLastOpndFromHistory(); void RemoveLastOpndFromHistory();
void AddBinOpToHistory(int nOpCode, bool isIntgerMode, bool fNoRepetition = true); void AddBinOpToHistory(int nOpCode, bool isIntegerMode, bool fNoRepetition = true);
void ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntgerMode); void ChangeLastBinOp(int nOpCode, bool fPrecInvToHigher, bool isIntegerMode);
void AddUnaryOpToHistory(int nOpCode, bool fInv, AngleType angletype); void AddUnaryOpToHistory(int nOpCode, bool fInv, AngleType angletype);
void AddOpenBraceToHistory(); void AddOpenBraceToHistory();
void AddCloseBraceToHistory(); void AddCloseBraceToHistory();

View file

@ -3,6 +3,8 @@
#pragma once #pragma once
#include <cstdint>
// CalcErr.h // CalcErr.h
// //
// Defines the error codes thrown by ratpak and caught by Calculator // Defines the error codes thrown by ratpak and caught by Calculator
@ -36,7 +38,7 @@
// This format is based loosely on an OLE HRESULT and is compatible with the // This format is based loosely on an OLE HRESULT and is compatible with the
// SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro // SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro
typedef int32_t ResultCode; using ResultCode = int32_t;
// CALC_E_DIVIDEBYZERO // CALC_E_DIVIDEBYZERO
// //

View file

@ -25,7 +25,7 @@
using namespace std; using namespace std;
void _readconstants(void); void _readconstants();
#if defined(GEN_CONST) #if defined(GEN_CONST)
static int cbitsofprecision = 0; static int cbitsofprecision = 0;
@ -136,13 +136,7 @@ void ChangeConstants(uint32_t radix, int32_t precision)
// in the internal BASEX radix, this is important for length calculations // in the internal BASEX radix, this is important for length calculations
// in translating from radix to BASEX and back. // in translating from radix to BASEX and back.
uint64_t limit = static_cast<uint64_t>(BASEX) / static_cast<uint64_t>(radix); g_ratio = static_cast<int32_t>(ceil(BASEXPWR / log2(radix))) - 1;
g_ratio = 0;
for (uint32_t digit = 1; digit < limit; digit *= radix)
{
g_ratio++;
}
g_ratio += !g_ratio;
destroyrat(rat_nRadix); destroyrat(rat_nRadix);
rat_nRadix = i32torat(radix); rat_nRadix = i32torat(radix);

View file

@ -156,13 +156,12 @@ namespace UnitConversionManager
std::wstring targetCurrencyCode; std::wstring targetCurrencyCode;
}; };
typedef std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer; using CategorySelectionInitializer = std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit>;
typedef std::unordered_map< using UnitToUnitToConversionDataMap = std::unordered_map<
UnitConversionManager::Unit, UnitConversionManager::Unit,
std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>, std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>,
UnitConversionManager::UnitHash> UnitConversionManager::UnitHash>;
UnitToUnitToConversionDataMap; using CategoryToUnitVectorMap = std::unordered_map<int, std::vector<UnitConversionManager::Unit>>;
typedef std::unordered_map<int, std::vector<UnitConversionManager::Unit>> CategoryToUnitVectorMap;
class IViewModelCurrencyCallback class IViewModelCurrencyCallback
{ {

View file

@ -288,9 +288,8 @@ bool CopyPasteManager::ExpressionRegExMatch(
} }
else if (mode == ViewMode::Programmer) else if (mode == ViewMode::Programmer)
{ {
patterns.assign( auto pattern = &programmerModePatterns[static_cast<int>(programmerNumberBase) - static_cast<int>(NumberBase::HexBase)];
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].begin(), patterns.assign(pattern->begin(), pattern->end());
programmerModePatterns[(int)programmerNumberBase - (int)NumberBase::HexBase].end());
} }
else if (modeType == CategoryGroupType::Converter) else if (modeType == CategoryGroupType::Converter)
{ {
@ -505,9 +504,7 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
const bool hasDecimal = operandWstring.find('.') != wstring::npos; const bool hasDecimal = operandWstring.find('.') != wstring::npos;
auto length = operandWstring.length(); auto length = operandWstring.length();
if (hasDecimal) if (hasDecimal && length >= 2)
{
if (length >= 2)
{ {
if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.')) if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.'))
{ {
@ -518,7 +515,6 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope
length -= 1; length -= 1;
} }
} }
}
auto exponentPos = operandWstring.find('e'); auto exponentPos = operandWstring.find('e');
const bool hasExponent = exponentPos != wstring::npos; const bool hasExponent = exponentPos != wstring::npos;

View file

@ -17,24 +17,16 @@ std::shared_ptr<IExpressionCommand> CommandDeserializer::Deserialize(_In_ Calcul
switch (cmdType) switch (cmdType)
{ {
case CalculationManager::CommandType::OperandCommand: case CalculationManager::CommandType::OperandCommand:
return std::make_shared<COpndCommand>(DeserializeOperand()); return std::make_shared<COpndCommand>(DeserializeOperand());
break;
case CalculationManager::CommandType::Parentheses: case CalculationManager::CommandType::Parentheses:
return std::make_shared<CParentheses>(DeserializeParentheses()); return std::make_shared<CParentheses>(DeserializeParentheses());
break;
case CalculationManager::CommandType::UnaryCommand: case CalculationManager::CommandType::UnaryCommand:
return std::make_shared<CUnaryCommand>(DeserializeUnary()); return std::make_shared<CUnaryCommand>(DeserializeUnary());
break;
case CalculationManager::CommandType::BinaryCommand: case CalculationManager::CommandType::BinaryCommand:
return std::make_shared<CBinaryCommand>(DeserializeBinary()); return std::make_shared<CBinaryCommand>(DeserializeBinary());
break;
default: default:
throw ref new Platform::Exception(E_INVALIDARG, ref new Platform::String(L"Unknown command type")); throw ref new Platform::Exception(E_INVALIDARG, ref new Platform::String(L"Unknown command type"));

View file

@ -16,7 +16,7 @@ namespace CalculatorApp::ViewModel
{ {
std::wstring returnString = L""; std::wstring returnString = L"";
const UINT32 length = 1024; const UINT32 length = 1024;
std::unique_ptr<wchar_t[]> spBuffer = std::unique_ptr<wchar_t[]>(new wchar_t[length]); std::unique_ptr<wchar_t[]> spBuffer = std::make_unique<wchar_t[]>(length);
va_list args = NULL; va_list args = NULL;
va_start(args, pMessage); va_start(args, pMessage);
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args); DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args);

View file

@ -104,7 +104,6 @@ namespace CalculatorApp
if (NavCategoryStates::IsValidViewMode(mode)) if (NavCategoryStates::IsValidViewMode(mode))
{ {
auto fields = ref new LoggingFields(); auto fields = ref new LoggingFields();
;
fields->AddString(StringReference(CALC_MODE), NavCategoryStates::GetFriendlyName(mode)); fields->AddString(StringReference(CALC_MODE), NavCategoryStates::GetFriendlyName(mode));
TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_MODE_CHANGED), fields); TraceLoggingCommon::GetInstance()->LogLevel2Event(StringReference(EVENT_NAME_MODE_CHANGED), fields);
} }

View file

@ -42,14 +42,3 @@
#include "winrt/Windows.UI.Xaml.h" #include "winrt/Windows.UI.Xaml.h"
#include "winrt/Windows.Foundation.Metadata.h" #include "winrt/Windows.Foundation.Metadata.h"
#include "winrt/Windows.Management.Policies.h" #include "winrt/Windows.Management.Policies.h"
// The following namespaces exist as a convenience to resolve
// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers
// namespace that only exist on RS3.
// Once the app switches to min version RS3, the namespaces can be removed.
// TODO - MSFT 12735088
namespace StandardPeers = Windows::UI::Xaml::Automation::Peers;
namespace CalculatorApp::ViewModel::Common::Automation
{
}
namespace CustomPeers = CalculatorApp::ViewModel::Common::Automation;

View file

@ -30,7 +30,7 @@ namespace CalculatorApp
{ {
namespace ApplicationResourceKeys namespace ApplicationResourceKeys
{ {
public static partial class Globals public static class Globals
{ {
public static readonly string AppMinWindowHeight = "AppMinWindowHeight"; public static readonly string AppMinWindowHeight = "AppMinWindowHeight";
public static readonly string AppMinWindowWidth = "AppMinWindowWidth"; public static readonly string AppMinWindowWidth = "AppMinWindowWidth";
@ -425,7 +425,7 @@ namespace CalculatorApp
ViewMode mode = option.ViewMode; ViewMode mode = option.ViewMode;
var item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode)); var item = JumpListItem.CreateWithArguments(((int)mode).ToString(), "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode));
item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode); item.Description = "ms-resource:///Resources/" + NavCategoryStates.GetNameResourceKey(mode);
item.Logo = new Uri("ms-appx:///Assets/" + mode.ToString() + ".png"); item.Logo = new Uri("ms-appx:///Assets/" + mode + ".png");
jumpList.Items.Add(item); jumpList.Items.Add(item);
} }

View file

@ -794,9 +794,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version> <Version>6.2.14</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.0" /> <PackageReference Include="Microsoft.UI.Xaml" Version="2.8.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj"> <ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj">

View file

@ -44,10 +44,10 @@ namespace CalculatorApp
// restore the selection to the way we wanted it to begin with // restore the selection to the way we wanted it to begin with
if (CurrentPosition >= 0 && CurrentPosition < m_source.Count) if (CurrentPosition >= 0 && CurrentPosition < m_source.Count)
{ {
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{ {
CurrentChanged?.Invoke(this, null); CurrentChanged?.Invoke(this, null);
})).AsTask().Wait(); }).AsTask().Wait();
} }
return false; return false;
} }

View file

@ -33,11 +33,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for MinFontSize. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for MinFontSize. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinFontSizeProperty = public static readonly DependencyProperty MinFontSizeProperty =
DependencyProperty.Register(nameof(MinFontSize), typeof(double), typeof(CalculationResult), new PropertyMetadata(0.0, new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(MinFontSize), typeof(double), typeof(CalculationResult), new PropertyMetadata(0.0, (sender, args) =>
{ {
var self = (CalculationResult)sender; var self = (CalculationResult)sender;
self.OnMinFontSizePropertyChanged((double)args.OldValue, (double)args.NewValue); self.OnMinFontSizePropertyChanged((double)args.OldValue, (double)args.NewValue);
}))); }));
public double MaxFontSize public double MaxFontSize
{ {
@ -47,11 +47,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for MaxFontSize. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for MaxFontSize. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MaxFontSizeProperty = public static readonly DependencyProperty MaxFontSizeProperty =
DependencyProperty.Register(nameof(MaxFontSize), typeof(double), typeof(CalculationResult), new PropertyMetadata(30.0, new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(MaxFontSize), typeof(double), typeof(CalculationResult), new PropertyMetadata(30.0, (sender, args) =>
{ {
var self = (CalculationResult)sender; var self = (CalculationResult)sender;
self.OnMaxFontSizePropertyChanged((double)args.OldValue, (double)args.NewValue); self.OnMaxFontSizePropertyChanged((double)args.OldValue, (double)args.NewValue);
}))); }));
public Thickness DisplayMargin public Thickness DisplayMargin
{ {
@ -71,11 +71,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for IsActive. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for IsActive. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsActiveProperty = public static readonly DependencyProperty IsActiveProperty =
DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(CalculationResult), new PropertyMetadata(default(bool), new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(CalculationResult), new PropertyMetadata(default(bool), (sender, args) =>
{ {
var self = (CalculationResult)sender; var self = (CalculationResult)sender;
self.OnIsActivePropertyChanged((bool)args.OldValue, (bool)args.NewValue); self.OnIsActivePropertyChanged((bool)args.OldValue, (bool)args.NewValue);
}))); }));
public string DisplayValue public string DisplayValue
{ {
@ -85,11 +85,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for DisplayValue. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for DisplayValue. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DisplayValueProperty = public static readonly DependencyProperty DisplayValueProperty =
DependencyProperty.Register(nameof(DisplayValue), typeof(string), typeof(CalculationResult), new PropertyMetadata(string.Empty, new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(DisplayValue), typeof(string), typeof(CalculationResult), new PropertyMetadata(string.Empty, (sender, args) =>
{ {
var self = (CalculationResult)sender; var self = (CalculationResult)sender;
self.OnDisplayValuePropertyChanged((string)args.OldValue, (string)args.NewValue); self.OnDisplayValuePropertyChanged((string)args.OldValue, (string)args.NewValue);
}))); }));
public bool IsInError public bool IsInError
{ {
@ -99,11 +99,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for IsInError. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for IsInError. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsInErrorProperty = public static readonly DependencyProperty IsInErrorProperty =
DependencyProperty.Register(nameof(IsInError), typeof(bool), typeof(CalculationResult), new PropertyMetadata(default(bool), new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(IsInError), typeof(bool), typeof(CalculationResult), new PropertyMetadata(default(bool), (sender, args) =>
{ {
var self = (CalculationResult)sender; var self = (CalculationResult)sender;
self.OnIsInErrorPropertyChanged((bool)args.OldValue, (bool)args.NewValue); self.OnIsInErrorPropertyChanged((bool)args.OldValue, (bool)args.NewValue);
}))); }));
public bool IsOperatorCommand public bool IsOperatorCommand
{ {
@ -151,7 +151,7 @@ namespace CalculatorApp
if (widthDiff > WIDTHCUTOFF) if (widthDiff > WIDTHCUTOFF)
{ {
fontSizeChange = Math.Min((double)Math.Max((double)Math.Floor(WIDTHTOFONTSCALAR * widthDiff) - WIDTHTOFONTOFFSET, INCREMENTOFFSET), MAXFONTINCREMENT); fontSizeChange = Math.Min(Math.Max(Math.Floor(WIDTHTOFONTSCALAR * widthDiff) - WIDTHTOFONTOFFSET, INCREMENTOFFSET), MAXFONTINCREMENT);
} }
if (m_textBlock.ActualWidth < containerSize && Math.Abs(m_textBlock.FontSize - MaxFontSize) > FONTTOLERANCE && !m_haveCalculatedMax) if (m_textBlock.ActualWidth < containerSize && Math.Abs(m_textBlock.FontSize - MaxFontSize) > FONTTOLERANCE && !m_haveCalculatedMax)
{ {

View file

@ -33,11 +33,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for ButtonId. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for ButtonId. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ButtonIdProperty = public static readonly DependencyProperty ButtonIdProperty =
DependencyProperty.Register(nameof(ButtonId), typeof(NumbersAndOperatorsEnum), typeof(CalculatorButton), new PropertyMetadata(default(NumbersAndOperatorsEnum), new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(ButtonId), typeof(NumbersAndOperatorsEnum), typeof(CalculatorButton), new PropertyMetadata(default(NumbersAndOperatorsEnum), (sender, args) =>
{ {
var self = (CalculatorButton)sender; var self = (CalculatorButton)sender;
self.OnButtonIdPropertyChanged((NumbersAndOperatorsEnum)args.OldValue, (NumbersAndOperatorsEnum)args.NewValue); self.OnButtonIdPropertyChanged((NumbersAndOperatorsEnum)args.OldValue, (NumbersAndOperatorsEnum)args.NewValue);
}))); }));
public string AuditoryFeedback public string AuditoryFeedback
{ {
@ -47,11 +47,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for AuditoryFeedback. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for AuditoryFeedback. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AuditoryFeedbackProperty = public static readonly DependencyProperty AuditoryFeedbackProperty =
DependencyProperty.Register(nameof(AuditoryFeedback), typeof(string), typeof(CalculatorButton), new PropertyMetadata(string.Empty, new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(AuditoryFeedback), typeof(string), typeof(CalculatorButton), new PropertyMetadata(string.Empty, (sender, args) =>
{ {
var self = (CalculatorButton)sender; var self = (CalculatorButton)sender;
self.OnAuditoryFeedbackPropertyChanged((string)args.OldValue, (string)args.NewValue); self.OnAuditoryFeedbackPropertyChanged((string)args.OldValue, (string)args.NewValue);
}))); }));
public Windows.UI.Xaml.Media.Brush HoverBackground public Windows.UI.Xaml.Media.Brush HoverBackground
{ {

View file

@ -37,11 +37,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for TokensUpdated. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for TokensUpdated. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TokensUpdatedProperty = public static readonly DependencyProperty TokensUpdatedProperty =
DependencyProperty.Register(nameof(TokensUpdated), typeof(bool), typeof(OverflowTextBlock), new PropertyMetadata(default(bool), new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(TokensUpdated), typeof(bool), typeof(OverflowTextBlock), new PropertyMetadata(default(bool), (sender, args) =>
{ {
var self = (OverflowTextBlock)sender; var self = (OverflowTextBlock)sender;
self.OnTokensUpdatedPropertyChanged((bool)args.OldValue, (bool)args.NewValue); self.OnTokensUpdatedPropertyChanged((bool)args.OldValue, (bool)args.NewValue);
}))); }));
public OverflowButtonPlacement ScrollButtonsPlacement public OverflowButtonPlacement ScrollButtonsPlacement
{ {
@ -51,11 +51,11 @@ namespace CalculatorApp
// Using a DependencyProperty as the backing store for ScrollButtonsPlacement. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for ScrollButtonsPlacement. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ScrollButtonsPlacementProperty = public static readonly DependencyProperty ScrollButtonsPlacementProperty =
DependencyProperty.Register(nameof(ScrollButtonsPlacement), typeof(OverflowButtonPlacement), typeof(OverflowTextBlock), new PropertyMetadata(default(OverflowButtonPlacement), new PropertyChangedCallback((sender, args) => DependencyProperty.Register(nameof(ScrollButtonsPlacement), typeof(OverflowButtonPlacement), typeof(OverflowTextBlock), new PropertyMetadata(default(OverflowButtonPlacement), (sender, args) =>
{ {
var self = (OverflowTextBlock)sender; var self = (OverflowTextBlock)sender;
self.OnScrollButtonsPlacementPropertyChanged((OverflowButtonPlacement)args.OldValue, (OverflowButtonPlacement)args.NewValue); self.OnScrollButtonsPlacementPropertyChanged((OverflowButtonPlacement)args.OldValue, (OverflowButtonPlacement)args.NewValue);
}))); }));
public bool IsActive public bool IsActive
{ {

View file

@ -8,7 +8,7 @@
<Logo>Assets\CalculatorStoreLogo.png</Logo> <Logo>Assets\CalculatorStoreLogo.png</Logo>
</Properties> </Properties>
<Dependencies> <Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.22000.0" MaxVersionTested="10.0.22000.0" /> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.19041.0" MaxVersionTested="10.0.22000.0" />
</Dependencies> </Dependencies>
<Resources> <Resources>
<Resource Language="x-generate" /> <Resource Language="x-generate" />

View file

@ -694,6 +694,7 @@
<Flyout x:Name="HistoryFlyout" <Flyout x:Name="HistoryFlyout"
AutomationProperties.AutomationId="HistoryFlyout" AutomationProperties.AutomationId="HistoryFlyout"
Closed="HistoryFlyout_Closed" Closed="HistoryFlyout_Closed"
Closing="HistoryFlyout_Closing"
FlyoutPresenterStyle="{StaticResource HistoryFlyoutStyle}" FlyoutPresenterStyle="{StaticResource HistoryFlyoutStyle}"
Opened="HistoryFlyout_Opened" Opened="HistoryFlyout_Opened"
Placement="Full"/> Placement="Full"/>
@ -803,6 +804,7 @@
AutomationProperties.AutomationId="MemoryFlyout" AutomationProperties.AutomationId="MemoryFlyout"
AutomationProperties.Name="{utils:ResourceString Name=MemoryFlyout/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}" AutomationProperties.Name="{utils:ResourceString Name=MemoryFlyout/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}"
Closed="OnMemoryFlyoutClosed" Closed="OnMemoryFlyoutClosed"
Closing="OnMemoryFlyoutClosing"
FlyoutPresenterStyle="{StaticResource MemoryFlyoutStyle}" FlyoutPresenterStyle="{StaticResource MemoryFlyoutStyle}"
Opened="OnMemoryFlyoutOpened" Opened="OnMemoryFlyoutOpened"
Placement="Full"/> Placement="Full"/>

View file

@ -225,16 +225,10 @@ namespace CalculatorApp
string memoryPaneName = AppResourceProvider.GetInstance().GetResourceString("MemoryPane"); string memoryPaneName = AppResourceProvider.GetInstance().GetResourceString("MemoryPane");
MemoryFlyout.FlyoutPresenterStyle.Setters.Add(new Setter(AutomationProperties.NameProperty, memoryPaneName)); MemoryFlyout.FlyoutPresenterStyle.Setters.Add(new Setter(AutomationProperties.NameProperty, memoryPaneName));
if (Windows.Foundation.Metadata.ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.Primitives.FlyoutBase", "Closing"))
{
HistoryFlyout.Closing += HistoryFlyout_Closing;
MemoryFlyout.Closing += OnMemoryFlyoutClosing;
}
// Delay load things later when we get a chance. // Delay load things later when we get a chance.
WeakReference weakThis = new WeakReference(this); WeakReference weakThis = new WeakReference(this);
_ = this.Dispatcher.RunAsync( _ = this.Dispatcher.RunAsync(
CoreDispatcherPriority.Normal, new DispatchedHandler(() => CoreDispatcherPriority.Normal, () =>
{ {
if (TraceLogger.GetInstance().IsWindowIdInLog(ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread()))) if (TraceLogger.GetInstance().IsWindowIdInLog(ApplicationView.GetApplicationViewIdForWindow(CoreWindow.GetForCurrentThread())))
{ {
@ -243,7 +237,7 @@ namespace CalculatorApp
refThis.GetMemory(); refThis.GetMemory();
} }
} }
})); });
} }
private void LoadResourceStrings() private void LoadResourceStrings()
@ -533,7 +527,7 @@ namespace CalculatorApp
// Since we need different font sizes for different numeric system, // Since we need different font sizes for different numeric system,
// we use a table of optimal font sizes for each numeric system. // we use a table of optimal font sizes for each numeric system.
private static readonly FontTable[] fontTables = new FontTable[] { private static readonly FontTable[] fontTables = {
new FontTable { numericSystem = "Arab", fullFont = 104, fullFontMin = 29.333, portraitMin = 23, snapFont = 40, new FontTable { numericSystem = "Arab", fullFont = 104, fullFontMin = 29.333, portraitMin = 23, snapFont = 40,
fullNumPadFont = 56, snapScientificNumPadFont = 40, portraitScientificNumPadFont = 56 }, fullNumPadFont = 56, snapScientificNumPadFont = 40, portraitScientificNumPadFont = 56 },
new FontTable { numericSystem = "ArabExt", fullFont = 104, fullFontMin = 29.333, portraitMin = 23, snapFont = 40, new FontTable { numericSystem = "ArabExt", fullFont = 104, fullFontMin = 29.333, portraitMin = 23, snapFont = 40,
@ -650,9 +644,6 @@ namespace CalculatorApp
private void HistoryFlyout_Closed(object sender, object args) private void HistoryFlyout_Closed(object sender, object args)
{ {
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
// Closing is not available until RS1+ so we set the name again here for TH2 support.
AutomationProperties.SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
m_fIsHistoryFlyoutOpen = false; m_fIsHistoryFlyoutOpen = false;
EnableControls(true); EnableControls(true);
if (HistoryButton.IsEnabled && HistoryButton.Visibility == Visibility.Visible) if (HistoryButton.IsEnabled && HistoryButton.Visibility == Visibility.Visible)
@ -745,9 +736,6 @@ namespace CalculatorApp
private void OnMemoryFlyoutClosed(object sender, object args) private void OnMemoryFlyoutClosed(object sender, object args)
{ {
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
// Closing is not available until RS1+ so we set the name again here for TH2 support.
AutomationProperties.SetName(MemoryButton, m_openMemoryFlyoutAutomationName);
m_fIsMemoryFlyoutOpen = false; m_fIsMemoryFlyoutOpen = false;
EnableControls(true); EnableControls(true);
if (MemoryButton.IsEnabled) if (MemoryButton.IsEnabled)

View file

@ -124,11 +124,11 @@ namespace CalculatorApp
{ {
InverseHyperbolicTrigFunctions.Visibility = Visibility.Visible; InverseHyperbolicTrigFunctions.Visibility = Visibility.Visible;
} }
else if (isShiftChecked && !isHypeChecked) else if (isShiftChecked)
{ {
InverseTrigFunctions.Visibility = Visibility.Visible; InverseTrigFunctions.Visibility = Visibility.Visible;
} }
else if (!isShiftChecked && isHypeChecked) else if (isHypeChecked)
{ {
HyperbolicTrigFunctions.Visibility = Visibility.Visible; HyperbolicTrigFunctions.Visibility = Visibility.Visible;
} }

View file

@ -258,8 +258,7 @@ namespace CalculatorApp
} }
if (submission.Source == EquationSubmissionSource.ENTER_KEY if (submission.Source == EquationSubmissionSource.ENTER_KEY
|| (submission.Source == EquationSubmissionSource.FOCUS_LOST && submission.HasTextChanged && eq.Expression != null || (submission.Source == EquationSubmissionSource.FOCUS_LOST && submission.HasTextChanged && !string.IsNullOrEmpty(eq.Expression)))
&& eq.Expression.Length > 0))
{ {
if (submission.Source == EquationSubmissionSource.ENTER_KEY) if (submission.Source == EquationSubmissionSource.ENTER_KEY)
{ {
@ -355,13 +354,13 @@ namespace CalculatorApp
{ {
WeakReference weakThis = new WeakReference(this); WeakReference weakThis = new WeakReference(this);
_ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => _ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{ {
if (weakThis.Target is EquationInputArea refThis && refThis.m_isHighContrast == refThis.m_accessibilitySettings.HighContrast) if (weakThis.Target is EquationInputArea refThis && refThis.m_isHighContrast == refThis.m_accessibilitySettings.HighContrast)
{ {
refThis.ReloadAvailableColors(false, false); refThis.ReloadAvailableColors(false, false);
} }
})); });
} }
private void EquationTextBox_RemoveButtonClicked(object sender, RoutedEventArgs e) private void EquationTextBox_RemoveButtonClicked(object sender, RoutedEventArgs e)
@ -436,10 +435,7 @@ namespace CalculatorApp
if (index >= 0) if (index >= 0)
{ {
var container = (UIElement)EquationInputList.ContainerFromIndex(index); var container = (UIElement)EquationInputList.ContainerFromIndex(index);
if (container != null) container?.StartBringIntoView();
{
container.StartBringIntoView();
}
} }
} }
} }
@ -466,10 +462,7 @@ namespace CalculatorApp
if (index >= 0) if (index >= 0)
{ {
var container = (UIElement)EquationInputList.ContainerFromIndex(index); var container = (UIElement)EquationInputList.ContainerFromIndex(index);
if (container != null) container?.StartBringIntoView();
{
container.StartBringIntoView();
}
} }
} }
} }
@ -594,11 +587,11 @@ namespace CalculatorApp
{ {
TimeSpan timeSpan = new TimeSpan(10000000); // 1 tick = 100 nanoseconds, and 10000000 ticks = 1 second. TimeSpan timeSpan = new TimeSpan(10000000); // 1 tick = 100 nanoseconds, and 10000000 ticks = 1 second.
DispatcherTimerDelayer delayer = new DispatcherTimerDelayer(timeSpan); DispatcherTimerDelayer delayer = new DispatcherTimerDelayer(timeSpan);
delayer.Action += new EventHandler<object>((object s, object arg) => delayer.Action += (s, arg) =>
{ {
CalculatorApp.ViewModel.Common.TraceLogger.GetInstance().LogVariableChanged("Slider", name); CalculatorApp.ViewModel.Common.TraceLogger.GetInstance().LogVariableChanged("Slider", name);
variableSliders.Remove(name); variableSliders.Remove(name);
}); };
delayer.Start(); delayer.Start();
variableSliders.Add(name, delayer); variableSliders.Add(name, delayer);
} }
@ -612,12 +605,8 @@ namespace CalculatorApp
private EquationViewModel GetViewModelFromEquationTextBox(object sender) private EquationViewModel GetViewModelFromEquationTextBox(object sender)
{ {
var tb = (EquationTextBox)sender; var tb = (EquationTextBox)sender;
if (tb == null)
{
return null;
}
var eq = (EquationViewModel)tb.DataContext; var eq = (EquationViewModel)tb?.DataContext;
return eq; return eq;
} }

View file

@ -752,13 +752,13 @@ namespace CalculatorApp
private void OnColorValuesChanged(UISettings sender, object args) private void OnColorValuesChanged(UISettings sender, object args)
{ {
WeakReference weakThis = new WeakReference(this); WeakReference weakThis = new WeakReference(this);
_ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => _ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{ {
if (weakThis.Target is GraphingCalculator refThis && IsMatchAppTheme) if (weakThis.Target is GraphingCalculator refThis && IsMatchAppTheme)
{ {
refThis.UpdateGraphTheme(); refThis.UpdateGraphTheme();
} }
})); });
} }
private void UpdateGraphTheme() private void UpdateGraphTheme()
@ -788,13 +788,13 @@ namespace CalculatorApp
IsMatchAppTheme = isMatchAppTheme; IsMatchAppTheme = isMatchAppTheme;
WeakReference weakThis = new WeakReference(this); WeakReference weakThis = new WeakReference(this);
_ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => _ = this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{ {
if (weakThis.Target is GraphingCalculator refThis) if (weakThis.Target is GraphingCalculator refThis)
{ {
refThis.UpdateGraphTheme(); refThis.UpdateGraphTheme();
} }
})); });
} }
private const double zoomInScale = 1 / 1.0625; private const double zoomInScale = 1 / 1.0625;

View file

@ -187,7 +187,7 @@ namespace CalculatorApp
} }
} }
private static readonly Dictionary<NumbersAndOperatorsEnum, Tuple<string, int, int>> buttonOutput = new Dictionary<NumbersAndOperatorsEnum, Tuple<string, int, int>>() private static readonly Dictionary<NumbersAndOperatorsEnum, Tuple<string, int, int>> buttonOutput = new Dictionary<NumbersAndOperatorsEnum, Tuple<string, int, int>>
{ {
{ NumbersAndOperatorsEnum.Sin, Tuple.Create("sin()", 4, 0) }, { NumbersAndOperatorsEnum.Sin, Tuple.Create("sin()", 4, 0) },
{ NumbersAndOperatorsEnum.Cos, Tuple.Create("cos()", 4, 0) }, { NumbersAndOperatorsEnum.Cos, Tuple.Create("cos()", 4, 0) },

View file

@ -206,34 +206,37 @@ namespace CalculatorApp
KeyboardShortcutManager.DisableShortcuts(false); KeyboardShortcutManager.DisableShortcuts(false);
if (newValue == ViewMode.Standard) switch (newValue)
{ {
case ViewMode.Standard:
EnsureCalculator(); EnsureCalculator();
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true; Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode)); m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue); Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
} break;
else if (newValue == ViewMode.Scientific) case ViewMode.Scientific:
{
EnsureCalculator(); EnsureCalculator();
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true; Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
if (Model.PreviousMode != ViewMode.Scientific) if (Model.PreviousMode != ViewMode.Scientific)
{ {
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode)); m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
} }
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue); Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
} break;
else if (newValue == ViewMode.Programmer) case ViewMode.Programmer:
{
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false; Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
EnsureCalculator(); EnsureCalculator();
if (Model.PreviousMode != ViewMode.Programmer) if (Model.PreviousMode != ViewMode.Programmer)
{ {
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode)); m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
} }
} break;
else if (NavCategory.IsDateCalculatorViewMode(newValue)) case ViewMode.Graphing:
EnsureGraphingCalculator();
KeyboardShortcutManager.DisableShortcuts(true);
break;
default:
if (NavCategory.IsDateCalculatorViewMode(newValue))
{ {
if (Model.CalculatorViewModel != null) if (Model.CalculatorViewModel != null)
{ {
@ -241,11 +244,6 @@ namespace CalculatorApp
} }
EnsureDateCalculator(); EnsureDateCalculator();
} }
else if (newValue == ViewMode.Graphing)
{
EnsureGraphingCalculator();
KeyboardShortcutManager.DisableShortcuts(true);
}
else if (NavCategory.IsConverterViewMode(newValue)) else if (NavCategory.IsConverterViewMode(newValue))
{ {
if (Model.CalculatorViewModel != null) if (Model.CalculatorViewModel != null)
@ -259,6 +257,8 @@ namespace CalculatorApp
m_converter.AnimateConverter(); m_converter.AnimateConverter();
} }
} }
break;
}
ShowHideControls(newValue); ShowHideControls(newValue);

View file

@ -92,7 +92,7 @@ namespace CalculatorApp
{ {
if (Frame.RequestedThemeProperty == dp) if (Frame.RequestedThemeProperty == dp)
{ {
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => { SetTitleBarControlColors(); })); _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, SetTitleBarControlColors);
} }
} }
@ -120,8 +120,8 @@ namespace CalculatorApp
return; return;
} }
double leftAddition = 0; double leftAddition;
double rightAddition = 0; double rightAddition;
if (FlowDirection == FlowDirection.LeftToRight) if (FlowDirection == FlowDirection.LeftToRight)
{ {
@ -140,18 +140,14 @@ namespace CalculatorApp
private void ColorValuesChanged(Windows.UI.ViewManagement.UISettings sender, object e) private void ColorValuesChanged(Windows.UI.ViewManagement.UISettings sender, object e)
{ {
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => { SetTitleBarControlColors(); })); _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, SetTitleBarControlColors);
} }
private void SetTitleBarControlColors() private void SetTitleBarControlColors()
{ {
var applicationView = ApplicationView.GetForCurrentView(); var applicationView = ApplicationView.GetForCurrentView();
if (applicationView == null)
{
return;
}
var applicationTitleBar = applicationView.TitleBar; var applicationTitleBar = applicationView?.TitleBar;
if (applicationTitleBar == null) if (applicationTitleBar == null)
{ {
return; return;
@ -184,11 +180,11 @@ namespace CalculatorApp
private void OnHighContrastChanged(Windows.UI.ViewManagement.AccessibilitySettings sender, object args) private void OnHighContrastChanged(Windows.UI.ViewManagement.AccessibilitySettings sender, object args)
{ {
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() => _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{ {
SetTitleBarControlColors(); SetTitleBarControlColors();
SetTitleBarVisibility(false); SetTitleBarVisibility(false);
})); });
} }
private void OnWindowActivated(object sender, WindowActivatedEventArgs e) private void OnWindowActivated(object sender, WindowActivatedEventArgs e)
@ -281,12 +277,12 @@ namespace CalculatorApp
public static readonly DependencyProperty BackButtonSpaceReservedProperty = public static readonly DependencyProperty BackButtonSpaceReservedProperty =
DependencyProperty.Register( DependencyProperty.Register(
nameof(BackButtonSpaceReserved), typeof(bool), typeof(TitleBar), nameof(BackButtonSpaceReserved), typeof(bool), typeof(TitleBar),
new PropertyMetadata(false, new PropertyChangedCallback((sender, args) => new PropertyMetadata(false, (sender, args) =>
{ {
var self = sender as TitleBar; var self = sender as TitleBar;
VisualStateManager.GoToState( VisualStateManager.GoToState(
self, (bool)args.NewValue ? self.BackButtonVisible.Name : self.BackButtonCollapsed.Name, true); self, (bool)args.NewValue ? self.BackButtonVisible.Name : self.BackButtonCollapsed.Name, true);
}))); }));
private readonly Windows.ApplicationModel.Core.CoreApplicationViewTitleBar m_coreTitleBar; private readonly Windows.ApplicationModel.Core.CoreApplicationViewTitleBar m_coreTitleBar;
private readonly Windows.UI.ViewManagement.UISettings m_uiSettings; private readonly Windows.UI.ViewManagement.UISettings m_uiSettings;

View file

@ -86,7 +86,7 @@ namespace CalculatorApp
public void SetDefaultFocus() public void SetDefaultFocus()
{ {
Control[] focusPrecedence = new Control[] { Value1, CurrencyRefreshBlockControl, OfflineBlock, ClearEntryButtonPos0 }; Control[] focusPrecedence = { Value1, CurrencyRefreshBlockControl, OfflineBlock, ClearEntryButtonPos0 };
foreach (Control control in focusPrecedence) foreach (Control control in focusPrecedence)
{ {
@ -368,10 +368,7 @@ namespace CalculatorApp
private void HideProgressRing() private void HideProgressRing()
{ {
if (m_delayTimer != null) m_delayTimer?.Stop();
{
m_delayTimer.Stop();
}
CurrencyLoadingProgressRing.IsActive = false; CurrencyLoadingProgressRing.IsActive = false;
} }
@ -391,8 +388,8 @@ namespace CalculatorApp
private static readonly Lazy<UISettings> uiSettings = new Lazy<UISettings>(true); private static readonly Lazy<UISettings> uiSettings = new Lazy<UISettings>(true);
private readonly Windows.UI.Xaml.Controls.MenuFlyout m_resultsFlyout = default; private readonly Windows.UI.Xaml.Controls.MenuFlyout m_resultsFlyout = default;
private readonly string m_chargesMayApplyText = string.Empty; private readonly string m_chargesMayApplyText;
private readonly string m_failedToRefreshText = string.Empty; private readonly string m_failedToRefreshText;
private bool m_meteredConnectionOverride; private bool m_meteredConnectionOverride;

View file

@ -59,7 +59,7 @@ namespace CalculatorApp
public Task HandleViewRelease() public Task HandleViewRelease()
{ {
TaskCompletionSource<object> tsource = new TaskCompletionSource<object>(); TaskCompletionSource<object> tsource = new TaskCompletionSource<object>();
_ = m_coreDispatcher.RunAsync(CoreDispatcherPriority.Low, new DispatchedHandler(() => _ = m_coreDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
{ {
KeyboardShortcutManager.OnWindowClosed(this.m_viewId); KeyboardShortcutManager.OnWindowClosed(this.m_viewId);
Window.Current.Content = null; Window.Current.Content = null;
@ -70,7 +70,7 @@ namespace CalculatorApp
tsource.SetResult(new object()); tsource.SetResult(new object());
this.m_coreDispatcher.StopProcessEvents(); this.m_coreDispatcher.StopProcessEvents();
Window.Current.Close(); Window.Current.Close();
})); });
return tsource.Task; return tsource.Task;
} }

View file

@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.3.1" /> <PackageReference Include="Appium.WebDriver" Version="4.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -41,63 +41,27 @@ namespace CalculatorUITestFramework
/// <param name="mode">The mode to be changed to</param> /// <param name="mode">The mode to be changed to</param>
public void ChangeCalculatorMode(CalculatorMode mode) public void ChangeCalculatorMode(CalculatorMode mode)
{ {
string modeAccessibilityId; string modeAccessibilityId = mode switch
switch (mode)
{ {
case CalculatorMode.StandardCalculator: CalculatorMode.StandardCalculator => "Standard",
modeAccessibilityId = "Standard"; CalculatorMode.ScientificCalculator => "Scientific",
break; CalculatorMode.ProgrammerCalculator => "Programmer",
case CalculatorMode.ScientificCalculator: CalculatorMode.DateCalculator => "Date",
modeAccessibilityId = "Scientific"; CalculatorMode.Currency => "Currency",
break; CalculatorMode.Volume => "Volume",
case CalculatorMode.ProgrammerCalculator: CalculatorMode.Length => "Length",
modeAccessibilityId = "Programmer"; CalculatorMode.Weight => "Weight",
break; CalculatorMode.Temperature => "Temperature",
case CalculatorMode.DateCalculator: CalculatorMode.Energy => "Energy",
modeAccessibilityId = "Date"; CalculatorMode.Area => "Area",
break; CalculatorMode.Speed => "Speed",
case CalculatorMode.Currency: CalculatorMode.Time => "Time",
modeAccessibilityId = "Currency"; CalculatorMode.Power => "Power",
break; CalculatorMode.Data => "Data",
case CalculatorMode.Volume: CalculatorMode.Pressure => "Pressure",
modeAccessibilityId = "Volume"; CalculatorMode.Angle => "Angle",
break; _ => throw (new ArgumentException("The mode is not valid"))
case CalculatorMode.Length: };
modeAccessibilityId = "Length";
break;
case CalculatorMode.Weight:
modeAccessibilityId = "Weight";
break;
case CalculatorMode.Temperature:
modeAccessibilityId = "Temperature";
break;
case CalculatorMode.Energy:
modeAccessibilityId = "Energy";
break;
case CalculatorMode.Area:
modeAccessibilityId = "Area";
break;
case CalculatorMode.Speed:
modeAccessibilityId = "Speed";
break;
case CalculatorMode.Time:
modeAccessibilityId = "Time";
break;
case CalculatorMode.Power:
modeAccessibilityId = "Power";
break;
case CalculatorMode.Data:
modeAccessibilityId = "Data";
break;
case CalculatorMode.Pressure:
modeAccessibilityId = "Pressure";
break;
case CalculatorMode.Angle:
modeAccessibilityId = "Angle";
break;
default:
throw (new ArgumentException("The mode is not valid"));
}
this.NavigationMenuButton.Click(); this.NavigationMenuButton.Click();
this.NavigationMenuPane.WaitForDisplayed(); this.NavigationMenuPane.WaitForDisplayed();

View file

@ -77,7 +77,7 @@ namespace CalculatorUITestFramework
this.NegateButton.Click(); this.NegateButton.Click();
break; break;
default: default:
throw (new ArgumentException(string.Format("{0} is not valid", digit))); throw (new ArgumentException($"{digit} is not valid"));
} }
} }
} }

View file

@ -109,21 +109,13 @@ namespace CalculatorUITestFramework
public void SetAngleOperator(AngleOperatorState value) public void SetAngleOperator(AngleOperatorState value)
{ {
//set the desired string value for the button //set the desired string value for the button
string desiredId; string desiredId = value switch
switch (value)
{ {
case AngleOperatorState.Degrees: AngleOperatorState.Degrees => "degButton",
desiredId = "degButton"; AngleOperatorState.Gradians => "gradButton",
break; AngleOperatorState.Radians => "radButton",
case AngleOperatorState.Gradians: _ => throw new NotImplementedException()
desiredId = "gradButton"; };
break;
case AngleOperatorState.Radians:
desiredId = "radButton";
break;
default:
throw new NotImplementedException();
}
while (this.DegRadGradButton.GetAttribute("AutomationId") != desiredId) while (this.DegRadGradButton.GetAttribute("AutomationId") != desiredId)
{ {
this.DegRadGradButton.Click(); this.DegRadGradButton.Click();

View file

@ -20,6 +20,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace CalculatorUITestFramework namespace CalculatorUITestFramework
{ {
@ -146,7 +147,8 @@ namespace CalculatorUITestFramework
{ {
Uri status; Uri status;
Uri service = this.ServiceUrl; Uri service = this.ServiceUrl;
HttpClient httpClient = new HttpClient(); using (HttpClient httpClient = new HttpClient())
{
httpClient.Timeout = this.InitializationTimeout; httpClient.Timeout = this.InitializationTimeout;
if (service.IsLoopback) if (service.IsLoopback)
@ -158,8 +160,10 @@ namespace CalculatorUITestFramework
status = new Uri(service + "/status"); status = new Uri(service + "/status");
} }
var httpResponse = httpClient.GetAsync(status); var httpResponse = Task.Run(() => httpClient.GetAsync(status)).ConfigureAwait(false).GetAwaiter().GetResult();
return httpResponse.Result.IsSuccessStatusCode;
return httpResponse.IsSuccessStatusCode;
}
} }
} }
} }

View file

@ -45,10 +45,6 @@ namespace CalculatorUITestFramework
public WindowsDriverServiceBuilder WithStartUpTimeOut(TimeSpan startUpTimeout) public WindowsDriverServiceBuilder WithStartUpTimeOut(TimeSpan startUpTimeout)
{ {
if (startUpTimeout == null)
{
throw new ArgumentNullException("A startup timeout should not be NULL");
}
this.StartUpTimeout = startUpTimeout; this.StartUpTimeout = startUpTimeout;
return this; return this;
} }

View file

@ -4,10 +4,10 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" /> <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Appium.WebDriver" Version="4.3.1" /> <PackageReference Include="Appium.WebDriver" Version="4.3.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\CalculatorUITestFramework\CalculatorUITestFramework.csproj" /> <ProjectReference Include="..\CalculatorUITestFramework\CalculatorUITestFramework.csproj" />

View file

@ -11,7 +11,7 @@
namespace Graphing::Analyzer namespace Graphing::Analyzer
{ {
typedef unsigned int NativeAnalysisType; // PerformAnalysisType using NativeAnalysisType = unsigned int; // PerformAnalysisType
struct IGraphAnalyzer : public NonCopyable, public NonMoveable struct IGraphAnalyzer : public NonCopyable, public NonMoveable
{ {