Add identation

This commit is contained in:
Stefan Markovic
2021-11-08 15:43:01 +01:00
parent 3c593a8623
commit cfa8aa02e0
5 changed files with 10 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
namespace winrt::PowerRenameUILib::implementation namespace winrt::PowerRenameUILib::implementation
{ {
ExplorerItem::ExplorerItem(int32_t id, hstring const& original, hstring const& renamed, int32_t type, uint32_t depth, bool checked) : 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_id{ id }, m_idStr{ std::to_wstring(id) }, m_original{ original }, m_renamed{ renamed }, m_type{ type }, m_indentation{ depth * 20 }, m_checked{ checked }
{ {
if (m_type == static_cast<UINT>(ExplorerItemType::Folder)) if (m_type == static_cast<UINT>(ExplorerItemType::Folder))
{ {
@@ -51,8 +51,8 @@ namespace winrt::PowerRenameUILib::implementation
} }
} }
uint32_t ExplorerItem::Depth() { double ExplorerItem::Indentation() {
return m_depth; return m_indentation;
} }
int32_t ExplorerItem::Type() int32_t ExplorerItem::Type()

View File

@@ -20,7 +20,7 @@ namespace winrt::PowerRenameUILib::implementation
void Original(hstring const& value); void Original(hstring const& value);
hstring Renamed(); hstring Renamed();
void Renamed(hstring const& value); void Renamed(hstring const& value);
uint32_t Depth(); double Indentation();
int32_t Type(); int32_t Type();
void Type(int32_t value); void Type(int32_t value);
bool Checked(); bool Checked();
@@ -35,7 +35,7 @@ namespace winrt::PowerRenameUILib::implementation
hstring m_idStr; hstring m_idStr;
winrt::hstring m_original; winrt::hstring m_original;
winrt::hstring m_renamed; winrt::hstring m_renamed;
uint32_t m_depth; uint32_t m_indentation;
winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUILib::ExplorerItem> m_children; winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUILib::ExplorerItem> m_children;
int32_t m_type; int32_t m_type;
bool m_checked; bool m_checked;

View File

@@ -7,7 +7,7 @@ namespace PowerRenameUILib
String IdStr { get; }; String IdStr { get; };
String Original; String Original;
String Renamed; String Renamed;
UInt32 Depth { get; }; Double Indentation { get; };
Int32 Type; Int32 Type;
Boolean Checked; Boolean Checked;
Windows.Foundation.Collections.IObservableVector<ExplorerItem> Children; Windows.Foundation.Collections.IObservableVector<ExplorerItem> Children;

View File

@@ -206,10 +206,7 @@ namespace winrt::PowerRenameUILib::implementation
void MainWindow::ToggleAll(bool checked) void MainWindow::ToggleAll(bool checked)
{ {
for (auto item : m_explorerItems) std::for_each(m_explorerItems.begin(), m_explorerItems.end(), [checked](auto item) { item.Checked(checked); });
{
item.Checked(checked);
}
} }
void MainWindow::Checked_ids(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const&) void MainWindow::Checked_ids(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const&)
@@ -217,7 +214,7 @@ namespace winrt::PowerRenameUILib::implementation
auto checkbox = sender.as<Windows::UI::Xaml::Controls::CheckBox>(); auto checkbox = sender.as<Windows::UI::Xaml::Controls::CheckBox>();
auto id = std::stoi(std::wstring{ checkbox.Name() }); auto id = std::stoi(std::wstring{ checkbox.Name() });
auto item = FindById(id); auto item = FindById(id);
if (checkbox.IsChecked().GetBoolean() != item.Checked()) if (item != NULL && checkbox.IsChecked().GetBoolean() != item.Checked())
{ {
m_uiUpdatesItem.Checked(checkbox.IsChecked().GetBoolean()); m_uiUpdatesItem.Checked(checkbox.IsChecked().GetBoolean());
m_uiUpdatesItem.ChangedExplorerItemId(id); m_uiUpdatesItem.ChangedExplorerItemId(id);

View File

@@ -13,6 +13,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0"> <StackPanel Orientation="Horizontal" Grid.Column="0">
<StackPanel MinWidth="{x:Bind Indentation}"/>
<CheckBox TabIndex="0" <CheckBox TabIndex="0"
MinWidth="36" MinWidth="36"
XYFocusKeyboardNavigation="Enabled" XYFocusKeyboardNavigation="Enabled"
@@ -43,6 +44,7 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0"> <StackPanel Orientation="Horizontal" Grid.Column="0">
<StackPanel MinWidth="{x:Bind Indentation}"/>
<CheckBox TabIndex="0" <CheckBox TabIndex="0"
IsTabStop="True" IsTabStop="True"
XYFocusKeyboardNavigation="Enabled" XYFocusKeyboardNavigation="Enabled"