[projects] Adding info message for cases: there are no projects or no results for the search

This commit is contained in:
donlaci
2024-06-19 14:58:29 +02:00
parent 20a7dd4a7f
commit 90979cbecb
5 changed files with 71 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace ProjectsEditor.Converters
{
public class BooleanToInvertedVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -5,11 +5,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:props="clr-namespace:ProjectsEditor.Properties" xmlns:props="clr-namespace:ProjectsEditor.Properties"
xmlns:converters="clr-namespace:ProjectsEditor.Converters"
xmlns:local="clr-namespace:ProjectsEditor" xmlns:local="clr-namespace:ProjectsEditor"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
Title="MainPage"> Title="MainPage">
<Page.Resources> <Page.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<converters:BooleanToInvertedVisibilityConverter x:Key="BooleanToInvertedVisibilityConverter" />
<Thickness x:Key="ContentDialogPadding">24,16,0,24</Thickness> <Thickness x:Key="ContentDialogPadding">24,16,0,24</Thickness>
<Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,24,0</Thickness> <Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,24,0</Thickness>
<Style x:Key="DeleteButtonStyle" TargetType="Button"> <Style x:Key="DeleteButtonStyle" TargetType="Button">
@@ -149,12 +152,19 @@
<ComboBoxItem Content="{x:Static props:Resources.Name}" /> <ComboBoxItem Content="{x:Static props:Resources.Name}" />
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
<TextBlock
Grid.Row="2"
Text="{Binding EmptyProjectsViewMessage, UpdateSourceTrigger=PropertyChanged}"
FontSize="20"
Foreground="{DynamicResource PrimaryForegroundBrush}"
Margin="40,40,40,40"
Visibility="{Binding IsProjectsViewEmpty, Mode=OneWay, Converter={StaticResource BoolToVis}, UpdateSourceTrigger=PropertyChanged}"/>
<ScrollViewer <ScrollViewer
VerticalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Grid.Row="2" Grid.Row="2"
Margin="40,15,40,40"> Margin="40,15,40,40"
Visibility="{Binding IsProjectsViewEmpty, Mode=OneWay, Converter={StaticResource BooleanToInvertedVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl ItemsSource="{Binding ProjectsView, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"> <ItemsControl ItemsSource="{Binding ProjectsView, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>

View File

@@ -303,6 +303,15 @@ namespace ProjectsEditor.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to No projects match the current search..
/// </summary>
public static string NoProjectsMatch {
get {
return ResourceManager.GetString("NoProjectsMatch", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to The application cannot be found. /// Looks up a localized string similar to The application cannot be found.
/// </summary> /// </summary>

View File

@@ -195,6 +195,9 @@
<data name="New_project" xml:space="preserve"> <data name="New_project" xml:space="preserve">
<value>New project</value> <value>New project</value>
</data> </data>
<data name="NoProjectsMatch" xml:space="preserve">
<value>No projects match the current search.</value>
</data>
<data name="NotFoundTooltip" xml:space="preserve"> <data name="NotFoundTooltip" xml:space="preserve">
<value>The application cannot be found</value> <value>The application cannot be found</value>
</data> </data>

View File

@@ -30,8 +30,21 @@ namespace ProjectsEditor.ViewModels
get get
{ {
IEnumerable<Project> projects = GetFilteredProjects(); IEnumerable<Project> projects = GetFilteredProjects();
if (projects == null) IsProjectsViewEmpty = !(projects != null && projects.Any());
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsProjectsViewEmpty)));
if (IsProjectsViewEmpty)
{ {
if (Projects != null && Projects.Any())
{
EmptyProjectsViewMessage = Properties.Resources.NoProjectsMatch;
}
else
{
EmptyProjectsViewMessage = Properties.Resources.No_Projects_Message;
}
OnPropertyChanged(new PropertyChangedEventArgs(nameof(EmptyProjectsViewMessage)));
return Enumerable.Empty<Project>(); return Enumerable.Empty<Project>();
} }
@@ -51,6 +64,10 @@ namespace ProjectsEditor.ViewModels
} }
} }
public bool IsProjectsViewEmpty { get; set; }
public string EmptyProjectsViewMessage { get; set; }
// return those projects where the project name or any of the selected apps' name contains the search term // return those projects where the project name or any of the selected apps' name contains the search term
private IEnumerable<Project> GetFilteredProjects() private IEnumerable<Project> GetFilteredProjects()
{ {