2020-07-07 23:46:16 +02:00
|
|
|
#include "pch.h"
|
2020-08-18 21:32:17 +02:00
|
|
|
#include "HasNestedCommandsVisibilityConverter.h"
|
|
|
|
#include "HasNestedCommandsVisibilityConverter.g.cpp"
|
2020-07-07 23:46:16 +02:00
|
|
|
|
|
|
|
using namespace winrt::Windows;
|
|
|
|
using namespace winrt::Windows::UI::Xaml;
|
|
|
|
|
|
|
|
namespace winrt::TerminalApp::implementation
|
|
|
|
{
|
|
|
|
// Method Description:
|
|
|
|
// - Attempt to convert something into another type. For the
|
2020-08-18 21:32:17 +02:00
|
|
|
// HasNestedCommandsVisibilityConverter, we're gonna check if `value` is a
|
2020-07-07 23:46:16 +02:00
|
|
|
// string, and try and convert it into a Visibility value. If the input
|
|
|
|
// param wasn't a string, or was the empty string, we'll return
|
|
|
|
// Visibility::Collapsed. Otherwise, we'll return Visible.
|
|
|
|
|
|
|
|
// Arguments:
|
|
|
|
// - value: the input object to attempt to convert into a Visibility.
|
|
|
|
// Return Value:
|
|
|
|
// - Visible if the object was a string and wasn't the empty string.
|
2020-08-18 21:32:17 +02:00
|
|
|
Foundation::IInspectable HasNestedCommandsVisibilityConverter::Convert(Foundation::IInspectable const& value,
|
|
|
|
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
|
|
Foundation::IInspectable const& /* parameter */,
|
|
|
|
hstring const& /* language */)
|
2020-07-07 23:46:16 +02:00
|
|
|
{
|
2020-12-10 01:36:28 +01:00
|
|
|
const auto paletteItem{ value.try_as<winrt::TerminalApp::ActionPaletteItem>() };
|
|
|
|
const auto& hasNestedCommands = paletteItem && paletteItem.Command().HasNestedCommands();
|
2020-08-18 21:32:17 +02:00
|
|
|
return winrt::box_value(hasNestedCommands ? Visibility::Visible : Visibility::Collapsed);
|
2020-07-07 23:46:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// unused for one-way bindings
|
2020-08-18 21:32:17 +02:00
|
|
|
Foundation::IInspectable HasNestedCommandsVisibilityConverter::ConvertBack(Foundation::IInspectable const& /* value */,
|
|
|
|
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
|
|
|
|
Foundation::IInspectable const& /* parameter */,
|
|
|
|
hstring const& /* language */)
|
2020-07-07 23:46:16 +02:00
|
|
|
{
|
|
|
|
throw hresult_not_implemented();
|
|
|
|
}
|
|
|
|
}
|