forked from microsoft/calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HistoryItemViewModel.cpp
43 lines (37 loc) · 1.42 KB
/
HistoryItemViewModel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "HistoryItemViewModel.h"
#include "Common/LocalizationService.h"
using namespace CalculatorApp::Common;
using namespace CalculatorApp::ViewModel;
using namespace std;
using namespace Platform;
HistoryItemViewModel::HistoryItemViewModel(
String ^ expression,
String ^ result,
_In_ const shared_ptr<vector<pair<wstring, int>>>& spTokens,
_In_ const shared_ptr<vector<shared_ptr<IExpressionCommand>>>& spCommands)
: m_expression(expression)
, m_result(result)
, m_spTokens(spTokens)
, m_spCommands(spCommands)
{
// updating accessibility names for expression and result
m_accExpression = HistoryItemViewModel::GetAccessibleExpressionFromTokens(spTokens, m_expression);
m_accResult = LocalizationService::GetNarratorReadableString(m_result);
}
String
^ HistoryItemViewModel::GetAccessibleExpressionFromTokens(
_In_ shared_ptr<vector<pair<wstring, int>>> const& spTokens,
_In_ String ^ fallbackExpression)
{
// updating accessibility names for expression and result
wstringstream accExpression{};
accExpression << L"";
for (const auto& tokenItem : *spTokens)
{
accExpression << LocalizationService::GetNarratorReadableToken(StringReference(tokenItem.first.c_str()))->Data();
}
return ref new String(accExpression.str().c_str());
}