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
{
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))
{
@@ -51,8 +51,8 @@ namespace winrt::PowerRenameUILib::implementation
}
}
uint32_t ExplorerItem::Depth() {
return m_depth;
double ExplorerItem::Indentation() {
return m_indentation;
}
int32_t ExplorerItem::Type()

View File

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

View File

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

View File

@@ -206,10 +206,7 @@ namespace winrt::PowerRenameUILib::implementation
void MainWindow::ToggleAll(bool checked)
{
for (auto item : m_explorerItems)
{
item.Checked(checked);
}
std::for_each(m_explorerItems.begin(), m_explorerItems.end(), [checked](auto item) { item.Checked(checked); });
}
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 id = std::stoi(std::wstring{ checkbox.Name() });
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.ChangedExplorerItemId(id);

View File

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