mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 22:43:31 +08:00
PowerRename cleanup (#19849)
This commit is contained in:
parent
a5ecbc4088
commit
9100e03be9
2
.github/actions/spell-check/expect.txt
vendored
2
.github/actions/spell-check/expect.txt
vendored
@ -672,7 +672,7 @@ GUITHREADINFO
|
||||
GValue
|
||||
gwl
|
||||
GWLP
|
||||
haccel
|
||||
HACCEL
|
||||
hangeul
|
||||
hanselman
|
||||
hardcoded
|
||||
|
@ -1,10 +1,9 @@
|
||||
import "ExplorerItem.idl";
|
||||
import "PatternSnippet.idl";
|
||||
import "UIUpdates.idl";
|
||||
|
||||
namespace PowerRenameUI
|
||||
{
|
||||
[default_interface] runtimeclass MainWindow : Microsoft.UI.Xaml.Window
|
||||
[default_interface] runtimeclass MainWindow : Microsoft.UI.Xaml.Window, Microsoft.UI.Xaml.Data.INotifyPropertyChanged
|
||||
{
|
||||
MainWindow();
|
||||
|
||||
@ -15,13 +14,11 @@ namespace PowerRenameUI
|
||||
Windows.Foundation.Collections.IObservableVector<PatternSnippet> SearchRegExShortcuts { get; };
|
||||
Windows.Foundation.Collections.IObservableVector<PatternSnippet> DateTimeShortcuts { get; };
|
||||
|
||||
UIUpdates UIUpdatesItem { get; };
|
||||
String OriginalCount;
|
||||
String RenamedCount;
|
||||
|
||||
void AddExplorerItem(Int32 id, String original, String renamed, Int32 type, UInt32 depth, Boolean checked);
|
||||
void UpdateExplorerItem(Int32 id, String newName);
|
||||
void UpdateRenamedExplorerItem(Int32 id, String newOriginalName);
|
||||
void AppendSearchMRU(String value);
|
||||
void AppendReplaceMRU(String value);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Column="2" Margin="6,-2,0,0" >
|
||||
<TextBlock x:Uid="TxtBlock_Original" FontWeight="Medium" />
|
||||
<TextBlock FontWeight="Medium" Margin="4,0,0,0" >
|
||||
<Run Text="(" /><Run Text="{x:Bind UIUpdatesItem.OriginalCount, Mode=OneWay}" /><Run Text=")" />
|
||||
<Run Text="(" /><Run Text="{x:Bind OriginalCount, Mode=OneWay}" /><Run Text=")" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
@ -55,7 +55,7 @@
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Column="2" Margin="4,-2,0,0" >
|
||||
<TextBlock x:Uid="TxtBlock_Renamed" FontWeight="Medium" />
|
||||
<TextBlock FontWeight="Medium" Margin="4,0,0,0" >
|
||||
<Run Text="(" /><Run Text="{x:Bind UIUpdatesItem.RenamedCount, Mode=OneWay}" /><Run Text=")" />
|
||||
<Run Text="(" /><Run Text="{x:Bind RenamedCount, Mode=OneWay}" /><Run Text=")" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
|
@ -29,8 +29,6 @@ using namespace winrt;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace winrt::Microsoft::Windows::ApplicationModel::Resources;
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
// Non-localizable
|
||||
const std::wstring PowerRenameUIIco = L"PowerRenameUI.ico";
|
||||
const wchar_t c_WindowClass[] = L"PowerRename";
|
||||
@ -52,7 +50,7 @@ void handleTheme() {
|
||||
namespace winrt::PowerRenameUI::implementation
|
||||
{
|
||||
MainWindow::MainWindow() :
|
||||
m_instance{ nullptr }, m_allSelected{ true }, m_managerEvents{ this }
|
||||
m_allSelected{ true }, m_managerEvents{ this }
|
||||
{
|
||||
auto windowNative{ this->try_as<::IWindowNative>() };
|
||||
winrt::check_bool(windowNative);
|
||||
@ -199,6 +197,36 @@ namespace winrt::PowerRenameUI::implementation
|
||||
SearchReplaceChanged();
|
||||
}
|
||||
|
||||
winrt::event_token MainWindow::PropertyChanged(Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler)
|
||||
{
|
||||
return m_propertyChanged.add(handler);
|
||||
}
|
||||
|
||||
void MainWindow::PropertyChanged(winrt::event_token const& token) noexcept
|
||||
{
|
||||
m_propertyChanged.remove(token);
|
||||
}
|
||||
|
||||
hstring MainWindow::OriginalCount()
|
||||
{
|
||||
return hstring{ std::to_wstring(m_explorerItems.Size()) };
|
||||
}
|
||||
|
||||
void MainWindow::OriginalCount(hstring)
|
||||
{
|
||||
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"OriginalCount" });
|
||||
}
|
||||
|
||||
hstring MainWindow::RenamedCount()
|
||||
{
|
||||
return hstring{ std::to_wstring(m_renamingCount) };
|
||||
}
|
||||
|
||||
void MainWindow::RenamedCount(hstring)
|
||||
{
|
||||
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"RenamedCount" });
|
||||
}
|
||||
|
||||
void MainWindow::AddExplorerItem(int32_t id, hstring const& original, hstring const& renamed, int32_t type, uint32_t depth, bool checked)
|
||||
{
|
||||
auto newItem = winrt::make<PowerRenameUI::implementation::ExplorerItem>(id, original, renamed, type, depth, checked);
|
||||
@ -234,16 +262,6 @@ namespace winrt::PowerRenameUI::implementation
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::AppendSearchMRU(hstring const& value)
|
||||
{
|
||||
m_searchMRUList.Append(value);
|
||||
}
|
||||
|
||||
void MainWindow::AppendReplaceMRU(hstring const& value)
|
||||
{
|
||||
m_replaceMRUList.Append(value);
|
||||
}
|
||||
|
||||
PowerRenameUI::ExplorerItem MainWindow::FindById(int32_t id)
|
||||
{
|
||||
return m_explorerItemsMap.contains(id) ? m_explorerItemsMap[id] : NULL;
|
||||
@ -418,7 +436,7 @@ namespace winrt::PowerRenameUI::implementation
|
||||
{
|
||||
if (!item.empty())
|
||||
{
|
||||
AppendSearchMRU(hstring{ item });
|
||||
m_searchMRUList.Append(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -432,7 +450,7 @@ namespace winrt::PowerRenameUI::implementation
|
||||
{
|
||||
if (!item.empty())
|
||||
{
|
||||
AppendReplaceMRU(hstring{ item });
|
||||
m_replaceMRUList.Append(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -950,8 +968,8 @@ namespace winrt::PowerRenameUI::implementation
|
||||
button_rename().IsEnabled(renamingCount > 0);
|
||||
}
|
||||
|
||||
m_uiUpdatesItem.OriginalCount(std::to_wstring(m_explorerItems.Size()));
|
||||
m_uiUpdatesItem.RenamedCount(std::to_wstring(m_renamingCount));
|
||||
OriginalCount(hstring{ std::to_wstring(m_explorerItems.Size()) });
|
||||
RenamedCount(hstring{ std::to_wstring(m_renamingCount) });
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnItemAdded(_In_ IPowerRenameItem* renameItem)
|
||||
@ -1016,21 +1034,6 @@ namespace winrt::PowerRenameUI::implementation
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnError(_In_ IPowerRenameItem*)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnRegExStarted(_In_ DWORD)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnRegExCanceled(_In_ DWORD)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnRegExCompleted(_In_ DWORD)
|
||||
{
|
||||
_TRACER_;
|
||||
@ -1054,11 +1057,6 @@ namespace winrt::PowerRenameUI::implementation
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnRenameStarted()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT MainWindow::OnRenameCompleted(bool closeUIWindowAfterRenaming)
|
||||
{
|
||||
_TRACER_;
|
||||
|
@ -80,13 +80,16 @@ namespace winrt::PowerRenameUI::implementation
|
||||
winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUI::ExplorerItem> ExplorerItems() { return m_explorerItems; }
|
||||
winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUI::PatternSnippet> SearchRegExShortcuts() { return m_searchRegExShortcuts; }
|
||||
winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUI::PatternSnippet> DateTimeShortcuts() { return m_dateTimeShortcuts; }
|
||||
PowerRenameUI::UIUpdates UIUpdatesItem() { return m_uiUpdatesItem; }
|
||||
hstring OriginalCount();
|
||||
void OriginalCount(hstring value);
|
||||
hstring RenamedCount();
|
||||
void RenamedCount(hstring value);
|
||||
winrt::event_token PropertyChanged(winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler);
|
||||
void PropertyChanged(winrt::event_token const& token) noexcept;
|
||||
|
||||
void AddExplorerItem(int32_t id, hstring const& original, hstring const& renamed, int32_t type, uint32_t depth, bool checked);
|
||||
void UpdateExplorerItem(int32_t id, hstring const& newName);
|
||||
void UpdateRenamedExplorerItem(int32_t id, hstring const& newOriginalName);
|
||||
void AppendSearchMRU(hstring const& value);
|
||||
void AppendReplaceMRU(hstring const& value);
|
||||
|
||||
void SelectAll(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
|
||||
void ShowAll(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
|
||||
@ -94,7 +97,6 @@ namespace winrt::PowerRenameUI::implementation
|
||||
|
||||
private:
|
||||
bool m_allSelected;
|
||||
PowerRenameUI::UIUpdates m_uiUpdatesItem;
|
||||
inline PowerRenameUI::ExplorerItem FindById(int32_t id);
|
||||
|
||||
winrt::Windows::Foundation::Collections::IObservableVector<hstring> m_searchMRUList;
|
||||
@ -108,11 +110,11 @@ namespace winrt::PowerRenameUI::implementation
|
||||
HRESULT OnItemAdded(_In_ IPowerRenameItem* renameItem);
|
||||
HRESULT OnUpdate(_In_ IPowerRenameItem* renameItem);
|
||||
HRESULT OnRename(_In_ IPowerRenameItem* renameItem);
|
||||
HRESULT OnError(_In_ IPowerRenameItem* renameItem);
|
||||
HRESULT OnRegExStarted(_In_ DWORD threadId);
|
||||
HRESULT OnRegExCanceled(_In_ DWORD threadId);
|
||||
HRESULT OnError(_In_ IPowerRenameItem*) { return S_OK; }
|
||||
HRESULT OnRegExStarted(_In_ DWORD) { return S_OK; }
|
||||
HRESULT OnRegExCanceled(_In_ DWORD) { return S_OK; }
|
||||
HRESULT OnRegExCompleted(_In_ DWORD threadId);
|
||||
HRESULT OnRenameStarted();
|
||||
HRESULT OnRenameStarted() { return S_OK; }
|
||||
HRESULT OnRenameCompleted(bool closeUIWindowAfterRenaming);
|
||||
|
||||
enum class UpdateFlagCommand
|
||||
@ -140,14 +142,10 @@ namespace winrt::PowerRenameUI::implementation
|
||||
void SetCheckboxesFromFlags(DWORD flags);
|
||||
void UpdateCounts();
|
||||
|
||||
wil::unique_haccel m_accelerators;
|
||||
const HINSTANCE m_instance;
|
||||
HWND m_xamlIsland{};
|
||||
HWND m_window{};
|
||||
|
||||
bool m_disableCountUpdate = false;
|
||||
CComPtr<IPowerRenameManager> m_prManager;
|
||||
CComPtr<::IUnknown> m_dataSource;
|
||||
CComPtr<IPowerRenameEnum> m_prEnum;
|
||||
PowerRenameManagerEvents m_managerEvents;
|
||||
DWORD m_cookie = 0;
|
||||
@ -155,6 +153,7 @@ namespace winrt::PowerRenameUI::implementation
|
||||
CComPtr<IPowerRenameMRU> m_replaceMRU;
|
||||
UINT m_selectedCount = 0;
|
||||
UINT m_renamingCount = 0;
|
||||
winrt::event<Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged;
|
||||
|
||||
bool m_flagValidationInProgress = false;
|
||||
public:
|
||||
|
@ -100,10 +100,6 @@
|
||||
<ClInclude Include="MainWindow.xaml.h">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="UIUpdates.h">
|
||||
<DependentUpon>UIUpdates.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml" />
|
||||
@ -126,9 +122,6 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="UIUpdates.cpp">
|
||||
<DependentUpon>UIUpdates.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="App.idl">
|
||||
@ -141,7 +134,6 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Midl>
|
||||
<Midl Include="PatternSnippet.idl" />
|
||||
<Midl Include="UIUpdates.idl" />
|
||||
</ItemGroup>
|
||||
<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
Tools extension to be activated for this project even if the Windows App SDK Nuget
|
||||
|
@ -11,7 +11,6 @@
|
||||
<Midl Include="MainWindow.idl" />
|
||||
<Midl Include="PatternSnippet.idl" />
|
||||
<Midl Include="ExplorerItem.idl" />
|
||||
<Midl Include="UIUpdates.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
|
@ -1,48 +0,0 @@
|
||||
#include "pch.h"
|
||||
#include "UIUpdates.h"
|
||||
#include "UIUpdates.g.cpp"
|
||||
|
||||
namespace winrt::PowerRenameUI::implementation
|
||||
{
|
||||
UIUpdates::UIUpdates()
|
||||
{
|
||||
}
|
||||
|
||||
winrt::event_token UIUpdates::PropertyChanged(Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler)
|
||||
{
|
||||
return m_propertyChanged.add(handler);
|
||||
}
|
||||
|
||||
void UIUpdates::PropertyChanged(winrt::event_token const& token) noexcept
|
||||
{
|
||||
m_propertyChanged.remove(token);
|
||||
}
|
||||
|
||||
hstring UIUpdates::OriginalCount()
|
||||
{
|
||||
return m_originalCount;
|
||||
}
|
||||
|
||||
void UIUpdates::OriginalCount(hstring value)
|
||||
{
|
||||
if (m_originalCount != value)
|
||||
{
|
||||
m_originalCount = value;
|
||||
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"OriginalCount" });
|
||||
}
|
||||
}
|
||||
|
||||
hstring UIUpdates::RenamedCount()
|
||||
{
|
||||
return m_renamedCount;
|
||||
}
|
||||
|
||||
void UIUpdates::RenamedCount(hstring value)
|
||||
{
|
||||
if (m_renamedCount != value)
|
||||
{
|
||||
m_renamedCount = value;
|
||||
m_propertyChanged(*this, Microsoft::UI::Xaml::Data::PropertyChangedEventArgs{ L"RenamedCount" });
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#pragma once
|
||||
#include "UIUpdates.g.h"
|
||||
|
||||
namespace winrt::PowerRenameUI::implementation
|
||||
{
|
||||
struct UIUpdates : UIUpdatesT<UIUpdates>
|
||||
{
|
||||
UIUpdates();
|
||||
|
||||
winrt::event_token PropertyChanged(winrt::Microsoft::UI::Xaml::Data::PropertyChangedEventHandler const& handler);
|
||||
void PropertyChanged(winrt::event_token const& token) noexcept;
|
||||
hstring OriginalCount();
|
||||
void OriginalCount(hstring value);
|
||||
hstring RenamedCount();
|
||||
void RenamedCount(hstring value);
|
||||
|
||||
private:
|
||||
hstring m_originalCount;
|
||||
hstring m_renamedCount;
|
||||
winrt::event<Microsoft::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged;
|
||||
};
|
||||
}
|
||||
namespace winrt::PowerRenameUI::factory_implementation
|
||||
{
|
||||
struct UIUpdates : UIUpdatesT<UIUpdates, implementation::UIUpdates>
|
||||
{
|
||||
};
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
namespace PowerRenameUI
|
||||
{
|
||||
runtimeclass UIUpdates : Microsoft.UI.Xaml.Data.INotifyPropertyChanged
|
||||
{
|
||||
UIUpdates();
|
||||
String OriginalCount;
|
||||
String RenamedCount;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user