mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Merge branch 'master' into Issue62-Squashed
This commit is contained in:
commit
6972bb617a
52 changed files with 226 additions and 390 deletions
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <sstream>
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Header Files/CalcUtils.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Command.h"
|
||||
#include "CalculatorVector.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
#include "pch.h"
|
||||
#include <algorithm>
|
||||
#include "Header Files/Number.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
#include "pch.h"
|
||||
#include <intsafe.h>
|
||||
#include "Header Files/Rational.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/RationalMath.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <cassert>
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
#include "CalculatorResource.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
*
|
||||
* Author:
|
||||
\****************************************************************************/
|
||||
#include "pch.h"
|
||||
|
||||
#include <string>
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Header Files/CalcUtils.h"
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
*
|
||||
* Author:
|
||||
\****************************************************************************/
|
||||
#include "pch.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <regex>
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
/*** ***/
|
||||
/*** ***/
|
||||
/**************************************************************************/
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace CalcEngine;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace CalcEngine;
|
||||
|
|
|
@ -157,6 +157,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -173,6 +174,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -189,6 +191,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -205,6 +208,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -222,6 +226,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -238,6 +243,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -254,6 +260,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -270,6 +277,7 @@
|
|||
<AdditionalIncludeDirectories>$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
|
@ -278,7 +286,6 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CalcException.h" />
|
||||
<ClInclude Include="CalculatorHistory.h" />
|
||||
<ClInclude Include="CalculatorManager.h" />
|
||||
<ClInclude Include="CalculatorResource.h" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <cassert>
|
||||
#include "CalculatorHistory.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <climits> // for UCHAR_MAX
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "CalculatorManager.h"
|
||||
#include "CalculatorResource.h"
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <winerror.h>
|
||||
#include "Ratpack/CalcErr.h"
|
||||
#include <stdexcept> // for std::out_of_range
|
||||
#include <sal.h> // for SAL
|
||||
|
||||
template <typename TType>
|
||||
class CalculatorVector
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#include "Header Files/CCommand.h"
|
||||
#include "CalculatorVector.h"
|
||||
#include "ExpressionCommand.h"
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory> // for std::shared_ptr
|
||||
#include "CalculatorVector.h"
|
||||
#include "Command.h"
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*
|
||||
\****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
// The following are the valid id's which can be passed to CCalcEngine::ProcessCommand
|
||||
|
||||
#define IDM_HEX 313
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
* Created: 13-Feb-2008
|
||||
*
|
||||
\****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
inline constexpr auto IDS_ERRORS_FIRST = 99;
|
||||
|
||||
// This is the list of error strings corresponding to SCERR_DIVIDEZERO..
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include "ICalcDisplay.h"
|
||||
#include "IHistoryDisplay.h"
|
||||
#include "Rational.h"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "Ratpack/ratpak.h"
|
||||
|
||||
namespace CalcEngine
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
// internal base is a power of 2.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
#include <cstring> // for memmove
|
||||
|
||||
void _mulnumx( PNUMBER *pa, PNUMBER b );
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include <algorithm>
|
||||
#include <winerror.h>
|
||||
#include <sstream>
|
||||
#include <cstring> // for memmove, memcpy
|
||||
#include "ratpak.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// Contains fact(orial) and supporting _gamma functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// Special Information
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// Contains routines for and, or, xor, not and other support
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include <list>
|
||||
#include <cstring> // for memmove
|
||||
#include "ratpak.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include "CalcErr.h"
|
||||
#include <cstring> // for memmove
|
||||
#include <sal.h> // for SAL
|
||||
|
||||
static constexpr uint32_t BASEXPWR = 31L;// Internal log2(BASEX)
|
||||
static constexpr uint32_t BASEX = 0x80000000; // Internal radix used in calculations, hope to raise
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#include <cstring> // for memmove
|
||||
#include <iostream> // for wostream
|
||||
#include "ratpak.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "pch.h"
|
||||
#include "ratpak.h"
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <algorithm> // for std::sort
|
||||
#include "Command.h"
|
||||
#include "UnitConverter.h"
|
||||
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <ppltasks.h>
|
||||
#include <sal.h> // for SAL
|
||||
#include <memory> // for std::shared_ptr
|
||||
|
||||
namespace UnitConversionManager
|
||||
{
|
||||
enum class Command;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
// Intentionally do not include the pch.h here. For projects that don't
|
||||
// use precompiled headers, including the header here would force unnecessary compilation.
|
||||
// The pch will be included through forced include.
|
||||
|
|
|
@ -3,27 +3,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
// The CalcManager project should be able to be compiled with or without a precompiled header
|
||||
// in - order to support other toolchains besides MSVC. When adding new system headers, make sure
|
||||
// that the relevant source file includes all headers it needs, but then also add the system headers
|
||||
// here so that MSVC users see the performance benefit.
|
||||
|
||||
// Windows headers define min/max macros.
|
||||
// Disable it for project code.
|
||||
#define NOMINMAX
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <winerror.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <regex>
|
||||
#include <unordered_map>
|
||||
#include <intsafe.h>
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <intsafe.h>
|
||||
#include <list>
|
||||
#include <ppltasks.h>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <winerror.h>
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||
|
||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||
|
||||
#include <SDKDDKVer.h>
|
|
@ -66,6 +66,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() :
|
|||
m_BinaryDisplayValue(L"0"),
|
||||
m_OctalDisplayValue(L"0"),
|
||||
m_standardCalculatorManager(&m_calculatorDisplay, &m_resourceProvider),
|
||||
m_ExpressionTokens(ref new Vector<DisplayExpressionToken^>()),
|
||||
m_MemorizedNumbers(ref new Vector<MemoryItemViewModel^>()),
|
||||
m_IsMemoryEmpty(true),
|
||||
m_IsFToEChecked(false),
|
||||
|
@ -314,59 +315,67 @@ void StandardCalculatorViewModel::SetTokens(_Inout_ shared_ptr<CalculatorVector<
|
|||
{
|
||||
AreTokensUpdated = false;
|
||||
|
||||
if (m_ExpressionTokens == nullptr)
|
||||
{
|
||||
m_ExpressionTokens = ref new Vector<DisplayExpressionToken^>();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ExpressionTokens->Clear();
|
||||
}
|
||||
|
||||
unsigned int nTokens = 0;
|
||||
tokens->GetSize(&nTokens);
|
||||
|
||||
if (nTokens == 0)
|
||||
{
|
||||
m_ExpressionTokens->Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
pair <wstring, int> currentToken;
|
||||
const auto& localizer = LocalizationSettings::GetInstance();
|
||||
|
||||
const wstring separator = L" ";
|
||||
for (unsigned int i = 0; i < nTokens; ++i)
|
||||
{
|
||||
if (SUCCEEDED(tokens->GetAt(i, ¤tToken)))
|
||||
{
|
||||
Common::TokenType type;
|
||||
const wstring separator = L" ";
|
||||
bool isEditable = (currentToken.second == -1) ? false : true;
|
||||
localizer.LocalizeDisplayValue(&(currentToken.first));
|
||||
|
||||
if (!isEditable)
|
||||
{
|
||||
if (currentToken.first == separator)
|
||||
{
|
||||
type = TokenType::Separator;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = TokenType::Operator;
|
||||
}
|
||||
type = currentToken.first == separator ? TokenType::Separator : TokenType::Operator;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
shared_ptr<IExpressionCommand> command;
|
||||
IFTPlatformException(m_commands->GetAt(static_cast<unsigned int>(currentToken.second), &command));
|
||||
type = command->GetCommandType() == CommandType::OperandCommand ? TokenType::Operand : TokenType::Operator;
|
||||
}
|
||||
|
||||
if (command->GetCommandType() == CommandType::OperandCommand)
|
||||
auto currentTokenString = ref new String(currentToken.first.c_str());
|
||||
if (i < m_ExpressionTokens->Size)
|
||||
{
|
||||
auto existingItem = m_ExpressionTokens->GetAt(i);
|
||||
if (type == existingItem->Type && existingItem->Token->Equals(currentTokenString))
|
||||
{
|
||||
type = TokenType::Operand;
|
||||
existingItem->TokenPosition = i;
|
||||
existingItem->IsTokenEditable = isEditable;
|
||||
existingItem->CommandIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = TokenType::Operator;
|
||||
auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type);
|
||||
m_ExpressionTokens->InsertAt(i, expressionToken);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
auto expressionToken = ref new DisplayExpressionToken(currentTokenString, i, isEditable, type);
|
||||
m_ExpressionTokens->Append(expressionToken);
|
||||
}
|
||||
DisplayExpressionToken^ expressionToken = ref new DisplayExpressionToken(ref new String(currentToken.first.c_str()), i, isEditable, type);
|
||||
m_ExpressionTokens->Append(expressionToken);
|
||||
}
|
||||
}
|
||||
|
||||
while (m_ExpressionTokens->Size != nTokens)
|
||||
{
|
||||
m_ExpressionTokens->RemoveAtEnd();
|
||||
}
|
||||
}
|
||||
|
||||
String^ StandardCalculatorViewModel::GetCalculatorExpressionAutomationName()
|
||||
|
@ -524,7 +533,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
|
|||
{
|
||||
if (commandIndex == 0)
|
||||
{
|
||||
delete [] temp;
|
||||
delete[] temp;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -545,7 +554,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
|
|||
length = m_selectedExpressionLastData->Length() + 1;
|
||||
if (length > 50)
|
||||
{
|
||||
delete [] temp;
|
||||
delete[] temp;
|
||||
return;
|
||||
}
|
||||
for (; i < length; ++i)
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace CalculatorApp
|
|||
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsInError);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsOperatorCommand);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DisplayStringExpression);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::Foundation::Collections::IVector<Common::DisplayExpressionToken^>^, ExpressionTokens);
|
||||
OBSERVABLE_PROPERTY_R(Windows::Foundation::Collections::IObservableVector<Common::DisplayExpressionToken^>^, ExpressionTokens);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DecimalDisplayValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, HexDisplayValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, OctalDisplayValue);
|
||||
|
|
|
@ -243,7 +243,6 @@
|
|||
<ClInclude Include="Converters\BitFlipAutomationNameConverter.h" />
|
||||
<ClInclude Include="Converters\BooleanNegationConverter.h" />
|
||||
<ClInclude Include="Converters\BooleanToVisibilityConverter.h" />
|
||||
<ClInclude Include="Converters\ExpressionItemContainerStyle.h" />
|
||||
<ClInclude Include="Converters\ExpressionItemTemplateSelector.h" />
|
||||
<ClInclude Include="Converters\ItemSizeToVisibilityConverter.h" />
|
||||
<ClInclude Include="Converters\RadixToStringConverter.h" />
|
||||
|
@ -375,7 +374,6 @@
|
|||
<ClCompile Include="Converters\BitFlipAutomationNameConverter.cpp" />
|
||||
<ClCompile Include="Converters\BooleanNegationConverter.cpp" />
|
||||
<ClCompile Include="Converters\BooleanToVisibilityConverter.cpp" />
|
||||
<ClCompile Include="Converters\ExpressionItemContainerStyle.cpp" />
|
||||
<ClCompile Include="Converters\ExpressionItemTemplateSelector.cpp" />
|
||||
<ClCompile Include="Converters\ItemSizeToVisibilityConverter.cpp" />
|
||||
<ClCompile Include="Converters\RadixToStringConverter.cpp" />
|
||||
|
|
|
@ -243,9 +243,6 @@
|
|||
<ClCompile Include="Converters\BooleanToVisibilityConverter.cpp">
|
||||
<Filter>Converters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Converters\ExpressionItemContainerStyle.cpp">
|
||||
<Filter>Converters</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Converters\ExpressionItemTemplateSelector.cpp">
|
||||
<Filter>Converters</Filter>
|
||||
</ClCompile>
|
||||
|
@ -333,9 +330,6 @@
|
|||
<ClInclude Include="Converters\BooleanToVisibilityConverter.h">
|
||||
<Filter>Converters</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Converters\ExpressionItemContainerStyle.h">
|
||||
<Filter>Converters</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Converters\ExpressionItemTemplateSelector.h">
|
||||
<Filter>Converters</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -30,25 +30,38 @@ DEPENDENCY_PROPERTY_INITIALIZATION(OverflowTextBlock, TokensUpdated);
|
|||
|
||||
void OverflowTextBlock::OnApplyTemplate()
|
||||
{
|
||||
assert(((m_scrollLeft == nullptr) && (m_scrollRight == nullptr)) || ((m_scrollLeft != nullptr) && (m_scrollRight != nullptr)));
|
||||
UnregisterEventHandlers();
|
||||
|
||||
m_expressionContainer = safe_cast<ScrollViewer^>(GetTemplateChild("ExpressionContainer"));
|
||||
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
|
||||
auto uiElement = GetTemplateChild("ExpressionContainer");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_expressionContainer = safe_cast<ScrollViewer^>(uiElement);
|
||||
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
|
||||
m_containerViewChangedToken = m_expressionContainer->ViewChanged += ref new EventHandler<ScrollViewerViewChangedEventArgs ^>(this, &OverflowTextBlock::OnViewChanged);
|
||||
}
|
||||
|
||||
m_scrollLeft = safe_cast<Button^>(GetTemplateChild("ScrollLeft"));
|
||||
m_scrollRight = safe_cast<Button^>(GetTemplateChild("ScrollRight"));
|
||||
uiElement = GetTemplateChild("ScrollLeft");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_scrollLeft = safe_cast<Button^>(uiElement);
|
||||
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
}
|
||||
|
||||
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
uiElement = GetTemplateChild("ScrollRight");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_scrollRight = safe_cast<Button^>(uiElement);
|
||||
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
}
|
||||
|
||||
m_scrollingLeft = false;
|
||||
m_scrollingRight = false;
|
||||
|
||||
auto borderContainer = safe_cast<Border^>(GetTemplateChild("ExpressionBorder"));
|
||||
m_pointerEnteredEventToken = borderContainer->PointerEntered += ref new PointerEventHandler(this, &OverflowTextBlock::OnPointerEntered);
|
||||
m_pointerExitedEventToken = borderContainer->PointerExited += ref new PointerEventHandler(this, &OverflowTextBlock::OnPointerExited);
|
||||
|
||||
m_listView = safe_cast<ListView^>(GetTemplateChild("TokenList"));
|
||||
uiElement = GetTemplateChild("TokenList");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_itemsControl = safe_cast<ItemsControl^>(uiElement);
|
||||
}
|
||||
|
||||
UpdateAllState();
|
||||
}
|
||||
|
@ -60,18 +73,19 @@ AutomationPeer^ OverflowTextBlock::OnCreateAutomationPeer()
|
|||
|
||||
void OverflowTextBlock::OnTokensUpdatedPropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
{
|
||||
if ((m_listView != nullptr) && (newValue))
|
||||
if (m_expressionContainer != nullptr && newValue)
|
||||
{
|
||||
unsigned int tokenCount = m_listView->Items->Size;
|
||||
if (tokenCount > 0)
|
||||
{
|
||||
m_listView->UpdateLayout();
|
||||
m_listView->ScrollIntoView(m_listView->Items->GetAt(tokenCount - 1));
|
||||
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
|
||||
}
|
||||
m_expressionContainer->UpdateLayout();
|
||||
m_expressionContainer->ChangeView(m_expressionContainer->ScrollableWidth, nullptr, nullptr, true);
|
||||
}
|
||||
AutomationProperties::SetAccessibilityView(this,
|
||||
m_listView != nullptr && m_listView->Items->Size > 0 ? AccessibilityView::Control : AccessibilityView::Raw);
|
||||
auto newIsAccessibilityViewControl = m_itemsControl != nullptr && m_itemsControl->Items->Size > 0;
|
||||
if (m_isAccessibilityViewControl != newIsAccessibilityViewControl)
|
||||
{
|
||||
m_isAccessibilityViewControl = newIsAccessibilityViewControl;
|
||||
AutomationProperties::SetAccessibilityView(this,
|
||||
newIsAccessibilityViewControl ? AccessibilityView::Control : AccessibilityView::Raw);
|
||||
}
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
|
||||
void OverflowTextBlock::UpdateAllState()
|
||||
|
@ -93,7 +107,7 @@ void OverflowTextBlock::UpdateVisualState()
|
|||
|
||||
void OverflowTextBlock::ScrollLeft()
|
||||
{
|
||||
if (m_expressionContainer->HorizontalOffset > 0)
|
||||
if (m_expressionContainer != nullptr && m_expressionContainer->HorizontalOffset > 0)
|
||||
{
|
||||
m_scrollingLeft = true;
|
||||
double offset = m_expressionContainer->HorizontalOffset - (scrollRatio * m_expressionContainer->ViewportWidth);
|
||||
|
@ -105,7 +119,7 @@ void OverflowTextBlock::ScrollLeft()
|
|||
|
||||
void OverflowTextBlock::ScrollRight()
|
||||
{
|
||||
if (m_expressionContainer->HorizontalOffset < m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)
|
||||
if (m_expressionContainer != nullptr && m_expressionContainer->HorizontalOffset < m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)
|
||||
{
|
||||
m_scrollingRight = true;
|
||||
double offset = m_expressionContainer->HorizontalOffset + (scrollRatio * m_expressionContainer->ViewportWidth);
|
||||
|
@ -128,26 +142,15 @@ void OverflowTextBlock::OnScrollClick(_In_ Object^ sender, _In_ RoutedEventArgs^
|
|||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::OnPointerEntered(_In_ Object^, _In_ PointerRoutedEventArgs^ e)
|
||||
{
|
||||
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
|
||||
{
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::OnPointerExited(_In_ Object^, _In_ PointerRoutedEventArgs^ e)
|
||||
{
|
||||
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
|
||||
{
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::UpdateScrollButtons()
|
||||
{
|
||||
if (m_itemsControl == nullptr || m_expressionContainer == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// When the width is smaller than the container, don't show any
|
||||
if (m_listView->ActualWidth <= m_expressionContainer->ActualWidth)
|
||||
if (m_itemsControl->ActualWidth <= m_expressionContainer->ActualWidth)
|
||||
{
|
||||
ShowHideScrollButtons(::Visibility::Collapsed, ::Visibility::Collapsed);
|
||||
}
|
||||
|
@ -163,7 +166,10 @@ void OverflowTextBlock::UpdateScrollButtons()
|
|||
if (m_scrollingLeft)
|
||||
{
|
||||
m_scrollingLeft = false;
|
||||
m_scrollRight->Focus(::FocusState::Programmatic);
|
||||
if (m_scrollRight != nullptr)
|
||||
{
|
||||
m_scrollRight->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Width is larger than the container and right most part of the number is shown. Should be able to scroll left.
|
||||
|
@ -172,7 +178,10 @@ void OverflowTextBlock::UpdateScrollButtons()
|
|||
if (m_scrollingRight)
|
||||
{
|
||||
m_scrollingRight = false;
|
||||
m_scrollLeft->Focus(::FocusState::Programmatic);
|
||||
if (m_scrollLeft != nullptr)
|
||||
{
|
||||
m_scrollLeft->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,12 +208,13 @@ void OverflowTextBlock::UnregisterEventHandlers()
|
|||
m_scrollRight->Click -= m_scrollRightClickEventToken;
|
||||
}
|
||||
|
||||
auto borderContainer = safe_cast<Border^>(GetTemplateChild("ExpressionBorder"));
|
||||
|
||||
// Adding an extra check, in case the returned template is null
|
||||
if (borderContainer != nullptr)
|
||||
if (m_expressionContainer != nullptr)
|
||||
{
|
||||
borderContainer->PointerEntered -= m_pointerEnteredEventToken;
|
||||
borderContainer->PointerExited -= m_pointerExitedEventToken;
|
||||
m_expressionContainer->ViewChanged -= m_containerViewChangedToken;
|
||||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::OnViewChanged(_In_opt_ Object^ /*sender*/, _In_opt_ ScrollViewerViewChangedEventArgs^ /*args*/)
|
||||
{
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace CalculatorApp
|
|||
void OnPointerExited(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
|
||||
void ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
|
||||
void OnTokensUpdatedPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnViewChanged(_In_opt_ Platform::Object ^sender, _In_opt_ Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^args);
|
||||
|
||||
void UpdateVisualState();
|
||||
void UpdateExpressionState();
|
||||
|
@ -44,15 +45,15 @@ namespace CalculatorApp
|
|||
double scrollRatio = 0.7;
|
||||
bool m_scrollingLeft;
|
||||
bool m_scrollingRight;
|
||||
Windows::UI::Xaml::Controls::ListView^ m_listView;
|
||||
bool m_isAccessibilityViewControl;
|
||||
Windows::UI::Xaml::Controls::ItemsControl^ m_itemsControl;
|
||||
Windows::UI::Xaml::Controls::ScrollViewer^ m_expressionContainer;
|
||||
Windows::UI::Xaml::Controls::Button^ m_scrollLeft;
|
||||
Windows::UI::Xaml::Controls::Button^ m_scrollRight;
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_scrollLeftClickEventToken;
|
||||
Windows::Foundation::EventRegistrationToken m_scrollRightClickEventToken;
|
||||
Windows::Foundation::EventRegistrationToken m_pointerEnteredEventToken;
|
||||
Windows::Foundation::EventRegistrationToken m_pointerExitedEventToken;
|
||||
Windows::Foundation::EventRegistrationToken m_containerViewChangedToken;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "ExpressionItemContainerStyle.h"
|
||||
#include "CalcViewModel/Common/DisplayExpressionToken.h"
|
||||
|
||||
using namespace CalculatorApp::Common;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
Windows::UI::Xaml::Style^ ExpressionItemContainerStyle::SelectStyleCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container)
|
||||
{
|
||||
DisplayExpressionToken^ token = dynamic_cast<DisplayExpressionToken^>(item);
|
||||
if (token != nullptr)
|
||||
{
|
||||
Common::TokenType type = token->Type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TokenType::Operator:
|
||||
if (token->IsTokenEditable)
|
||||
{
|
||||
return m_editableOperatorStyle;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_nonEditableOperatorStyle;
|
||||
}
|
||||
case TokenType::Operand:
|
||||
return m_operandStyle;
|
||||
case TokenType::Separator:
|
||||
return m_separatorStyle;
|
||||
default:
|
||||
throw ref new Platform::Exception(E_FAIL, L"Invalid token type");
|
||||
}
|
||||
}
|
||||
|
||||
return m_separatorStyle;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class ExpressionItemContainerStyle sealed : public Windows::UI::Xaml::Controls::StyleSelector
|
||||
{
|
||||
public:
|
||||
virtual Windows::UI::Xaml::Style^ SelectStyleCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container) override;
|
||||
|
||||
property Windows::UI::Xaml::Style^ EditableOperatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_editableOperatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_editableOperatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ OperandStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_operandStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_operandStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ SeparatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_separatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_separatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::Style^ NonEditableOperatorStyle
|
||||
{
|
||||
Windows::UI::Xaml::Style^ get()
|
||||
{
|
||||
return m_nonEditableOperatorStyle;
|
||||
}
|
||||
void set(Windows::UI::Xaml::Style^ val)
|
||||
{
|
||||
m_nonEditableOperatorStyle = val;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Style^ m_editableOperatorStyle;
|
||||
Windows::UI::Xaml::Style^ m_nonEditableOperatorStyle;
|
||||
Windows::UI::Xaml::Style^ m_operandStyle;
|
||||
Windows::UI::Xaml::Style^ m_separatorStyle;
|
||||
};
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="using:CalculatorApp.ViewModel"
|
||||
Loaded="OnLoaded"
|
||||
mc:Ignorable="d">
|
||||
|
||||
|
@ -19,20 +18,20 @@
|
|||
<TextBlock Margin="2,0,0,0"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
|
||||
IsTextScaleFactorEnabled="False"
|
||||
Text="{Binding Token, Mode=OneWay}"/>
|
||||
Text="{x:Bind Token, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="Operator" x:DataType="common:DisplayExpressionToken">
|
||||
<TextBlock Margin="2,0,0,0"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
|
||||
IsTextScaleFactorEnabled="False"
|
||||
Text="{Binding Token, Mode=OneWay}"/>
|
||||
Text="{x:Bind Token, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="Separator" x:DataType="common:DisplayExpressionToken">
|
||||
<TextBlock x:Name="MainText"
|
||||
IsTextScaleFactorEnabled="False"
|
||||
Text="{Binding Token, Mode=OneWay}"/>
|
||||
Text="{x:Bind Token, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- TextBox Styles -->
|
||||
|
@ -42,119 +41,59 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:OverflowTextBlock">
|
||||
<Border x:Name="ExpressionBorder" Background="Transparent">
|
||||
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer x:Name="ExpressionContainer"
|
||||
Grid.Column="1"
|
||||
Padding="0,0,0,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Style="{StaticResource ResultsScrollerSnapped}"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
LayoutUpdated="expressionContainer_LayoutUpdated">
|
||||
<ListView x:Name="TokenList"
|
||||
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="12"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ScrollViewer x:Name="ExpressionContainer"
|
||||
Grid.Column="1"
|
||||
Padding="0,0,0,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
Style="{StaticResource ResultsScrollerSnapped}"
|
||||
AutomationProperties.AccessibilityView="Raw">
|
||||
<ItemsControl x:Name="TokenList"
|
||||
Padding="0"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Right"
|
||||
VerticalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
ItemContainerStyleSelector="{StaticResource ExpressionItemContainerStyle}"
|
||||
ItemTemplateSelector="{StaticResource ExpressionItemTemplateSelector}"
|
||||
ItemsSource="{Binding ExpressionTokens}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
|
||||
ScrollViewer.HorizontalScrollMode="Enabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollMode="Disabled"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel HorizontalAlignment="Right"
|
||||
VerticalAlignment="Stretch"
|
||||
Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemContainerTransitions>
|
||||
<TransitionCollection/>
|
||||
</ListView.ItemContainerTransitions>
|
||||
</ListView>
|
||||
</ScrollViewer>
|
||||
<Button x:Name="ScrollLeft"
|
||||
x:Uid="scrollLeft"
|
||||
Grid.Column="0"
|
||||
Margin="-4,3,-4,0"
|
||||
Style="{StaticResource ScrollButtonStyle}">
|
||||
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
Glyph=""/>
|
||||
</Button>
|
||||
<Button x:Name="ScrollRight"
|
||||
x:Uid="scrollRight"
|
||||
Grid.Column="2"
|
||||
Margin="0,3,-9,0"
|
||||
Style="{StaticResource ScrollButtonStyle}">
|
||||
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
Glyph=""/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
ItemsSource="{Binding ExpressionTokens}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsStackPanel HorizontalAlignment="Right"
|
||||
VerticalAlignment="Stretch"
|
||||
Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<Button x:Name="ScrollLeft"
|
||||
x:Uid="scrollLeft"
|
||||
Grid.Column="0"
|
||||
Margin="-4,3,-4,0"
|
||||
Style="{StaticResource ScrollButtonStyle}">
|
||||
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
Glyph=""/>
|
||||
</Button>
|
||||
<Button x:Name="ScrollRight"
|
||||
x:Uid="scrollRight"
|
||||
Grid.Column="2"
|
||||
Margin="0,3,-9,0"
|
||||
Style="{StaticResource ScrollButtonStyle}">
|
||||
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}"
|
||||
FontSize="12"
|
||||
Glyph=""/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- ListViewItem Styles -->
|
||||
|
||||
<Style x:Key="ExpressionBaseContainerStyle" TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="MinWidth" Value="0"/>
|
||||
<Setter Property="MinHeight" Value="0"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListViewItem">
|
||||
<ListViewItemPresenter Padding="0"
|
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
ContentMargin="0"
|
||||
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
|
||||
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
|
||||
PointerOverBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
|
||||
PointerOverBackgroundMargin="0"
|
||||
SelectedBackground="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
SelectedBorderThickness="0"
|
||||
SelectedForeground="{ThemeResource SystemControlForegroundChromeWhiteBrush}"
|
||||
SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
|
||||
SelectedPointerOverBorderBrush="Transparent"
|
||||
SelectionCheckMarkVisualEnabled="False"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="NonEditableOperatorContainerStyle"
|
||||
BasedOn="{StaticResource ExpressionBaseContainerStyle}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="IsHitTestVisible" Value="False"/>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="MinWidth" Value="4"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="EditableOperatorContainerStyle"
|
||||
BasedOn="{StaticResource ExpressionBaseContainerStyle}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="IsHitTestVisible" Value="True"/>
|
||||
<Setter Property="MinWidth" Value="32"/>
|
||||
</Style>
|
||||
|
||||
<!-- Calculation Result Styles -->
|
||||
<Style x:Key="ResultsStyle"
|
||||
BasedOn="{StaticResource CalculationResultStyle}"
|
||||
|
@ -313,12 +252,6 @@
|
|||
OperatorTemplate="{StaticResource Operator}"
|
||||
SeparatorTemplate="{StaticResource Separator}"/>
|
||||
|
||||
<converters:ExpressionItemContainerStyle x:Key="ExpressionItemContainerStyle"
|
||||
EditableOperatorStyle="{StaticResource NonEditableOperatorContainerStyle}"
|
||||
NonEditableOperatorStyle="{StaticResource NonEditableOperatorContainerStyle}"
|
||||
OperandStyle="{StaticResource NonEditableOperatorContainerStyle}"
|
||||
SeparatorStyle="{StaticResource NonEditableOperatorContainerStyle}"/>
|
||||
|
||||
<!-- Miscellaneous Resources -->
|
||||
|
||||
<automation:NarratorNotifier x:Name="NarratorNotifier" Announcement="{x:Bind Model.Announcement, Mode=OneWay}"/>
|
||||
|
@ -528,7 +461,7 @@
|
|||
AutomationProperties.AutomationId="CalculatorExpression"
|
||||
AutomationProperties.Name="{x:Bind Model.CalculationExpressionAutomationName, Mode=OneWay}"
|
||||
IsTabStop="False"
|
||||
TokensUpdated="{Binding AreTokensUpdated, Mode=OneWay}"/>
|
||||
TokensUpdated="{x:Bind Model.AreTokensUpdated, Mode=OneWay}"/>
|
||||
|
||||
<!-- Programmer display panel controls -->
|
||||
<local:CalculatorProgrammerOperators x:Name="ProgrammerOperators"
|
||||
|
|
|
@ -659,11 +659,6 @@ void Calculator::OnHistoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEve
|
|||
}
|
||||
}
|
||||
|
||||
void Calculator::expressionContainer_LayoutUpdated(_In_ Object^ sender, _In_ Object^ e)
|
||||
{
|
||||
ExpressionText->UpdateScrollButtons();
|
||||
}
|
||||
|
||||
bool Calculator::IsValidRegularExpression(std::wstring str)
|
||||
{
|
||||
bool result = false;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "Views/Calculator.g.h"
|
||||
#include "Converters/BooleanNegationConverter.h"
|
||||
#include "Converters/ExpressionItemContainerStyle.h"
|
||||
#include "Converters/ExpressionItemTemplateSelector.h"
|
||||
#include "Converters/VisibilityNegationConverter.h"
|
||||
#include "CalcViewModel/Common/Automation/NarratorNotifier.h"
|
||||
|
@ -130,7 +129,6 @@ namespace CalculatorApp
|
|||
void EnableMemoryControls(bool enable);
|
||||
void OnMemoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnHistoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void expressionContainer_LayoutUpdated(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
bool IsValidRegularExpression(std::wstring str);
|
||||
void DockPanelTapped(_In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnErrorLayoutCompleted(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue