Show something when there are no results

This commit is contained in:
Ivan Stošić 2022-09-21 14:29:39 +02:00
parent 9293c8c395
commit 13ff89c5f9
4 changed files with 24 additions and 1 deletions

View File

@ -4,5 +4,6 @@ namespace FileLocksmithGUI
runtimeclass MainWindow : Microsoft.UI.Xaml.Window runtimeclass MainWindow : Microsoft.UI.Xaml.Window
{ {
MainWindow(); MainWindow();
void DisplayNoResultsInfo();
} }
} }

View File

@ -32,11 +32,17 @@ namespace winrt::FileLocksmithGUI::implementation
// TODO move to another thread // TODO move to another thread
stackPanel().Children().Clear(); stackPanel().Children().Clear();
for (const auto& process : m_process_info) for (const auto& process : m_process_info)
{ {
ProcessEntry entry(process.name, process.pid, process.num_files); ProcessEntry entry(process.name, process.pid, process.num_files);
stackPanel().Children().Append(entry); stackPanel().Children().Append(entry);
} }
if (m_process_info.empty())
{
DisplayNoResultsInfo();
}
} }
void MainWindow::place_and_resize() void MainWindow::place_and_resize()
@ -81,4 +87,14 @@ namespace winrt::FileLocksmithGUI::implementation
app_window.MoveAndResize(rect); app_window.MoveAndResize(rect);
} }
void MainWindow::DisplayNoResultsInfo()
{
// Construct the UI element and display it
Controls::TextBlock text;
text.Text(L"No results.");
text.HorizontalAlignment(HorizontalAlignment::Center);
text.VerticalAlignment(VerticalAlignment::Center);
stackPanel().Children().Append(text);
}
} }

View File

@ -8,7 +8,7 @@ namespace winrt::FileLocksmithGUI::implementation
struct MainWindow : MainWindowT<MainWindow> struct MainWindow : MainWindowT<MainWindow>
{ {
MainWindow(); MainWindow();
void DisplayNoResultsInfo();
private: private:
std::vector<ProcessResult> m_process_info; std::vector<ProcessResult> m_process_info;
void find_processes(); void find_processes();

View File

@ -42,5 +42,11 @@ namespace winrt::FileLocksmithGUI::implementation
{ {
siblings.RemoveAt(index); siblings.RemoveAt(index);
} }
if (siblings.Size() == 0)
{
auto main_window = Parent().as<Controls::StackPanel>().Parent().as<MainWindow>();
main_window.DisplayNoResultsInfo();
}
} }
} }