mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Add support for memory list
This commit is contained in:
parent
e5cdaeaf0d
commit
3fbc99db74
5 changed files with 324 additions and 227 deletions
|
@ -1518,7 +1518,7 @@ namespace CalculatorApp.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
void OnMemoryItemPressed(object memoryItemPosition)
|
||||
public void OnMemoryItemPressed(object memoryItemPosition)
|
||||
{
|
||||
if (MemorizedNumbers != null && MemorizedNumbers.Count > 0)
|
||||
{
|
||||
|
|
|
@ -4,140 +4,102 @@
|
|||
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"
|
||||
-->
|
||||
|
||||
<!-- UNO TODO
|
||||
<UserControl.Resources>
|
||||
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<converters:BooleanToVisibilityNegationConverter x:Key="BooleanToVisibilityNegationConverter" />
|
||||
<converters:BooleanNegationConverter x:Key="BooleanNegationConverter" />
|
||||
<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 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>
|
||||
|
||||
<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" />
|
||||
<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"
|
||||
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="2">
|
||||
|
||||
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}}" />
|
||||
|
||||
Visibility="{Binding IsMemoryEmpty, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||
<ListView x:Name="MemoryListView"
|
||||
Padding="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
@ -152,15 +114,13 @@
|
|||
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"
|
||||
|
@ -168,13 +128,8 @@
|
|||
AutomationProperties.AutomationId="ClearMemory"
|
||||
Command="{x:Bind Model.ClearMemoryCommand, Mode=OneWay}"
|
||||
Content=""
|
||||
Visibility="{x:Bind Model.IsMemoryEmpty, Mode=OneWay, Converter={StaticResource BooleanToVisibilityNegationConverter}}" />
|
||||
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,125 @@
|
|||
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();
|
||||
m_memoryItemFlyout = (MenuFlyout)(Resources["MemoryContextMenu"]);
|
||||
|
||||
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,99 +1,92 @@
|
|||
<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"-->
|
||||
|
||||
<UserControl.Resources>
|
||||
|
||||
<!--
|
||||
UNO TODO
|
||||
<UserControl.Resources>
|
||||
<muxc:FontIconSource x:Key="MemClearGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
|
||||
Glyph=""/>
|
||||
<muxc:FontIconSource x:Key="MemPlusGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
|
||||
Glyph=""/>
|
||||
<muxc:FontIconSource x:Key="MemMinusGlyph"
|
||||
FontFamily="{StaticResource CalculatorFontFamily}"
|
||||
Glyph="" />
|
||||
|
||||
<muxc:SwipeItems x:Key="MemorySwipeItems"
|
||||
Mode="Reveal">
|
||||
Glyph=""/>
|
||||
|
||||
<muxc:SwipeItems x:Key="MemorySwipeItems" Mode="Reveal">
|
||||
<muxc:SwipeItem x:Uid="ClearMemorySwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemClearGlyph}"
|
||||
Invoked="OnClearSwipeInvoked" />
|
||||
|
||||
Invoked="OnClearSwipeInvoked"/>
|
||||
<muxc:SwipeItem x:Uid="MemPlusSwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemPlusGlyph}"
|
||||
Invoked="OnMemoryAddSwipeInvoked" />
|
||||
|
||||
Invoked="OnMemoryAddSwipeInvoked"/>
|
||||
<muxc:SwipeItem x:Uid="MemMinusSwipeItem"
|
||||
Background="{ThemeResource SystemControlBackgroundAccentBrush}"
|
||||
IconSource="{StaticResource MemMinusGlyph}"
|
||||
Invoked="OnMemorySubtractSwipeInvoked" />
|
||||
</muxc:SwipeItems>-->
|
||||
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"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{ThemeResource TitleTextBlockStyle}"
|
||||
FontWeight="SemiBold"
|
||||
FlowDirection="LeftToRight"
|
||||
IsTextSelectionEnabled="True"
|
||||
Text="{x:Bind Model.Value, Mode=OneWay}"
|
||||
TextAlignment="Right"
|
||||
TextReadingOrder="DetectFromContent"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
TextWrapping="Wrap"/>
|
||||
<Grid x:Name="MemoryHoverButtons"
|
||||
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" />
|
||||
|
||||
Content="MC"/>
|
||||
<Button x:Uid="MemPlusItem"
|
||||
Grid.Column="1"
|
||||
Margin="0"
|
||||
|
@ -101,16 +94,15 @@
|
|||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MAddButton"
|
||||
Click="OnMemoryAddButtonClicked"
|
||||
Content="M+" />
|
||||
|
||||
Content="M+"/>
|
||||
<Button x:Uid="MemMinusItem"
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource MemoryHoverButtonStyle}"
|
||||
Background="{ThemeResource SystemControlBackgroundAltMediumHighBrush}"
|
||||
AutomationProperties.AutomationId="MSubButton"
|
||||
Click="OnMemorySubtractButtonClicked"
|
||||
Content="M-" />
|
||||
Content="M-"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</muxc:SwipeControl>-->
|
||||
</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