diff --git a/src/Calculator/Resources/en-US/Resources.resw b/src/Calculator/Resources/en-US/Resources.resw index 4b24313..5d38a1a 100644 --- a/src/Calculator/Resources/en-US/Resources.resw +++ b/src/Calculator/Resources/en-US/Resources.resw @@ -1109,6 +1109,10 @@ Delete Text string for the Calculator Delete swipe button in the History list + + Copy + Text string for the Calculator Copy option in the History list context menu + Delete Text string for the Calculator Delete option in the History list context menu diff --git a/src/Calculator/Views/HistoryList.xaml b/src/Calculator/Views/HistoryList.xaml index 58f27a0..eff64ad 100644 --- a/src/Calculator/Views/HistoryList.xaml +++ b/src/Calculator/Views/HistoryList.xaml @@ -50,6 +50,9 @@ + diff --git a/src/Calculator/Views/HistoryList.xaml.cpp b/src/Calculator/Views/HistoryList.xaml.cpp index e9e74e4..3130c48 100644 --- a/src/Calculator/Views/HistoryList.xaml.cpp +++ b/src/Calculator/Views/HistoryList.xaml.cpp @@ -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(HistoryListView->ItemFromContainer(listViewItem)); + if (itemViewModel != nullptr) + { + CopyPasteManager::CopyToClipboard(itemViewModel->Result); + } +} + void HistoryList::OnDeleteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) { auto listViewItem = HistoryContextMenu->Target; diff --git a/src/Calculator/Views/HistoryList.xaml.h b/src/Calculator/Views/HistoryList.xaml.h index f8399a8..839e47f 100644 --- a/src/Calculator/Views/HistoryList.xaml.h +++ b/src/Calculator/Views/HistoryList.xaml.h @@ -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); };