mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
[projects] Adding info message for cases: there are no projects or no results for the search
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,14 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:props="clr-namespace:ProjectsEditor.Properties"
|
||||
xmlns:converters="clr-namespace:ProjectsEditor.Converters"
|
||||
xmlns:local="clr-namespace:ProjectsEditor"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Title="MainPage">
|
||||
<Page.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
<converters:BooleanToInvertedVisibilityConverter x:Key="BooleanToInvertedVisibilityConverter" />
|
||||
<Thickness x:Key="ContentDialogPadding">24,16,0,24</Thickness>
|
||||
<Thickness x:Key="ContentDialogCommandSpaceMargin">0,24,24,0</Thickness>
|
||||
<Style x:Key="DeleteButtonStyle" TargetType="Button">
|
||||
@@ -149,12 +152,19 @@
|
||||
<ComboBoxItem Content="{x:Static props:Resources.Name}" />
|
||||
</ComboBox>
|
||||
</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
|
||||
VerticalContentAlignment="Stretch"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
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.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
|
||||
@@ -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>
|
||||
/// Looks up a localized string similar to The application cannot be found.
|
||||
/// </summary>
|
||||
|
||||
@@ -195,6 +195,9 @@
|
||||
<data name="New_project" xml:space="preserve">
|
||||
<value>New project</value>
|
||||
</data>
|
||||
<data name="NoProjectsMatch" xml:space="preserve">
|
||||
<value>No projects match the current search.</value>
|
||||
</data>
|
||||
<data name="NotFoundTooltip" xml:space="preserve">
|
||||
<value>The application cannot be found</value>
|
||||
</data>
|
||||
|
||||
@@ -30,8 +30,21 @@ namespace ProjectsEditor.ViewModels
|
||||
get
|
||||
{
|
||||
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>();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
private IEnumerable<Project> GetFilteredProjects()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user