mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-23 00:17:58 +08:00
90ecd5e10f
* Migrate PowerRename to Unpackaged WinUI3 * [ARM64] PowerRename (#18002) * Migrate PowerRename to Unpackaged WinUI3 * Removed Project Config and update PlatformToolset to v143 * Updated solution config * Migrate PowerRename to Unpackaged WinUI3 * Fixed configs changed from ARM64 build * Left one project out of fix Co-authored-by: Stefan Markovic <stefan@janeasystems.com> Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> * Minor fixes * Remove PowerRenameUILib from signing list - doesn't exist anymore * Remove PowerRenameUILib from move_uwp_resources.ps1 * Bring back old dir name to see if localization is preserved Remove move_uwp_resources.ps1 - not needed anymore * Remove UWP localization docs part * Fix minor UI quirk Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
123 lines
3.5 KiB
C++
123 lines
3.5 KiB
C++
#include "pch.h"
|
|
#include "ExplorerItem.h"
|
|
#include "ExplorerItem.g.cpp"
|
|
|
|
namespace {
|
|
const wchar_t fileImagePath[] = L"ms-appx:///Assets/file.png";
|
|
const wchar_t folderImagePath[] = L"ms-appx:///Assets/folder.png";
|
|
}
|
|
|
|
namespace winrt::PowerRenameUI::implementation
|
|
{
|
|
ExplorerItem::ExplorerItem(int32_t id, hstring const& original, hstring const& renamed, int32_t type, uint32_t depth, bool checked) :
|
|
m_id{ id }, m_idStr{ std::to_wstring(id) }, m_original{ original }, m_renamed{ renamed }, m_type{ type }, m_depth{ depth }, m_checked{ checked }
|
|
{
|
|
m_imagePath = (m_type == static_cast<UINT>(ExplorerItemType::Folder)) ? folderImagePath : fileImagePath;
|
|
m_highlight = m_checked && !m_renamed.empty() ? Microsoft::UI::Xaml::Visibility::Visible : Microsoft::UI::Xaml::Visibility::Collapsed;
|
|
}
|
|
|
|
int32_t ExplorerItem::Id()
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
hstring ExplorerItem::IdStr()
|
|
{
|
|
return m_idStr;
|
|
}
|
|
|
|
hstring ExplorerItem::Original()
|
|
{
|
|
return m_original;
|
|
}
|
|
|
|
void ExplorerItem::Original(hstring const& value)
|
|
{
|
|
if (m_original != value)
|
|
{
|
|
m_original = value;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Original" });
|
|
}
|
|
}
|
|
|
|
hstring ExplorerItem::Renamed()
|
|
{
|
|
return m_renamed;
|
|
}
|
|
|
|
void ExplorerItem::Renamed(hstring const& value)
|
|
{
|
|
if (m_renamed != value)
|
|
{
|
|
m_renamed = value;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Renamed" });
|
|
|
|
auto visibility = m_checked && !m_renamed.empty() ? Microsoft::UI::Xaml::Visibility::Visible : Microsoft::UI::Xaml::Visibility::Collapsed;
|
|
if (m_highlight != visibility)
|
|
{
|
|
m_highlight = visibility;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Highlight" });
|
|
}
|
|
}
|
|
}
|
|
|
|
double ExplorerItem::Indentation() {
|
|
return static_cast<double>(m_depth) * 12;
|
|
}
|
|
|
|
hstring ExplorerItem::ImagePath()
|
|
{
|
|
return m_imagePath;
|
|
}
|
|
|
|
int32_t ExplorerItem::Type()
|
|
{
|
|
return m_type;
|
|
}
|
|
|
|
void ExplorerItem::Type(int32_t value)
|
|
{
|
|
if (m_type != value)
|
|
{
|
|
m_type = value;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Type" });
|
|
}
|
|
}
|
|
|
|
bool ExplorerItem::Checked()
|
|
{
|
|
return m_checked;
|
|
}
|
|
|
|
void ExplorerItem::Checked(bool value)
|
|
{
|
|
if (m_checked != value)
|
|
{
|
|
m_checked = value;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Checked" });
|
|
|
|
auto visibility = m_checked && !m_renamed.empty() ? Microsoft::UI::Xaml::Visibility::Visible : Microsoft::UI::Xaml::Visibility::Collapsed;
|
|
if (m_highlight != visibility)
|
|
{
|
|
m_highlight = visibility;
|
|
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"Highlight" });
|
|
}
|
|
}
|
|
}
|
|
|
|
Microsoft::UI::Xaml::Visibility ExplorerItem::Highlight()
|
|
{
|
|
return m_highlight;
|
|
}
|
|
|
|
winrt::event_token ExplorerItem::PropertyChanged(winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler)
|
|
{
|
|
return m_propertyChanged.add(handler);
|
|
}
|
|
|
|
void ExplorerItem::PropertyChanged(winrt::event_token const& token) noexcept
|
|
{
|
|
m_propertyChanged.remove(token);
|
|
}
|
|
}
|