mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Additional formatting tweaks (#5909)
This commit is contained in:
@@ -43,7 +43,10 @@ namespace PowerLauncher.Helper
|
|||||||
|
|
||||||
public override string ContentType
|
public override string ContentType
|
||||||
{
|
{
|
||||||
get { return m_contentType; }
|
get
|
||||||
|
{
|
||||||
|
return m_contentType;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -53,7 +56,10 @@ namespace PowerLauncher.Helper
|
|||||||
|
|
||||||
public override long ContentLength
|
public override long ContentLength
|
||||||
{
|
{
|
||||||
get { return m_data.Length; }
|
get
|
||||||
|
{
|
||||||
|
return m_data.Length;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ namespace PowerLauncher.Helper
|
|||||||
{
|
{
|
||||||
public class ResultCollection : List<ResultViewModel>, INotifyCollectionChanged
|
public class ResultCollection : List<ResultViewModel>, INotifyCollectionChanged
|
||||||
{
|
{
|
||||||
public ResultCollection() { }
|
public ResultCollection()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public ResultCollection(IEnumerable<ResultViewModel> rvm) : base(rvm) { }
|
public ResultCollection(IEnumerable<ResultViewModel> rvm)
|
||||||
|
: base(rvm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.IO.Pipes;
|
using System.IO.Pipes;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -121,18 +121,14 @@ namespace PowerLauncher.Helper
|
|||||||
DWMNCRENDERINGCHANGED = 0x031F,
|
DWMNCRENDERINGCHANGED = 0x031F,
|
||||||
DWMCOLORIZATIONCOLORCHANGED = 0x0320,
|
DWMCOLORIZATIONCOLORCHANGED = 0x0320,
|
||||||
DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
|
DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
|
||||||
|
|
||||||
#region Windows 7
|
|
||||||
DWMSENDICONICTHUMBNAIL = 0x0323,
|
DWMSENDICONICTHUMBNAIL = 0x0323,
|
||||||
DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326,
|
DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326,
|
||||||
#endregion
|
|
||||||
|
|
||||||
USER = 0x0400,
|
USER = 0x0400,
|
||||||
|
|
||||||
// This is the hard-coded message value used by WinForms for Shell_NotifyIcon.
|
// This is the hard-coded message value used by WinForms for Shell_NotifyIcon.
|
||||||
// It's relatively safe to reuse.
|
// It's relatively safe to reuse.
|
||||||
TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024
|
TRAYMOUSEMESSAGE = 0x800, // WM_USER + 1024
|
||||||
APP = 0x8000
|
APP = 0x8000,
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressUnmanagedCodeSecurity]
|
[SuppressUnmanagedCodeSecurity]
|
||||||
@@ -229,8 +225,6 @@ namespace PowerLauncher.Helper
|
|||||||
where TApplication : Application, ISingleInstanceApp
|
where TApplication : Application, ISingleInstanceApp
|
||||||
|
|
||||||
{
|
{
|
||||||
#region Private Fields
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// String delimiter used in channel names.
|
/// String delimiter used in channel names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -246,14 +240,6 @@ namespace PowerLauncher.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static Mutex singleInstanceMutex;
|
internal static Mutex singleInstanceMutex;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Properties
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the instance of the application attempting to start is the first instance.
|
/// Checks if the instance of the application attempting to start is the first instance.
|
||||||
/// If not, activates the first instance.
|
/// If not, activates the first instance.
|
||||||
@@ -264,7 +250,7 @@ namespace PowerLauncher.Helper
|
|||||||
// Build unique application Id and the IPC channel name.
|
// Build unique application Id and the IPC channel name.
|
||||||
string applicationIdentifier = uniqueName + Environment.UserName;
|
string applicationIdentifier = uniqueName + Environment.UserName;
|
||||||
|
|
||||||
string channelName = String.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
|
string channelName = string.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
|
||||||
|
|
||||||
// Create mutex based on unique application Id to check if this is the first instance of the application.
|
// Create mutex based on unique application Id to check if this is the first instance of the application.
|
||||||
bool firstInstance;
|
bool firstInstance;
|
||||||
@@ -289,10 +275,6 @@ namespace PowerLauncher.Helper
|
|||||||
singleInstanceMutex?.ReleaseMutex();
|
singleInstanceMutex?.ReleaseMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Methods
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved.
|
/// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -409,7 +391,5 @@ namespace PowerLauncher.Helper
|
|||||||
|
|
||||||
((TApplication)Application.Current).OnSecondAppStarted();
|
((TApplication)Application.Current).OnSecondAppStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ namespace PowerLauncher
|
|||||||
{
|
{
|
||||||
public partial class MainWindow : IDisposable
|
public partial class MainWindow : IDisposable
|
||||||
{
|
{
|
||||||
#region Private Fields
|
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private MainViewModel _viewModel;
|
private MainViewModel _viewModel;
|
||||||
private bool _isTextSetProgrammatically;
|
private bool _isTextSetProgrammatically;
|
||||||
@@ -28,9 +27,8 @@ namespace PowerLauncher
|
|||||||
Timer _firstDeleteTimer = new Timer();
|
Timer _firstDeleteTimer = new Timer();
|
||||||
bool _coldStateHotkeyPressed = false;
|
bool _coldStateHotkeyPressed = false;
|
||||||
|
|
||||||
#endregion
|
public MainWindow(Settings settings, MainViewModel mainVM)
|
||||||
|
: this()
|
||||||
public MainWindow(Settings settings, MainViewModel mainVM) : this()
|
|
||||||
{
|
{
|
||||||
DataContext = mainVM;
|
DataContext = mainVM;
|
||||||
_viewModel = mainVM;
|
_viewModel = mainVM;
|
||||||
@@ -148,7 +146,10 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
if (e.ChangedButton == MouseButton.Left)
|
||||||
|
{
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializePosition()
|
private void InitializePosition()
|
||||||
@@ -362,7 +363,7 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
_settings.ActivateTimes++;
|
_settings.ActivateTimes++;
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(SearchBox.QueryTextBox.Text))
|
if (!string.IsNullOrEmpty(SearchBox.QueryTextBox.Text))
|
||||||
{
|
{
|
||||||
SearchBox.QueryTextBox.SelectAll();
|
SearchBox.QueryTextBox.SelectAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using PowerLauncher.Helper;
|
||||||
|
using PowerLauncher.ViewModel;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using PowerLauncher.Helper;
|
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Image;
|
using Wox.Infrastructure.Image;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using PowerLauncher.ViewModel;
|
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -22,13 +22,11 @@ namespace Wox
|
|||||||
private readonly SettingWindowViewModel _settingsVM;
|
private readonly SettingWindowViewModel _settingsVM;
|
||||||
private readonly MainViewModel _mainVM;
|
private readonly MainViewModel _mainVM;
|
||||||
private readonly Alphabet _alphabet;
|
private readonly Alphabet _alphabet;
|
||||||
private bool _disposed = false;
|
|
||||||
private readonly ThemeManager _themeManager;
|
private readonly ThemeManager _themeManager;
|
||||||
|
private bool _disposed = false;
|
||||||
|
|
||||||
public event ThemeChangedHandler ThemeChanged;
|
public event ThemeChangedHandler ThemeChanged;
|
||||||
|
|
||||||
#region Constructor
|
|
||||||
|
|
||||||
public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM, Alphabet alphabet, ThemeManager themeManager)
|
public PublicAPIInstance(SettingWindowViewModel settingsVM, MainViewModel mainVM, Alphabet alphabet, ThemeManager themeManager)
|
||||||
{
|
{
|
||||||
_settingsVM = settingsVM ?? throw new ArgumentNullException(nameof(settingsVM));
|
_settingsVM = settingsVM ?? throw new ArgumentNullException(nameof(settingsVM));
|
||||||
@@ -39,10 +37,6 @@ namespace Wox
|
|||||||
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
|
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public API
|
|
||||||
|
|
||||||
public void ChangeQuery(string query, bool requery = false)
|
public void ChangeQuery(string query, bool requery = false)
|
||||||
{
|
{
|
||||||
_mainVM.ChangeQueryText(query, requery);
|
_mainVM.ChangeQueryText(query, requery);
|
||||||
@@ -110,10 +104,6 @@ namespace Wox
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Protected Methods
|
|
||||||
|
|
||||||
protected void OnThemeChanged(Theme oldTheme, Theme newTheme)
|
protected void OnThemeChanged(Theme oldTheme, Theme newTheme)
|
||||||
{
|
{
|
||||||
ThemeChanged?.Invoke(oldTheme, newTheme);
|
ThemeChanged?.Invoke(oldTheme, newTheme);
|
||||||
@@ -130,6 +120,5 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace PowerLauncher
|
|||||||
var ps = new ProcessStartInfo(e.Uri.ToString())
|
var ps = new ProcessStartInfo(e.Uri.ToString())
|
||||||
{
|
{
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
Verb = "open"
|
Verb = "open",
|
||||||
};
|
};
|
||||||
Process.Start(ps);
|
Process.Start(ps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace PowerLauncher.Properties
|
|||||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||||
//
|
//
|
||||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e)
|
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e)
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ namespace PowerLauncher.Storage
|
|||||||
{
|
{
|
||||||
int years = (span.Days / 365);
|
int years = (span.Days / 365);
|
||||||
if (span.Days % 365 != 0)
|
if (span.Days % 365 != 0)
|
||||||
|
{
|
||||||
years += 1;
|
years += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $"about {years} {(years == 1 ? "year" : "years")} ago";
|
return $"about {years} {(years == 1 ? "year" : "years")} ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,20 +35,38 @@ namespace PowerLauncher.Storage
|
|||||||
{
|
{
|
||||||
int months = (span.Days / 30);
|
int months = (span.Days / 30);
|
||||||
if (span.Days % 31 != 0)
|
if (span.Days % 31 != 0)
|
||||||
|
{
|
||||||
months += 1;
|
months += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $"about {months} {(months == 1 ? "month" : "months")} ago";
|
return $"about {months} {(months == 1 ? "month" : "months")} ago";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (span.Days > 0)
|
if (span.Days > 0)
|
||||||
|
{
|
||||||
return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago";
|
return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago";
|
||||||
|
}
|
||||||
|
|
||||||
if (span.Hours > 0)
|
if (span.Hours > 0)
|
||||||
|
{
|
||||||
return $"about {span.Hours} {(span.Hours == 1 ? "hour" : "hours")} ago";
|
return $"about {span.Hours} {(span.Hours == 1 ? "hour" : "hours")} ago";
|
||||||
|
}
|
||||||
|
|
||||||
if (span.Minutes > 0)
|
if (span.Minutes > 0)
|
||||||
|
{
|
||||||
return $"about {span.Minutes} {(span.Minutes == 1 ? "minute" : "minutes")} ago";
|
return $"about {span.Minutes} {(span.Minutes == 1 ? "minute" : "minutes")} ago";
|
||||||
|
}
|
||||||
|
|
||||||
if (span.Seconds > 5)
|
if (span.Seconds > 5)
|
||||||
|
{
|
||||||
return $"about {span.Seconds} seconds ago";
|
return $"about {span.Seconds} seconds ago";
|
||||||
|
}
|
||||||
|
|
||||||
if (span.Seconds <= 5)
|
if (span.Seconds <= 5)
|
||||||
|
{
|
||||||
return "just now";
|
return "just now";
|
||||||
|
}
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ namespace PowerLauncher.Storage
|
|||||||
|
|
||||||
public void Add(string query)
|
public void Add(string query)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(query)) return;
|
if (string.IsNullOrEmpty(query))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Items.Count > _maxHistory)
|
if (Items.Count > _maxHistory)
|
||||||
{
|
{
|
||||||
Items.RemoveAt(0);
|
Items.RemoveAt(0);
|
||||||
@@ -31,7 +35,7 @@ namespace PowerLauncher.Storage
|
|||||||
Items.Add(new HistoryItem
|
Items.Add(new HistoryItem
|
||||||
{
|
{
|
||||||
Query = query,
|
Query = query,
|
||||||
ExecutedDateTime = DateTime.Now
|
ExecutedDateTime = DateTime.Now,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace PowerLauncher.Storage
|
|||||||
{
|
{
|
||||||
PluginID = result.PluginID,
|
PluginID = result.PluginID,
|
||||||
Title = result.Title,
|
Title = result.Title,
|
||||||
SubTitle = result.SubTitle
|
SubTitle = result.SubTitle,
|
||||||
};
|
};
|
||||||
records[result.OriginQuery.RawQuery] = record;
|
records[result.OriginQuery.RawQuery] = record;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
PluginName = PluginName,
|
PluginName = PluginName,
|
||||||
Trigger = triggerType.ToString(),
|
Trigger = triggerType.ToString(),
|
||||||
ActionName = Title
|
ActionName = Title,
|
||||||
};
|
};
|
||||||
PowerToysTelemetry.Log.WriteEvent(eventData);
|
PowerToysTelemetry.Log.WriteEvent(eventData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
public class MainViewModel : BaseModel, ISavable, IDisposable
|
public class MainViewModel : BaseModel, ISavable, IDisposable
|
||||||
{
|
{
|
||||||
#region Private Fields
|
|
||||||
|
|
||||||
private Query _currentQuery;
|
private Query _currentQuery;
|
||||||
private static Query _emptyQuery = new Query();
|
private static Query _emptyQuery = new Query();
|
||||||
private static bool _disposed;
|
private static bool _disposed;
|
||||||
@@ -56,15 +54,12 @@ namespace PowerLauncher.ViewModel
|
|||||||
private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch();
|
private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch();
|
||||||
|
|
||||||
private readonly object _addResultsLock = new object();
|
private readonly object _addResultsLock = new object();
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructor
|
|
||||||
|
|
||||||
public MainViewModel(Settings settings)
|
public MainViewModel(Settings settings)
|
||||||
{
|
{
|
||||||
_hotkeyManager = new HotkeyManager();
|
_hotkeyManager = new HotkeyManager();
|
||||||
_saved = false;
|
_saved = false;
|
||||||
_queryTextBeforeLeaveResults = "";
|
_queryTextBeforeLeaveResults = string.Empty;
|
||||||
_currentQuery = _emptyQuery;
|
_currentQuery = _emptyQuery;
|
||||||
_disposed = false;
|
_disposed = false;
|
||||||
|
|
||||||
@@ -204,7 +199,9 @@ namespace PowerLauncher.ViewModel
|
|||||||
if (!didExecuteContextButton)
|
if (!didExecuteContextButton)
|
||||||
{
|
{
|
||||||
var result = results.SelectedItem.Result;
|
var result = results.SelectedItem.Result;
|
||||||
if (result != null && result.Action != null) // SelectedItem returns null if selection is empty.
|
|
||||||
|
// SelectedItem returns null if selection is empty.
|
||||||
|
if (result != null && result.Action != null)
|
||||||
{
|
{
|
||||||
MainWindowVisibility = Visibility.Collapsed;
|
MainWindowVisibility = Visibility.Collapsed;
|
||||||
|
|
||||||
@@ -212,7 +209,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
result.Action(new ActionContext
|
result.Action(new ActionContext
|
||||||
{
|
{
|
||||||
SpecialKeyState = KeyboardHelper.CheckModifiers()
|
SpecialKeyState = KeyboardHelper.CheckModifiers(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -266,10 +263,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ViewModel Properties
|
|
||||||
|
|
||||||
public Brush MainWindowBackground { get; set; }
|
public Brush MainWindowBackground { get; set; }
|
||||||
|
|
||||||
public Brush MainWindowBorderBrush { get; set; }
|
public Brush MainWindowBorderBrush { get; set; }
|
||||||
@@ -280,16 +273,16 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ResultsViewModel History { get; private set; }
|
public ResultsViewModel History { get; private set; }
|
||||||
|
|
||||||
public string SystemQueryText { get; set; } = String.Empty;
|
public string SystemQueryText { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string QueryText { get; set; } = String.Empty;
|
public string QueryText { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// we need move cursor to end when we manually changed query
|
/// we need move cursor to end when we manually changed query
|
||||||
/// but we don't want to move cursor to end when query is updated from TextBox.
|
/// but we don't want to move cursor to end when query is updated from TextBox.
|
||||||
/// Also we don't want to force the results to change unless explicitly told to.
|
/// Also we don't want to force the results to change unless explicitly told to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="queryText"></param>
|
/// <param name="queryText">Text that is being queried from user</param>
|
||||||
/// <param name="requery">Optional Parameter that if true, will automatically execute a query against the updated text</param>
|
/// <param name="requery">Optional Parameter that if true, will automatically execute a query against the updated text</param>
|
||||||
public void ChangeQueryText(string queryText, bool requery = false)
|
public void ChangeQueryText(string queryText, bool requery = false)
|
||||||
{
|
{
|
||||||
@@ -308,7 +301,10 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
private ResultsViewModel SelectedResults
|
private ResultsViewModel SelectedResults
|
||||||
{
|
{
|
||||||
get { return _selectedResults; }
|
get
|
||||||
|
{
|
||||||
|
return _selectedResults;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -337,6 +333,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
QueryText = string.Empty;
|
QueryText = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_selectedResults.Visibility = Visibility.Visible;
|
_selectedResults.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,7 +344,10 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public Visibility MainWindowVisibility
|
public Visibility MainWindowVisibility
|
||||||
{
|
{
|
||||||
get { return _visibility; }
|
get
|
||||||
|
{
|
||||||
|
return _visibility;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -360,7 +360,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
|
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,8 +395,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ICommand ClearQueryCommand { get; set; }
|
public ICommand ClearQueryCommand { get; set; }
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void Query()
|
public void Query()
|
||||||
{
|
{
|
||||||
if (SelectedIsFromQueryResults())
|
if (SelectedIsFromQueryResults())
|
||||||
@@ -433,18 +430,17 @@ namespace PowerLauncher.ViewModel
|
|||||||
SelectedResults = Results;
|
SelectedResults = Results;
|
||||||
ChangeQueryText(h.Query);
|
ChangeQueryText(h.Query);
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
results.Add(result);
|
results.Add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(query))
|
if (!string.IsNullOrEmpty(query))
|
||||||
{
|
{
|
||||||
var filtered = results.Where
|
var filtered = results.Where(
|
||||||
(
|
|
||||||
r => StringMatcher.FuzzySearch(query, r.Title).IsSearchPrecisionScoreMet() ||
|
r => StringMatcher.FuzzySearch(query, r.Title).IsSearchPrecisionScoreMet() ||
|
||||||
StringMatcher.FuzzySearch(query, r.SubTitle).IsSearchPrecisionScoreMet()
|
StringMatcher.FuzzySearch(query, r.SubTitle).IsSearchPrecisionScoreMet()).ToList();
|
||||||
).ToList();
|
|
||||||
History.AddResults(filtered, _updateToken);
|
History.AddResults(filtered, _updateToken);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -547,7 +543,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
@@ -559,10 +554,9 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
QueryTimeMs = queryTimer.ElapsedMilliseconds,
|
QueryTimeMs = queryTimer.ElapsedMilliseconds,
|
||||||
NumResults = Results.Results.Count,
|
NumResults = Results.Results.Count,
|
||||||
QueryLength = query.RawQuery.Length
|
QueryLength = query.RawQuery.Length,
|
||||||
};
|
};
|
||||||
PowerToysTelemetry.Log.WriteEvent(queryEvent);
|
PowerToysTelemetry.Log.WriteEvent(queryEvent);
|
||||||
|
|
||||||
}, currentCancellationToken);
|
}, currentCancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -617,7 +611,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
var selected = SelectedResults == History;
|
var selected = SelectedResults == History;
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
#region Hotkey
|
|
||||||
|
|
||||||
private void SetHotkey(string hotkeyStr, HotkeyCallback action)
|
private void SetHotkey(string hotkeyStr, HotkeyCallback action)
|
||||||
{
|
{
|
||||||
@@ -651,25 +644,37 @@ namespace PowerLauncher.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if Wox should ignore any hotkeys
|
/// Checks if Wox should ignore any hotkeys
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns>if any hotkeys should be ignored</returns>
|
||||||
private bool ShouldIgnoreHotkeys()
|
private bool ShouldIgnoreHotkeys()
|
||||||
{
|
{
|
||||||
// double if to omit calling win32 function
|
// double if to omit calling win32 function
|
||||||
if (_settings.IgnoreHotkeysOnFullscreen)
|
if (_settings.IgnoreHotkeysOnFullscreen)
|
||||||
|
{
|
||||||
if (WindowsInteropHelper.IsWindowFullscreen())
|
if (WindowsInteropHelper.IsWindowFullscreen())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCustomPluginHotkey()
|
private void SetCustomPluginHotkey()
|
||||||
{
|
{
|
||||||
if (_settings.CustomPluginHotkeys == null) return;
|
if (_settings.CustomPluginHotkeys == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)
|
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)
|
||||||
{
|
{
|
||||||
SetHotkey(hotkey.Hotkey, () =>
|
SetHotkey(hotkey.Hotkey, () =>
|
||||||
{
|
{
|
||||||
if (ShouldIgnoreHotkeys()) return;
|
if (ShouldIgnoreHotkeys())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MainWindowVisibility = Visibility.Visible;
|
MainWindowVisibility = Visibility.Visible;
|
||||||
ChangeQueryText(hotkey.ActionKeyword);
|
ChangeQueryText(hotkey.ActionKeyword);
|
||||||
});
|
});
|
||||||
@@ -687,6 +692,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
StartHotkeyTimer();
|
StartHotkeyTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings.LastQueryMode == LastQueryMode.Empty)
|
if (_settings.LastQueryMode == LastQueryMode.Empty)
|
||||||
{
|
{
|
||||||
ChangeQueryText(string.Empty);
|
ChangeQueryText(string.Empty);
|
||||||
@@ -721,10 +727,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
if (!_saved)
|
if (!_saved)
|
||||||
@@ -777,7 +779,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
List<Result> list = new List<Result>();
|
List<Result> list = new List<Result>();
|
||||||
Result r = new Result
|
Result r = new Result
|
||||||
{
|
{
|
||||||
Title = "hello"
|
Title = "hello",
|
||||||
};
|
};
|
||||||
list.Add(r);
|
list.Add(r);
|
||||||
Results.AddResults(list, _updateToken);
|
Results.AddResults(list, _updateToken);
|
||||||
@@ -794,17 +796,17 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
var _ = PluginManager.QueryForPlugin(plugin, query);
|
var _ = PluginManager.QueryForPlugin(plugin, query);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleContextMenu(Key AcceleratorKey, ModifierKeys AcceleratorModifiers)
|
public void HandleContextMenu(Key acceleratorKey, ModifierKeys acceleratorModifiers)
|
||||||
{
|
{
|
||||||
var results = SelectedResults;
|
var results = SelectedResults;
|
||||||
if (results.SelectedItem != null)
|
if (results.SelectedItem != null)
|
||||||
{
|
{
|
||||||
foreach (ContextMenuItemViewModel contextMenuItems in results.SelectedItem.ContextMenuItems)
|
foreach (ContextMenuItemViewModel contextMenuItems in results.SelectedItem.ContextMenuItems)
|
||||||
{
|
{
|
||||||
if (contextMenuItems.AcceleratorKey == AcceleratorKey && contextMenuItems.AcceleratorModifiers == AcceleratorModifiers)
|
if (contextMenuItems.AcceleratorKey == acceleratorKey && contextMenuItems.AcceleratorModifiers == acceleratorModifiers)
|
||||||
{
|
{
|
||||||
MainWindowVisibility = Visibility.Collapsed;
|
MainWindowVisibility = Visibility.Collapsed;
|
||||||
contextMenuItems.Command.Execute(null);
|
contextMenuItems.Command.Execute(null);
|
||||||
@@ -813,7 +815,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAutoCompleteText(int index, string input, String query)
|
public static string GetAutoCompleteText(int index, string input, string query)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(query))
|
if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(query))
|
||||||
{
|
{
|
||||||
@@ -830,7 +832,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSearchText(int index, String input, string query)
|
public static string GetSearchText(int index, string input, string query)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(input))
|
if (!string.IsNullOrEmpty(input))
|
||||||
{
|
{
|
||||||
@@ -841,6 +843,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
return query + input.Substring(query.Length);
|
return query + input.Substring(query.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,6 +874,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
_hotkeyManager?.UnregisterHotkey(_hotkeyHandle);
|
_hotkeyManager?.UnregisterHotkey(_hotkeyHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
_hotkeyManager?.Dispose();
|
_hotkeyManager?.Dispose();
|
||||||
_updateSource?.Dispose();
|
_updateSource?.Dispose();
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
@@ -898,7 +902,5 @@ namespace PowerLauncher.ViewModel
|
|||||||
hotkeyTimer.Reset();
|
hotkeyTimer.Reset();
|
||||||
return recordedTime;
|
return recordedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ using System;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using PowerLauncher.Helper;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Infrastructure.Image;
|
using Wox.Infrastructure.Image;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using PowerLauncher.Helper;
|
|
||||||
|
|
||||||
namespace PowerLauncher.ViewModel
|
namespace PowerLauncher.ViewModel
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
public enum ActivationType
|
public enum ActivationType
|
||||||
{
|
{
|
||||||
Selection,
|
Selection,
|
||||||
Hover
|
Hover,
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>();
|
public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>();
|
||||||
@@ -140,17 +140,20 @@ namespace PowerLauncher.ViewModel
|
|||||||
AcceleratorModifiers = r.AcceleratorModifiers,
|
AcceleratorModifiers = r.AcceleratorModifiers,
|
||||||
Command = new RelayCommand(_ =>
|
Command = new RelayCommand(_ =>
|
||||||
{
|
{
|
||||||
bool hideWindow = r.Action != null && r.Action(new ActionContext
|
bool hideWindow =
|
||||||
{
|
r.Action != null &&
|
||||||
SpecialKeyState = KeyboardHelper.CheckModifiers()
|
r.Action(
|
||||||
});
|
new ActionContext
|
||||||
|
{
|
||||||
|
SpecialKeyState = KeyboardHelper.CheckModifiers(),
|
||||||
|
});
|
||||||
|
|
||||||
if (hideWindow)
|
if (hideWindow)
|
||||||
{
|
{
|
||||||
// TODO - Do we hide the window
|
// TODO - Do we hide the window
|
||||||
// MainWindowVisibility = Visibility.Collapsed;
|
// MainWindowVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +272,7 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var display = String.IsNullOrEmpty(Result.QueryTextDisplay) ? Result.Title : Result.QueryTextDisplay;
|
var display = string.IsNullOrEmpty(Result.QueryTextDisplay) ? Result.Title : Result.QueryTextDisplay;
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,21 +18,18 @@ namespace PowerLauncher.ViewModel
|
|||||||
{
|
{
|
||||||
public class ResultsViewModel : BaseModel
|
public class ResultsViewModel : BaseModel
|
||||||
{
|
{
|
||||||
#region Private Fields
|
|
||||||
|
|
||||||
private readonly object _collectionLock = new object();
|
private readonly object _collectionLock = new object();
|
||||||
|
|
||||||
private readonly Settings _settings;
|
private readonly Settings _settings;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public ResultsViewModel()
|
public ResultsViewModel()
|
||||||
{
|
{
|
||||||
Results = new ResultCollection();
|
Results = new ResultCollection();
|
||||||
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
BindingOperations.EnableCollectionSynchronization(Results, _collectionLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultsViewModel(Settings settings) : this()
|
public ResultsViewModel(Settings settings)
|
||||||
|
: this()
|
||||||
{
|
{
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||||
_settings.PropertyChanged += (s, e) =>
|
_settings.PropertyChanged += (s, e) =>
|
||||||
@@ -47,8 +44,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
public int MaxHeight
|
public int MaxHeight
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -63,11 +58,13 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ResultViewModel SelectedItem
|
public ResultViewModel SelectedItem
|
||||||
{
|
{
|
||||||
get { return _selectedItem; }
|
get
|
||||||
|
{
|
||||||
|
return _selectedItem;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// value can be null when selecting an item in a virtualized list
|
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
if (_selectedItem != null)
|
if (_selectedItem != null)
|
||||||
@@ -91,10 +88,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
|
|
||||||
public ResultCollection Results { get; }
|
public ResultCollection Results { get; }
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Methods
|
|
||||||
|
|
||||||
private static int InsertIndexOf(int newScore, IList<ResultViewModel> list)
|
private static int InsertIndexOf(int newScore, IList<ResultViewModel> list)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -125,10 +118,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
public void SelectNextResult()
|
public void SelectNextResult()
|
||||||
{
|
{
|
||||||
SelectedIndex = NewIndex(SelectedIndex + 1);
|
SelectedIndex = NewIndex(SelectedIndex + 1);
|
||||||
@@ -247,9 +236,6 @@ namespace PowerLauncher.ViewModel
|
|||||||
Results.AddRange(sorted);
|
Results.AddRange(sorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region FormattedText Dependency Property
|
|
||||||
public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached(
|
||||||
"FormattedText",
|
"FormattedText",
|
||||||
typeof(Inline),
|
typeof(Inline),
|
||||||
@@ -272,16 +258,20 @@ namespace PowerLauncher.ViewModel
|
|||||||
private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var textBlock = d as TextBlock;
|
var textBlock = d as TextBlock;
|
||||||
if (textBlock == null) return;
|
if (textBlock == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var inline = (Inline)e.NewValue;
|
var inline = (Inline)e.NewValue;
|
||||||
|
|
||||||
textBlock.Inlines.Clear();
|
textBlock.Inlines.Clear();
|
||||||
if (inline == null) return;
|
if (inline == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
textBlock.Inlines.Add(inline);
|
textBlock.Inlines.Add(inline);
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,8 @@ namespace PowerLauncher.ViewModel
|
|||||||
_storage.Save();
|
_storage.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region general
|
|
||||||
|
|
||||||
private static Internationalization _translater => InternationalizationManager.Instance;
|
private static Internationalization _translater => InternationalizationManager.Instance;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region about
|
|
||||||
|
|
||||||
public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user