Skip to content

Commit

Permalink
Remove all the PT Run v1 icons we no longer need
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Jan 28, 2025
1 parent cce6878 commit 2a1216b
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 61 deletions.
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
Expand Up @@ -11,7 +11,10 @@
<ItemGroup>
<Content Include="Images\WindowsTerminal.dark.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</Content>
<Content Include="Images\WindowsTerminal.light.png">
<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(), "Images\\WindowsTerminal.light.png")),
new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Images\\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];
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\extensionsdk\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
<ProjectReference Include="..\..\extensionsdk\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
</ItemGroup>

<!--
Expand All @@ -41,8 +41,11 @@
</ItemGroup>

<ItemGroup>
<CsWinRTInputs Include="$(TargetDir)\Microsoft.Management.Deployment.winmd" />
<Content Include="$(TargetDir)\Microsoft.Management.Deployment.winmd" Link="Microsoft.Management.Deployment.winmd" CopyToOutputDirectory="PreserveNewest" />
<CsWinRTInputs Include="$(PkgMicrosoft_WindowsPackageManager_ComInterop)\lib\uap10.0\Microsoft.Management.Deployment.winmd" />
<!-- <Content Include="$(TargetDir)\Microsoft.Management.Deployment.winmd" Link="Microsoft.Management.Deployment.winmd" CopyToOutputDirectory="PreserveNewest" /> -->

<!-- Before v1.10 of this package, it wasn't in the uap10.0 dir -->
<Content Include="$(PkgMicrosoft_WindowsPackageManager_ComInterop)\lib\uap10.0\Microsoft.Management.Deployment.winmd" Link="Microsoft.Management.Deployment.winmd" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32">
Expand All @@ -56,10 +59,9 @@
</PackageReference>
</ItemGroup>

<Target Name="CopyWinmdToTargetDir" BeforeTargets="BeforeBuild">
<!-- Before v1.10 of this package, it wasn't in the uap10.0 dir -->
<Copy SourceFiles="$(PkgMicrosoft_WindowsPackageManager_ComInterop)\lib\uap10.0\Microsoft.Management.Deployment.winmd" DestinationFolder="$(TargetDir)" />
</Target>
<!-- <Target Name="CopyWinmdToTargetDir" BeforeTargets="BeforeBuild">
<Copy SourceFiles="$(PkgMicrosoft_WindowsPackageManager_ComInterop)\lib\uap10.0\Microsoft.Management.Deployment.winmd" DestinationFolder="$(TargetDir)" />
</Target> -->

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Expand Down

0 comments on commit 2a1216b

Please sign in to comment.