Add copy button to history menu item context menu (#628)

Adds a Copy button to the context menu for history menu items located above the delete button in the menu. Copy only copies the result and not the entire content of the history item (equation and result).

Fixes #429
This commit is contained in:
Zach Herman 2019-09-19 16:41:50 -07:00 committed by Howard Wolosky
parent d6d5591148
commit d68e505b04
4 changed files with 19 additions and 0 deletions

View File

@ -1109,6 +1109,10 @@
<value>Delete</value>
<comment>Text string for the Calculator Delete swipe button in the History list</comment>
</data>
<data name="CopyHistoryMenuItem.Text" xml:space="preserve">
<value>Copy</value>
<comment>Text string for the Calculator Copy option in the History list context menu</comment>
</data>
<data name="DeleteHistoryMenuItem.Text" xml:space="preserve">
<value>Delete</value>
<comment>Text string for the Calculator Delete option in the History list context menu</comment>

View File

@ -50,6 +50,9 @@
</muxc:SwipeItems>
<MenuFlyout x:Name="HistoryContextMenu">
<MenuFlyoutItem x:Uid="CopyHistoryMenuItem"
Click="OnCopyMenuItemClicked"
Icon="Copy"/>
<MenuFlyoutItem x:Uid="DeleteHistoryMenuItem"
Click="OnDeleteMenuItemClicked"
Icon="Delete"/>

View File

@ -8,6 +8,7 @@
#include "pch.h"
#include "HistoryList.xaml.h"
#include "CalcViewModel/Common/CopyPasteManager.h"
#include "CalcViewModel/Common/LocalizationService.h"
using namespace CalculatorApp;
@ -52,6 +53,16 @@ void HistoryList::ListView_ItemClick(_In_ Object ^ sender, _In_ ItemClickEventAr
}
}
void HistoryList::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{
auto listViewItem = HistoryContextMenu->Target;
auto itemViewModel = dynamic_cast<HistoryItemViewModel ^>(HistoryListView->ItemFromContainer(listViewItem));
if (itemViewModel != nullptr)
{
CopyPasteManager::CopyToClipboard(itemViewModel->Result);
}
}
void HistoryList::OnDeleteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{
auto listViewItem = HistoryContextMenu->Target;

View File

@ -34,6 +34,7 @@ namespace CalculatorApp
Windows::Foundation::Rect m_visibleBounds;
Windows::Foundation::Rect m_coreBounds;
void ListView_ItemClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnDeleteMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnDeleteSwipeInvoked(_In_ Microsoft::UI::Xaml::Controls::SwipeItem ^ sender, _In_ Microsoft::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
};