lotta baseline adjustments

This commit is contained in:
Clint Rutkas
2024-09-05 15:54:04 -07:00
parent 586d6172a5
commit e6d4cde45f
25 changed files with 259 additions and 68 deletions

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Action : BaseObservable, ICommand
{

View File

@@ -1,20 +1,39 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class ActionResult : ICommandResult
{
private ICommandResultArgs _Args = null;
private CommandResultKind _Kind = CommandResultKind.Dismiss;
public ICommandResultArgs Args => _Args;
public CommandResultKind Kind => _Kind;
public static ActionResult Dismiss() {
return new ActionResult() { _Kind = CommandResultKind.Dismiss };
private ICommandResultArgs _args;
private CommandResultKind _kind = CommandResultKind.Dismiss;
public ICommandResultArgs Args => _args;
public CommandResultKind Kind => _kind;
public static ActionResult Dismiss()
{
return new ActionResult()
{
_kind = CommandResultKind.Dismiss
};
}
public static ActionResult GoHome()
{
return new ActionResult() { _Kind = CommandResultKind.GoHome };
return new ActionResult()
{
_kind = CommandResultKind.GoHome
};
}
public static ActionResult KeepOpen()
{
return new ActionResult() { _Kind = CommandResultKind.KeepOpen };
return new ActionResult()
{
_kind = CommandResultKind.KeepOpen
};
}
}

View File

@@ -1,3 +1,7 @@
// 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 Windows.Foundation;
namespace Microsoft.CmdPal.Extensions.Helpers;
@@ -11,6 +15,8 @@ public class BaseObservable : INotifyPropChanged
protected void OnPropertyChanged(string propertyName)
{
if (PropChanged != null)
PropChanged.Invoke(this, new Microsoft.CmdPal.Extensions.PropChangedEventArgs(propertyName));
{
PropChanged.Invoke(this, new PropChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// 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.Diagnostics;

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class CommandContextItem : ICommandContextItem
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Details : BaseObservable, IDetails
{

View File

@@ -1,7 +1,12 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class DetailsElement : IDetailsElement
{
public string Key { get; set; }
public string Key { get; set; } = string.Empty;
public IDetailsData? Data { get; set; }
}

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class DetailsLink : IDetailsLink
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class DetailsTags : IDetailsTags
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class DynamicListPage : ListPage, IDynamicListPage
{

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// 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.Runtime.InteropServices;
using Windows.Win32;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// 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.Diagnostics;
using System.Runtime.InteropServices;

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Filter : IFilter
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Form: IForm
{

View File

@@ -1,10 +1,22 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class FormPage : Action, IFormPage
{
private bool _Loading = false;
private bool _loading;
public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } }
public bool Loading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(Loading));
}
}
public virtual IForm[] Forms() => throw new NotImplementedException();
}

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class GoToPageArgs : IGoToPageArgs
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class InvokableCommand : Action, IInvokableCommand
{

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// 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.Collections.ObjectModel;

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class ListItem : BaseObservable, IListItem
{
@@ -26,7 +30,7 @@ public class ListItem : BaseObservable, IListItem
public ICommand Command { get => _command; set { _command = value; OnPropertyChanged(nameof(Command)); } }
public IContextItem[] MoreCommands { get => _moreCommands; set { _moreCommands = value; OnPropertyChanged(nameof(MoreCommands)); } }
public IFallbackHandler? FallbackHandler { get => _fallbackHandler ?? _command as IFallbackHandler; init { _fallbackHandler = value; } }
public IFallbackHandler? FallbackHandler { get => _fallbackHandler ?? _command as IFallbackHandler; init => _fallbackHandler = value; }
public ListItem(ICommand command)
{

View File

@@ -2,19 +2,72 @@
public class ListPage : Action, IListPage
{
private string _PlaceholderText = "";
private string _SearchText = "";
private bool _ShowDetails = false;
private bool _Loading = false;
private IFilters _Filters = null;
private IGridProperties _GridProperties = null;
private string _placeholderText = string.Empty;
private string _searchText = string.Empty;
private bool _showDetails;
private bool _loading;
private IFilters _filters;
private IGridProperties _gridProperties;
public string PlaceholderText { get => _PlaceholderText; set { _PlaceholderText = value; OnPropertyChanged(nameof(PlaceholderText)); } }
public string SearchText { get => _SearchText; set { _SearchText = value; OnPropertyChanged(nameof(SearchText)); } }
public bool ShowDetails { get => _ShowDetails; set { _ShowDetails = value; OnPropertyChanged(nameof(ShowDetails)); } }
public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } }
public IFilters Filters { get => _Filters; set { _Filters = value; OnPropertyChanged(nameof(Filters)); } }
public IGridProperties GridProperties { get => _GridProperties; set { _GridProperties = value; OnPropertyChanged(nameof(GridProperties)); } }
public string PlaceholderText
{
get => _placeholderText;
set
{
_placeholderText = value;
OnPropertyChanged(nameof(PlaceholderText));
}
}
public string SearchText
{
get => _searchText;
set
{
_searchText = value;
OnPropertyChanged(nameof(SearchText));
}
}
public bool ShowDetails
{
get => _showDetails;
set
{
_showDetails = value;
OnPropertyChanged(nameof(ShowDetails));
}
}
public bool Loading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(Loading));
}
}
public IFilters Filters
{
get => _filters;
set
{
_filters = value;
OnPropertyChanged(nameof(Filters));
}
}
public IGridProperties GridProperties
{
get => _gridProperties;
set
{
_gridProperties = value;
OnPropertyChanged(nameof(GridProperties));
}
}
public virtual ISection[] GetItems() => throw new NotImplementedException();
}

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class ListSection : ISection
{

View File

@@ -1,4 +1,8 @@
namespace Microsoft.CmdPal.Extensions.Helpers;
// 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.
namespace Microsoft.CmdPal.Extensions.Helpers;
public class MarkdownPage : Action, IMarkdownPage
{

View File

@@ -2,10 +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.
//[assembly: InternalsVisibleTo("Microsoft.Plugin.Program.UnitTests")]
//[assembly: InternalsVisibleTo("Microsoft.PowerToys.Run.Plugin.System.UnitTests")]
//[assembly: InternalsVisibleTo("Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests")]
namespace Microsoft.CmdPal.Extensions.Helpers;
public enum SearchPrecisionScore

View File

@@ -4,10 +4,6 @@
using System.Globalization;
//[assembly: InternalsVisibleTo("Microsoft.Plugin.Program.UnitTests")]
//[assembly: InternalsVisibleTo("Microsoft.PowerToys.Run.Plugin.System.UnitTests")]
//[assembly: InternalsVisibleTo("Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests")]
namespace Microsoft.CmdPal.Extensions.Helpers;
public class StringMatcher

View File

@@ -1,19 +1,67 @@
using Windows.UI;
// 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 Windows.UI;
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Tag : BaseObservable, ITag
{
protected Color _Color = new();
protected IconDataType _Icon = null;
protected string _Text = "";
protected string _ToolTip = "";
protected ICommand _Action;
private Color _color;
private IconDataType _icon = new(string.Empty);
private string _text = string.Empty;
private string _ToolTip = string.Empty;
private ICommand _command;
public Color Color { get => _Color; set { _Color = value; OnPropertyChanged(nameof(Color)); } }
public IconDataType Icon { get => _Icon; set { _Icon = value; OnPropertyChanged(nameof(Icon)); } }
public string Text { get => _Text; set { _Text = value; OnPropertyChanged(nameof(Text)); } }
public string ToolTip { get => _ToolTip; set { _ToolTip = value; OnPropertyChanged(nameof(ToolTip)); } }
public ICommand Command { get => _Action; set { _Action = value; OnPropertyChanged(nameof(Action)); } }
public Color Color
{
get => _color;
set
{
_color = value;
OnPropertyChanged(nameof(Color));
}
}
public IconDataType Icon
{
get => _icon;
set
{
_icon = value;
OnPropertyChanged(nameof(Icon));
}
}
public string Text
{
get => _text;
set
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
public string ToolTip
{
get => _ToolTip;
set
{
_ToolTip = value;
OnPropertyChanged(nameof(ToolTip));
}
}
public ICommand Command
{
get => _command;
set
{
_command = value;
OnPropertyChanged(nameof(Action));
}
}
}