mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-12 15:26:28 +01:00
Merge pull request #11 from zadjii-msft/dev/crutkas/dsafdsaWhiteSpace
small whitespace checkin part 1
This commit is contained in:
@@ -35,7 +35,7 @@ public class LocalSettingsService : ILocalSettingsService
|
||||
|
||||
public LocalSettingsService(IFileService fileService, IOptions<LocalSettingsOptions> options)
|
||||
{
|
||||
_isMsix = false;// RuntimeHelper.IsMSIX;
|
||||
_isMsix = false; // RuntimeHelper.IsMSIX;
|
||||
|
||||
_fileService = fileService;
|
||||
_options = options.Value;
|
||||
@@ -91,8 +91,11 @@ public class LocalSettingsService : ILocalSettingsService
|
||||
if (_settings != null && _settings.TryGetValue(key, out var obj))
|
||||
{
|
||||
var s = obj.ToString();
|
||||
if (s !=null)
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
return await Json.ToObjectAsync<T>(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,15 +155,22 @@ internal sealed class AddBookmarkForm : Form
|
||||
var state = File.ReadAllText(BookmarksActionProvider.StateJsonPath());
|
||||
var jsonState = JsonNode.Parse(state);
|
||||
var items = jsonState?["items"]?.AsArray();
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
// var items = jsonState["items"];
|
||||
var newItem = new JsonObject();
|
||||
newItem["name"] = formName;
|
||||
newItem["bookmark"] = formBookmark;
|
||||
var formData = new BookmarkData() { name = formName.ToString(), bookmark=formBookmark.ToString(), type = bookmarkType };
|
||||
var formData = new BookmarkData()
|
||||
{
|
||||
name = formName.ToString(),
|
||||
bookmark = formBookmark.ToString(),
|
||||
type = bookmarkType,
|
||||
};
|
||||
|
||||
items.Add(JsonSerializer.SerializeToNode(formData, typeof(BookmarkData), SourceGenerationContext.Default));
|
||||
//items.Add(newItem);
|
||||
|
||||
json = jsonState?.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,24 +13,44 @@ namespace DeveloperCommandPalette;
|
||||
public sealed class ListItemViewModel : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
private readonly DispatcherQueue DispatcherQueue;
|
||||
|
||||
internal ExtensionObject<IListItem> ListItem { get; init; }
|
||||
|
||||
internal string Title { get; private set; }
|
||||
|
||||
internal string Subtitle { get; private set; }
|
||||
|
||||
internal string Icon { get; private set; }
|
||||
|
||||
internal Lazy<DetailsViewModel?> _Details;
|
||||
|
||||
internal DetailsViewModel? Details => _Details.Value;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
internal ICommand? DefaultAction { get {try{ return ListItem.Unsafe.Command;} catch (COMException){return null;}}}
|
||||
internal ICommand? DefaultAction
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return ListItem.Unsafe.Command;
|
||||
}
|
||||
catch (COMException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool CanInvoke => DefaultAction != null && DefaultAction is IInvokableCommand or IPage;
|
||||
|
||||
internal IconElement IcoElement => Microsoft.Terminal.UI.IconPathConverter.IconMUX(Icon);
|
||||
|
||||
private IEnumerable<ICommandContextItem> contextActions
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var item = ListItem.Unsafe;
|
||||
@@ -45,9 +65,11 @@ public sealed class ListItemViewModel : INotifyPropertyChanged, IDisposable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasMoreCommands => contextActions.Any();
|
||||
|
||||
internal TagViewModel[] Tags = [];
|
||||
|
||||
internal bool HasTags => Tags.Length > 0;
|
||||
|
||||
internal IList<ContextItemViewModel> ContextActions
|
||||
|
||||
@@ -158,19 +158,20 @@ public sealed class ListPageViewModel : PageViewModel
|
||||
var sectionItems = new SectionInfoList(
|
||||
section,
|
||||
section.Items
|
||||
.Where(i=>i!= null && !string.IsNullOrEmpty(i.Title))
|
||||
.Where(i => i != null && !string.IsNullOrEmpty(i.Title))
|
||||
.Select(i => new ListItemViewModel(i))
|
||||
);
|
||||
|
||||
// var items = section.Items;
|
||||
// for (var i = 0; i < items.Length; i++) {
|
||||
// ListItemViewModel vm = new(items[i]);
|
||||
// Items.Add(vm);
|
||||
// FilteredItems.Add(vm);
|
||||
// }
|
||||
|
||||
newItems.Add(sectionItems);
|
||||
//Items.Add(sectionItems);
|
||||
//FilteredItems.Add(sectionItems);
|
||||
|
||||
// Items.Add(sectionItems);
|
||||
// FilteredItems.Add(sectionItems);
|
||||
}
|
||||
|
||||
ListHelpers.InPlaceUpdateList(Items, newItems);
|
||||
|
||||
@@ -31,7 +31,7 @@ public sealed class MainViewModel
|
||||
internal bool LoadedApps;
|
||||
|
||||
public event TypedEventHandler<object, object?>? HideRequested;
|
||||
|
||||
|
||||
public event TypedEventHandler<object, object?>? SummonRequested;
|
||||
|
||||
public event TypedEventHandler<object, object?>? AppsReady;
|
||||
@@ -65,7 +65,8 @@ public sealed class MainViewModel
|
||||
handlers?.Invoke(this, null);
|
||||
}
|
||||
|
||||
public void Summon(){
|
||||
public void Summon()
|
||||
{
|
||||
var handlers = SummonRequested;
|
||||
handlers?.Invoke(this, null);
|
||||
}
|
||||
@@ -75,20 +76,26 @@ public sealed class MainViewModel
|
||||
return title + subtitle;
|
||||
}
|
||||
|
||||
private string[] _recentCommandHashes = [];// ["SpotifySpotify", "All Apps", "GitHub Issues", "Microsoft/GithubBookmark"];
|
||||
private string[] _recentCommandHashes = [];
|
||||
|
||||
public IEnumerable<IListItem> RecentActions => TopLevelCommands
|
||||
.Select(i=>i.Unsafe)
|
||||
.Where((i) => {
|
||||
.Select(i => i.Unsafe)
|
||||
.Where((i) =>
|
||||
{
|
||||
if (i != null)
|
||||
{
|
||||
try{
|
||||
try
|
||||
{
|
||||
return _recentCommandHashes.Contains(CreateHash(i.Title, i.Subtitle));
|
||||
} catch(COMException){ return false; }
|
||||
}
|
||||
catch (COMException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.Select(i=>i!);
|
||||
}).Select(i => i!);
|
||||
|
||||
public IEnumerable<IListItem> AppItems => LoadedApps? apps.GetItems().First().Items : [];
|
||||
|
||||
@@ -139,7 +146,7 @@ public sealed class MainViewModel
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(COMException){ /* log something */ }
|
||||
catch (COMException) { /* log something */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ internal sealed class SettingsForm: Form
|
||||
var hotkey = "win+ctrl+.";
|
||||
try
|
||||
{
|
||||
hotkey = await Application.Current.GetService<ILocalSettingsService>().ReadSettingAsync<string>("GlobalHotkey") ;
|
||||
hotkey = await Application.Current.GetService<ILocalSettingsService>().ReadSettingAsync<string>("GlobalHotkey");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -94,7 +94,9 @@ internal sealed class SettingsForm: Form
|
||||
}
|
||||
""";
|
||||
}
|
||||
|
||||
public override string StateJson() => throw new NotImplementedException();
|
||||
|
||||
public override ActionResult SubmitForm(string payload)
|
||||
{
|
||||
var formInput = JsonNode.Parse(payload)?.AsObject();
|
||||
|
||||
Reference in New Issue
Block a user