Merge pull request #24 from nventive/dev/jela/history

Restore Memory and History lists
This commit is contained in:
Jérôme Laban 2019-05-23 08:00:44 -04:00 committed by GitHub
commit 16ccc6034a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 757 additions and 467 deletions

View file

@ -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();
}

View file

@ -22,26 +22,27 @@ 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__)
#define DLL_EXPORT #define DLL_EXPORT
#else #else
#define DLL_EXPORT __declspec(dllexport) #define DLL_EXPORT __declspec(dllexport)
#endif #endif
@ -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);
}

Binary file not shown.

View file

@ -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);
} }

View file

@ -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;
} }
} }

View file

@ -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);

View file

@ -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();

View file

@ -167,7 +167,7 @@ namespace CalculatorApp.Common
} }
} }
public FlowDirection GetFlowDirection() public FlowDirection GetFlowDirection()
{ {
return m_flowDirection; return m_flowDirection;
} }

View file

@ -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)

View file

@ -1518,7 +1518,7 @@ namespace CalculatorApp.ViewModel
} }
} }
void OnMemoryItemPressed(object memoryItemPosition) public void OnMemoryItemPressed(object memoryItemPosition)
{ {
if (MemorizedNumbers != null && MemorizedNumbers.Count > 0) if (MemorizedNumbers != null && MemorizedNumbers.Count > 0)
{ {

View file

@ -1,220 +1,204 @@
<UserControl x:Class="CalculatorApp.HistoryList" <UserControl x:Class="CalculatorApp.HistoryList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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-->
UNO TODO <win:MenuFlyout x:Key="HistoryContextMenu">
<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">
<MenuFlyoutItem x:Uid="DeleteHistoryMenuItem" <MenuFlyoutItem x:Uid="DeleteHistoryMenuItem"
Click="OnDeleteMenuItemClicked" Click="OnDeleteMenuItemClicked"
Icon="Delete" /> Icon="Delete"/>
</MenuFlyout> </win:MenuFlyout>
<DataTemplate x:Key="HistoryItemTemplate"
x:DataType="model:HistoryItemViewModel">
--><!-- UNO TODO
<muxc:SwipeControl RightItems="{StaticResource HistorySwipeItems}"> <!--
UNO TODO
<StackPanel Margin="0,6,4,6" <automation:NarratorNotifier x:Name="NarratorNotifier" Announcement="{x:Bind Model.HistoryAnnouncement, Mode=OneWay}"/>
Background="Transparent"
ContextFlyout="{StaticResource HistoryContextMenu}">
<TextBlock x:Name="exprTextBlock"
Margin="0,0,0,4"
Style="{ThemeResource BodyTextBlockMediumStyle}"
AutomationProperties.Name="{x:Bind AccExpression}"
Text="{x:Bind Expression}"
TextAlignment="Right"
TextWrapping="Wrap" />
<TextBlock x:Name="resultTextBlock"
Style="{ThemeResource TitleTextBlockStyle}"
FontWeight="SemiBold"
AutomationProperties.Name="{x:Bind AccResult}"
Text="{x:Bind Result}"
TextAlignment="Right"
TextWrapping="Wrap" />
</StackPanel>
</muxc:SwipeControl>--><!--
<TextBlock Text="TODO HistoryItemTemplate not supported"/>
</DataTemplate>
<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"
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>
</muxc:SwipeControl>
</DataTemplate>
-->
<Style x:Key="HistoryItemContainerStyle" <Style x:Key="HistoryItemContainerStyle"
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}" BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
TargetType="ListViewItem"> TargetType="ListViewItem">
<Setter Property="Margin" <Setter Property="Margin" Value="0,0,0,20"/>
Value="0,0,0,20" />
</Style> </Style>
<DataTemplate x:Key="HistoryItemTemplate" x:DataType="model:HistoryItemViewModel">
<StackPanel Margin="0,6,4,6"
Background="Transparent"
win: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>
</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 x:Name="HistoryListRootGrid" Grid.Row="1">
Grid.Row="2">
<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="&#xE74D;" Content="&#xE74D;"
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" </UserControl>
Height="32"
HorizontalAlignment="Stretch"
Background="{ThemeResource TitleBarBackgroundTransparentBrush}" />
</Grid>-->
</UserControl>

View file

@ -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]);
}
}
};
} }

View file

@ -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>

View file

@ -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)
{ {

View file

@ -1,180 +1,137 @@
<UserControl x:Class="CalculatorApp.Memory" <UserControl x:Class="CalculatorApp.Memory"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:CalculatorApp.Common" xmlns:common="using:CalculatorApp.Common"
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"
x:Name="MemoryList" x:Name="MemoryList"
FlowDirection="LeftToRight" FlowDirection="LeftToRight"
mc:Ignorable=""> mc:Ignorable="d">
<!-- UNO TODO <UserControl.Resources>
Loaded="MemoryList_Loaded" <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
Unloaded="MemoryList_Unloaded" <converters:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter"/>
--> <converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
<!-- UNO TODO <!--UNO TODO-->
<UserControl.Resources> <win:MenuFlyout x:Key="MemoryContextMenu">
<MenuFlyoutItem x:Uid="ClearMemoryMenuItem" Click="OnClearMenuItemClicked">
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter" />
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter" />
<MenuFlyout x:Key="MemoryContextMenu">
<MenuFlyoutItem x:Uid="ClearMemoryMenuItem"
Click="OnClearMenuItemClicked">
<MenuFlyoutItem.Icon> <MenuFlyoutItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" <FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xf754;"/>
Glyph="&#xf754;" />
</MenuFlyoutItem.Icon> </MenuFlyoutItem.Icon>
</MenuFlyoutItem> </MenuFlyoutItem>
<MenuFlyoutItem x:Uid="MemPlusMenuItem" Click="OnMemoryAddMenuItemClicked">
<MenuFlyoutItem x:Uid="MemPlusMenuItem"
Click="OnMemoryAddMenuItemClicked">
<MenuFlyoutItem.Icon> <MenuFlyoutItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" <FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xf757;"/>
Glyph="&#xf757;" />
</MenuFlyoutItem.Icon> </MenuFlyoutItem.Icon>
</MenuFlyoutItem> </MenuFlyoutItem>
<MenuFlyoutItem x:Uid="MemMinusMenuItem" Click="OnMemorySubtractMenuItemClicked">
<MenuFlyoutItem x:Uid="MemMinusMenuItem"
Click="OnMemorySubtractMenuItemClicked">
<MenuFlyoutItem.Icon> <MenuFlyoutItem.Icon>
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" <FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph="&#xf758;"/>
Glyph="&#xf758;" />
</MenuFlyoutItem.Icon> </MenuFlyoutItem.Icon>
</MenuFlyoutItem> </MenuFlyoutItem>
</MenuFlyout> </win:MenuFlyout>
<DataTemplate x:Key="MemoryItemTemplate" <DataTemplate x:Key="MemoryItemTemplate" x:DataType="model:MemoryItemViewModel">
x:DataType="model:MemoryItemViewModel"> <local:MemoryListItem Model="{x:Bind Mode=OneWay}"/>
<local:MemoryListItem Model="{x:Bind Mode=OneWay}" />
</DataTemplate> </DataTemplate>
<Style x:Key="MemoryItemContainerStyle" <Style x:Key="MemoryItemContainerStyle"
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}" BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
TargetType="ListViewItem"> TargetType="ListViewItem">
<Setter Property="Margin" <Setter Property="Margin" Value="0,0,0,8"/>
Value="0,0,0,8" />
</Style> </Style>
</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=MemoryList, Mode=OneWay}"/>
<RowDefinition Height="{Binding RowHeight, ElementName=MemoryList, Mode=OneWay}" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ErrorVisualStates"> <VisualStateGroup x:Name="ErrorVisualStates">
<VisualState x:Name="NoErrorLayout" /> <VisualState x:Name="NoErrorLayout"/>
<VisualState x:Name="ErrorLayout"> <VisualState x:Name="ErrorLayout">
<VisualState.Setters> <VisualState.Setters>
<Setter Target="MemoryListView.IsEnabled" <Setter Target="MemoryListView.IsEnabled" Value="False"/>
Value="False" />
</VisualState.Setters> </VisualState.Setters>
</VisualState> </VisualState>
</VisualStateGroup> </VisualStateGroup>
<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="MemoryPanel.(Grid.Row)" <Setter Target="MemoryPanel.(Grid.Row)" Value="0"/>
Value="1" /> <Setter Target="MemoryPanel.(Grid.RowSpan)" Value="2"/>
<Setter Target="MemoryPanel.(Grid.RowSpan)" <Setter Target="MemoryListView.Padding" Value="0"/>
Value="2" /> <Setter Target="BackgroundShade.Visibility" Value="Collapsed"/>
<Setter Target="MemoryListView.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="MemoryPanel" Grid.Row="1">
<Grid x:Name="MemoryPanel"
Grid.Row="2">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*"/>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock x:Name="MemoryPaneEmpty" <TextBlock x:Name="MemoryPaneEmpty"
x:Uid="MemoryPaneEmpty" x:Uid="MemoryPaneEmpty"
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 IsMemoryEmpty, Converter={StaticResource BooleanToVisibilityConverter}}" /> Visibility="{Binding IsMemoryEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<ListView x:Name="MemoryListView" <ListView x:Name="MemoryListView"
Padding="0,12,0,0" Padding="0,12,0,0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
ContextCanceled="OnContextCanceled" ContextCanceled="OnContextCanceled"
ContextRequested="OnContextRequested" ContextRequested="OnContextRequested"
IsItemClickEnabled="true" IsItemClickEnabled="true"
ItemClick="MemoryListItemClick" ItemClick="MemoryListItemClick"
ItemContainerStyle="{ThemeResource MemoryItemContainerStyle}" ItemContainerStyle="{ThemeResource MemoryItemContainerStyle}"
ItemTemplate="{ThemeResource MemoryItemTemplate}" ItemTemplate="{ThemeResource MemoryItemTemplate}"
ItemsSource="{x:Bind Model.MemorizedNumbers, Mode=OneWay}" ItemsSource="{x:Bind Model.MemorizedNumbers, Mode=OneWay}"
SelectionMode="None" SelectionMode="None"
TabIndex="0" TabIndex="0"
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"> Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
<ListView.ItemContainerTransitions> <ListView.ItemContainerTransitions>
<TransitionCollection> <TransitionCollection>
<AddDeleteThemeTransition /> <AddDeleteThemeTransition/>
<ContentThemeTransition /> <ContentThemeTransition/>
<ReorderThemeTransition /> <ReorderThemeTransition/>
</TransitionCollection> </TransitionCollection>
</ListView.ItemContainerTransitions> </ListView.ItemContainerTransitions>
</ListView> </ListView>
<Button x:Name="ClearMemory" <Button x:Name="ClearMemory"
x:Uid="ClearMemory" x:Uid="ClearMemory"
Grid.Row="1" Grid.Row="1"
Style="{ThemeResource ClearAllHistoryMemoryButtonStyle}" Style="{ThemeResource ClearAllHistoryMemoryButtonStyle}"
AutomationProperties.AutomationId="ClearMemory" AutomationProperties.AutomationId="ClearMemory"
Command="{x:Bind Model.ClearMemoryCommand, Mode=OneWay}" Command="{x:Bind Model.ClearMemoryCommand, Mode=OneWay}"
Content="&#xE74D;" Content="&#xE74D;"
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}" /> Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/>
</Grid> </Grid>
<Border x:Name="CustomTitleBar" </Grid>
Height="32"
HorizontalAlignment="Stretch"
Background="{ThemeResource TitleBarBackgroundTransparentBrush}" />
</Grid>-->
</UserControl> </UserControl>

View file

@ -1,29 +1,127 @@
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 System.Runtime.InteropServices.WindowsRuntime; // xaml.h
// Declaration of the Memory class
//
using CalculatorApp.Common;
using CalculatorApp.ViewModel;
using Windows.Foundation; 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.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 Memory : UserControl public partial class Memory
{ {
public Memory() private Windows.UI.Xaml.Controls.MenuFlyout m_memoryItemFlyout;
private bool m_isErrorVisualState;
public CalculatorApp.ViewModel.StandardCalculatorViewModel Model => (CalculatorApp.ViewModel.StandardCalculatorViewModel)(this.DataContext);
public GridLength RowHeight
{ {
this.InitializeComponent(); get { return (GridLength)GetValue(RowHeightProperty); }
set { SetValue(RowHeightProperty, value); }
} }
public bool IsErrorVisualState { get; set; } public static readonly DependencyProperty RowHeightProperty =
} DependencyProperty.Register("RowHeight", typeof(GridLength), typeof(Memory), new PropertyMetadata(GridLength.Auto));
public Memory()
{
m_isErrorVisualState = false;
InitializeComponent();
// UNO TODO
m_memoryItemFlyout = Resources["MemoryContextMenu"] as MenuFlyout ?? new MenuFlyout();
MemoryPaneEmpty.FlowDirection = LocalizationService.GetInstance().GetFlowDirection();
}
void MemoryListItemClick(object sender, ItemClickEventArgs e)
{
MemoryItemViewModel memorySlot = (MemoryItemViewModel)(e.ClickedItem);
// In case the memory list is clicked and enter is pressed,
// On Item clicked event gets fired and e.ClickedItem is Null.
if (memorySlot != null)
{
Model.OnMemoryItemPressed(memorySlot.Position);
}
}
void OnContextRequested(Windows.UI.Xaml.UIElement sender, Windows.UI.Xaml.Input.ContextRequestedEventArgs e)
{
// Walk up the tree to find the ListViewItem.
// There may not be one if the click wasn't on an item.
var requestedElement = (FrameworkElement)(e.OriginalSource);
while ((requestedElement != sender) && !(requestedElement is ListViewItem))
{
requestedElement = (FrameworkElement)(VisualTreeHelper.GetParent(requestedElement));
}
if (requestedElement != sender)
{
// The context menu request was for a ListViewItem.
var memorySlot = (MemoryItemViewModel)(MemoryListView.ItemFromContainer(requestedElement));
Point point;
if (e.TryGetPosition(requestedElement, out point))
{
m_memoryItemFlyout.ShowAt(requestedElement, point);
}
else
{
// Not invoked via pointer, so let XAML choose a default location.
m_memoryItemFlyout.ShowAt(requestedElement);
}
e.Handled = true;
}
}
void OnContextCanceled(Windows.UI.Xaml.UIElement sender, Windows.UI.Xaml.RoutedEventArgs e)
{
m_memoryItemFlyout.Hide();
}
void OnClearMenuItemClicked(object sender, RoutedEventArgs e)
{
GetMemoryItemForCurrentFlyout().Clear();
}
void OnMemoryAddMenuItemClicked(object sender, RoutedEventArgs e)
{
GetMemoryItemForCurrentFlyout().MemoryAdd();
}
void OnMemorySubtractMenuItemClicked(object sender, RoutedEventArgs e)
{
GetMemoryItemForCurrentFlyout().MemorySubtract();
}
public bool IsErrorVisualState
{
get => m_isErrorVisualState;
set
{
if (m_isErrorVisualState != value)
{
m_isErrorVisualState = value;
string newState = m_isErrorVisualState ? "ErrorLayout" : "NoErrorLayout";
VisualStateManager.GoToState(this, newState, false);
}
}
}
MemoryItemViewModel GetMemoryItemForCurrentFlyout()
{
var listViewItem = m_memoryItemFlyout.Target;
return (MemoryItemViewModel)(MemoryListView.ItemFromContainer(listViewItem));
}
}
} }

View file

@ -1,116 +1,108 @@
<UserControl x:Class="WindowsCalculator.Shared.Views.MemoryListItem" <UserControl x:Class="CalculatorApp.MemoryListItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:CalculatorApp.Common" xmlns:common="using:CalculatorApp.Common"
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"
FlowDirection="LeftToRight" FlowDirection="LeftToRight"
mc:Ignorable=""> mc:Ignorable="d">
<!-- UNO TODO x:Name="MemoryListItem"--> <!-- UNO TODO x:Name="MemoryListItem"-->
<!--
UNO TODO
<UserControl.Resources> <UserControl.Resources>
<muxc:FontIconSource x:Key="MemClearGlyph"
<!-- FontFamily="{StaticResource CalculatorFontFamily}"
UNO TODO Glyph="&#xf754;"/>
<muxc:FontIconSource x:Key="MemClearGlyph"
FontFamily="{StaticResource CalculatorFontFamily}"
Glyph="&#xf754;" />
<muxc:FontIconSource x:Key="MemPlusGlyph" <muxc:FontIconSource x:Key="MemPlusGlyph"
FontFamily="{StaticResource CalculatorFontFamily}" FontFamily="{StaticResource CalculatorFontFamily}"
Glyph="&#xf757;" /> Glyph="&#xf757;"/>
<muxc:FontIconSource x:Key="MemMinusGlyph" <muxc:FontIconSource x:Key="MemMinusGlyph"
FontFamily="{StaticResource CalculatorFontFamily}" FontFamily="{StaticResource CalculatorFontFamily}"
Glyph="&#xf758;" /> Glyph="&#xf758;"/>
<muxc:SwipeItems x:Key="MemorySwipeItems" <muxc:SwipeItems x:Key="MemorySwipeItems" Mode="Reveal">
Mode="Reveal">
<muxc:SwipeItem x:Uid="ClearMemorySwipeItem" <muxc:SwipeItem x:Uid="ClearMemorySwipeItem"
Background="{ThemeResource SystemControlBackgroundAccentBrush}" Background="{ThemeResource SystemControlBackgroundAccentBrush}"
IconSource="{StaticResource MemClearGlyph}" IconSource="{StaticResource MemClearGlyph}"
Invoked="OnClearSwipeInvoked" /> Invoked="OnClearSwipeInvoked"/>
<muxc:SwipeItem x:Uid="MemPlusSwipeItem" <muxc:SwipeItem x:Uid="MemPlusSwipeItem"
Background="{ThemeResource SystemControlBackgroundAccentBrush}" Background="{ThemeResource SystemControlBackgroundAccentBrush}"
IconSource="{StaticResource MemPlusGlyph}" IconSource="{StaticResource MemPlusGlyph}"
Invoked="OnMemoryAddSwipeInvoked" /> Invoked="OnMemoryAddSwipeInvoked"/>
<muxc:SwipeItem x:Uid="MemMinusSwipeItem" <muxc:SwipeItem x:Uid="MemMinusSwipeItem"
Background="{ThemeResource SystemControlBackgroundAccentBrush}" Background="{ThemeResource SystemControlBackgroundAccentBrush}"
IconSource="{StaticResource MemMinusGlyph}" IconSource="{StaticResource MemMinusGlyph}"
Invoked="OnMemorySubtractSwipeInvoked" /> Invoked="OnMemorySubtractSwipeInvoked"/>
</muxc:SwipeItems>--> </muxc:SwipeItems>
</UserControl.Resources> </UserControl.Resources>
<muxc:SwipeControl RightItems="{StaticResource MemorySwipeItems}">
<!--<muxc:SwipeControl RightItems="{StaticResource MemorySwipeItems}"> -->
<Grid>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="HoverStates"> <VisualStateGroup x:Name="HoverStates">
<VisualState x:Name="MemoryButtonsVisible"> <VisualState x:Name="MemoryButtonsVisible">
<VisualState.Setters> <VisualState.Setters>
<Setter Target="MemoryHoverButtons.Opacity" <Setter Target="MemoryHoverButtons.Opacity" Value="1"/>
Value="1" />
</VisualState.Setters> </VisualState.Setters>
</VisualState> </VisualState>
<VisualState x:Name="MemoryButtonsHidden" /> <VisualState x:Name="MemoryButtonsHidden"/>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<Grid Background="Transparent"> <Grid Background="Transparent">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Margin="0,2,14,0" <TextBlock Margin="0,2,14,0"
Style="{ThemeResource TitleTextBlockStyle}" HorizontalAlignment="Right"
FontWeight="SemiBold" Style="{ThemeResource TitleTextBlockStyle}"
FlowDirection="LeftToRight" FontWeight="SemiBold"
Text="{x:Bind Model.Value, Mode=OneWay}" FlowDirection="LeftToRight"
TextAlignment="Right" IsTextSelectionEnabled="True"
TextReadingOrder="DetectFromContent" Text="{x:Bind Model.Value, Mode=OneWay}"
TextWrapping="Wrap" /> TextAlignment="Right"
TextReadingOrder="DetectFromContent"
TextWrapping="Wrap"/>
<Grid x:Name="MemoryHoverButtons" <Grid x:Name="MemoryHoverButtons"
Grid.Row="1" Grid.Row="1"
Margin="0,0,10,2" Margin="0,0,10,2"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Opacity="0"> Opacity="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Uid="ClearMemoryItemButton" <Button x:Uid="ClearMemoryItemButton"
Style="{StaticResource MemoryHoverButtonStyle}" Style="{StaticResource MemoryHoverButtonStyle}"
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}" Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
AutomationProperties.AutomationId="MClearButton" AutomationProperties.AutomationId="MClearButton"
Click="OnClearButtonClicked" Click="OnClearButtonClicked"
Content="MC" /> Content="MC"/>
<Button x:Uid="MemPlusItem" <Button x:Uid="MemPlusItem"
Grid.Column="1" Grid.Column="1"
Margin="0" Margin="0"
Style="{StaticResource MemoryHoverButtonStyle}" Style="{StaticResource MemoryHoverButtonStyle}"
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}" Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
AutomationProperties.AutomationId="MAddButton" AutomationProperties.AutomationId="MAddButton"
Click="OnMemoryAddButtonClicked" Click="OnMemoryAddButtonClicked"
Content="M+" /> Content="M+"/>
<Button x:Uid="MemMinusItem" <Button x:Uid="MemMinusItem"
Grid.Column="2" Grid.Column="2"
Style="{StaticResource MemoryHoverButtonStyle}" Style="{StaticResource MemoryHoverButtonStyle}"
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}" Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
AutomationProperties.AutomationId="MSubButton" AutomationProperties.AutomationId="MSubButton"
Click="OnMemorySubtractButtonClicked" Click="OnMemorySubtractButtonClicked"
Content="M-" /> Content="M-"/>
</Grid> </Grid>
</Grid> </Grid>
</muxc:SwipeControl>--> </Grid>
</UserControl> </UserControl>

View file

@ -1,27 +1,81 @@
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.ViewModel;
using System.Runtime.InteropServices.WindowsRuntime;
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.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 WindowsCalculator.Shared.Views
{ {
public sealed partial class MemoryListItem : UserControl /// <summary>
/// Represents a single item in the Memory list.
/// </summary>
public partial class MemoryListItem
{ {
public MemoryItemViewModel Model
{
get { return (MemoryItemViewModel)GetValue(ModelProperty); }
set { SetValue(ModelProperty, value); }
}
// Using a DependencyProperty as the backing store for Model. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ModelProperty =
DependencyProperty.Register("Model", typeof(MemoryItemViewModel), typeof(MemoryListItem), new PropertyMetadata(null));
public MemoryListItem() public MemoryListItem()
{ {
this.InitializeComponent(); InitializeComponent();
} }
}
protected override void OnPointerEntered(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
base.OnPointerEntered(e);
// Only show hover buttons when the user is using mouse or pen.
if (e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse
|| e.Pointer.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
{
VisualStateManager.GoToState(this, "MemoryButtonsVisible", true);
}
}
protected override void OnPointerExited(Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
base.OnPointerExited(e);
VisualStateManager.GoToState(this, "MemoryButtonsHidden", true);
}
void OnClearButtonClicked(object sender, RoutedEventArgs e)
{
Model.Clear();
}
void OnMemoryAddButtonClicked(object sender, RoutedEventArgs e)
{
Model.MemoryAdd();
}
void OnMemorySubtractButtonClicked(object sender, RoutedEventArgs e)
{
Model.MemorySubtract();
}
#if false
void OnClearSwipeInvoked(object sender, SwipeItemInvokedEventArgs e)
{
Model.Clear();
}
void OnMemoryAddSwipeInvoked(object sender, SwipeItemInvokedEventArgs e)
{
Model.MemoryAdd();
}
void OnMemorySubtractSwipeInvoked(object sender, SwipeItemInvokedEventArgs e)
{
Model.MemorySubtract();
}
#endif
};
} }