2022-07-29 07:09:33 +00:00
|
|
|
|
using System;
|
2016-05-21 21:44:27 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-05-22 18:14:59 +00:00
|
|
|
|
using System.IO;
|
2016-05-21 21:44:27 +00:00
|
|
|
|
using System.Linq;
|
2020-01-07 00:34:46 +00:00
|
|
|
|
using System.Net;
|
2021-10-17 02:28:55 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2016-05-21 22:16:32 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Controls;
|
2016-05-22 18:14:59 +00:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
2020-04-21 09:12:17 +00:00
|
|
|
|
using Flow.Launcher.Core;
|
|
|
|
|
|
using Flow.Launcher.Core.Configuration;
|
2021-10-10 21:46:54 +00:00
|
|
|
|
using Flow.Launcher.Core.ExternalPlugins;
|
2020-04-21 09:12:17 +00:00
|
|
|
|
using Flow.Launcher.Core.Plugin;
|
|
|
|
|
|
using Flow.Launcher.Core.Resource;
|
|
|
|
|
|
using Flow.Launcher.Helper;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.Storage;
|
|
|
|
|
|
using Flow.Launcher.Infrastructure.UserSettings;
|
|
|
|
|
|
using Flow.Launcher.Plugin;
|
2021-01-26 07:01:39 +00:00
|
|
|
|
using Flow.Launcher.Plugin.SharedModels;
|
2022-03-01 19:29:21 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2022-11-08 17:05:58 +00:00
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2022-11-18 16:47:04 +00:00
|
|
|
|
using System.Globalization;
|
2016-05-21 21:44:27 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.ViewModel
|
2016-05-21 21:44:27 +00:00
|
|
|
|
{
|
2022-11-08 17:05:58 +00:00
|
|
|
|
public partial class SettingWindowViewModel : BaseModel
|
2016-05-21 21:44:27 +00:00
|
|
|
|
{
|
2020-01-07 00:34:46 +00:00
|
|
|
|
private readonly Updater _updater;
|
2020-04-01 11:20:33 +00:00
|
|
|
|
private readonly IPortable _portable;
|
2020-04-21 12:16:10 +00:00
|
|
|
|
private readonly FlowLauncherJsonStorage<Settings> _storage;
|
2016-05-22 04:30:38 +00:00
|
|
|
|
|
2020-04-01 11:20:33 +00:00
|
|
|
|
public SettingWindowViewModel(Updater updater, IPortable portable)
|
2016-05-22 22:51:17 +00:00
|
|
|
|
{
|
2020-01-07 00:34:46 +00:00
|
|
|
|
_updater = updater;
|
2020-04-01 11:20:33 +00:00
|
|
|
|
_portable = portable;
|
2020-04-21 12:16:10 +00:00
|
|
|
|
_storage = new FlowLauncherJsonStorage<Settings>();
|
2016-05-22 22:51:17 +00:00
|
|
|
|
Settings = _storage.Load();
|
2016-05-23 21:08:13 +00:00
|
|
|
|
Settings.PropertyChanged += (s, e) =>
|
|
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
switch (e.PropertyName)
|
2016-05-23 21:08:13 +00:00
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
case nameof(Settings.ActivateTimes):
|
|
|
|
|
|
OnPropertyChanged(nameof(ActivatedTimes));
|
|
|
|
|
|
break;
|
2022-10-10 06:33:33 +00:00
|
|
|
|
case nameof(Settings.WindowSize):
|
|
|
|
|
|
OnPropertyChanged(nameof(WindowWidthSize));
|
|
|
|
|
|
break;
|
2016-05-23 21:08:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2022-11-19 22:11:13 +00:00
|
|
|
|
int tmp = 0;
|
|
|
|
|
|
TimeFormatIndex = (tmp = TimeFormatList.FindIndex(x => x.Equals(Settings.TimeFormat))) >= 0 ? tmp : 0;
|
|
|
|
|
|
DateFormatIndex = (tmp = DateFormatList.FindIndex(x => x.Equals(Settings.DateFormat))) >= 0 ? tmp : 0;
|
|
|
|
|
|
// TODO: CurrentCulture may not equal to settings.language when this is constructed
|
|
|
|
|
|
TimeFormatDisplayList = TimeFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
|
|
|
|
|
|
DateFormatDisplayList = DateFormatList.Select(x => DateTime.Now.ToString(x, CultureInfo.CurrentCulture)).ToList();
|
2016-05-22 22:51:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Settings Settings { get; set; }
|
|
|
|
|
|
|
2020-01-07 00:34:46 +00:00
|
|
|
|
public async void UpdateApp()
|
|
|
|
|
|
{
|
2021-10-09 16:34:41 +00:00
|
|
|
|
await _updater.UpdateAppAsync(App.API, false);
|
2020-01-07 00:34:46 +00:00
|
|
|
|
}
|
2022-11-19 04:25:46 +00:00
|
|
|
|
|
2020-04-28 11:10:42 +00:00
|
|
|
|
public bool AutoUpdates
|
|
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
get => Settings.AutoUpdates;
|
2020-04-28 11:10:42 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.AutoUpdates = value;
|
|
|
|
|
|
|
|
|
|
|
|
if (value)
|
2022-08-01 16:36:35 +00:00
|
|
|
|
{
|
2020-04-28 11:10:42 +00:00
|
|
|
|
UpdateApp();
|
2022-08-01 16:36:35 +00:00
|
|
|
|
}
|
2020-04-28 11:10:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-08 01:23:35 +00:00
|
|
|
|
public bool StartFlowLauncherOnSystemStartup
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.StartFlowLauncherOnSystemStartup;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.StartFlowLauncherOnSystemStartup = value;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value)
|
|
|
|
|
|
AutoStartup.Enable();
|
|
|
|
|
|
else
|
|
|
|
|
|
AutoStartup.Disable();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), e.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-01 11:20:33 +00:00
|
|
|
|
// This is only required to set at startup. When portable mode enabled/disabled a restart is always required
|
|
|
|
|
|
private bool _portableMode = DataLocation.PortableDataLocationInUse();
|
|
|
|
|
|
public bool PortableMode
|
|
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
get => _portableMode;
|
2020-04-01 11:20:33 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_portable.CanUpdatePortability())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (DataLocation.PortableDataLocationInUse())
|
|
|
|
|
|
{
|
|
|
|
|
|
_portable.DisablePortableMode();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_portable.EnablePortableMode();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-22 22:51:17 +00:00
|
|
|
|
public void Save()
|
|
|
|
|
|
{
|
2020-04-29 04:03:58 +00:00
|
|
|
|
foreach (var vm in PluginViewModels)
|
|
|
|
|
|
{
|
|
|
|
|
|
var id = vm.PluginPair.Metadata.ID;
|
|
|
|
|
|
|
|
|
|
|
|
Settings.PluginSettings.Plugins[id].Disabled = vm.PluginPair.Metadata.Disabled;
|
2021-01-05 08:11:38 +00:00
|
|
|
|
Settings.PluginSettings.Plugins[id].Priority = vm.Priority;
|
2020-04-29 04:03:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PluginManager.Save();
|
2016-05-22 22:51:17 +00:00
|
|
|
|
_storage.Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
#region general
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2017-02-19 20:27:25 +00:00
|
|
|
|
// todo a better name?
|
2022-09-27 22:37:55 +00:00
|
|
|
|
public class LastQueryMode : BaseModel
|
2017-02-12 22:34:12 +00:00
|
|
|
|
{
|
|
|
|
|
|
public string Display { get; set; }
|
|
|
|
|
|
public Infrastructure.UserSettings.LastQueryMode Value { get; set; }
|
|
|
|
|
|
}
|
2022-09-27 22:37:55 +00:00
|
|
|
|
|
|
|
|
|
|
private List<LastQueryMode> _lastQueryModes = new List<LastQueryMode>();
|
2017-02-12 22:34:12 +00:00
|
|
|
|
public List<LastQueryMode> LastQueryModes
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2022-09-27 22:37:55 +00:00
|
|
|
|
if (_lastQueryModes.Count == 0)
|
2017-02-12 22:34:12 +00:00
|
|
|
|
{
|
2022-09-27 22:37:55 +00:00
|
|
|
|
_lastQueryModes = InitLastQueryModes();
|
2017-02-12 22:34:12 +00:00
|
|
|
|
}
|
2022-09-27 22:37:55 +00:00
|
|
|
|
return _lastQueryModes;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<LastQueryMode> InitLastQueryModes()
|
|
|
|
|
|
{
|
|
|
|
|
|
var modes = new List<LastQueryMode>();
|
|
|
|
|
|
var enums = (Infrastructure.UserSettings.LastQueryMode[])Enum.GetValues(typeof(Infrastructure.UserSettings.LastQueryMode));
|
|
|
|
|
|
foreach (var e in enums)
|
|
|
|
|
|
{
|
|
|
|
|
|
var key = $"LastQuery{e}";
|
|
|
|
|
|
var display = _translater.GetTranslation(key);
|
2022-11-19 22:11:13 +00:00
|
|
|
|
var m = new LastQueryMode { Display = display, Value = e, };
|
2022-09-27 22:37:55 +00:00
|
|
|
|
modes.Add(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
return modes;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UpdateLastQueryModeDisplay()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in LastQueryModes)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Display = _translater.GetTranslation($"LastQuery{item.Value}");
|
2017-02-12 22:34:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-31 11:00:09 +00:00
|
|
|
|
public string Language
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Settings.Language;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
InternationalizationManager.Instance.ChangeLanguage(value);
|
|
|
|
|
|
|
|
|
|
|
|
if (InternationalizationManager.Instance.PromptShouldUsePinyin(value))
|
|
|
|
|
|
ShouldUsePinyin = true;
|
2022-09-27 22:37:55 +00:00
|
|
|
|
|
|
|
|
|
|
UpdateLastQueryModeDisplay();
|
2020-03-31 11:00:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool ShouldUsePinyin
|
|
|
|
|
|
{
|
2021-06-21 05:39:54 +00:00
|
|
|
|
get
|
2020-03-31 11:00:09 +00:00
|
|
|
|
{
|
2021-06-21 05:39:54 +00:00
|
|
|
|
return Settings.ShouldUsePinyin;
|
2020-03-31 11:00:09 +00:00
|
|
|
|
}
|
2021-06-21 05:39:54 +00:00
|
|
|
|
set
|
2020-03-31 11:00:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
Settings.ShouldUsePinyin = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-09-29 10:04:30 +00:00
|
|
|
|
public List<string> QuerySearchPrecisionStrings
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
2020-01-07 11:30:36 +00:00
|
|
|
|
{
|
2019-09-29 10:04:30 +00:00
|
|
|
|
var precisionStrings = new List<string>();
|
|
|
|
|
|
|
2021-01-08 07:52:45 +00:00
|
|
|
|
var enumList = Enum.GetValues(typeof(SearchPrecisionScore)).Cast<SearchPrecisionScore>().ToList();
|
2019-09-29 10:04:30 +00:00
|
|
|
|
|
|
|
|
|
|
enumList.ForEach(x => precisionStrings.Add(x.ToString()));
|
|
|
|
|
|
|
|
|
|
|
|
return precisionStrings;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-01 19:29:21 +00:00
|
|
|
|
public List<string> OpenResultModifiersList => new List<string>
|
|
|
|
|
|
{
|
|
|
|
|
|
KeyConstant.Alt,
|
|
|
|
|
|
KeyConstant.Ctrl,
|
|
|
|
|
|
$"{KeyConstant.Ctrl}+{KeyConstant.Alt}"
|
|
|
|
|
|
};
|
2016-05-22 21:49:41 +00:00
|
|
|
|
private Internationalization _translater => InternationalizationManager.Instance;
|
2017-02-12 22:34:12 +00:00
|
|
|
|
public List<Language> Languages => _translater.LoadAvailableLanguages();
|
2016-05-21 21:44:27 +00:00
|
|
|
|
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2022-11-03 07:56:48 +00:00
|
|
|
|
public ObservableCollection<CustomShortcutModel> CustomShortcuts => Settings.CustomShortcuts;
|
2022-11-07 12:04:13 +00:00
|
|
|
|
public ObservableCollection<BuiltinShortcutModel> BuiltinShortcuts => Settings.BuiltinShortcuts;
|
2021-12-23 22:13:49 +00:00
|
|
|
|
|
2020-01-07 00:34:46 +00:00
|
|
|
|
public string TestProxy()
|
|
|
|
|
|
{
|
|
|
|
|
|
var proxyServer = Settings.Proxy.Server;
|
|
|
|
|
|
var proxyUserName = Settings.Proxy.UserName;
|
|
|
|
|
|
if (string.IsNullOrEmpty(proxyServer))
|
|
|
|
|
|
{
|
|
|
|
|
|
return InternationalizationManager.Instance.GetTranslation("serverCantBeEmpty");
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Settings.Proxy.Port <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return InternationalizationManager.Instance.GetTranslation("portCantBeEmpty");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_updater.GitHubRepository);
|
2021-06-21 05:39:54 +00:00
|
|
|
|
|
2020-01-07 00:34:46 +00:00
|
|
|
|
if (string.IsNullOrEmpty(proxyUserName) || string.IsNullOrEmpty(Settings.Proxy.Password))
|
|
|
|
|
|
{
|
|
|
|
|
|
request.Proxy = new WebProxy(proxyServer, Settings.Proxy.Port);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
request.Proxy = new WebProxy(proxyServer, Settings.Proxy.Port)
|
|
|
|
|
|
{
|
|
|
|
|
|
Credentials = new NetworkCredential(proxyUserName, Settings.Proxy.Password)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = (HttpWebResponse)request.GetResponse();
|
|
|
|
|
|
if (response.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
return InternationalizationManager.Instance.GetTranslation("proxyIsCorrect");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return InternationalizationManager.Instance.GetTranslation("proxyConnectFailed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
return InternationalizationManager.Instance.GetTranslation("proxyConnectFailed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
#endregion
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
#region plugin
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2020-12-22 19:28:59 +00:00
|
|
|
|
public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";
|
2016-05-22 04:30:38 +00:00
|
|
|
|
public PluginViewModel SelectedPlugin { get; set; }
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 04:51:00 +00:00
|
|
|
|
public IList<PluginViewModel> PluginViewModels
|
2016-05-22 04:30:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2020-02-22 09:02:07 +00:00
|
|
|
|
var metadatas = PluginManager.AllPlugins
|
|
|
|
|
|
.OrderBy(x => x.Metadata.Disabled)
|
|
|
|
|
|
.ThenBy(y => y.Metadata.Name)
|
2022-03-01 19:29:21 +00:00
|
|
|
|
.Select(p => new PluginViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
PluginPair = p
|
|
|
|
|
|
})
|
2020-02-22 09:02:07 +00:00
|
|
|
|
.ToList();
|
2016-05-22 04:30:38 +00:00
|
|
|
|
return metadatas;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-21 22:42:23 +00:00
|
|
|
|
|
2022-10-08 06:57:41 +00:00
|
|
|
|
public IList<PluginStoreItemViewModel> ExternalPlugins
|
2021-10-10 21:46:54 +00:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2022-10-07 07:34:08 +00:00
|
|
|
|
return LabelMaker(PluginsManifest.UserPlugins);
|
2021-10-10 21:46:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-19 04:25:46 +00:00
|
|
|
|
private IList<PluginStoreItemViewModel> LabelMaker(IList<UserPlugin> list)
|
2022-10-07 07:34:08 +00:00
|
|
|
|
{
|
2022-11-19 04:25:46 +00:00
|
|
|
|
return list.Select(p => new PluginStoreItemViewModel(p))
|
2022-10-28 11:44:06 +00:00
|
|
|
|
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
|
2022-11-19 04:25:46 +00:00
|
|
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.RecentlyUpdated)
|
2022-10-28 11:44:06 +00:00
|
|
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
|
|
|
|
|
|
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed)
|
2022-10-08 06:57:41 +00:00
|
|
|
|
.ToList();
|
2022-10-07 07:34:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-22 04:30:38 +00:00
|
|
|
|
public Control SettingProvider
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2016-06-20 23:14:32 +00:00
|
|
|
|
var settingProvider = SelectedPlugin.PluginPair.Plugin as ISettingProvider;
|
2016-05-22 04:30:38 +00:00
|
|
|
|
if (settingProvider != null)
|
|
|
|
|
|
{
|
2016-05-22 18:23:20 +00:00
|
|
|
|
var control = settingProvider.CreateSettingPanel();
|
2016-05-22 04:30:38 +00:00
|
|
|
|
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|
|
|
|
|
control.VerticalAlignment = VerticalAlignment.Stretch;
|
|
|
|
|
|
return control;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Control();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2022-11-08 17:05:58 +00:00
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private async Task RefreshExternalPluginsAsync()
|
2021-10-17 02:28:55 +00:00
|
|
|
|
{
|
|
|
|
|
|
await PluginsManifest.UpdateManifestAsync();
|
|
|
|
|
|
OnPropertyChanged(nameof(ExternalPlugins));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-28 12:15:00 +00:00
|
|
|
|
internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int actionKeywordPosition = 0)
|
|
|
|
|
|
{
|
2022-11-19 04:25:46 +00:00
|
|
|
|
var actionKeyword = plugin.Metadata.ActionKeywords.Count == 0
|
|
|
|
|
|
? string.Empty
|
2022-10-28 12:15:00 +00:00
|
|
|
|
: plugin.Metadata.ActionKeywords[actionKeywordPosition];
|
2022-11-19 04:25:46 +00:00
|
|
|
|
|
2022-10-28 12:15:00 +00:00
|
|
|
|
App.API.ChangeQuery($"{actionKeyword} {queryToDisplay}");
|
|
|
|
|
|
App.API.ShowMainWindow();
|
|
|
|
|
|
}
|
2016-06-20 23:14:32 +00:00
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
#endregion
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
#region theme
|
2016-05-22 04:30:38 +00:00
|
|
|
|
|
2022-01-02 12:34:56 +00:00
|
|
|
|
public static string Theme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme";
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
public string SelectedTheme
|
2016-05-22 04:51:00 +00:00
|
|
|
|
{
|
2016-05-22 22:51:17 +00:00
|
|
|
|
get { return Settings.Theme; }
|
2016-05-22 18:14:59 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.Theme = value;
|
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(value);
|
2022-09-27 22:37:55 +00:00
|
|
|
|
|
2021-06-27 11:42:37 +00:00
|
|
|
|
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect)
|
|
|
|
|
|
DropShadowEffect = false;
|
2016-05-22 18:14:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
|
|
|
|
|
public List<string> Themes
|
|
|
|
|
|
=> ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension).ToList();
|
2016-05-22 18:14:59 +00:00
|
|
|
|
|
2020-05-07 04:30:55 +00:00
|
|
|
|
public bool DropShadowEffect
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Settings.UseDropShadowEffect; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2021-06-27 11:42:37 +00:00
|
|
|
|
if (ThemeManager.Instance.BlurEnabled && value)
|
|
|
|
|
|
{
|
2021-06-27 12:13:58 +00:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("shadowEffectNotAllowed"));
|
2021-06-27 11:42:37 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-07 04:30:55 +00:00
|
|
|
|
if (value)
|
|
|
|
|
|
{
|
|
|
|
|
|
ThemeManager.Instance.AddDropShadowEffectToCurrentTheme();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-06-27 11:42:37 +00:00
|
|
|
|
ThemeManager.Instance.RemoveDropShadowEffectFromCurrentTheme();
|
2020-05-07 04:30:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Settings.UseDropShadowEffect = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-29 22:07:52 +00:00
|
|
|
|
public class ColorScheme
|
2021-11-23 05:33:11 +00:00
|
|
|
|
{
|
2021-11-23 06:44:26 +00:00
|
|
|
|
public string Display { get; set; }
|
2021-11-29 22:07:52 +00:00
|
|
|
|
public ColorSchemes Value { get; set; }
|
2021-11-23 05:33:11 +00:00
|
|
|
|
}
|
2021-11-29 22:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
public List<ColorScheme> ColorSchemes
|
2021-11-23 05:33:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2021-11-29 22:07:52 +00:00
|
|
|
|
List<ColorScheme> modes = new List<ColorScheme>();
|
|
|
|
|
|
var enums = (ColorSchemes[])Enum.GetValues(typeof(ColorSchemes));
|
2021-11-23 06:44:26 +00:00
|
|
|
|
foreach (var e in enums)
|
|
|
|
|
|
{
|
2021-11-29 22:07:52 +00:00
|
|
|
|
var key = $"ColorScheme{e}";
|
2021-11-23 06:44:26 +00:00
|
|
|
|
var display = _translater.GetTranslation(key);
|
2022-03-01 19:29:21 +00:00
|
|
|
|
var m = new ColorScheme
|
|
|
|
|
|
{
|
2022-11-19 22:11:13 +00:00
|
|
|
|
Display = display,
|
|
|
|
|
|
Value = e,
|
2022-03-01 19:29:21 +00:00
|
|
|
|
};
|
2021-11-23 06:44:26 +00:00
|
|
|
|
modes.Add(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
return modes;
|
2021-11-23 05:33:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-20 10:34:05 +00:00
|
|
|
|
public class SearchWindowPosition
|
2022-09-07 01:39:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
public string Display { get; set; }
|
2022-10-20 10:34:05 +00:00
|
|
|
|
public SearchWindowPositions Value { get; set; }
|
2022-09-07 01:39:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-20 10:34:05 +00:00
|
|
|
|
public List<SearchWindowPosition> SearchWindowPositions
|
2022-09-07 01:39:06 +00:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2022-10-20 10:34:05 +00:00
|
|
|
|
List<SearchWindowPosition> modes = new List<SearchWindowPosition>();
|
|
|
|
|
|
var enums = (SearchWindowPositions[])Enum.GetValues(typeof(SearchWindowPositions));
|
2022-09-07 01:39:06 +00:00
|
|
|
|
foreach (var e in enums)
|
|
|
|
|
|
{
|
2022-10-20 10:34:05 +00:00
|
|
|
|
var key = $"SearchWindowPosition{e}";
|
2022-09-07 01:39:06 +00:00
|
|
|
|
var display = _translater.GetTranslation(key);
|
2022-11-19 22:11:13 +00:00
|
|
|
|
var m = new SearchWindowPosition { Display = display, Value = e, };
|
2022-09-07 01:39:06 +00:00
|
|
|
|
modes.Add(m);
|
|
|
|
|
|
}
|
|
|
|
|
|
return modes;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
public List<string> TimeFormatList { get; set; } = new List<string>()
|
2022-09-05 06:48:10 +00:00
|
|
|
|
{
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"h:mm",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"hh:mm",
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"H:mm",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"HH:mm",
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"tt h:mm",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"tt hh:mm",
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"h:mm tt",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"hh:mm tt"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
public List<string> DateFormatList { get; set; } = new List<string>()
|
2022-09-05 06:48:10 +00:00
|
|
|
|
{
|
|
|
|
|
|
"MM'/'dd dddd",
|
|
|
|
|
|
"MM'/'dd ddd",
|
|
|
|
|
|
"MM'/'dd",
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"MM'-'dd",
|
|
|
|
|
|
"MMMM', 'dd",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"dd'/'MM",
|
2022-11-19 05:33:27 +00:00
|
|
|
|
"dd'-'MM",
|
2022-09-05 06:48:10 +00:00
|
|
|
|
"ddd MM'/'dd",
|
|
|
|
|
|
"dddd MM'/'dd",
|
2022-11-18 11:52:15 +00:00
|
|
|
|
"dddd",
|
2022-11-18 12:08:39 +00:00
|
|
|
|
"ddd dd'/'MM",
|
|
|
|
|
|
"dddd dd'/'MM",
|
|
|
|
|
|
"dddd dd', 'MMMM",
|
|
|
|
|
|
"dd', 'MMMM"
|
2022-09-05 06:48:10 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
private int timeFormatIndex = 0;
|
|
|
|
|
|
public int TimeFormatIndex
|
2022-11-19 04:25:46 +00:00
|
|
|
|
{
|
2022-11-19 22:11:13 +00:00
|
|
|
|
get => timeFormatIndex;
|
2022-11-19 04:25:46 +00:00
|
|
|
|
set
|
|
|
|
|
|
{
|
2022-11-19 22:11:13 +00:00
|
|
|
|
if (value != -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
timeFormatIndex = value;
|
|
|
|
|
|
Settings.TimeFormat = TimeFormatList[value];
|
|
|
|
|
|
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
2022-11-19 04:25:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-18 16:47:04 +00:00
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
private int dateFormatIndex = 0;
|
|
|
|
|
|
public int DateFormatIndex
|
2022-11-19 04:25:46 +00:00
|
|
|
|
{
|
2022-11-19 22:11:13 +00:00
|
|
|
|
get => dateFormatIndex;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value != -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
dateFormatIndex = value;
|
|
|
|
|
|
Settings.DateFormat = DateFormatList[value];
|
|
|
|
|
|
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
2022-11-19 04:25:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-11-18 16:47:04 +00:00
|
|
|
|
|
2022-11-19 08:03:44 +00:00
|
|
|
|
public string ClockText { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string DateText { get; private set; }
|
|
|
|
|
|
|
2022-11-19 22:11:13 +00:00
|
|
|
|
public List<string> TimeFormatDisplayList { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
|
|
public List<string> DateFormatDisplayList { get; set; } = null;
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateDateDisplayList()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < DateFormatList.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
DateFormatDisplayList[i] = DateTime.Now.ToString(DateFormatList[i], CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
|
|
|
|
|
// TODO: CurrentCulture may not equal to settings.language
|
|
|
|
|
|
// Cross thread issue?
|
|
|
|
|
|
DateText = DateTime.Now.ToString(Settings.DateFormat, CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateTimeDisplayList()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < TimeFormatList.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeFormatDisplayList[i] = DateTime.Now.ToString(TimeFormatList[i], CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
|
|
|
|
|
// TODO: CurrentCulture may not equal to settings.language
|
|
|
|
|
|
// Cross thread issue?
|
|
|
|
|
|
ClockText = DateTime.Now.ToString(Settings.TimeFormat, CultureInfo.CurrentCulture);
|
|
|
|
|
|
}
|
2022-11-18 16:47:04 +00:00
|
|
|
|
|
2021-10-21 01:07:11 +00:00
|
|
|
|
public double WindowWidthSize
|
|
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
get => Settings.WindowSize;
|
2021-10-22 20:26:13 +00:00
|
|
|
|
set => Settings.WindowSize = value;
|
2021-10-21 01:07:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-07 10:58:54 +00:00
|
|
|
|
public bool UseGlyphIcons
|
|
|
|
|
|
{
|
2021-10-22 04:31:51 +00:00
|
|
|
|
get => Settings.UseGlyphIcons;
|
|
|
|
|
|
set => Settings.UseGlyphIcons = value;
|
2021-10-07 10:58:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-13 22:45:47 +00:00
|
|
|
|
public bool UseAnimation
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.UseAnimation;
|
|
|
|
|
|
set => Settings.UseAnimation = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool UseSound
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.UseSound;
|
|
|
|
|
|
set => Settings.UseSound = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-01 07:19:00 +00:00
|
|
|
|
public bool UseClock
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.UseClock;
|
|
|
|
|
|
set => Settings.UseClock = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool UseDate
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.UseDate;
|
|
|
|
|
|
set => Settings.UseDate = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-07 04:11:46 +00:00
|
|
|
|
public double SettingWindowWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowWidth;
|
|
|
|
|
|
set => Settings.SettingWindowWidth = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double SettingWindowHeight
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowHeight;
|
|
|
|
|
|
set => Settings.SettingWindowHeight = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double SettingWindowTop
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowTop;
|
|
|
|
|
|
set => Settings.SettingWindowTop = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double SettingWindowLeft
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Settings.SettingWindowLeft;
|
|
|
|
|
|
set => Settings.SettingWindowLeft = value;
|
|
|
|
|
|
}
|
2022-09-01 07:19:00 +00:00
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
public Brush PreviewBackground
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var wallpaper = WallpaperPathRetrieval.GetWallpaperPath();
|
|
|
|
|
|
if (wallpaper != null && File.Exists(wallpaper))
|
|
|
|
|
|
{
|
|
|
|
|
|
var memStream = new MemoryStream(File.ReadAllBytes(wallpaper));
|
|
|
|
|
|
var bitmap = new BitmapImage();
|
|
|
|
|
|
bitmap.BeginInit();
|
|
|
|
|
|
bitmap.StreamSource = memStream;
|
2022-11-02 08:34:07 +00:00
|
|
|
|
bitmap.DecodePixelWidth = 800;
|
|
|
|
|
|
bitmap.DecodePixelHeight = 600;
|
2016-05-22 18:14:59 +00:00
|
|
|
|
bitmap.EndInit();
|
2022-03-01 19:29:21 +00:00
|
|
|
|
var brush = new ImageBrush(bitmap)
|
|
|
|
|
|
{
|
|
|
|
|
|
Stretch = Stretch.UniformToFill
|
|
|
|
|
|
};
|
2016-05-22 18:14:59 +00:00
|
|
|
|
return brush;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var wallpaperColor = WallpaperPathRetrieval.GetWallpaperColor();
|
|
|
|
|
|
var brush = new SolidColorBrush(wallpaperColor);
|
|
|
|
|
|
return brush;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ResultsViewModel PreviewResults
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2016-05-22 22:51:17 +00:00
|
|
|
|
var results = new List<Result>
|
2016-05-22 18:14:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
new Result
|
|
|
|
|
|
{
|
2020-08-03 22:29:22 +00:00
|
|
|
|
Title = "Explorer",
|
|
|
|
|
|
SubTitle = "Search for files, folders and file contents",
|
|
|
|
|
|
IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Explorer\Images\explorer.png")
|
2016-05-22 18:14:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
new Result
|
|
|
|
|
|
{
|
2020-08-03 22:29:22 +00:00
|
|
|
|
Title = "WebSearch",
|
|
|
|
|
|
SubTitle = "Search the web with different search engine support",
|
2022-03-01 19:29:21 +00:00
|
|
|
|
IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.WebSearch\Images\web_search.png")
|
2016-05-22 18:14:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
new Result
|
|
|
|
|
|
{
|
2020-08-03 22:29:22 +00:00
|
|
|
|
Title = "Program",
|
|
|
|
|
|
SubTitle = "Launch programs as admin or a different user",
|
2022-03-01 19:29:21 +00:00
|
|
|
|
IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.Program\Images\program.png")
|
2016-05-22 18:14:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
new Result
|
|
|
|
|
|
{
|
2020-08-03 22:29:22 +00:00
|
|
|
|
Title = "ProcessKiller",
|
|
|
|
|
|
SubTitle = "Terminate unwanted processes",
|
2022-03-01 19:29:21 +00:00
|
|
|
|
IcoPath = Path.Combine(Constant.ProgramDirectory, @"Plugins\Flow.Launcher.Plugin.ProcessKiller\Images\app.png")
|
2016-05-22 18:14:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
2020-08-03 22:29:22 +00:00
|
|
|
|
var vm = new ResultsViewModel(Settings);
|
2016-05-22 18:14:59 +00:00
|
|
|
|
vm.AddResults(results, "PREVIEW");
|
|
|
|
|
|
return vm;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FontFamily SelectedQueryBoxFont
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Fonts.SystemFontFamilies.Count(o =>
|
2022-03-01 19:29:21 +00:00
|
|
|
|
o.FamilyNames.Values != null &&
|
|
|
|
|
|
o.FamilyNames.Values.Contains(Settings.QueryBoxFont)) > 0)
|
2016-05-22 18:14:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
var font = new FontFamily(Settings.QueryBoxFont);
|
|
|
|
|
|
return font;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var font = new FontFamily("Segoe UI");
|
|
|
|
|
|
return font;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.QueryBoxFont = value.ToString();
|
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FamilyTypeface SelectedQueryBoxFontFaces
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var typeface = SyntaxSugars.CallOrRescueDefault(
|
|
|
|
|
|
() => SelectedQueryBoxFont.ConvertFromInvariantStringsOrNormal(
|
|
|
|
|
|
Settings.QueryBoxFontStyle,
|
|
|
|
|
|
Settings.QueryBoxFontWeight,
|
|
|
|
|
|
Settings.QueryBoxFontStretch
|
2022-03-01 19:29:21 +00:00
|
|
|
|
));
|
2016-05-22 18:14:59 +00:00
|
|
|
|
return typeface;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.QueryBoxFontStretch = value.Stretch.ToString();
|
|
|
|
|
|
Settings.QueryBoxFontWeight = value.Weight.ToString();
|
|
|
|
|
|
Settings.QueryBoxFontStyle = value.Style.ToString();
|
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FontFamily SelectedResultFont
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Fonts.SystemFontFamilies.Count(o =>
|
2022-03-01 19:29:21 +00:00
|
|
|
|
o.FamilyNames.Values != null &&
|
|
|
|
|
|
o.FamilyNames.Values.Contains(Settings.ResultFont)) > 0)
|
2016-05-22 18:14:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
var font = new FontFamily(Settings.ResultFont);
|
|
|
|
|
|
return font;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var font = new FontFamily("Segoe UI");
|
|
|
|
|
|
return font;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.ResultFont = value.ToString();
|
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
|
|
|
|
|
}
|
2016-05-22 04:51:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-22 18:14:59 +00:00
|
|
|
|
public FamilyTypeface SelectedResultFontFaces
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var typeface = SyntaxSugars.CallOrRescueDefault(
|
2019-03-04 03:00:57 +00:00
|
|
|
|
() => SelectedResultFont.ConvertFromInvariantStringsOrNormal(
|
2016-05-22 18:14:59 +00:00
|
|
|
|
Settings.ResultFontStyle,
|
|
|
|
|
|
Settings.ResultFontWeight,
|
|
|
|
|
|
Settings.ResultFontStretch
|
2022-03-01 19:29:21 +00:00
|
|
|
|
));
|
2016-05-22 18:14:59 +00:00
|
|
|
|
return typeface;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.ResultFontStretch = value.Stretch.ToString();
|
|
|
|
|
|
Settings.ResultFontWeight = value.Weight.ToString();
|
|
|
|
|
|
Settings.ResultFontStyle = value.Style.ToString();
|
|
|
|
|
|
ThemeManager.Instance.ChangeTheme(Settings.Theme);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-22 04:51:00 +00:00
|
|
|
|
|
2021-01-06 07:51:52 +00:00
|
|
|
|
public string ThemeImage => Constant.QueryTextBoxIconImagePath;
|
2020-05-06 11:40:34 +00:00
|
|
|
|
|
2016-05-22 19:50:06 +00:00
|
|
|
|
#endregion
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 19:50:06 +00:00
|
|
|
|
#region hotkey
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 21:49:41 +00:00
|
|
|
|
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2016-05-22 21:49:41 +00:00
|
|
|
|
#endregion
|
2016-05-22 22:51:17 +00:00
|
|
|
|
|
2022-11-06 05:20:30 +00:00
|
|
|
|
#region shortcut
|
|
|
|
|
|
|
2022-11-06 06:52:21 +00:00
|
|
|
|
public CustomShortcutModel? SelectedCustomShortcut { get; set; }
|
|
|
|
|
|
|
2022-11-06 05:20:30 +00:00
|
|
|
|
public void DeleteSelectedCustomShortcut()
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = SelectedCustomShortcut;
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-06 06:52:21 +00:00
|
|
|
|
string deleteWarning = string.Format(
|
|
|
|
|
|
InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"),
|
2022-11-19 22:11:13 +00:00
|
|
|
|
item.Key, item.Value);
|
2022-11-06 06:52:21 +00:00
|
|
|
|
if (MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
|
2022-11-06 05:20:30 +00:00
|
|
|
|
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
|
|
|
|
|
{
|
|
|
|
|
|
Settings.CustomShortcuts.Remove(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool EditSelectedCustomShortcut()
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = SelectedCustomShortcut;
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem"));
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-06 06:52:21 +00:00
|
|
|
|
var shortcutSettingWindow = new CustomShortcutSetting(item.Key, item.Value, this);
|
2022-11-06 05:20:30 +00:00
|
|
|
|
if (shortcutSettingWindow.ShowDialog() == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.Key = shortcutSettingWindow.Key;
|
|
|
|
|
|
item.Value = shortcutSettingWindow.Value;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddCustomShortcut()
|
|
|
|
|
|
{
|
2022-11-06 06:52:21 +00:00
|
|
|
|
var shortcutSettingWindow = new CustomShortcutSetting(this);
|
2022-11-06 05:20:30 +00:00
|
|
|
|
if (shortcutSettingWindow.ShowDialog() == true)
|
|
|
|
|
|
{
|
2022-11-06 06:52:21 +00:00
|
|
|
|
var shortcut = new CustomShortcutModel(shortcutSettingWindow.Key, shortcutSettingWindow.Value);
|
|
|
|
|
|
Settings.CustomShortcuts.Add(shortcut);
|
2022-11-06 05:20:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-06 06:52:21 +00:00
|
|
|
|
public bool ShortcutExists(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Settings.CustomShortcuts.Any(x => x.Key == key) || Settings.BuiltinShortcuts.Any(x => x.Key == key);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-06 05:20:30 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2016-05-22 21:49:41 +00:00
|
|
|
|
#region about
|
2016-05-22 19:50:06 +00:00
|
|
|
|
|
2020-12-20 10:10:55 +00:00
|
|
|
|
public string Website => Constant.Website;
|
2021-06-21 05:39:54 +00:00
|
|
|
|
public string ReleaseNotes => _updater.GitHubRepository + @"/releases/latest";
|
2021-03-29 19:51:42 +00:00
|
|
|
|
public string Documentation => Constant.Documentation;
|
2021-11-24 11:43:17 +00:00
|
|
|
|
public string Docs => Constant.Docs;
|
|
|
|
|
|
public string Github => Constant.GitHub;
|
2022-10-31 05:29:56 +00:00
|
|
|
|
public string Version
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Constant.Version == "1.0.0")
|
|
|
|
|
|
{
|
|
|
|
|
|
return Constant.Dev;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return Constant.Version;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-05-23 21:08:13 +00:00
|
|
|
|
public string ActivatedTimes => string.Format(_translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
2022-11-19 04:25:46 +00:00
|
|
|
|
|
2022-09-27 06:44:00 +00:00
|
|
|
|
public string CheckLogFolder
|
|
|
|
|
|
{
|
2022-11-19 04:25:46 +00:00
|
|
|
|
get
|
2022-09-27 06:44:00 +00:00
|
|
|
|
{
|
2022-10-05 10:11:57 +00:00
|
|
|
|
var dirInfo = new DirectoryInfo(Path.Combine(DataLocation.DataDirectory(), Constant.Logs, Constant.Version));
|
|
|
|
|
|
long size = dirInfo.EnumerateFiles("*", SearchOption.AllDirectories).Sum(file => file.Length);
|
2022-11-19 04:25:46 +00:00
|
|
|
|
|
|
|
|
|
|
return _translater.GetTranslation("clearlogfolder") + " (" + FormatBytes(size) + ")";
|
2022-09-27 06:44:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-05 10:11:57 +00:00
|
|
|
|
internal void ClearLogFolder()
|
|
|
|
|
|
{
|
|
|
|
|
|
var directory = new DirectoryInfo(
|
2022-11-19 22:11:13 +00:00
|
|
|
|
Path.Combine(
|
|
|
|
|
|
DataLocation.DataDirectory(),
|
|
|
|
|
|
Constant.Logs,
|
|
|
|
|
|
Constant.Version));
|
2022-10-05 10:11:57 +00:00
|
|
|
|
|
|
|
|
|
|
directory.EnumerateFiles()
|
2022-11-19 22:11:13 +00:00
|
|
|
|
.ToList()
|
|
|
|
|
|
.ForEach(x => x.Delete());
|
2022-10-05 10:11:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
internal string FormatBytes(long bytes)
|
2022-09-27 06:44:00 +00:00
|
|
|
|
{
|
|
|
|
|
|
const int scale = 1024;
|
2022-11-19 22:11:13 +00:00
|
|
|
|
string[] orders = new string[] { "GB", "MB", "KB", "Bytes" };
|
2022-09-27 06:44:00 +00:00
|
|
|
|
long max = (long)Math.Pow(scale, orders.Length - 1);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string order in orders)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (bytes > max)
|
|
|
|
|
|
return string.Format("{0:##.##} {1}", decimal.Divide(bytes, max), order);
|
|
|
|
|
|
|
|
|
|
|
|
max /= scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
return "0 Bytes";
|
|
|
|
|
|
}
|
2016-05-22 22:51:17 +00:00
|
|
|
|
#endregion
|
2016-05-21 21:44:27 +00:00
|
|
|
|
}
|
2016-11-20 20:01:47 +00:00
|
|
|
|
}
|