mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-20 05:13:11 -07:00
stash changes
This commit is contained in:
parent
3e45a394ce
commit
1645cfddcd
10 changed files with 167 additions and 71 deletions
|
@ -512,9 +512,9 @@ void ApplicationViewModel::Categories::set(IObservableVector<NavCategoryGroup ^>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationSnapshot ^ ApplicationViewModel::Snapshot::get()
|
CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot ^ ApplicationViewModel::Snapshot::get()
|
||||||
{
|
{
|
||||||
auto snapshot = ref new ApplicationSnapshot();
|
auto snapshot = ref new CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot();
|
||||||
snapshot->Mode = static_cast<int>(Mode);
|
snapshot->Mode = static_cast<int>(Mode);
|
||||||
if (m_CalculatorViewModel != nullptr && m_mode == ViewMode::Standard)
|
if (m_CalculatorViewModel != nullptr && m_mode == ViewMode::Standard)
|
||||||
{
|
{
|
||||||
|
@ -556,7 +556,7 @@ void ApplicationViewModel::Initialize(ViewMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationViewModel::Initialize(ApplicationSnapshot ^ snapshot)
|
void ApplicationViewModel::Initialize(CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot ^ snapshot)
|
||||||
{
|
{
|
||||||
// TODO: restore
|
// TODO: restore
|
||||||
Initialize(static_cast<ViewMode>(snapshot->Mode));
|
Initialize(static_cast<ViewMode>(snapshot->Mode));
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace CalculatorApp
|
||||||
|
|
||||||
[Windows::Foundation::Metadata::DefaultOverload]
|
[Windows::Foundation::Metadata::DefaultOverload]
|
||||||
void Initialize(CalculatorApp::ViewModel::Common::ViewMode mode); // Use for first init, use deserialize for rehydration
|
void Initialize(CalculatorApp::ViewModel::Common::ViewMode mode); // Use for first init, use deserialize for rehydration
|
||||||
void Initialize(ApplicationSnapshot^ snapshot);
|
void Initialize(CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot^ snapshot);
|
||||||
|
|
||||||
OBSERVABLE_OBJECT();
|
OBSERVABLE_OBJECT();
|
||||||
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel ^, CalculatorViewModel);
|
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel ^, CalculatorViewModel);
|
||||||
|
@ -73,9 +73,9 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property ApplicationSnapshot ^ Snapshot
|
property CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot ^ Snapshot
|
||||||
{
|
{
|
||||||
ApplicationSnapshot ^ get();
|
CalculatorApp::ViewModel::Snapshot::ApplicationSnapshot ^ get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static property Platform::String ^ LaunchedLocalSettings
|
static property Platform::String ^ LaunchedLocalSettings
|
||||||
|
|
|
@ -9,78 +9,64 @@
|
||||||
#include "CalcManager/ExpressionCommand.h"
|
#include "CalcManager/ExpressionCommand.h"
|
||||||
#include "Snapshots.h"
|
#include "Snapshots.h"
|
||||||
|
|
||||||
namespace
|
namespace CalculatorApp::ViewModel::Snapshot
|
||||||
{
|
{
|
||||||
ref struct UnaryCommand sealed : public CalculatorApp::ViewModel::ICalcManagerIExprCommand
|
UnaryCommand::UnaryCommand(Windows::Foundation::Collections::IVectorView<int> ^ cmds)
|
||||||
{
|
{
|
||||||
internal :;
|
for (auto cmd : cmds)
|
||||||
std::vector<int> Commands;
|
{
|
||||||
};
|
m_cmds.push_back(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ref struct BinaryCommand sealed : public CalculatorApp::ViewModel::ICalcManagerIExprCommand
|
Windows::Foundation::Collections::IVectorView<int> ^ UnaryCommand::Commands::get()
|
||||||
{
|
{
|
||||||
internal :;
|
return ref new Platform::Collections::VectorView<int>(m_cmds);
|
||||||
int Command;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
ref struct OperandCommand sealed : public CalculatorApp::ViewModel::ICalcManagerIExprCommand
|
OperandCommand::OperandCommand(bool isNegative, bool isDecimal, bool isSciFmt, Windows::Foundation::Collections::IVectorView<int> ^ cmds)
|
||||||
{
|
{
|
||||||
internal :;
|
IsNegative = isNegative;
|
||||||
bool IsNegative;
|
IsDecimalPresent = isDecimal;
|
||||||
bool IsDecimalPresent;
|
IsSciFmt = isSciFmt;
|
||||||
bool IsSciFmt;
|
for (auto cmd : cmds)
|
||||||
std::vector<int> Commands;
|
{
|
||||||
};
|
m_cmds.push_back(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ref struct Parentheses sealed : public CalculatorApp::ViewModel::ICalcManagerIExprCommand
|
|
||||||
{
|
|
||||||
internal :;
|
|
||||||
int Command;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace CalculatorApp::ViewModel
|
|
||||||
{
|
|
||||||
ICalcManagerIExprCommand ^ CreateExprCommand(const IExpressionCommand* exprCmd) {
|
ICalcManagerIExprCommand ^ CreateExprCommand(const IExpressionCommand* exprCmd) {
|
||||||
switch (exprCmd->GetCommandType())
|
switch (exprCmd->GetCommandType())
|
||||||
{
|
{
|
||||||
case CalculationManager::CommandType::UnaryCommand:
|
case CalculationManager::CommandType::UnaryCommand:
|
||||||
{
|
{
|
||||||
auto cmd = static_cast<const IUnaryCommand*>(exprCmd);
|
auto cmd = static_cast<const IUnaryCommand*>(exprCmd);
|
||||||
auto result = ref new UnaryCommand();
|
std::vector<int> cmdlist;
|
||||||
for (auto& subcmd : *cmd->GetCommands())
|
for (auto& subcmd : *cmd->GetCommands())
|
||||||
{
|
{
|
||||||
result->Commands.push_back(subcmd);
|
cmdlist.push_back(subcmd);
|
||||||
}
|
}
|
||||||
return result;
|
return ref new UnaryCommand(std::move(cmdlist));
|
||||||
}
|
}
|
||||||
case CalculationManager::CommandType::BinaryCommand:
|
case CalculationManager::CommandType::BinaryCommand:
|
||||||
{
|
{
|
||||||
auto cmd = static_cast<const IBinaryCommand*>(exprCmd);
|
auto cmd = static_cast<const IBinaryCommand*>(exprCmd);
|
||||||
auto result = ref new BinaryCommand();
|
return ref new BinaryCommand(cmd->GetCommand());
|
||||||
result->Command = cmd->GetCommand();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
case CalculationManager::CommandType::OperandCommand:
|
case CalculationManager::CommandType::OperandCommand:
|
||||||
{
|
{
|
||||||
auto cmd = static_cast<const IOpndCommand*>(exprCmd);
|
auto cmd = static_cast<const IOpndCommand*>(exprCmd);
|
||||||
auto result = ref new OperandCommand();
|
std::vector<int> cmdlist;
|
||||||
result->IsNegative = cmd->IsNegative();
|
|
||||||
result->IsDecimalPresent = cmd->IsDecimalPresent();
|
|
||||||
result->IsSciFmt = cmd->IsSciFmt();
|
|
||||||
for (auto& subcmd : *cmd->GetCommands())
|
for (auto& subcmd : *cmd->GetCommands())
|
||||||
{
|
{
|
||||||
result->Commands.push_back(subcmd);
|
cmdlist.push_back(subcmd);
|
||||||
}
|
}
|
||||||
return result;
|
return ref new OperandCommand(cmd->IsNegative(), cmd->IsDecimalPresent(), cmd->IsSciFmt(), std::move(cmdlist));
|
||||||
}
|
}
|
||||||
case CalculationManager::CommandType::Parentheses:
|
case CalculationManager::CommandType::Parentheses:
|
||||||
{
|
{
|
||||||
auto cmd = static_cast<const IParenthesisCommand*>(exprCmd);
|
auto cmd = static_cast<const IParenthesisCommand*>(exprCmd);
|
||||||
auto result = ref new Parentheses();
|
return ref new Parentheses(cmd->GetCommand());
|
||||||
result->Command = cmd->GetCommand();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw std::logic_error{ "unhandled command type." };
|
throw std::logic_error{ "unhandled command type." };
|
||||||
|
@ -161,13 +147,13 @@ namespace CalculatorApp::ViewModel
|
||||||
{
|
{
|
||||||
if (auto unary = dynamic_cast<UnaryCommand ^>(cmdEntry); unary != nullptr)
|
if (auto unary = dynamic_cast<UnaryCommand ^>(cmdEntry); unary != nullptr)
|
||||||
{
|
{
|
||||||
if (unary->Commands.size() == 1)
|
if (unary->m_cmds.size() == 1)
|
||||||
{
|
{
|
||||||
result.push_back(std::make_shared<CUnaryCommand>(unary->Commands[0]));
|
result.push_back(std::make_shared<CUnaryCommand>(unary->m_cmds[0]));
|
||||||
}
|
}
|
||||||
else if (unary->Commands.size() == 2)
|
else if (unary->m_cmds.size() == 2)
|
||||||
{
|
{
|
||||||
result.push_back(std::make_shared<CUnaryCommand>(unary->Commands[0], unary->Commands[1]));
|
result.push_back(std::make_shared<CUnaryCommand>(unary->m_cmds[0], unary->m_cmds[1]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -184,7 +170,7 @@ namespace CalculatorApp::ViewModel
|
||||||
}
|
}
|
||||||
else if (auto operand = dynamic_cast<OperandCommand ^>(cmdEntry); operand != nullptr)
|
else if (auto operand = dynamic_cast<OperandCommand ^>(cmdEntry); operand != nullptr)
|
||||||
{
|
{
|
||||||
auto subcmds = std::make_shared<std::vector<int>>(operand->Commands);
|
auto subcmds = std::make_shared<std::vector<int>>(operand->m_cmds);
|
||||||
result.push_back(std::make_shared<COpndCommand>(std::move(subcmds), operand->IsNegative, operand->IsDecimalPresent, operand->IsSciFmt));
|
result.push_back(std::make_shared<COpndCommand>(std::move(subcmds), operand->IsNegative, operand->IsDecimalPresent, operand->IsSciFmt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,70 @@
|
||||||
|
|
||||||
#include "CalcManager/CalculatorManager.h"
|
#include "CalcManager/CalculatorManager.h"
|
||||||
|
|
||||||
namespace CalculatorApp::ViewModel
|
namespace CalculatorApp::ViewModel::Snapshot
|
||||||
{
|
{
|
||||||
public
|
public
|
||||||
interface struct ICalcManagerIExprCommand
|
interface struct ICalcManagerIExprCommand
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ref struct UnaryCommand sealed : public ICalcManagerIExprCommand
|
||||||
|
{
|
||||||
|
property Windows::Foundation::Collections::IVectorView<int> ^ Commands { Windows::Foundation::Collections::IVectorView<int> ^ get(); };
|
||||||
|
|
||||||
|
explicit UnaryCommand(Windows::Foundation::Collections::IVectorView<int> ^ cmds);
|
||||||
|
|
||||||
|
internal :;
|
||||||
|
explicit UnaryCommand(std::vector<int> cmds)
|
||||||
|
: m_cmds(std::move(cmds))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
std::vector<int> m_cmds;
|
||||||
|
};
|
||||||
|
|
||||||
|
ref struct BinaryCommand sealed : public ICalcManagerIExprCommand
|
||||||
|
{
|
||||||
|
property int Command;
|
||||||
|
explicit BinaryCommand(int cmd)
|
||||||
|
{
|
||||||
|
Command = cmd;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ref struct OperandCommand sealed : public ICalcManagerIExprCommand
|
||||||
|
{
|
||||||
|
property bool IsNegative;
|
||||||
|
property bool IsDecimalPresent;
|
||||||
|
property bool IsSciFmt;
|
||||||
|
property Windows::Foundation::Collections::IVectorView<int> ^ Commands { Windows::Foundation::Collections::IVectorView<int> ^ get(); };
|
||||||
|
|
||||||
|
explicit OperandCommand(bool isNegative, bool isDecimal, bool isSciFmt, Windows::Foundation::Collections::IVectorView<int> ^ cmds);
|
||||||
|
internal :;
|
||||||
|
explicit OperandCommand(bool isNegative, bool isDecimal, bool isSciFmt, std::vector<int> cmds)
|
||||||
|
{
|
||||||
|
IsNegative = isNegative;
|
||||||
|
IsDecimalPresent = isDecimal;
|
||||||
|
IsSciFmt = isSciFmt;
|
||||||
|
m_cmds = std::move(cmds);
|
||||||
|
}
|
||||||
|
std::vector<int> m_cmds;
|
||||||
|
};
|
||||||
|
|
||||||
|
ref struct Parentheses sealed : public ICalcManagerIExprCommand
|
||||||
|
{
|
||||||
|
property int Command;
|
||||||
|
explicit Parentheses(int cmd)
|
||||||
|
{
|
||||||
|
Command = cmd;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public
|
public
|
||||||
ref struct CalcManagerHistoryToken sealed
|
ref struct CalcManagerHistoryToken sealed
|
||||||
{
|
{
|
||||||
property Platform::String ^ OpCodeName; // mandatory
|
property Platform::String ^ OpCodeName; // mandatory
|
||||||
property int CommandIndex;
|
property int CommandIndex;
|
||||||
|
|
||||||
internal :;
|
|
||||||
explicit CalcManagerHistoryToken(Platform::String ^ opCodeName, int cmdIndex);
|
explicit CalcManagerHistoryToken(Platform::String ^ opCodeName, int cmdIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,6 +82,12 @@ public
|
||||||
property Platform::String ^ Expression; // mandatory
|
property Platform::String ^ Expression; // mandatory
|
||||||
property Platform::String ^ Result; // mandatory
|
property Platform::String ^ Result; // mandatory
|
||||||
|
|
||||||
|
// explicit CalcManagerHistoryItem(
|
||||||
|
// Windows::Foundation::Collections::IVector<CalcManagerHistoryToken ^> ^ tokens,
|
||||||
|
// Windows::Foundation::Collections::IVector<ICalcManagerIExprCommand ^> ^ commands,
|
||||||
|
// Platform::String ^ expression,
|
||||||
|
// Platform::String ^ result);
|
||||||
|
|
||||||
internal :;
|
internal :;
|
||||||
explicit CalcManagerHistoryItem(const CalculationManager::HISTORYITEM& item);
|
explicit CalcManagerHistoryItem(const CalculationManager::HISTORYITEM& item);
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,7 +115,7 @@ namespace CalculatorResourceKeys
|
||||||
StringReference DisplayCopied(L"Display_Copied");
|
StringReference DisplayCopied(L"Display_Copied");
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardCalculatorViewModel::StandardCalculatorViewModel(StandardCalculatorSnapshot ^ snapshot)
|
StandardCalculatorViewModel::StandardCalculatorViewModel(CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ snapshot)
|
||||||
: m_DisplayValue(L"0")
|
: m_DisplayValue(L"0")
|
||||||
, m_DecimalDisplayValue(L"0")
|
, m_DecimalDisplayValue(L"0")
|
||||||
, m_HexDisplayValue(L"0")
|
, m_HexDisplayValue(L"0")
|
||||||
|
@ -208,7 +208,7 @@ StandardCalculatorViewModel::StandardCalculatorViewModel(StandardCalculatorSnaps
|
||||||
{
|
{
|
||||||
using RawTokenCollection = std::vector<std::pair<std::wstring, int>>;
|
using RawTokenCollection = std::vector<std::pair<std::wstring, int>>;
|
||||||
RawTokenCollection rawTokens;
|
RawTokenCollection rawTokens;
|
||||||
for (CalcManagerHistoryToken ^ token : snapshot->ExpressionDisplay->Tokens)
|
for (CalculatorApp::ViewModel::Snapshot::CalcManagerHistoryToken ^ token : snapshot->ExpressionDisplay->Tokens)
|
||||||
{
|
{
|
||||||
rawTokens.push_back(std::pair{ token->OpCodeName->Data(), token->CommandIndex });
|
rawTokens.push_back(std::pair{ token->OpCodeName->Data(), token->CommandIndex });
|
||||||
}
|
}
|
||||||
|
@ -1823,18 +1823,18 @@ void StandardCalculatorViewModel::SetBitshiftRadioButtonCheckedAnnouncement(Plat
|
||||||
Announcement = CalculatorAnnouncement::GetBitShiftRadioButtonCheckedAnnouncement(announcement);
|
Announcement = CalculatorAnnouncement::GetBitShiftRadioButtonCheckedAnnouncement(announcement);
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardCalculatorSnapshot ^ StandardCalculatorViewModel::GetSnapshot() const
|
CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ StandardCalculatorViewModel::GetSnapshot() const
|
||||||
{
|
{
|
||||||
auto result = ref new StandardCalculatorSnapshot();
|
auto result = ref new CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot();
|
||||||
result->CalcManager = ref new CalcManagerSnapshot(m_standardCalculatorManager);
|
result->CalcManager = ref new CalculatorApp::ViewModel::Snapshot::CalcManagerSnapshot(m_standardCalculatorManager);
|
||||||
result->PrimaryDisplay = ref new PrimaryDisplaySnapshot(m_DisplayValue, m_IsInError);
|
result->PrimaryDisplay = ref new CalculatorApp::ViewModel::Snapshot::PrimaryDisplaySnapshot(m_DisplayValue, m_IsInError);
|
||||||
result->ExpressionDisplay = ref new ExpressionDisplaySnapshot(*m_tokens, *m_commands);
|
result->ExpressionDisplay = ref new CalculatorApp::ViewModel::Snapshot::ExpressionDisplaySnapshot(*m_tokens, *m_commands);
|
||||||
result->DisplayCommands = ref new Platform::Collections::Vector<ICalcManagerIExprCommand ^>();
|
result->DisplayCommands = ref new Platform::Collections::Vector<CalculatorApp::ViewModel::Snapshot::ICalcManagerIExprCommand ^>();
|
||||||
for (auto cmd : m_standardCalculatorManager.GetDisplayCommandsSnapshot())
|
for (auto cmd : m_standardCalculatorManager.GetDisplayCommandsSnapshot())
|
||||||
{
|
{
|
||||||
result->DisplayCommands->Append(CreateExprCommand(cmd.get()));
|
result->DisplayCommands->Append(CalculatorApp::ViewModel::Snapshot::CreateExprCommand(cmd.get()));
|
||||||
}
|
}
|
||||||
return nullptr;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// StandardCalculatorSnapshot StandardCalculatorViewModel::GetStandardCalculatorSnapshot() const
|
// StandardCalculatorSnapshot StandardCalculatorViewModel::GetStandardCalculatorSnapshot() const
|
||||||
|
|
|
@ -268,8 +268,8 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property StandardCalculatorSnapshot
|
property CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot
|
||||||
^ Snapshot { StandardCalculatorSnapshot ^ get() { return GetSnapshot(); } }
|
^ Snapshot { CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ get() { return GetSnapshot(); } }
|
||||||
|
|
||||||
// Used by unit tests
|
// Used by unit tests
|
||||||
void
|
void
|
||||||
|
@ -327,10 +327,10 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
|
|
||||||
internal :;
|
internal :;
|
||||||
explicit StandardCalculatorViewModel(StandardCalculatorSnapshot ^ snapshot = nullptr);
|
explicit StandardCalculatorViewModel(CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ snapshot = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StandardCalculatorSnapshot ^ GetSnapshot() const;
|
CalculatorApp::ViewModel::Snapshot::StandardCalculatorSnapshot ^ GetSnapshot() const;
|
||||||
void SetMemorizedNumbers(const std::vector<std::wstring>& memorizedNumbers);
|
void SetMemorizedNumbers(const std::vector<std::wstring>& memorizedNumbers);
|
||||||
void UpdateProgrammerPanelDisplay();
|
void UpdateProgrammerPanelDisplay();
|
||||||
void HandleUpdatedOperandData(CalculationManager::Command cmdenum);
|
void HandleUpdatedOperandData(CalculationManager::Command cmdenum);
|
||||||
|
|
|
@ -167,6 +167,7 @@
|
||||||
<Compile Include="Selectors\NavViewMenuItemTemplateSelector.cs" />
|
<Compile Include="Selectors\NavViewMenuItemTemplateSelector.cs" />
|
||||||
<Compile Include="Utils\ResourceVirtualKey.cs" />
|
<Compile Include="Utils\ResourceVirtualKey.cs" />
|
||||||
<Compile Include="Utils\ResourceString.cs" />
|
<Compile Include="Utils\ResourceString.cs" />
|
||||||
|
<Compile Include="Utils\SerdeUtils.cs" />
|
||||||
<Compile Include="Utils\ThemeHelper.cs" />
|
<Compile Include="Utils\ThemeHelper.cs" />
|
||||||
<Compile Include="Views\GraphingCalculator\EquationStylePanelControl.xaml.cs">
|
<Compile Include="Views\GraphingCalculator\EquationStylePanelControl.xaml.cs">
|
||||||
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
<DependentUpon>EquationStylePanelControl.xaml</DependentUpon>
|
||||||
|
@ -799,6 +800,9 @@
|
||||||
<Version>6.2.14</Version>
|
<Version>6.2.14</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.1" />
|
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.1" />
|
||||||
|
<PackageReference Include="System.Text.Json">
|
||||||
|
<Version>8.0.5</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj">
|
<ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj">
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
using System;
|
|
||||||
using Windows.ApplicationModel.Activation;
|
using Windows.ApplicationModel.Activation;
|
||||||
using Windows.ApplicationModel.UserActivities;
|
using CalculatorApp.ViewModel.Snapshot;
|
||||||
using CalculatorApp.ViewModel;
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
||||||
|
|
49
src/Calculator/Utils/SerdeUtils.cs
Normal file
49
src/Calculator/Utils/SerdeUtils.cs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using CalculatorApp.ViewModel.Snapshot;
|
||||||
|
|
||||||
|
namespace CalculatorApp
|
||||||
|
{
|
||||||
|
internal class CalcManagerHistoryTokenAlias
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public CalcManagerHistoryToken Value;
|
||||||
|
|
||||||
|
[JsonPropertyName("t")]
|
||||||
|
public string OpCodeName
|
||||||
|
{
|
||||||
|
get => Value.OpCodeName;
|
||||||
|
set => Value.OpCodeName = value;
|
||||||
|
}
|
||||||
|
[JsonPropertyName("c")]
|
||||||
|
public int CommandIndex { get => Value.CommandIndex; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CalcManagerIExprCommandAlias
|
||||||
|
{
|
||||||
|
[JsonPropertyName("t")]
|
||||||
|
public string Type;
|
||||||
|
|
||||||
|
[JsonPropertyName("c")]
|
||||||
|
public string CmdString;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CalcManagerHistoryItemAlias
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public CalcManagerHistoryItem Value;
|
||||||
|
|
||||||
|
[JsonPropertyName("t")]
|
||||||
|
public IList<CalcManagerHistoryTokenAlias> Tokens
|
||||||
|
{
|
||||||
|
get => Value.Tokens.Select(x => new CalcManagerHistoryTokenAlias { Value = x }).ToList();
|
||||||
|
set => Value.Tokens = value.Select(x => new CalcManagerHistoryToken(x.OpCodeName, x.CommandIndex)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//public IList<CalcManagerIExprCommandAlias> Commands
|
||||||
|
//{
|
||||||
|
// get => Value.Commands;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ using CalculatorApp.ViewModel.Common;
|
||||||
using CalculatorApp.ViewModel.Common.Automation;
|
using CalculatorApp.ViewModel.Common.Automation;
|
||||||
|
|
||||||
using wuxc = Windows.UI.Xaml.Controls;
|
using wuxc = Windows.UI.Xaml.Controls;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
||||||
|
@ -69,6 +70,8 @@ namespace CalculatorApp
|
||||||
}
|
}
|
||||||
var channel = UserActivityChannel.GetDefault();
|
var channel = UserActivityChannel.GetDefault();
|
||||||
var activity = await channel.GetOrCreateUserActivityAsync($"{Guid.NewGuid()}");
|
var activity = await channel.GetOrCreateUserActivityAsync($"{Guid.NewGuid()}");
|
||||||
|
var s = Model.Snapshot;
|
||||||
|
var j = JsonSerializer.Serialize(s);
|
||||||
activity.ActivationUri = new Uri($"ms-calculator:snapshot/TODO");
|
activity.ActivationUri = new Uri($"ms-calculator:snapshot/TODO");
|
||||||
activity.IsRoamable = false;
|
activity.IsRoamable = false;
|
||||||
var resProvider = AppResourceProvider.GetInstance();
|
var resProvider = AppResourceProvider.GetInstance();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue