mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Merge pull request #24 from nventive/dev/jela/history
Restore Memory and History lists
This commit is contained in:
commit
16ccc6034a
18 changed files with 757 additions and 467 deletions
|
@ -83,13 +83,13 @@ public:
|
|||
{
|
||||
DBGPRINT("Native:SetExpressionDisplay()\n");
|
||||
|
||||
auto item = std::make_shared<HISTORYITEM>();
|
||||
auto item = std::make_shared<HISTORYITEM>();
|
||||
item->historyItemVector.expression = L"";
|
||||
item->historyItemVector.result = L"";
|
||||
item->historyItemVector.spCommands = commands;
|
||||
item->historyItemVector.spTokens = tokens;
|
||||
|
||||
auto pItem = MarshalHistoryItem(item);
|
||||
auto pItem = MarshalHistoryItem(item);
|
||||
|
||||
_params.SetExpressionDisplay(_params.CalculatorState, pItem);
|
||||
}
|
||||
|
@ -187,6 +187,21 @@ IExpressionCommand* AsIExpressionCommand(void* 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)
|
||||
{
|
||||
auto out = new wchar_t[str.size() + 1]{};
|
||||
|
@ -270,7 +285,6 @@ void* MarshalHistoryItems(std::vector<std::shared_ptr<CalculationManager::HISTOR
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
void* CalculatorManager_Create(CalculatorManager_CreateParams* pParams)
|
||||
{
|
||||
auto calcDisplay = new CalcDisplay(*pParams);
|
||||
|
@ -423,10 +437,71 @@ void* CalculatorManager_GetHistoryItem(void* manager, int index)
|
|||
{
|
||||
auto historyItem = AsManager(manager)->GetHistoryItem(index);
|
||||
|
||||
return MarshalHistoryItem(historyItem);
|
||||
return MarshalHistoryItem(historyItem);
|
||||
}
|
||||
|
||||
void Free(void* ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
int IExpressionCommand_GetCommandType(void* pExpressionCommand)
|
||||
{
|
||||
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,26 +22,27 @@ typedef void (*MemoryItemChangedFunc)(void* state, unsigned int indexOfMemory);
|
|||
|
||||
typedef const wchar_t* (*GetCEngineStringFunc)(void* state, const wchar_t* id);
|
||||
|
||||
struct CalculatorManager_CreateParams {
|
||||
void* CalculatorState;
|
||||
struct CalculatorManager_CreateParams
|
||||
{
|
||||
void* CalculatorState;
|
||||
|
||||
SetPrimaryDisplayFunc SetPrimaryDisplay;
|
||||
SetIsInErrorFunc SetIsInError;
|
||||
SetExpressionDisplayFunc SetExpressionDisplay;
|
||||
SetParenthesisNumberFunc SetParenthesisNumber;
|
||||
OnNoRightParenAddedFunc OnNoRightParenAdded;
|
||||
MaxDigitsReachedFunc MaxDigitsReached;
|
||||
BinaryOperatorReceivedFunc BinaryOperatorReceived;
|
||||
OnHistoryItemAddedFunc OnHistoryItemAdded;
|
||||
SetMemorizedNumbersFunc SetMemorizedNumbers;
|
||||
MemoryItemChangedFunc MemoryItemChanged;
|
||||
SetPrimaryDisplayFunc SetPrimaryDisplay;
|
||||
SetIsInErrorFunc SetIsInError;
|
||||
SetExpressionDisplayFunc SetExpressionDisplay;
|
||||
SetParenthesisNumberFunc SetParenthesisNumber;
|
||||
OnNoRightParenAddedFunc OnNoRightParenAdded;
|
||||
MaxDigitsReachedFunc MaxDigitsReached;
|
||||
BinaryOperatorReceivedFunc BinaryOperatorReceived;
|
||||
OnHistoryItemAddedFunc OnHistoryItemAdded;
|
||||
SetMemorizedNumbersFunc SetMemorizedNumbers;
|
||||
MemoryItemChangedFunc MemoryItemChanged;
|
||||
|
||||
void* ResourceState;
|
||||
GetCEngineStringFunc GetCEngineString;
|
||||
void* ResourceState;
|
||||
GetCEngineStringFunc GetCEngineString;
|
||||
};
|
||||
|
||||
#if defined(__EMSCRIPTEN__) || defined(__APPLE__)
|
||||
#define DLL_EXPORT
|
||||
#define DLL_EXPORT
|
||||
#else
|
||||
#define DLL_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
@ -49,9 +50,9 @@ struct CalculatorManager_CreateParams {
|
|||
GetHistoryItemResult* MarshalHistoryItem(std::shared_ptr<CalculationManager::HISTORYITEM>& historyItem);
|
||||
void* MarshalHistoryItems(std::vector<std::shared_ptr<CalculationManager::HISTORYITEM>>& historyItems);
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct GetHistoryItemsResult
|
||||
extern "C"
|
||||
{
|
||||
struct GetHistoryItemsResult
|
||||
{
|
||||
int32_t ItemsCount;
|
||||
void* HistoryItems;
|
||||
|
@ -70,6 +71,18 @@ extern "C" {
|
|||
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_SendCommand(void* manager, int command);
|
||||
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_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.
|
@ -9,12 +9,17 @@ namespace CalculatorApp
|
|||
{
|
||||
List<TType> m_vector;
|
||||
|
||||
public CalculatorList()
|
||||
{
|
||||
m_vector = new List<TType>();
|
||||
}
|
||||
public CalculatorList()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -99,15 +99,32 @@ namespace CalculationManager
|
|||
[DllImport(DllPath)]
|
||||
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)]
|
||||
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)]
|
||||
public delegate IntPtr GetCEngineStringFunc(IntPtr state, IntPtr id);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void BinaryOperatorReceivedFunc(IntPtr state);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetPrimaryDisplayCallbackFunc(IntPtr state, IntPtr pDisplayStringValue, bool isError);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetIsInErrorCallbackFunc(IntPtr state, bool isError);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
|
@ -353,8 +370,8 @@ namespace CalculationManager
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct GetHistoryItemResult
|
||||
{
|
||||
public string expression;
|
||||
public string result;
|
||||
public IntPtr expression;
|
||||
public IntPtr result;
|
||||
|
||||
public int TokenCount;
|
||||
public IntPtr TokenStrings;
|
||||
|
@ -364,6 +381,19 @@ namespace CalculationManager
|
|||
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
|
||||
{
|
||||
|
@ -371,6 +401,5 @@ namespace CalculationManager
|
|||
private GCHandle _displayCallbackHandle;
|
||||
private GCHandle _resourceProviderHandle;
|
||||
private readonly IntPtr _nativeManager;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,8 +251,8 @@ namespace CalculationManager
|
|||
internal static HISTORYITEM UnmarshalHistoryItemResult(GetHistoryItemResult historyResultItem)
|
||||
{
|
||||
var historyItem = new HISTORYITEM();
|
||||
historyItem.historyItemVector.expression = historyResultItem.expression;
|
||||
historyItem.historyItemVector.result = historyResultItem.result;
|
||||
historyItem.historyItemVector.expression = NativeDispatch.PtrToString(historyResultItem.expression);
|
||||
historyItem.historyItemVector.result = NativeDispatch.PtrToString(historyResultItem.result);
|
||||
historyItem.historyItemVector.spTokens = new CalculatorList<(string, int)>();
|
||||
|
||||
for (var i = 0; i < historyResultItem.TokenCount; i++)
|
||||
|
@ -274,7 +274,7 @@ namespace CalculationManager
|
|||
switch (commandType)
|
||||
{
|
||||
case CommandType.BinaryCommand:
|
||||
return new CUnaryCommand(pExpressionCommand);
|
||||
return new CBinaryCommand(pExpressionCommand);
|
||||
|
||||
case CommandType.OperandCommand:
|
||||
return new COpndCommand(pExpressionCommand);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using CalculatorApp;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CalculationManager
|
||||
{
|
||||
|
@ -73,13 +74,27 @@ namespace CalculationManager
|
|||
|
||||
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 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 void SetCommand(int command) => throw new NotImplementedException();
|
||||
public void SetCommands(int command1, int command2) => throw new NotImplementedException();
|
||||
|
@ -88,32 +103,45 @@ namespace CalculationManager
|
|||
|
||||
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 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 void Accept(ISerializeCommandVisitor commandVisitor) => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
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(IntPtr pExpressionCommand) => this.pExpressionCommand = pExpressionCommand;
|
||||
public COpndCommand(IntPtr pExpressionCommand) => this.m_pExpressionCommand = pExpressionCommand;
|
||||
|
||||
// public void Initialize(CalcEngine.Rational rat) => throw new NotImplementedException();
|
||||
|
||||
public CalculatorList<int> GetCommands() => throw new NotImplementedException();
|
||||
public void SetCommands(CalculatorList<int> commands) => throw new NotImplementedException();
|
||||
public CalculatorList<int> GetCommands()
|
||||
{
|
||||
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 ToggleSign() => 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 IsDecimalPresent() => 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;
|
||||
}
|
||||
|
|
|
@ -153,12 +153,12 @@ namespace CalculatorApp
|
|||
calculatorDisplay.SetHistoryCallback(new WeakReference(this));
|
||||
}
|
||||
|
||||
void ShowItem(HistoryItemViewModel e)
|
||||
public void ShowItem(HistoryItemViewModel e)
|
||||
{
|
||||
HistoryItemClicked(e);
|
||||
}
|
||||
|
||||
void DeleteItem(HistoryItemViewModel e)
|
||||
public void DeleteItem(HistoryItemViewModel e)
|
||||
{
|
||||
int itemIndex= Items.IndexOf(e);
|
||||
if (itemIndex != -1)
|
||||
|
|
|
@ -1518,7 +1518,7 @@ namespace CalculatorApp.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
void OnMemoryItemPressed(object memoryItemPosition)
|
||||
public void OnMemoryItemPressed(object memoryItemPosition)
|
||||
{
|
||||
if (MemorizedNumbers != null && MemorizedNumbers.Count > 0)
|
||||
{
|
||||
|
|
|
@ -1,220 +1,204 @@
|
|||
<UserControl x:Class="CalculatorApp.HistoryList"
|
||||
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:automation="using:CalculatorApp.Common.Automation"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
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:model="using:CalculatorApp.ViewModel"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
AutomationProperties.AutomationId="HistoryList"
|
||||
FlowDirection="LeftToRight"
|
||||
mc:Ignorable="">
|
||||
|
||||
<!--UNO TODO
|
||||
x:Name="HistoryList"
|
||||
Loaded="HistoryList_Loaded"
|
||||
Unloaded="HistoryList_Unloaded"
|
||||
-->
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- UNO TODO x:Name="HistoryList"-->
|
||||
|
||||
<!--<UserControl.Resources>
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<Style x:Key="BodyTextBlockMediumStyle"
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock">
|
||||
<Setter Property="Foreground"
|
||||
Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<Style x:Key="BodyTextBlockMediumStyle"
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock">
|
||||
<Setter Property="Foreground"
|
||||
Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<Style x:Key="BodyTextBlockMediumStyle"
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock" />
|
||||
BasedOn="{StaticResource BodyTextBlockStyle}"
|
||||
TargetType="TextBlock"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
|
||||
<converters:ItemSizeToVisibilityNegationConverter x:Key="ItemSizeToVisibilityNegationConverter" />
|
||||
|
||||
<converters:ItemSizeToVisibilityConverter x:Key="ItemSizeToVisibilityConverter" />
|
||||
|
||||
--><!--
|
||||
UNO TODO
|
||||
<automation:NarratorNotifier x:Name="NarratorNotifier"
|
||||
Announcement="{x:Bind Model.HistoryAnnouncement, Mode=OneWay}" />
|
||||
--><!--
|
||||
<converters:ItemSizeToVisibilityNegationConverter x:Key="ItemSizeToVisibilityNegationConverter"/>
|
||||
<converters:ItemSizeToVisibilityConverter x:Key="ItemSizeToVisibilityConverter"/>
|
||||
|
||||
--><!--
|
||||
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">
|
||||
<!--UNO TODO-->
|
||||
<win:MenuFlyout x:Key="HistoryContextMenu">
|
||||
<MenuFlyoutItem x:Uid="DeleteHistoryMenuItem"
|
||||
Click="OnDeleteMenuItemClicked"
|
||||
Icon="Delete" />
|
||||
</MenuFlyout>
|
||||
Click="OnDeleteMenuItemClicked"
|
||||
Icon="Delete"/>
|
||||
</win:MenuFlyout>
|
||||
|
||||
<DataTemplate x:Key="HistoryItemTemplate"
|
||||
x:DataType="model:HistoryItemViewModel">
|
||||
|
||||
--><!-- UNO TODO
|
||||
|
||||
<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"
|
||||
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>
|
||||
<!--
|
||||
UNO TODO
|
||||
<automation:NarratorNotifier x:Name="NarratorNotifier" Announcement="{x:Bind Model.HistoryAnnouncement, Mode=OneWay}"/>
|
||||
|
||||
<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"
|
||||
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="Margin"
|
||||
Value="0,0,0,20" />
|
||||
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"
|
||||
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>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="LayoutGrid">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="{Binding RowHeight, ElementName=HistoryList, Mode=OneWay}" />
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="{Binding RowHeight, ElementName=HistoryList, Mode=OneWay}"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup>
|
||||
<VisualState x:Name="DockedLayout">
|
||||
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="560" />
|
||||
<AdaptiveTrigger MinWindowWidth="560"/>
|
||||
</VisualState.StateTriggers>
|
||||
|
||||
<VisualState.Setters>
|
||||
<Setter Target="HistoryListRootGrid.(Grid.Row)"
|
||||
Value="1" />
|
||||
<Setter Target="HistoryListRootGrid.(Grid.RowSpan)"
|
||||
Value="2" />
|
||||
<Setter Target="HistoryListView.Padding"
|
||||
Value="0" />
|
||||
<Setter Target="BackgroundShade.Opacity"
|
||||
Value="0" />
|
||||
<Setter Target="CustomTitleBar.Height"
|
||||
Value="0" />
|
||||
<Setter Target="HistoryListRootGrid.(Grid.Row)" Value="0"/>
|
||||
<Setter Target="HistoryListRootGrid.(Grid.RowSpan)" Value="2"/>
|
||||
<Setter Target="HistoryListView.Padding" Value="0"/>
|
||||
<Setter Target="BackgroundShade.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="DefaultLayout">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="0" />
|
||||
<AdaptiveTrigger MinWindowWidth="0"/>
|
||||
</VisualState.StateTriggers>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<Border x:Name="BackgroundShade"
|
||||
Grid.Row="2"
|
||||
Margin="0,-1,0,0"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
||||
BorderThickness="{ThemeResource HighContrastThicknessTop}" />
|
||||
Grid.Row="1"
|
||||
Margin="0,-1,0,0"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
||||
BorderThickness="{ThemeResource HighContrastThicknessTop}"/>
|
||||
|
||||
<Grid x:Name="HistoryListRootGrid"
|
||||
Grid.Row="2">
|
||||
|
||||
<Grid x:Name="HistoryListRootGrid" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="HistoryEmpty"
|
||||
x:Uid="HistoryEmpty"
|
||||
Margin="12,14,24,0"
|
||||
Style="{ThemeResource BaseTextBlockStyle}"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding ItemSize, Converter={StaticResource ItemSizeToVisibilityConverter}}" />
|
||||
|
||||
x:Uid="HistoryEmpty"
|
||||
Margin="12,14,24,0"
|
||||
Style="{ThemeResource BaseTextBlockStyle}"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding ItemSize, Converter={StaticResource ItemSizeToVisibilityConverter}}"/>
|
||||
<ListView x:Name="HistoryListView"
|
||||
MinHeight="60"
|
||||
Padding="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.AutomationId="HistoryListView"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ListView_ItemClick"
|
||||
ItemContainerStyle="{StaticResource HistoryItemContainerStyle}"
|
||||
ItemTemplate="{StaticResource HistoryItemTemplate}"
|
||||
ItemsSource="{x:Bind Model.Items, Mode=OneWay}"
|
||||
SelectionMode="None"
|
||||
TabIndex="0"
|
||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}">
|
||||
MinHeight="60"
|
||||
Padding="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.AutomationId="HistoryListView"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="ListView_ItemClick"
|
||||
ItemContainerStyle="{StaticResource HistoryItemContainerStyle}"
|
||||
ItemTemplate="{StaticResource HistoryItemTemplate}"
|
||||
ItemsSource="{x:Bind Model.Items, Mode=OneWay}"
|
||||
SelectionMode="None"
|
||||
TabIndex="0"
|
||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}">
|
||||
<ListView.ItemContainerTransitions>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
<ContentThemeTransition />
|
||||
<ReorderThemeTransition />
|
||||
<AddDeleteThemeTransition/>
|
||||
<ContentThemeTransition/>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ListView.ItemContainerTransitions>
|
||||
</ListView>
|
||||
|
||||
<Button x:Name="ClearHistory"
|
||||
x:Uid="ClearHistory"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource ClearAllHistoryMemoryButtonStyle}"
|
||||
AutomationProperties.AutomationId="ClearHistory"
|
||||
Command="{x:Bind Model.ClearCommand, Mode=OneWay}"
|
||||
Content=""
|
||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}" />
|
||||
x:Uid="ClearHistory"
|
||||
Grid.Row="1"
|
||||
Style="{StaticResource ClearAllHistoryMemoryButtonStyle}"
|
||||
AutomationProperties.AutomationId="ClearHistory"
|
||||
Command="{x:Bind Model.ClearCommand, Mode=OneWay}"
|
||||
Content=""
|
||||
Visibility="{x:Bind Model.ItemSize, Mode=OneWay, Converter={StaticResource ItemSizeToVisibilityNegationConverter}}"/>
|
||||
</Grid>
|
||||
|
||||
<Border x:Name="CustomTitleBar"
|
||||
Height="32"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{ThemeResource TitleBarBackgroundTransparentBrush}" />
|
||||
</Grid>-->
|
||||
</UserControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -1,27 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using CalculatorApp.Common;
|
||||
using CalculatorApp.ViewModel;
|
||||
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
|
||||
{
|
||||
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()
|
||||
{
|
||||
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"
|
||||
Visibility="Collapsed"/>
|
||||
|
||||
<!--
|
||||
x:Uid="NavView"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
PaneClosed="OnNavPaneClosed"
|
||||
PaneOpened="OnNavPaneOpened"
|
||||
PaneOpening="OnNavPaneOpening"
|
||||
-->
|
||||
<!--UNO TODO
|
||||
CompactModeThresholdWidth="Infinity"
|
||||
ExpandedModeThresholdWidth="Infinity"
|
||||
-->
|
||||
<NavigationView x:Name="NavView"
|
||||
Grid.Row="2"
|
||||
DataContext="{x:Bind Model}"
|
||||
IsSettingsVisible="False"
|
||||
Loaded="OnNavLoaded"
|
||||
MenuItemsSource="{x:Bind UIElementsForCategories, Mode=OneWay}"
|
||||
OpenPaneLength="{StaticResource SplitViewOpenPaneLength}"
|
||||
SelectionChanged="OnNavSelectionChanged"
|
||||
TabIndex="1"
|
||||
UseSystemFocusVisuals="True">
|
||||
CompactModeThresholdWidth="10000"
|
||||
ExpandedModeThresholdWidth="10000"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
PaneClosed="OnNavPaneClosed"
|
||||
PaneOpened="OnNavPaneOpened"
|
||||
PaneOpening="OnNavPaneOpening"
|
||||
Grid.Row="2"
|
||||
DataContext="{x:Bind Model}"
|
||||
IsSettingsVisible="False"
|
||||
Loaded="OnNavLoaded"
|
||||
MenuItemsSource="{x:Bind UIElementsForCategories, Mode=OneWay}"
|
||||
OpenPaneLength="{StaticResource SplitViewOpenPaneLength}"
|
||||
SelectionChanged="OnNavSelectionChanged"
|
||||
TabIndex="1"
|
||||
UseSystemFocusVisuals="True">
|
||||
|
||||
<NavigationView.PaneFooter>
|
||||
|
||||
|
|
|
@ -77,7 +77,11 @@ namespace CalculatorApp
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -1,180 +1,137 @@
|
|||
<UserControl x:Class="CalculatorApp.Memory"
|
||||
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:common="using:CalculatorApp.Common"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
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:model="using:CalculatorApp.ViewModel"
|
||||
x:Name="MemoryList"
|
||||
FlowDirection="LeftToRight"
|
||||
mc:Ignorable="">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<!-- UNO TODO
|
||||
Loaded="MemoryList_Loaded"
|
||||
Unloaded="MemoryList_Unloaded"
|
||||
-->
|
||||
<UserControl.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<converters:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter"/>
|
||||
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
|
||||
|
||||
<!-- UNO TODO
|
||||
<UserControl.Resources>
|
||||
|
||||
<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">
|
||||
<!--UNO TODO-->
|
||||
<win:MenuFlyout x:Key="MemoryContextMenu">
|
||||
<MenuFlyoutItem x:Uid="ClearMemoryMenuItem" Click="OnClearMenuItemClicked">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph=""/>
|
||||
</MenuFlyoutItem.Icon>
|
||||
</MenuFlyoutItem>
|
||||
|
||||
<MenuFlyoutItem x:Uid="MemPlusMenuItem"
|
||||
Click="OnMemoryAddMenuItemClicked">
|
||||
<MenuFlyoutItem x:Uid="MemPlusMenuItem" Click="OnMemoryAddMenuItemClicked">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph=""/>
|
||||
</MenuFlyoutItem.Icon>
|
||||
</MenuFlyoutItem>
|
||||
|
||||
<MenuFlyoutItem x:Uid="MemMinusMenuItem"
|
||||
Click="OnMemorySubtractMenuItemClicked">
|
||||
<MenuFlyoutItem x:Uid="MemMinusMenuItem" Click="OnMemorySubtractMenuItemClicked">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
<FontIcon FontFamily="{StaticResource CalculatorFontFamily}" Glyph=""/>
|
||||
</MenuFlyoutItem.Icon>
|
||||
</MenuFlyoutItem>
|
||||
</MenuFlyout>
|
||||
</win:MenuFlyout>
|
||||
|
||||
<DataTemplate x:Key="MemoryItemTemplate"
|
||||
x:DataType="model:MemoryItemViewModel">
|
||||
<local:MemoryListItem Model="{x:Bind Mode=OneWay}" />
|
||||
<DataTemplate x:Key="MemoryItemTemplate" x:DataType="model:MemoryItemViewModel">
|
||||
<local:MemoryListItem Model="{x:Bind Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="MemoryItemContainerStyle"
|
||||
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="Margin"
|
||||
Value="0,0,0,8" />
|
||||
BasedOn="{StaticResource HistoryMemoryItemContainerStyle}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="Margin" Value="0,0,0,8"/>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid x:Name="LayoutGrid">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="{Binding RowHeight, ElementName=MemoryList, Mode=OneWay}" />
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="{Binding RowHeight, ElementName=MemoryList, Mode=OneWay}"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
|
||||
<VisualStateGroup x:Name="ErrorVisualStates">
|
||||
<VisualState x:Name="NoErrorLayout" />
|
||||
<VisualState x:Name="NoErrorLayout"/>
|
||||
<VisualState x:Name="ErrorLayout">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="MemoryListView.IsEnabled"
|
||||
Value="False" />
|
||||
<Setter Target="MemoryListView.IsEnabled" Value="False"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
|
||||
<VisualStateGroup>
|
||||
|
||||
<VisualState x:Name="DockedLayout">
|
||||
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="560" />
|
||||
<AdaptiveTrigger MinWindowWidth="560"/>
|
||||
</VisualState.StateTriggers>
|
||||
|
||||
<VisualState.Setters>
|
||||
<Setter Target="MemoryPanel.(Grid.Row)"
|
||||
Value="1" />
|
||||
<Setter Target="MemoryPanel.(Grid.RowSpan)"
|
||||
Value="2" />
|
||||
<Setter Target="MemoryListView.Padding"
|
||||
Value="0" />
|
||||
<Setter Target="BackgroundShade.Opacity"
|
||||
Value="0" />
|
||||
<Setter Target="CustomTitleBar.Height"
|
||||
Value="0" />
|
||||
<Setter Target="MemoryPanel.(Grid.Row)" Value="0"/>
|
||||
<Setter Target="MemoryPanel.(Grid.RowSpan)" Value="2"/>
|
||||
<Setter Target="MemoryListView.Padding" Value="0"/>
|
||||
<Setter Target="BackgroundShade.Visibility" Value="Collapsed"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
|
||||
<VisualState x:Name="DefaultLayout">
|
||||
<VisualState.StateTriggers>
|
||||
<AdaptiveTrigger MinWindowWidth="0" />
|
||||
<AdaptiveTrigger MinWindowWidth="0"/>
|
||||
</VisualState.StateTriggers>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<Border x:Name="BackgroundShade"
|
||||
Grid.Row="2"
|
||||
Margin="0,-1,0,0"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
||||
BorderThickness="{ThemeResource HighContrastThicknessTop}" />
|
||||
|
||||
<Grid x:Name="MemoryPanel"
|
||||
Grid.Row="2">
|
||||
|
||||
Grid.Row="1"
|
||||
Margin="0,-1,0,0"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{ThemeResource SystemControlChromeMediumLowAcrylicElementMediumBrush}"
|
||||
BorderBrush="{ThemeResource SystemControlForegroundChromeHighBrush}"
|
||||
BorderThickness="{ThemeResource HighContrastThicknessTop}"/>
|
||||
<Grid x:Name="MemoryPanel" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock x:Name="MemoryPaneEmpty"
|
||||
x:Uid="MemoryPaneEmpty"
|
||||
Margin="12,14,24,0"
|
||||
Style="{ThemeResource BaseTextBlockStyle}"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding IsMemoryEmpty, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
|
||||
x:Uid="MemoryPaneEmpty"
|
||||
Margin="12,14,24,0"
|
||||
Style="{ThemeResource BaseTextBlockStyle}"
|
||||
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
|
||||
TextWrapping="Wrap"
|
||||
Visibility="{Binding IsMemoryEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||
<ListView x:Name="MemoryListView"
|
||||
Padding="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
IsItemClickEnabled="true"
|
||||
ItemClick="MemoryListItemClick"
|
||||
ItemContainerStyle="{ThemeResource MemoryItemContainerStyle}"
|
||||
ItemTemplate="{ThemeResource MemoryItemTemplate}"
|
||||
ItemsSource="{x:Bind Model.MemorizedNumbers, Mode=OneWay}"
|
||||
SelectionMode="None"
|
||||
TabIndex="0"
|
||||
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
|
||||
Padding="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ContextCanceled="OnContextCanceled"
|
||||
ContextRequested="OnContextRequested"
|
||||
IsItemClickEnabled="true"
|
||||
ItemClick="MemoryListItemClick"
|
||||
ItemContainerStyle="{ThemeResource MemoryItemContainerStyle}"
|
||||
ItemTemplate="{ThemeResource MemoryItemTemplate}"
|
||||
ItemsSource="{x:Bind Model.MemorizedNumbers, Mode=OneWay}"
|
||||
SelectionMode="None"
|
||||
TabIndex="0"
|
||||
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}">
|
||||
<ListView.ItemContainerTransitions>
|
||||
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
<ContentThemeTransition />
|
||||
<ReorderThemeTransition />
|
||||
<AddDeleteThemeTransition/>
|
||||
<ContentThemeTransition/>
|
||||
<ReorderThemeTransition/>
|
||||
</TransitionCollection>
|
||||
</ListView.ItemContainerTransitions>
|
||||
</ListView>
|
||||
|
||||
<Button x:Name="ClearMemory"
|
||||
x:Uid="ClearMemory"
|
||||
Grid.Row="1"
|
||||
Style="{ThemeResource ClearAllHistoryMemoryButtonStyle}"
|
||||
AutomationProperties.AutomationId="ClearMemory"
|
||||
Command="{x:Bind Model.ClearMemoryCommand, Mode=OneWay}"
|
||||
Content=""
|
||||
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}" />
|
||||
x:Uid="ClearMemory"
|
||||
Grid.Row="1"
|
||||
Style="{ThemeResource ClearAllHistoryMemoryButtonStyle}"
|
||||
AutomationProperties.AutomationId="ClearMemory"
|
||||
Command="{x:Bind Model.ClearMemoryCommand, Mode=OneWay}"
|
||||
Content=""
|
||||
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}"/>
|
||||
</Grid>
|
||||
|
||||
<Border x:Name="CustomTitleBar"
|
||||
Height="32"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{ThemeResource TitleBarBackgroundTransparentBrush}" />
|
||||
</Grid>-->
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
|
|
|
@ -1,29 +1,127 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//
|
||||
// xaml.h
|
||||
// Declaration of the Memory class
|
||||
//
|
||||
|
||||
using CalculatorApp.Common;
|
||||
using CalculatorApp.ViewModel;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
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
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:common="using:CalculatorApp.Common"
|
||||
xmlns:controls="using:CalculatorApp.Controls"
|
||||
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:model="using:CalculatorApp.ViewModel"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
FlowDirection="LeftToRight"
|
||||
mc:Ignorable="">
|
||||
mc:Ignorable="d">
|
||||
<!-- UNO TODO x:Name="MemoryListItem"-->
|
||||
|
||||
<!--
|
||||
UNO TODO
|
||||
<UserControl.Resources>
|
||||
|
||||
<!--
|
||||
UNO TODO
|
||||
<muxc:FontIconSource x:Key="MemClearGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
|
||||
<muxc:FontIconSource x:Key="MemClearGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph=""/>
|
||||
<muxc:FontIconSource x:Key="MemPlusGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph=""/>
|
||||
<muxc:FontIconSource x:Key="MemMinusGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph=""/>
|
||||
|
||||
<muxc:SwipeItems x:Key="MemorySwipeItems"
|
||||
Mode="Reveal">
|
||||
|
||||
<muxc:SwipeItems x:Key="MemorySwipeItems" Mode="Reveal">
|
||||
<muxc:SwipeItem x:Uid="ClearMemorySwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemClearGlyph}"
|
||||
Invoked="OnClearSwipeInvoked" />
|
||||
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemClearGlyph}"
|
||||
Invoked="OnClearSwipeInvoked"/>
|
||||
<muxc:SwipeItem x:Uid="MemPlusSwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemPlusGlyph}"
|
||||
Invoked="OnMemoryAddSwipeInvoked" />
|
||||
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemPlusGlyph}"
|
||||
Invoked="OnMemoryAddSwipeInvoked"/>
|
||||
<muxc:SwipeItem x:Uid="MemMinusSwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemMinusGlyph}"
|
||||
Invoked="OnMemorySubtractSwipeInvoked" />
|
||||
</muxc:SwipeItems>-->
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemMinusGlyph}"
|
||||
Invoked="OnMemorySubtractSwipeInvoked"/>
|
||||
</muxc:SwipeItems>
|
||||
</UserControl.Resources>
|
||||
|
||||
<muxc:SwipeControl RightItems="{StaticResource MemorySwipeItems}">
|
||||
|
||||
<!--<muxc:SwipeControl RightItems="{StaticResource MemorySwipeItems}">
|
||||
-->
|
||||
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="HoverStates">
|
||||
<VisualState x:Name="MemoryButtonsVisible">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="MemoryHoverButtons.Opacity"
|
||||
Value="1" />
|
||||
<Setter Target="MemoryHoverButtons.Opacity" Value="1"/>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="MemoryButtonsHidden" />
|
||||
<VisualState x:Name="MemoryButtonsHidden"/>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<Grid Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Margin="0,2,14,0"
|
||||
Style="{ThemeResource TitleTextBlockStyle}"
|
||||
FontWeight="SemiBold"
|
||||
FlowDirection="LeftToRight"
|
||||
Text="{x:Bind Model.Value, Mode=OneWay}"
|
||||
TextAlignment="Right"
|
||||
TextReadingOrder="DetectFromContent"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
HorizontalAlignment="Right"
|
||||
Style="{ThemeResource TitleTextBlockStyle}"
|
||||
FontWeight="SemiBold"
|
||||
FlowDirection="LeftToRight"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Model.Value, Mode=OneWay}"
|
||||
TextAlignment="Right"
|
||||
TextReadingOrder="DetectFromContent"
|
||||
TextWrapping="Wrap"/>
|
||||
<Grid x:Name="MemoryHoverButtons"
|
||||
Grid.Row="1"
|
||||
Margin="0,0,10,2"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0">
|
||||
Grid.Row="1"
|
||||
Margin="0,0,10,2"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button x:Uid="ClearMemoryItemButton"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MClearButton"
|
||||
Click="OnClearButtonClicked"
|
||||
Content="MC" />
|
||||
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MClearButton"
|
||||
Click="OnClearButtonClicked"
|
||||
Content="MC"/>
|
||||
<Button x:Uid="MemPlusItem"
|
||||
Grid.Column="1"
|
||||
Margin="0"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MAddButton"
|
||||
Click="OnMemoryAddButtonClicked"
|
||||
Content="M+" />
|
||||
|
||||
Grid.Column="1"
|
||||
Margin="0"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MAddButton"
|
||||
Click="OnMemoryAddButtonClicked"
|
||||
Content="M+"/>
|
||||
<Button x:Uid="MemMinusItem"
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MSubButton"
|
||||
Click="OnMemorySubtractButtonClicked"
|
||||
Content="M-" />
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MSubButton"
|
||||
Click="OnMemorySubtractButtonClicked"
|
||||
Content="M-"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</muxc:SwipeControl>-->
|
||||
</UserControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -1,27 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using CalculatorApp.ViewModel;
|
||||
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 WindowsCalculator.Shared.Views
|
||||
namespace CalculatorApp
|
||||
{
|
||||
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()
|
||||
{
|
||||
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
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue