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