mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-23 06:25:19 -07:00
Add support for history listing
This commit is contained in:
parent
332ccadc1b
commit
e5cdaeaf0d
12 changed files with 423 additions and 236 deletions
|
@ -83,13 +83,13 @@ public:
|
||||||
{
|
{
|
||||||
DBGPRINT("Native:SetExpressionDisplay()\n");
|
DBGPRINT("Native:SetExpressionDisplay()\n");
|
||||||
|
|
||||||
auto item = std::make_shared<HISTORYITEM>();
|
auto item = std::make_shared<HISTORYITEM>();
|
||||||
item->historyItemVector.expression = L"";
|
item->historyItemVector.expression = L"";
|
||||||
item->historyItemVector.result = L"";
|
item->historyItemVector.result = L"";
|
||||||
item->historyItemVector.spCommands = commands;
|
item->historyItemVector.spCommands = commands;
|
||||||
item->historyItemVector.spTokens = tokens;
|
item->historyItemVector.spTokens = tokens;
|
||||||
|
|
||||||
auto pItem = MarshalHistoryItem(item);
|
auto pItem = MarshalHistoryItem(item);
|
||||||
|
|
||||||
_params.SetExpressionDisplay(_params.CalculatorState, pItem);
|
_params.SetExpressionDisplay(_params.CalculatorState, pItem);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +187,21 @@ IExpressionCommand* AsIExpressionCommand(void* pExpressionCommand)
|
||||||
return static_cast<IExpressionCommand*>(pExpressionCommand);
|
return static_cast<IExpressionCommand*>(pExpressionCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
COpndCommand* AsCOpndCommand(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
return static_cast<COpndCommand*>(pExpressionCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
CUnaryCommand* AsCUnaryCommand(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
return static_cast<CUnaryCommand*>(pExpressionCommand);
|
||||||
|
}
|
||||||
|
|
||||||
|
CBinaryCommand* AsCBinaryCommand(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
return static_cast<CBinaryCommand*>(pExpressionCommand);
|
||||||
|
}
|
||||||
|
|
||||||
const wchar_t* ToWChar(std::wstring& str)
|
const wchar_t* ToWChar(std::wstring& str)
|
||||||
{
|
{
|
||||||
auto out = new wchar_t[str.size() + 1]{};
|
auto out = new wchar_t[str.size() + 1]{};
|
||||||
|
@ -270,7 +285,6 @@ void* MarshalHistoryItems(std::vector<std::shared_ptr<CalculationManager::HISTOR
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void* CalculatorManager_Create(CalculatorManager_CreateParams* pParams)
|
void* CalculatorManager_Create(CalculatorManager_CreateParams* pParams)
|
||||||
{
|
{
|
||||||
auto calcDisplay = new CalcDisplay(*pParams);
|
auto calcDisplay = new CalcDisplay(*pParams);
|
||||||
|
@ -423,10 +437,71 @@ void* CalculatorManager_GetHistoryItem(void* manager, int index)
|
||||||
{
|
{
|
||||||
auto historyItem = AsManager(manager)->GetHistoryItem(index);
|
auto historyItem = AsManager(manager)->GetHistoryItem(index);
|
||||||
|
|
||||||
return MarshalHistoryItem(historyItem);
|
return MarshalHistoryItem(historyItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Free(void* ptr)
|
||||||
|
{
|
||||||
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IExpressionCommand_GetCommandType(void* pExpressionCommand)
|
int IExpressionCommand_GetCommandType(void* pExpressionCommand)
|
||||||
{
|
{
|
||||||
return (int)AsIExpressionCommand(pExpressionCommand)->GetCommandType();
|
return (int)AsIExpressionCommand(pExpressionCommand)->GetCommandType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* COpndCommand_GetCommands(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
auto res = AsCOpndCommand(pExpressionCommand)->GetCommands();
|
||||||
|
|
||||||
|
auto pRes = (COpndCommand_GetCommandsResult*)malloc(sizeof(COpndCommand_GetCommandsResult));
|
||||||
|
|
||||||
|
unsigned int commandCount;
|
||||||
|
res->GetSize(&commandCount);
|
||||||
|
pRes->CommandCount = commandCount;
|
||||||
|
|
||||||
|
auto pCommands = (int32_t*)malloc(commandCount * sizeof(int32_t));
|
||||||
|
pRes->pCommands = pCommands;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < commandCount; i++)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
res->GetAt(i, &value);
|
||||||
|
pCommands[i] = (int32_t)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* CUnaryCommand_GetCommands(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
auto res = AsCUnaryCommand(pExpressionCommand)->GetCommands();
|
||||||
|
|
||||||
|
auto pRes = (CUnaryCommand_GetCommandsResult*)malloc(sizeof(CUnaryCommand_GetCommandsResult));
|
||||||
|
|
||||||
|
unsigned int commandCount;
|
||||||
|
res->GetSize(&commandCount);
|
||||||
|
pRes->CommandCount = commandCount;
|
||||||
|
|
||||||
|
auto pCommands = (int32_t*)malloc(commandCount * sizeof(int32_t));
|
||||||
|
pRes->pCommands = pCommands;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < commandCount; i++)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
res->GetAt(i, &value);
|
||||||
|
pCommands[i] = (int32_t)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool COpndCommand_IsNegative(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
return (int)AsCOpndCommand(pExpressionCommand)->IsNegative();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CBinaryCommand_GetCommand(void* pExpressionCommand)
|
||||||
|
{
|
||||||
|
return (int)AsCBinaryCommand(pExpressionCommand)->GetCommand();
|
||||||
|
}
|
||||||
|
|
|
@ -22,22 +22,23 @@ typedef void (*MemoryItemChangedFunc)(void* state, unsigned int indexOfMemory);
|
||||||
|
|
||||||
typedef const wchar_t* (*GetCEngineStringFunc)(void* state, const wchar_t* id);
|
typedef const wchar_t* (*GetCEngineStringFunc)(void* state, const wchar_t* id);
|
||||||
|
|
||||||
struct CalculatorManager_CreateParams {
|
struct CalculatorManager_CreateParams
|
||||||
void* CalculatorState;
|
{
|
||||||
|
void* CalculatorState;
|
||||||
|
|
||||||
SetPrimaryDisplayFunc SetPrimaryDisplay;
|
SetPrimaryDisplayFunc SetPrimaryDisplay;
|
||||||
SetIsInErrorFunc SetIsInError;
|
SetIsInErrorFunc SetIsInError;
|
||||||
SetExpressionDisplayFunc SetExpressionDisplay;
|
SetExpressionDisplayFunc SetExpressionDisplay;
|
||||||
SetParenthesisNumberFunc SetParenthesisNumber;
|
SetParenthesisNumberFunc SetParenthesisNumber;
|
||||||
OnNoRightParenAddedFunc OnNoRightParenAdded;
|
OnNoRightParenAddedFunc OnNoRightParenAdded;
|
||||||
MaxDigitsReachedFunc MaxDigitsReached;
|
MaxDigitsReachedFunc MaxDigitsReached;
|
||||||
BinaryOperatorReceivedFunc BinaryOperatorReceived;
|
BinaryOperatorReceivedFunc BinaryOperatorReceived;
|
||||||
OnHistoryItemAddedFunc OnHistoryItemAdded;
|
OnHistoryItemAddedFunc OnHistoryItemAdded;
|
||||||
SetMemorizedNumbersFunc SetMemorizedNumbers;
|
SetMemorizedNumbersFunc SetMemorizedNumbers;
|
||||||
MemoryItemChangedFunc MemoryItemChanged;
|
MemoryItemChangedFunc MemoryItemChanged;
|
||||||
|
|
||||||
void* ResourceState;
|
void* ResourceState;
|
||||||
GetCEngineStringFunc GetCEngineString;
|
GetCEngineStringFunc GetCEngineString;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__EMSCRIPTEN__) || defined(__APPLE__)
|
#if defined(__EMSCRIPTEN__) || defined(__APPLE__)
|
||||||
|
@ -49,9 +50,9 @@ struct CalculatorManager_CreateParams {
|
||||||
GetHistoryItemResult* MarshalHistoryItem(std::shared_ptr<CalculationManager::HISTORYITEM>& historyItem);
|
GetHistoryItemResult* MarshalHistoryItem(std::shared_ptr<CalculationManager::HISTORYITEM>& historyItem);
|
||||||
void* MarshalHistoryItems(std::vector<std::shared_ptr<CalculationManager::HISTORYITEM>>& historyItems);
|
void* MarshalHistoryItems(std::vector<std::shared_ptr<CalculationManager::HISTORYITEM>>& historyItems);
|
||||||
|
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
struct GetHistoryItemsResult
|
struct GetHistoryItemsResult
|
||||||
{
|
{
|
||||||
int32_t ItemsCount;
|
int32_t ItemsCount;
|
||||||
void* HistoryItems;
|
void* HistoryItems;
|
||||||
|
@ -70,6 +71,18 @@ extern "C" {
|
||||||
void** Commands;
|
void** Commands;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct COpndCommand_GetCommandsResult
|
||||||
|
{
|
||||||
|
int32_t CommandCount;
|
||||||
|
int32_t* pCommands;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CUnaryCommand_GetCommandsResult
|
||||||
|
{
|
||||||
|
int32_t CommandCount;
|
||||||
|
int32_t* pCommands;
|
||||||
|
};
|
||||||
|
|
||||||
DLL_EXPORT void* CalculatorManager_Create(CalculatorManager_CreateParams* params);
|
DLL_EXPORT void* CalculatorManager_Create(CalculatorManager_CreateParams* params);
|
||||||
DLL_EXPORT void CalculatorManager_SendCommand(void* manager, int command);
|
DLL_EXPORT void CalculatorManager_SendCommand(void* manager, int command);
|
||||||
DLL_EXPORT void CalculatorManager_SetRadix(void* manager, RADIX_TYPE iRadixType);
|
DLL_EXPORT void CalculatorManager_SetRadix(void* manager, RADIX_TYPE iRadixType);
|
||||||
|
@ -98,6 +111,14 @@ extern "C" {
|
||||||
DLL_EXPORT void* CalculatorManager_GetHistoryItems(void* manager);
|
DLL_EXPORT void* CalculatorManager_GetHistoryItems(void* manager);
|
||||||
DLL_EXPORT void* CalculatorManager_GetHistoryItem(void* manager, int index);
|
DLL_EXPORT void* CalculatorManager_GetHistoryItem(void* manager, int index);
|
||||||
|
|
||||||
DLL_EXPORT int IExpressionCommand_GetCommandType(void* pExpressionCommand);
|
DLL_EXPORT void Free(void* ptr);
|
||||||
}
|
|
||||||
|
|
||||||
|
DLL_EXPORT int IExpressionCommand_GetCommandType(void* pExpressionCommand);
|
||||||
|
|
||||||
|
DLL_EXPORT void* COpndCommand_GetCommands(void* pExpressionCommand);
|
||||||
|
DLL_EXPORT bool COpndCommand_IsNegative(void* pExpressionCommand);
|
||||||
|
|
||||||
|
DLL_EXPORT void* CUnaryCommand_GetCommands(void* pExpressionCommand);
|
||||||
|
|
||||||
|
DLL_EXPORT int CBinaryCommand_GetCommand(void* pExpressionCommand);
|
||||||
|
}
|
||||||
|
|
|
@ -9,12 +9,17 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
List<TType> m_vector;
|
List<TType> m_vector;
|
||||||
|
|
||||||
public CalculatorList()
|
public CalculatorList()
|
||||||
{
|
{
|
||||||
m_vector = new List<TType>();
|
m_vector = new List<TType>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalculatorList(CalculatorList<TType> source)
|
public CalculatorList(IEnumerable<TType> source)
|
||||||
|
{
|
||||||
|
m_vector = new List<TType>(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CalculatorList(CalculatorList<TType> source)
|
||||||
{
|
{
|
||||||
m_vector = new List<TType>(source.m_vector);
|
m_vector = new List<TType>(source.m_vector);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,15 +99,32 @@ namespace CalculationManager
|
||||||
[DllImport(DllPath)]
|
[DllImport(DllPath)]
|
||||||
public static extern IntPtr CalculatorManager_GetHistoryItem(IntPtr nativeManager, int uIdx);
|
public static extern IntPtr CalculatorManager_GetHistoryItem(IntPtr nativeManager, int uIdx);
|
||||||
|
|
||||||
|
[DllImport(DllPath)]
|
||||||
|
public static extern int CBinaryCommand_GetCommand(IntPtr m_pExpressionCommand);
|
||||||
|
|
||||||
|
[DllImport(DllPath)]
|
||||||
|
public static extern void Free(IntPtr ptr);
|
||||||
|
|
||||||
[DllImport(DllPath)]
|
[DllImport(DllPath)]
|
||||||
public static extern CommandType IExpressionCommand_GetCommandType(IntPtr pExpressionCommand);
|
public static extern CommandType IExpressionCommand_GetCommandType(IntPtr pExpressionCommand);
|
||||||
|
|
||||||
|
[DllImport(DllPath)]
|
||||||
|
public static extern bool COpndCommand_IsNegative(IntPtr pExpressionCommand);
|
||||||
|
|
||||||
|
[DllImport(DllPath)]
|
||||||
|
public static extern IntPtr COpndCommand_GetCommands(IntPtr pExpressionCommand);
|
||||||
|
|
||||||
|
[DllImport(DllPath)]
|
||||||
|
public static extern IntPtr CUnaryCommand_GetCommands(IntPtr pExpressionCommand);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate IntPtr GetCEngineStringFunc(IntPtr state, IntPtr id);
|
public delegate IntPtr GetCEngineStringFunc(IntPtr state, IntPtr id);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void BinaryOperatorReceivedFunc(IntPtr state);
|
public delegate void BinaryOperatorReceivedFunc(IntPtr state);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void SetPrimaryDisplayCallbackFunc(IntPtr state, IntPtr pDisplayStringValue, bool isError);
|
public delegate void SetPrimaryDisplayCallbackFunc(IntPtr state, IntPtr pDisplayStringValue, bool isError);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void SetIsInErrorCallbackFunc(IntPtr state, bool isError);
|
public delegate void SetIsInErrorCallbackFunc(IntPtr state, bool isError);
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
@ -353,8 +370,8 @@ namespace CalculationManager
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct GetHistoryItemResult
|
public struct GetHistoryItemResult
|
||||||
{
|
{
|
||||||
public string expression;
|
public IntPtr expression;
|
||||||
public string result;
|
public IntPtr result;
|
||||||
|
|
||||||
public int TokenCount;
|
public int TokenCount;
|
||||||
public IntPtr TokenStrings;
|
public IntPtr TokenStrings;
|
||||||
|
@ -364,6 +381,19 @@ namespace CalculationManager
|
||||||
public IntPtr Commands;
|
public IntPtr Commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct COpndCommand_GetCommandsResult
|
||||||
|
{
|
||||||
|
public int CommandCount;
|
||||||
|
public IntPtr Commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct CUnaryCommand_GetCommandsResult
|
||||||
|
{
|
||||||
|
public int CommandCount;
|
||||||
|
public IntPtr Commands;
|
||||||
|
}
|
||||||
|
|
||||||
public partial class CalculatorManager : ICalcDisplay
|
public partial class CalculatorManager : ICalcDisplay
|
||||||
{
|
{
|
||||||
|
@ -371,6 +401,5 @@ namespace CalculationManager
|
||||||
private GCHandle _displayCallbackHandle;
|
private GCHandle _displayCallbackHandle;
|
||||||
private GCHandle _resourceProviderHandle;
|
private GCHandle _resourceProviderHandle;
|
||||||
private readonly IntPtr _nativeManager;
|
private readonly IntPtr _nativeManager;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,8 +251,8 @@ namespace CalculationManager
|
||||||
internal static HISTORYITEM UnmarshalHistoryItemResult(GetHistoryItemResult historyResultItem)
|
internal static HISTORYITEM UnmarshalHistoryItemResult(GetHistoryItemResult historyResultItem)
|
||||||
{
|
{
|
||||||
var historyItem = new HISTORYITEM();
|
var historyItem = new HISTORYITEM();
|
||||||
historyItem.historyItemVector.expression = historyResultItem.expression;
|
historyItem.historyItemVector.expression = NativeDispatch.PtrToString(historyResultItem.expression);
|
||||||
historyItem.historyItemVector.result = historyResultItem.result;
|
historyItem.historyItemVector.result = NativeDispatch.PtrToString(historyResultItem.result);
|
||||||
historyItem.historyItemVector.spTokens = new CalculatorList<(string, int)>();
|
historyItem.historyItemVector.spTokens = new CalculatorList<(string, int)>();
|
||||||
|
|
||||||
for (var i = 0; i < historyResultItem.TokenCount; i++)
|
for (var i = 0; i < historyResultItem.TokenCount; i++)
|
||||||
|
@ -274,7 +274,7 @@ namespace CalculationManager
|
||||||
switch (commandType)
|
switch (commandType)
|
||||||
{
|
{
|
||||||
case CommandType.BinaryCommand:
|
case CommandType.BinaryCommand:
|
||||||
return new CUnaryCommand(pExpressionCommand);
|
return new CBinaryCommand(pExpressionCommand);
|
||||||
|
|
||||||
case CommandType.OperandCommand:
|
case CommandType.OperandCommand:
|
||||||
return new COpndCommand(pExpressionCommand);
|
return new COpndCommand(pExpressionCommand);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using CalculatorApp;
|
using CalculatorApp;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace CalculationManager
|
namespace CalculationManager
|
||||||
{
|
{
|
||||||
|
@ -73,13 +74,27 @@ namespace CalculationManager
|
||||||
|
|
||||||
public class CUnaryCommand : IUnaryCommand
|
public class CUnaryCommand : IUnaryCommand
|
||||||
{
|
{
|
||||||
private IntPtr pExpressionCommand;
|
private IntPtr m_pExpressionCommand;
|
||||||
|
|
||||||
public CUnaryCommand(IntPtr pExpressionCommand) => this.pExpressionCommand = pExpressionCommand;
|
public CUnaryCommand(IntPtr pExpressionCommand) => this.m_pExpressionCommand = pExpressionCommand;
|
||||||
|
|
||||||
public CUnaryCommand(int command) => throw new NotImplementedException();
|
public CUnaryCommand(int command) => throw new NotImplementedException();
|
||||||
public CUnaryCommand(int command1, int command2) => throw new NotImplementedException();
|
public CUnaryCommand(int command1, int command2) => throw new NotImplementedException();
|
||||||
public CalculatorList<int> GetCommands() => throw new NotImplementedException();
|
|
||||||
|
public CalculatorList<int> GetCommands()
|
||||||
|
{
|
||||||
|
var pResult = NativeDispatch.CUnaryCommand_GetCommands(m_pExpressionCommand);
|
||||||
|
var result = Marshal.PtrToStructure<CUnaryCommand_GetCommandsResult>(pResult);
|
||||||
|
|
||||||
|
int[] commandsArray = new int[result.CommandCount];
|
||||||
|
Marshal.Copy(result.Commands, commandsArray, 0, commandsArray.Length);
|
||||||
|
|
||||||
|
NativeDispatch.Free(result.Commands);
|
||||||
|
NativeDispatch.Free(pResult);
|
||||||
|
|
||||||
|
return new CalculatorList<int>(commandsArray);
|
||||||
|
}
|
||||||
|
|
||||||
public CalculationManager.CommandType GetCommandType() => CommandType.UnaryCommand;
|
public CalculationManager.CommandType GetCommandType() => CommandType.UnaryCommand;
|
||||||
public void SetCommand(int command) => throw new NotImplementedException();
|
public void SetCommand(int command) => throw new NotImplementedException();
|
||||||
public void SetCommands(int command1, int command2) => throw new NotImplementedException();
|
public void SetCommands(int command1, int command2) => throw new NotImplementedException();
|
||||||
|
@ -88,32 +103,45 @@ namespace CalculationManager
|
||||||
|
|
||||||
public class CBinaryCommand : IBinaryCommand
|
public class CBinaryCommand : IBinaryCommand
|
||||||
{
|
{
|
||||||
private IntPtr pExpressionCommand;
|
private IntPtr m_pExpressionCommand;
|
||||||
|
|
||||||
public CBinaryCommand(IntPtr pExpressionCommand) => this.pExpressionCommand = pExpressionCommand;
|
public CBinaryCommand(IntPtr pExpressionCommand) => this.m_pExpressionCommand = pExpressionCommand;
|
||||||
|
|
||||||
public CBinaryCommand(int command) => throw new NotImplementedException();
|
public CBinaryCommand(int command) => throw new NotImplementedException();
|
||||||
public void SetCommand(int command) => throw new NotImplementedException();
|
public void SetCommand(int command) => throw new NotImplementedException();
|
||||||
public int GetCommand() => throw new NotImplementedException();
|
public int GetCommand() => NativeDispatch.CBinaryCommand_GetCommand(m_pExpressionCommand);
|
||||||
public CalculationManager.CommandType GetCommandType() => CommandType.BinaryCommand;
|
public CalculationManager.CommandType GetCommandType() => CommandType.BinaryCommand;
|
||||||
public void Accept(ISerializeCommandVisitor commandVisitor) => throw new NotImplementedException();
|
public void Accept(ISerializeCommandVisitor commandVisitor) => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class COpndCommand : IOpndCommand
|
public class COpndCommand : IOpndCommand
|
||||||
{
|
{
|
||||||
private IntPtr pExpressionCommand;
|
private IntPtr m_pExpressionCommand;
|
||||||
|
|
||||||
public COpndCommand(CalculatorList<int> commands, bool fNegative, bool fDecimal, bool fSciFmt) => throw new NotImplementedException();
|
public COpndCommand(CalculatorList<int> commands, bool fNegative, bool fDecimal, bool fSciFmt) => throw new NotImplementedException();
|
||||||
public COpndCommand(IntPtr pExpressionCommand) => this.pExpressionCommand = pExpressionCommand;
|
public COpndCommand(IntPtr pExpressionCommand) => this.m_pExpressionCommand = pExpressionCommand;
|
||||||
|
|
||||||
// public void Initialize(CalcEngine.Rational rat) => throw new NotImplementedException();
|
// public void Initialize(CalcEngine.Rational rat) => throw new NotImplementedException();
|
||||||
|
|
||||||
public CalculatorList<int> GetCommands() => throw new NotImplementedException();
|
public CalculatorList<int> GetCommands()
|
||||||
public void SetCommands(CalculatorList<int> commands) => throw new NotImplementedException();
|
{
|
||||||
|
var pResult = NativeDispatch.COpndCommand_GetCommands(m_pExpressionCommand);
|
||||||
|
var result = Marshal.PtrToStructure<COpndCommand_GetCommandsResult>(pResult);
|
||||||
|
|
||||||
|
int[] commandsArray = new int[result.CommandCount];
|
||||||
|
Marshal.Copy(result.Commands, commandsArray, 0, commandsArray.Length);
|
||||||
|
|
||||||
|
NativeDispatch.Free(result.Commands);
|
||||||
|
NativeDispatch.Free(pResult);
|
||||||
|
|
||||||
|
return new CalculatorList<int>(commandsArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCommands(CalculatorList<int> commands) => throw new NotImplementedException();
|
||||||
public void AppendCommand(int command) => throw new NotImplementedException();
|
public void AppendCommand(int command) => throw new NotImplementedException();
|
||||||
public void ToggleSign() => throw new NotImplementedException();
|
public void ToggleSign() => throw new NotImplementedException();
|
||||||
public void RemoveFromEnd() => throw new NotImplementedException();
|
public void RemoveFromEnd() => throw new NotImplementedException();
|
||||||
public bool IsNegative() => throw new NotImplementedException();
|
public bool IsNegative() => NativeDispatch.COpndCommand_IsNegative(m_pExpressionCommand);
|
||||||
public bool IsSciFmt() => throw new NotImplementedException();
|
public bool IsSciFmt() => throw new NotImplementedException();
|
||||||
public bool IsDecimalPresent() => throw new NotImplementedException();
|
public bool IsDecimalPresent() => throw new NotImplementedException();
|
||||||
public string GetToken(char decimalSymbol) => throw new NotImplementedException();
|
public string GetToken(char decimalSymbol) => throw new NotImplementedException();
|
||||||
|
|
|
@ -167,7 +167,7 @@ namespace CalculatorApp.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowDirection GetFlowDirection()
|
public FlowDirection GetFlowDirection()
|
||||||
{
|
{
|
||||||
return m_flowDirection;
|
return m_flowDirection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,12 +153,12 @@ namespace CalculatorApp
|
||||||
calculatorDisplay.SetHistoryCallback(new WeakReference(this));
|
calculatorDisplay.SetHistoryCallback(new WeakReference(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowItem(HistoryItemViewModel e)
|
public void ShowItem(HistoryItemViewModel e)
|
||||||
{
|
{
|
||||||
HistoryItemClicked(e);
|
HistoryItemClicked(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteItem(HistoryItemViewModel e)
|
public void DeleteItem(HistoryItemViewModel e)
|
||||||
{
|
{
|
||||||
int itemIndex= Items.IndexOf(e);
|
int itemIndex= Items.IndexOf(e);
|
||||||
if (itemIndex != -1)
|
if (itemIndex != -1)
|
||||||
|
|
|
@ -4,217 +4,199 @@
|
||||||
xmlns:automation="using:CalculatorApp.Common.Automation"
|
xmlns:automation="using:CalculatorApp.Common.Automation"
|
||||||
xmlns:controls="using:CalculatorApp.Controls"
|
xmlns:controls="using:CalculatorApp.Controls"
|
||||||
xmlns:converters="using:CalculatorApp.Converters"
|
xmlns:converters="using:CalculatorApp.Converters"
|
||||||
xmlns:local="using:CalculatorApp.Views"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="using:CalculatorApp"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:model="using:CalculatorApp.ViewModel"
|
xmlns:model="using:CalculatorApp.ViewModel"
|
||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
AutomationProperties.AutomationId="HistoryList"
|
AutomationProperties.AutomationId="HistoryList"
|
||||||
FlowDirection="LeftToRight"
|
FlowDirection="LeftToRight"
|
||||||
mc:Ignorable="">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<!--UNO TODO
|
<!-- UNO TODO x:Name="HistoryList"-->
|
||||||
x:Name="HistoryList"
|
|
||||||
Loaded="HistoryList_Loaded"
|
|
||||||
Unloaded="HistoryList_Unloaded"
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!--<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
|
|
||||||
<ResourceDictionary x:Key="Default">
|
<ResourceDictionary x:Key="Default">
|
||||||
<Style x:Key="BodyTextBlockMediumStyle"
|
<Style x:Key="BodyTextBlockMediumStyle"
|
||||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||||
TargetType="TextBlock">
|
TargetType="TextBlock">
|
||||||
<Setter Property="Foreground"
|
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}"/>
|
||||||
Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
||||||
</Style>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
||||||
<ResourceDictionary x:Key="Light">
|
<ResourceDictionary x:Key="Light">
|
||||||
<Style x:Key="BodyTextBlockMediumStyle"
|
<Style x:Key="BodyTextBlockMediumStyle"
|
||||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||||
TargetType="TextBlock">
|
TargetType="TextBlock">
|
||||||
<Setter Property="Foreground"
|
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}"/>
|
||||||
Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
|
||||||
</Style>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
||||||
<ResourceDictionary x:Key="HighContrast">
|
<ResourceDictionary x:Key="HighContrast">
|
||||||
<Style x:Key="BodyTextBlockMediumStyle"
|
<Style x:Key="BodyTextBlockMediumStyle"
|
||||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||||
TargetType="TextBlock" />
|
TargetType="TextBlock"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
<converters:ItemSizeToVisibilityNegationConverter x:Key="ItemSizeToVisibilityNegationConverter"/>
|
||||||
<converters:ItemSizeToVisibilityNegationConverter x:Key="ItemSizeToVisibilityNegationConverter" />
|
<converters:ItemSizeToVisibilityConverter x:Key="ItemSizeToVisibilityConverter"/>
|
||||||
|
|
||||||
<converters:ItemSizeToVisibilityConverter x:Key="ItemSizeToVisibilityConverter" />
|
|
||||||
|
|
||||||
--><!--
|
|
||||||
UNO TODO
|
|
||||||
<automation:NarratorNotifier x:Name="NarratorNotifier"
|
|
||||||
Announcement="{x:Bind Model.HistoryAnnouncement, Mode=OneWay}" />
|
|
||||||
--><!--
|
|
||||||
|
|
||||||
--><!--
|
|
||||||
UNO TODO
|
|
||||||
<muxc:SymbolIconSource x:Key="DeleteSymbol"
|
|
||||||
Symbol="Delete" />
|
|
||||||
|
|
||||||
<muxc:SwipeItems x:Key="HistorySwipeItems"
|
|
||||||
Mode="Execute">
|
|
||||||
<muxc:SwipeItem x:Uid="DeleteHistorySwipeItem"
|
|
||||||
IconSource="{StaticResource DeleteSymbol}"
|
|
||||||
Invoked="OnDeleteSwipeInvoked" />
|
|
||||||
</muxc:SwipeItems>
|
|
||||||
--><!--
|
|
||||||
|
|
||||||
<MenuFlyout x:Key="HistoryContextMenu">
|
<MenuFlyout x:Key="HistoryContextMenu">
|
||||||
<MenuFlyoutItem x:Uid="DeleteHistoryMenuItem"
|
<MenuFlyoutItem x:Uid="DeleteHistoryMenuItem"
|
||||||
Click="OnDeleteMenuItemClicked"
|
Click="OnDeleteMenuItemClicked"
|
||||||
Icon="Delete" />
|
Icon="Delete"/>
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
|
|
||||||
<DataTemplate x:Key="HistoryItemTemplate"
|
|
||||||
x:DataType="model:HistoryItemViewModel">
|
|
||||||
|
|
||||||
--><!-- UNO TODO
|
<!--
|
||||||
|
UNO TODO
|
||||||
|
<automation:NarratorNotifier x:Name="NarratorNotifier" Announcement="{x:Bind Model.HistoryAnnouncement, Mode=OneWay}"/>
|
||||||
|
|
||||||
<muxc:SwipeControl RightItems="{StaticResource HistorySwipeItems}">
|
<muxc:SymbolIconSource x:Key="DeleteSymbol" Symbol="Delete"/>
|
||||||
|
|
||||||
|
<muxc:SwipeItems x:Key="HistorySwipeItems" Mode="Execute">
|
||||||
|
<muxc:SwipeItem x:Uid="DeleteHistorySwipeItem"
|
||||||
|
IconSource="{StaticResource DeleteSymbol}"
|
||||||
|
Invoked="OnDeleteSwipeInvoked"/>
|
||||||
|
</muxc:SwipeItems>
|
||||||
|
<DataTemplate x:Key="HistoryItemTemplate" x:DataType="model:HistoryItemViewModel">
|
||||||
|
<muxc:SwipeControl RightItems="{StaticResource HistorySwipeItems}">
|
||||||
<StackPanel Margin="0,6,4,6"
|
<StackPanel Margin="0,6,4,6"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ContextFlyout="{StaticResource HistoryContextMenu}">
|
ContextFlyout="{StaticResource HistoryContextMenu}">
|
||||||
|
<TextBlock x:Name="ExprTextBlock"
|
||||||
<TextBlock x:Name="exprTextBlock"
|
Margin="0,0,0,4"
|
||||||
Margin="0,0,0,4"
|
HorizontalAlignment="Right"
|
||||||
Style="{ThemeResource BodyTextBlockMediumStyle}"
|
Style="{ThemeResource BodyTextBlockMediumStyle}"
|
||||||
AutomationProperties.Name="{x:Bind AccExpression}"
|
AutomationProperties.Name="{x:Bind AccExpression}"
|
||||||
Text="{x:Bind Expression}"
|
IsTextSelectionEnabled="True"
|
||||||
TextAlignment="Right"
|
Text="{x:Bind Expression}"
|
||||||
TextWrapping="Wrap" />
|
TextAlignment="Right"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
<TextBlock x:Name="resultTextBlock"
|
<TextBlock x:Name="ResultTextBlock"
|
||||||
Style="{ThemeResource TitleTextBlockStyle}"
|
HorizontalAlignment="Right"
|
||||||
FontWeight="SemiBold"
|
Style="{ThemeResource TitleTextBlockStyle}"
|
||||||
AutomationProperties.Name="{x:Bind AccResult}"
|
FontWeight="SemiBold"
|
||||||
Text="{x:Bind Result}"
|
AutomationProperties.Name="{x:Bind AccResult}"
|
||||||
TextAlignment="Right"
|
IsTextSelectionEnabled="True"
|
||||||
TextWrapping="Wrap" />
|
Text="{x:Bind Result}"
|
||||||
|
TextAlignment="Right"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</muxc:SwipeControl>--><!--
|
</muxc:SwipeControl>
|
||||||
<TextBlock Text="TODO HistoryItemTemplate not supported"/>
|
</DataTemplate>
|
||||||
|
-->
|
||||||
|
<Style x:Key="HistoryItemContainerStyle"
|
||||||
|
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
|
||||||
|
TargetType="ListViewItem">
|
||||||
|
<Setter Property="Margin" Value="0,0,0,20"/>
|
||||||
|
</Style>
|
||||||
|
<DataTemplate x:Key="HistoryItemTemplate" x:DataType="model:HistoryItemViewModel">
|
||||||
|
<StackPanel Margin="0,6,4,6"
|
||||||
|
Background="Transparent"
|
||||||
|
ContextFlyout="{StaticResource HistoryContextMenu}">
|
||||||
|
<TextBlock x:Name="ExprTextBlock"
|
||||||
|
Margin="0,0,0,4"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Style="{ThemeResource BodyTextBlockMediumStyle}"
|
||||||
|
AutomationProperties.Name="{x:Bind AccExpression}"
|
||||||
|
IsTextSelectionEnabled="True"
|
||||||
|
Text="{x:Bind Expression}"
|
||||||
|
TextAlignment="Right"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
<TextBlock x:Name="ResultTextBlock"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Style="{ThemeResource TitleTextBlockStyle}"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
AutomationProperties.Name="{x:Bind AccResult}"
|
||||||
|
IsTextSelectionEnabled="True"
|
||||||
|
Text="{x:Bind Result}"
|
||||||
|
TextAlignment="Right"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<Style x:Key="HistoryItemContainerStyle"
|
|
||||||
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
|
|
||||||
TargetType="ListViewItem">
|
|
||||||
<Setter Property="Margin"
|
|
||||||
Value="0,0,0,20" />
|
|
||||||
</Style>
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid x:Name="LayoutGrid">
|
<Grid x:Name="LayoutGrid">
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="{Binding RowHeight, ElementName=HistoryList, Mode=OneWay}"/>
|
||||||
<RowDefinition Height="{Binding RowHeight, ElementName=HistoryList, Mode=OneWay}" />
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup>
|
<VisualStateGroup>
|
||||||
<VisualState x:Name="DockedLayout">
|
<VisualState x:Name="DockedLayout">
|
||||||
|
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<AdaptiveTrigger MinWindowWidth="560" />
|
<AdaptiveTrigger MinWindowWidth="560"/>
|
||||||
</VisualState.StateTriggers>
|
</VisualState.StateTriggers>
|
||||||
|
|
||||||
<VisualState.Setters>
|
<VisualState.Setters>
|
||||||
<Setter Target="HistoryListRootGrid.(Grid.Row)"
|
<Setter Target="HistoryListRootGrid.(Grid.Row)" Value="0"/>
|
||||||
Value="1" />
|
<Setter Target="HistoryListRootGrid.(Grid.RowSpan)" Value="2"/>
|
||||||
<Setter Target="HistoryListRootGrid.(Grid.RowSpan)"
|
<Setter Target="HistoryListView.Padding" Value="0"/>
|
||||||
Value="2" />
|
<Setter Target="BackgroundShade.Visibility" Value="Collapsed"/>
|
||||||
<Setter Target="HistoryListView.Padding"
|
|
||||||
Value="0" />
|
|
||||||
<Setter Target="BackgroundShade.Opacity"
|
|
||||||
Value="0" />
|
|
||||||
<Setter Target="CustomTitleBar.Height"
|
|
||||||
Value="0" />
|
|
||||||
</VisualState.Setters>
|
</VisualState.Setters>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
|
|
||||||
<VisualState x:Name="DefaultLayout">
|
<VisualState x:Name="DefaultLayout">
|
||||||
<VisualState.StateTriggers>
|
<VisualState.StateTriggers>
|
||||||
<AdaptiveTrigger MinWindowWidth="0" />
|
<AdaptiveTrigger MinWindowWidth="0"/>
|
||||||
</VisualState.StateTriggers>
|
</VisualState.StateTriggers>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
|
|
||||||
<Border x:Name="BackgroundShade"
|
<Border x:Name="BackgroundShade"
|
||||||
Grid.Row="2"
|
Grid.Row="1"
|
||||||
Margin="0,-1,0,0"
|
Margin="0,-1,0,0"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
||||||
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
||||||
BorderThickness="{ThemeResource HighContrastThicknessTop}" />
|
BorderThickness="{ThemeResource HighContrastThicknessTop}"/>
|
||||||
|
|
||||||
<Grid x:Name="HistoryListRootGrid"
|
|
||||||
Grid.Row="2">
|
|
||||||
|
|
||||||
|
<Grid x:Name="HistoryListRootGrid" Grid.Row="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock x:Name="HistoryEmpty"
|
<TextBlock x:Name="HistoryEmpty"
|
||||||
x:Uid="HistoryEmpty"
|
x:Uid="HistoryEmpty"
|
||||||
Margin="12,14,24,0"
|
Margin="12,14,24,0"
|
||||||
Style="{ThemeResource BaseTextBlockStyle}"
|
Style="{ThemeResource BaseTextBlockStyle}"
|
||||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
Visibility="{Binding ItemSize, Converter={StaticResource ItemSizeToVisibilityConverter}}" />
|
Visibility="{Binding ItemSize, Converter={StaticResource ItemSizeToVisibilityConverter}}"/>
|
||||||
|
|
||||||
<ListView x:Name="HistoryListView"
|
<ListView x:Name="HistoryListView"
|
||||||
MinHeight="60"
|
MinHeight="60"
|
||||||
Padding="0,12,0,0"
|
Padding="0,12,0,0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
AutomationProperties.AutomationId="HistoryListView"
|
AutomationProperties.AutomationId="HistoryListView"
|
||||||
IsItemClickEnabled="True"
|
IsItemClickEnabled="True"
|
||||||
ItemClick="ListView_ItemClick"
|
ItemClick="ListView_ItemClick"
|
||||||
ItemContainerStyle="{StaticResource HistoryItemContainerStyle}"
|
ItemContainerStyle="{StaticResource HistoryItemContainerStyle}"
|
||||||
ItemTemplate="{StaticResource HistoryItemTemplate}"
|
ItemTemplate="{StaticResource HistoryItemTemplate}"
|
||||||
ItemsSource="{x:Bind Model.Items, Mode=OneWay}"
|
ItemsSource="{x:Bind Model.Items, Mode=OneWay}"
|
||||||
SelectionMode="None"
|
SelectionMode="None"
|
||||||
TabIndex="0"
|
TabIndex="0"
|
||||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}">
|
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}">
|
||||||
<ListView.ItemContainerTransitions>
|
<ListView.ItemContainerTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
<AddDeleteThemeTransition />
|
<AddDeleteThemeTransition/>
|
||||||
<ContentThemeTransition />
|
<ContentThemeTransition/>
|
||||||
<ReorderThemeTransition />
|
<ReorderThemeTransition/>
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</ListView.ItemContainerTransitions>
|
</ListView.ItemContainerTransitions>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
<Button x:Name="ClearHistory"
|
<Button x:Name="ClearHistory"
|
||||||
x:Uid="ClearHistory"
|
x:Uid="ClearHistory"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Style="{StaticResource ClearAllHistoryMemoryButtonStyle}"
|
Style="{StaticResource ClearAllHistoryMemoryButtonStyle}"
|
||||||
AutomationProperties.AutomationId="ClearHistory"
|
AutomationProperties.AutomationId="ClearHistory"
|
||||||
Command="{x:Bind Model.ClearCommand, Mode=OneWay}"
|
Command="{x:Bind Model.ClearCommand, Mode=OneWay}"
|
||||||
Content=""
|
Content=""
|
||||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}" />
|
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</Grid>
|
||||||
<Border x:Name="CustomTitleBar"
|
|
||||||
Height="32"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
Background="{ThemeResource TitleBarBackgroundTransparentBrush}" />
|
|
||||||
</Grid>-->
|
|
||||||
</UserControl>
|
</UserControl>
|
|
@ -1,27 +1,73 @@
|
||||||
using System;
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
using System.Collections.Generic;
|
// Licensed under the MIT License.
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using CalculatorApp.Common;
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
using CalculatorApp.ViewModel;
|
||||||
using Windows.Foundation;
|
|
||||||
using Windows.Foundation.Collections;
|
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
using Windows.UI.Xaml.Data;
|
|
||||||
using Windows.UI.Xaml.Input;
|
|
||||||
using Windows.UI.Xaml.Media;
|
|
||||||
using Windows.UI.Xaml.Navigation;
|
|
||||||
|
|
||||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
||||||
public sealed partial class HistoryList : UserControl
|
public partial class HistoryList
|
||||||
{
|
{
|
||||||
|
public HistoryViewModel Model => (CalculatorApp.ViewModel.HistoryViewModel)(this.DataContext);
|
||||||
|
|
||||||
|
public GridLength RowHeight
|
||||||
|
{
|
||||||
|
get { return (GridLength)GetValue(RowHeightProperty); }
|
||||||
|
set { SetValue(RowHeightProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using a DependencyProperty as the backing store for RowHeight. This enables animation, styling, binding, etc...
|
||||||
|
public static readonly DependencyProperty RowHeightProperty =
|
||||||
|
DependencyProperty.Register("RowHeight", typeof(GridLength), typeof(HistoryList), new PropertyMetadata(GridLength.Auto));
|
||||||
|
|
||||||
|
Windows.Foundation.Rect m_visibleBounds;
|
||||||
|
Windows.Foundation.Rect m_coreBounds;
|
||||||
|
|
||||||
public HistoryList()
|
public HistoryList()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
HistoryEmpty.FlowDirection = LocalizationService.GetInstance().GetFlowDirection();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void ListView_ItemClick(object sender, ItemClickEventArgs e)
|
||||||
|
{
|
||||||
|
HistoryViewModel historyVM = (HistoryViewModel)(this.DataContext);
|
||||||
|
HistoryItemViewModel clickedItem = (HistoryItemViewModel)(e.ClickedItem);
|
||||||
|
|
||||||
|
// When the user clears the history list in the overlay view and presses enter, the clickedItem is null
|
||||||
|
if (clickedItem != null)
|
||||||
|
{
|
||||||
|
historyVM.ShowItem(clickedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDeleteMenuItemClicked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var clickedItem = (HistoryItemViewModel)((FrameworkElement)sender).DataContext;
|
||||||
|
|
||||||
|
Model.DeleteItem(clickedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if false // UNO TODO
|
||||||
|
void OnDeleteSwipeInvoked(MUXC.SwipeItem sender, MUXC.SwipeItemInvokedEventArgs e)
|
||||||
|
{
|
||||||
|
var swipedItem = safe_cast<HistoryItemViewModel>(e.SwipeControl.DataContext);
|
||||||
|
|
||||||
|
Model.DeleteItem(swipedItem);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void ScrollToBottom()
|
||||||
|
{
|
||||||
|
var historyItems = this.HistoryListView.Items;
|
||||||
|
if (historyItems.Count > 0)
|
||||||
|
{
|
||||||
|
this.HistoryListView.ScrollIntoView(historyItems[historyItems.Count - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,27 +127,24 @@
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Visibility="Collapsed"/>
|
Visibility="Collapsed"/>
|
||||||
|
|
||||||
<!--
|
|
||||||
x:Uid="NavView"
|
|
||||||
IsBackButtonVisible="Collapsed"
|
|
||||||
PaneClosed="OnNavPaneClosed"
|
|
||||||
PaneOpened="OnNavPaneOpened"
|
|
||||||
PaneOpening="OnNavPaneOpening"
|
|
||||||
-->
|
|
||||||
<!--UNO TODO
|
<!--UNO TODO
|
||||||
CompactModeThresholdWidth="Infinity"
|
|
||||||
ExpandedModeThresholdWidth="Infinity"
|
|
||||||
-->
|
-->
|
||||||
<NavigationView x:Name="NavView"
|
<NavigationView x:Name="NavView"
|
||||||
Grid.Row="2"
|
CompactModeThresholdWidth="10000"
|
||||||
DataContext="{x:Bind Model}"
|
ExpandedModeThresholdWidth="10000"
|
||||||
IsSettingsVisible="False"
|
IsBackButtonVisible="Collapsed"
|
||||||
Loaded="OnNavLoaded"
|
PaneClosed="OnNavPaneClosed"
|
||||||
MenuItemsSource="{x:Bind UIElementsForCategories, Mode=OneWay}"
|
PaneOpened="OnNavPaneOpened"
|
||||||
OpenPaneLength="{StaticResource SplitViewOpenPaneLength}"
|
PaneOpening="OnNavPaneOpening"
|
||||||
SelectionChanged="OnNavSelectionChanged"
|
Grid.Row="2"
|
||||||
TabIndex="1"
|
DataContext="{x:Bind Model}"
|
||||||
UseSystemFocusVisuals="True">
|
IsSettingsVisible="False"
|
||||||
|
Loaded="OnNavLoaded"
|
||||||
|
MenuItemsSource="{x:Bind UIElementsForCategories, Mode=OneWay}"
|
||||||
|
OpenPaneLength="{StaticResource SplitViewOpenPaneLength}"
|
||||||
|
SelectionChanged="OnNavSelectionChanged"
|
||||||
|
TabIndex="1"
|
||||||
|
UseSystemFocusVisuals="True">
|
||||||
|
|
||||||
<NavigationView.PaneFooter>
|
<NavigationView.PaneFooter>
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,11 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
NavView.DataContext = m_model;
|
if (NavView != null)
|
||||||
|
{
|
||||||
|
// UNO TODO OnNavigatedTo/Loaded Sequence is different
|
||||||
|
NavView.DataContext = m_model;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_model.CalculatorViewModel != null)
|
if (m_model.CalculatorViewModel != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue