[PowerRename] Show UI info if item cannot be renamed (#19934)

* PowerRename cleanup

* Extract ExplorerItem as a UserControl

* Add VisualStateManager

* UI fixes

* Implement error UI logic

Highlight items that couldn't be renamed and add error message flyout

* Update src/modules/powerrename/lib/PowerRenameManager.cpp

Address PR comment

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Update src/modules/powerrename/lib/PowerRenameManager.cpp

Address PR comment

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Folder max path is 247

* Implement State() properly

Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
This commit is contained in:
Stefan Markovic
2022-08-24 10:47:27 +02:00
committed by GitHub
parent c26e23b904
commit 13db8575e0
15 changed files with 684 additions and 224 deletions

View File

@@ -243,22 +243,22 @@ namespace winrt::PowerRenameUI::implementation
m_explorerItemsMap[id] = newItem;
}
void MainWindow::UpdateExplorerItem(int32_t id, hstring const& newName)
void MainWindow::UpdateExplorerItem(int32_t id, std::optional<hstring> newOriginalName, std::optional<hstring> newName, PowerRenameItemRenameStatus itemStatus)
{
auto itemToUpdate = FindById(id);
if (itemToUpdate != NULL)
{
itemToUpdate.Renamed(newName);
}
}
if (newOriginalName.has_value())
{
itemToUpdate.Original(*newOriginalName);
}
void MainWindow::UpdateRenamedExplorerItem(int32_t id, hstring const& newOriginalName)
{
auto itemToUpdate = FindById(id);
if (itemToUpdate != NULL)
{
itemToUpdate.Original(newOriginalName);
itemToUpdate.Renamed(L"");
if (newName.has_value())
{
itemToUpdate.Renamed(*newName);
}
itemToUpdate.State(static_cast<int32_t>(itemStatus));
}
}
@@ -1007,8 +1007,13 @@ namespace winrt::PowerRenameUI::implementation
hr = renameItem->GetNewName(&newName);
if (SUCCEEDED(hr))
{
hstring newNameStr = newName == nullptr ? hstring{} : newName;
UpdateExplorerItem(id, newNameStr);
PowerRenameItemRenameStatus status;
hr = renameItem->GetStatus(&status);
if (SUCCEEDED(hr))
{
hstring newNameStr = newName == nullptr ? hstring{} : newName;
UpdateExplorerItem(id, std::nullopt, newNameStr, status);
}
}
}
@@ -1026,7 +1031,7 @@ namespace winrt::PowerRenameUI::implementation
if (SUCCEEDED(hr))
{
hstring newNameStr = newName == nullptr ? hstring{} : newName;
UpdateRenamedExplorerItem(id, newNameStr);
UpdateExplorerItem(id, newNameStr, L"", PowerRenameItemRenameStatus::Init);
}
}