Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all the PT Run v1 icons we no longer need #377

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,27 @@ internal static class ResultHelper
/// Return a list with <see cref="Result"/>s, based on the given list
/// </summary>
/// <param name="list">The original result list to convert</param>
/// <param name="iconPath">The path to the icon of each entry</param>
/// <returns>A list with <see cref="Result"/></returns>
internal static List<ListItem> GetResultList(in IEnumerable<RegistryEntry> list, in string iconPath)
internal static List<ListItem> GetResultList(in IEnumerable<RegistryEntry> list)
{
var resultList = new List<ListItem>();

foreach (var entry in list)
{
var result = new ListItem(new OpenKeyInEditorCommand(entry))
{
Icon = new(iconPath),
Icon = RegistryListPage.RegistryIcon,
MoreCommands = ContextMenuHelper.GetContextMenu(entry).ToArray(),
};

if (entry.Exception is null && !(entry.Key is null))
if (entry.Exception is null && entry.Key is not null)
{
// when key contains keys or fields
result.TextToSuggest = entry.Key.Name;
result.Subtitle = RegistryHelper.GetSummary(entry.Key);
result.Title = GetTruncatedText(entry.Key.Name, MaxTextLength.MaximumTitleLengthWithTwoSymbols);
}
else if (entry.Key is null && !(entry.Exception is null))
else if (entry.Key is null && entry.Exception is not null)
{
// on error (e.g access denied)
result.TextToSuggest = entry.KeyPath;
Expand All @@ -68,12 +67,12 @@ internal static List<ListItem> GetResultList(in IEnumerable<RegistryEntry> list,
}

#pragma warning disable CS8632
internal static List<ListItem> GetValuesFromKey(in RegistryKey? key, in string iconPath, string searchValue = "")
internal static List<ListItem> GetValuesFromKey(in RegistryKey? key, string searchValue = "")
{
#pragma warning restore CS8632
if (key is null)
{
return new List<ListItem>(0);
return [];
}

var valueList = new List<KeyValuePair<string, object>>(key.ValueCount);
Expand Down Expand Up @@ -101,7 +100,7 @@ internal static List<ListItem> GetValuesFromKey(in RegistryKey? key, in string i

resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = new(iconPath),
Icon = RegistryListPage.RegistryIcon,
Subtitle = GetTruncatedText(valueException.Message, MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(key.Name, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
MoreCommands = ContextMenuHelper.GetContextMenu(registryEntry).ToArray(),
Expand Down Expand Up @@ -130,7 +129,7 @@ internal static List<ListItem> GetValuesFromKey(in RegistryKey? key, in string i

resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = new(iconPath),
Icon = RegistryListPage.RegistryIcon,
Subtitle = GetTruncatedText(GetSubTileForRegistryValue(key, valueEntry), MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(valueName, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
MoreCommands = ContextMenuHelper.GetContextMenu(registryEntry).ToArray(),
Expand All @@ -145,7 +144,7 @@ internal static List<ListItem> GetValuesFromKey(in RegistryKey? key, in string i

resultList.Add(new ListItem(new OpenKeyInEditorCommand(registryEntry))
{
Icon = new(iconPath),
Icon = RegistryListPage.RegistryIcon,
Subtitle = GetTruncatedText(exception.Message, MaxTextLength.MaximumSubTitleLengthWithThreeSymbols, TruncateSide.OnlyFromRight),
Title = GetTruncatedText(key.Name, MaxTextLength.MaximumTitleLengthWithThreeSymbols),
});
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ namespace Microsoft.CmdPal.Ext.Registry;

internal sealed partial class RegistryListPage : DynamicListPage
{
private readonly string _defaultIconPath;
public static IconInfo RegistryIcon { get; } = new("\uE74C"); // OEM

public RegistryListPage()
{
Icon = new("\uE74C"); // OEM
Icon = RegistryIcon;
Name = "Windows Registry";
Id = "com.microsoft.cmdpal.registry";
_defaultIconPath = "Images/reg.light.png";
}

public List<ListItem> Query(string query)
{
if (query is null)
{
return new List<ListItem>(0);
return [];
}

var searchForValueName = QueryHelper.GetQueryParts(query, out var queryKey, out var queryValueName);
Expand All @@ -37,7 +36,7 @@ public List<ListItem> Query(string query)
if (baseKeyList is null)
{
// no base key found
return ResultHelper.GetResultList(RegistryHelper.GetAllBaseKeys(), _defaultIconPath);
return ResultHelper.GetResultList(RegistryHelper.GetAllBaseKeys());
}
else if (baseKeyList.Count() == 1)
{
Expand All @@ -47,25 +46,19 @@ public List<ListItem> Query(string query)
// when only one sub-key was found and a user search for values ("\\")
// show the filtered list of values of one sub-key
return searchForValueName && list.Count == 1
? ResultHelper.GetValuesFromKey(list.First().Key, _defaultIconPath, queryValueName)
: ResultHelper.GetResultList(list, _defaultIconPath);
? ResultHelper.GetValuesFromKey(list.First().Key, queryValueName)
: ResultHelper.GetResultList(list);
}
else if (baseKeyList.Count() > 1)
{
// more than one base key was found -> show results
return ResultHelper.GetResultList(baseKeyList.Select(found => new RegistryEntry(found)), _defaultIconPath);
return ResultHelper.GetResultList(baseKeyList.Select(found => new RegistryEntry(found)));
}

return new List<ListItem>();
return [];
}

public override void UpdateSearchText(string oldSearch, string newSearch)
{
RaiseItemsChanged(0);
}
public override void UpdateSearchText(string oldSearch, string newSearch) => RaiseItemsChanged(0);

public override IListItem[] GetItems()
{
return Query(SearchText).ToArray();
}
public override IListItem[] GetItems() => Query(SearchText).ToArray();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ internal static class ResultHelper
/// Returns a list of all results for the query.
/// </summary>
/// <param name="searchControllerResults">List with all search controller matches</param>
/// <param name="icon">The path to the result icon</param>
/// <returns>List of results</returns>
internal static List<WindowWalkerListItem> GetResultList(List<SearchResult> searchControllerResults, bool isKeywordSearch, string infoIcon)
internal static List<WindowWalkerListItem> GetResultList(List<SearchResult> searchControllerResults, bool isKeywordSearch)
{
if (searchControllerResults == null || searchControllerResults.Count == 0)
{
Expand All @@ -43,7 +42,7 @@ internal static List<WindowWalkerListItem> GetResultList(List<SearchResult> sear

if (addExplorerInfo && !SettingsManager.Instance.HideExplorerSettingInfo)
{
resultsList.Insert(0, GetExplorerInfoResult(infoIcon));
resultsList.Insert(0, GetExplorerInfoResult());
}

return resultsList;
Expand All @@ -53,7 +52,6 @@ internal static List<WindowWalkerListItem> GetResultList(List<SearchResult> sear
/// Creates a Result object from a given SearchResult.
/// </summary>
/// <param name="searchResult">The SearchResult object to convert.</param>
/// <param name="icon">The path to the icon that should be used for the Result.</param>
/// <returns>A Result object populated with data from the SearchResult.</returns>
private static WindowWalkerListItem CreateResultFromSearchResult(SearchResult searchResult)
{
Expand All @@ -75,7 +73,7 @@ private static WindowWalkerListItem CreateResultFromSearchResult(SearchResult se
/// <returns>String with the subtitle</returns>
private static string GetSubtitle(Window window)
{
if (window is null or not Window)
if (window is null or null)
{
return string.Empty;
}
Expand Down Expand Up @@ -116,12 +114,12 @@ private static Tag[] GetTags(Window window)
return tags.ToArray();
}

private static WindowWalkerListItem GetExplorerInfoResult(string iIcon)
private static WindowWalkerListItem GetExplorerInfoResult()
{
return new WindowWalkerListItem(null)
{
Title = Resources.windowwalker_ExplorerInfoTitle,
Icon = new(iIcon),
Icon = new("\uE946"), // Info
Subtitle = Resources.windowwalker_ExplorerInfoSubTitle,
Command = new ExplorerInfoResultCommand(),
};
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public List<WindowWalkerListItem> Query(string query)
SearchController.Instance.UpdateSearchText(query);
var searchControllerResults = SearchController.Instance.SearchMatches;

return ResultHelper.GetResultList(searchControllerResults, !string.IsNullOrEmpty(query), "\uE946");
return ResultHelper.GetResultList(searchControllerResults, !string.IsNullOrEmpty(query));
}

public override IListItem[] GetItems() => Query(SearchText).ToArray();
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed partial class ServicesListPage : DynamicListPage
{
public ServicesListPage()
{
Icon = new("%windir%\\system32\\filemgmt.dll");
Icon = WindowsServicesCommandsProvider.ServicesIcon;
Name = "Windows Services";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ namespace Microsoft.CmdPal.Ext.WindowsServices;

public partial class WindowsServicesCommandsProvider : CommandProvider
{
// For giggles, "%windir%\\system32\\filemgmt.dll" also _just works_.
public static IconInfo ServicesIcon { get; } = new("\ue9f5");

public WindowsServicesCommandsProvider()
{
Id = "Windows.Services";
DisplayName = $"Windows Services";
Icon = new("%windir%\\system32\\filemgmt.dll");
Icon = ServicesIcon;
}

public override ICommandItem[] TopLevelCommands()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class TerminalQuery : ITerminalQuery
{
"Microsoft.WindowsTerminal",
"Microsoft.WindowsTerminalPreview",
"Microsoft.WindowsTerminalCanary",
}.AsReadOnly();

private IEnumerable<TerminalPackage> Terminals => GetTerminals();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
<Import Project="..\..\Microsoft.CmdPal.UI\CmdPal.pre.props" />
<PropertyGroup>
<RootNamespace>Microsoft.CmdPal.Ext.WindowsTerminal</RootNamespace>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath>
<!-- <OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath> -->
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<!-- MRT from windows app sdk will search for a pri file with the same name of the module before defaulting to resources.pri -->
<ProjectPriFileName>Microsoft.CmdPal.Ext.WindowsTerminal.pri</ProjectPriFileName>
</PropertyGroup>
<ItemGroup>
<Content Include="Images\WindowsTerminal.dark.png">
<Content Include="Assets\WindowsTerminal.dark.png">
<Link>Assets\WindowsTerminal.dark.png</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</Content>
<Content Include="Assets\WindowsTerminal.light.png">
<Link>Assets\WindowsTerminal.light.png</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\extensionsdk\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// 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.Collections.Generic;
using System.IO;
using Microsoft.CmdPal.Ext.WindowsTerminal.Commands;
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
Expand All @@ -18,15 +16,15 @@ internal sealed partial class ProfilesListPage : ListPage
{
private readonly TerminalQuery _terminalQuery = new();
private readonly SettingsManager _terminalSettings;
private readonly Dictionary<string, BitmapImage> _logoCache = new();
private readonly Dictionary<string, BitmapImage> _logoCache = [];

private bool showHiddenProfiles;
private bool openNewTab;
private bool openQuake;

public ProfilesListPage(SettingsManager terminalSettings)
{
Icon = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Images\\WindowsTerminal.dark.png"));
Icon = WindowsTerminalCommandsProvider.TerminalIcon;
Name = Resources.profiles_list_page_name;
_terminalSettings = terminalSettings;
}
Expand Down Expand Up @@ -71,10 +69,7 @@ public List<ListItem> Query()
return result;
}

public override IListItem[] GetItems()
{
return Query().ToArray();
}
public override IListItem[] GetItems() => Query().ToArray();

private BitmapImage GetLogo(TerminalPackage terminal)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.IO;
using Microsoft.CmdPal.Ext.WindowsTerminal.Helpers;
using Microsoft.CmdPal.Ext.WindowsTerminal.Pages;
using Microsoft.CmdPal.Ext.WindowsTerminal.Properties;
Expand All @@ -16,7 +14,7 @@ public partial class TerminalTopLevelCommandItem : CommandItem
public TerminalTopLevelCommandItem(SettingsManager settingsManager)
: base(new ProfilesListPage(settingsManager))
{
Icon = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Images\\WindowsTerminal.dark.png"));
Icon = WindowsTerminalCommandsProvider.TerminalIcon;
Title = Resources.list_item_title;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ public partial class WindowsTerminalCommandsProvider : CommandProvider
private readonly TerminalTopLevelCommandItem _terminalCommand;
private readonly SettingsManager _settingsManager = new();

public static IconInfo TerminalIcon { get; } = new(
new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Assets\\WindowsTerminal.light.png")),
new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Assets\\WindowsTerminal.dark.png")));

public WindowsTerminalCommandsProvider()
{
Id = "WindowsTerminalProfiles";
DisplayName = Resources.extension_name;
Icon = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Images\\WindowsTerminal.dark.png"));
Icon = TerminalIcon;

_terminalCommand = new TerminalTopLevelCommandItem(_settingsManager)
{
MoreCommands = [new CommandContextItem(new SettingsPage(_settingsManager))],
};
}

public override ICommandItem[] TopLevelCommands()
{
return [_terminalCommand];
}
public override ICommandItem[] TopLevelCommands() => [_terminalCommand];
}
22 changes: 5 additions & 17 deletions src/modules/cmdpal/Microsoft.CmdPal.UI/CmdPal.Branding.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Default CI builds to release. When we stand up our own CI, we'll change this -->
<PropertyGroup Condition="'$(CIBuild)'=='true'">
<CommandPaletteBranding>Release</CommandPaletteBranding>
</PropertyGroup>

<PropertyGroup>
<OutputPath Condition="'$(CommandPaletteBranding)'=='Release'">$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPal</OutputPath>
<OutputPath Condition="'$(CommandPaletteBranding)'=='Preview'">$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalPreview</OutputPath>
<OutputPath Condition="'$(CommandPaletteBranding)'=='Canary'">$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalCanary</OutputPath>
<OutputPath Condition="'$(CommandPaletteBranding)'=='' or '$(CommandPaletteBranding)'=='Dev'">$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalDev</OutputPath>
</PropertyGroup>

<PropertyGroup>
<CmdPalAssetSuffix Condition="'$(CommandPaletteBranding)'=='Release'">Stable</CmdPalAssetSuffix>
<CmdPalAssetSuffix Condition="'$(CommandPaletteBranding)'=='Preview'">Stable</CmdPalAssetSuffix>
Expand Down Expand Up @@ -47,14 +35,14 @@

<!-- In the future, when we actually want to support "preview" and "canary",
add a Package-Pre.appxmanifest, etc. -->
<AppxManifest Include="Package.appxmanifest"
<AppxManifest Include="Package.appxmanifest"
Condition="'$(CommandPaletteBranding)'=='Release'" />
<AppxManifest Include="Package.appxmanifest"
<AppxManifest Include="Package.appxmanifest"
Condition="'$(CommandPaletteBranding)'=='Preview'" />
<AppxManifest Include="Package.appxmanifest"
<AppxManifest Include="Package.appxmanifest"
Condition="'$(CommandPaletteBranding)'=='Canary'" />
<AppxManifest Include="Package-Dev.appxmanifest"
<AppxManifest Include="Package-Dev.appxmanifest"
Condition="'$(CommandPaletteBranding)'=='' or '$(CommandPaletteBranding)'=='Dev'" />
</ItemGroup>

</Project>
</Project>
Loading