public ToolbarControl() { InitializeComponent(); try { LoadThemes(); LoadItemTemplates(); ApplyItemTemplate(Properties.Settings.Default.itemTemplate); ApplyTheme(Properties.Settings.Default.theme); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to load resources."); } (SortByMenu.Items[Properties.Settings.Default.sortBy - 1] as MenuItem).IsChecked = true; searchResultsPopup.searchResultsView.EndOfListReached += OnEndOfListReached; searchResultsPopup.searchResultsView.FilterChanged += OnFilterChanged; searchResultsPopup.Closed += SearchResultsPopup_Closed; try { HotkeyManager.Current.AddOrReplace("FocusSearchBox", Key.S, ModifierKeys.Windows | ModifierKeys.Alt, FocusSearchBox); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Hotkey could not be registered."); } }
public void PreviewInQuickLook() { Task.Run(() => { try { using (var client = new NamedPipeClientStream(".", "QuickLook.App.Pipe." + WindowsIdentity.GetCurrent().User?.Value, PipeDirection.Out)) { client.Connect(1000); using (var writer = new StreamWriter(client)) { writer.WriteLine($"{"QuickLook.App.PipeMessages.Toggle"}|{FullPathAndFileName}"); writer.Flush(); } } } catch (TimeoutException) { ToolbarLogger.GetLogger("EverythingToolbar").Info("Opening QuickLook preview timed out. Is QuickLook running?"); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open preview."); } }); }
private EverythingSearch() { logger = ToolbarLogger.GetLogger("EverythingToolbar"); try { uint major = Everything_GetMajorVersion(); uint minor = Everything_GetMinorVersion(); uint revision = Everything_GetRevision(); if ((major > 1) || ((major == 1) && (minor > 4)) || ((major == 1) && (minor == 4) && (revision >= 1))) { logger.Info("Everything version: {major}.{minor}.{revision}", major, minor, revision); } else { logger.Error("Everything version {major}.{minor}.{revision} is not supported.", major, minor, revision); } } catch (Exception e) { logger.Error(e, "Everything64.dll could not be opened."); } Properties.Settings.Default.PropertyChanged += OnSettingChanged; BindingOperations.EnableCollectionSynchronization(SearchResults, _searchResultsLock); }
public ToolbarControl() { InitializeComponent(); ApplicationResources.Instance.ResourceChanged += (object sender, ResourcesChangedEventArgs e) => { try { Resources.MergedDictionaries.Add(e.NewResource); Properties.Settings.Default.Save(); } catch (Exception ex) { ToolbarLogger.GetLogger("EverythingToolbar").Error(ex, "Failed to apply resources."); } }; ApplicationResources.Instance.LoadDefaults(); SearchResultsPopup.Closed += (object sender, EventArgs e) => { Keyboard.Focus(KeyboardFocusCapture); }; try { HotkeyManager.Current.AddOrReplace("FocusSearchBox", (Key)Properties.Settings.Default.shortcutKey, (ModifierKeys)Properties.Settings.Default.shortcutModifiers, FocusSearchBox); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Hotkey could not be registered."); } }
public ToolbarControl() { InitializeComponent(); try { LoadThemes(); LoadItemTemplates(); ApplyItemTemplate(Properties.Settings.Default.itemTemplate); ApplyTheme(Properties.Settings.Default.theme); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to load resources."); } (SortByMenu.Items[Properties.Settings.Default.sortBy - 1] as MenuItem).IsChecked = true; SearchResultsPopup.SearchResultsView.EndOfListReached += OnEndOfListReached; SearchResultsPopup.Closed += (object sender, EventArgs e) => { Keyboard.Focus(KeyboardFocusCapture); }; try { HotkeyManager.Current.AddOrReplace("FocusSearchBox", (Key)Properties.Settings.Default.shortcutKey, (ModifierKeys)Properties.Settings.Default.shortcutModifiers, FocusSearchBox); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Hotkey could not be registered."); } }
bool ApplyItemTemplate(string templateName) { string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string templatePath = Path.Combine(assemblyFolder, "ItemTemplates", templateName + ".xaml"); if (!File.Exists(templatePath)) { ToolbarLogger.GetLogger("EverythingToolbar").Error("Item template file not found. Defaulting to 'Normal' template."); templatePath = Path.Combine(assemblyFolder, "ItemTemplates", "Normal.xaml"); } try { Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(templatePath) }); return(true); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Applying item template failed."); return(false); } }
private EverythingSearch() { logger = ToolbarLogger.GetLogger("EverythingToolbar"); try { uint major = Everything_GetMajorVersion(); uint minor = Everything_GetMinorVersion(); uint revision = Everything_GetRevision(); if ((major > 1) || ((major == 1) && (minor > 4)) || ((major == 1) && (minor == 4) && (revision >= 1))) { logger.Info("Everything version: {major}.{minor}.{revision}", major, minor, revision); } else if (major == 0 && minor == 0 && revision == 0 && (ErrorCode)Everything_GetLastError() == ErrorCode.EVERYTHING_ERROR_IPC) { ErrorCode errorCode = (ErrorCode)Everything_GetLastError(); HandleError(errorCode); logger.Error("Failed to get Everything version number. Is Everything running?"); } else { logger.Error("Everything version {major}.{minor}.{revision} is not supported.", major, minor, revision); } } catch (Exception e) { logger.Error(e, "Everything64.dll could not be opened."); } Properties.Settings.Default.PropertyChanged += OnSettingChanged; BindingOperations.EnableCollectionSynchronization(SearchResults, _searchResultsLock); }
bool ApplyTheme(string themeName) { string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string themePath = Path.Combine(assemblyFolder, "Themes", themeName + ".xaml"); if (!File.Exists(themePath)) { ToolbarLogger.GetLogger("EverythingToolbar").Error("Theme file not found. Defaulting to 'Medium' theme."); themePath = Path.Combine(assemblyFolder, "Themes", "Medium.xaml"); } try { Resources.MergedDictionaries.Clear(); Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(themePath) }); return(true); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Applying theme failed."); return(false); } }
private void OpenShortcutWindow(object sender, RoutedEventArgs e) { Keyboard.ClearFocus(); ShortcutSelector shortcutSelector = new ShortcutSelector(); if (shortcutSelector.ShowDialog().Value) { try { HotkeyManager.Current.AddOrReplace("FocusSearchBox", shortcutSelector.Key, shortcutSelector.Modifiers, FocusSearchBox); Properties.Settings.Default.shortcutKey = (int)shortcutSelector.Key; Properties.Settings.Default.shortcutModifiers = (int)shortcutSelector.Modifiers; Properties.Settings.Default.Save(); } catch (Exception ex) { ToolbarLogger.GetLogger("EverythingToolbar").Error(ex, "Hotkey could not be registered."); MessageBox.Show("Failed to register hotkey. It might be in use by another application.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public ToolbarControl() { InitializeComponent(); Loaded += OnLoaded; Unloaded += OnUnloaded; ApplicationResources.Instance.ResourceChanged += (object sender, ResourcesChangedEventArgs e) => { try { Resources.MergedDictionaries.Add(e.NewResource); Properties.Settings.Default.Save(); } catch (Exception ex) { ToolbarLogger.GetLogger("EverythingToolbar").Error(ex, "Failed to apply resource."); } }; ApplicationResources.Instance.LoadDefaults(); SearchResultsPopup.Closed += (object sender, EventArgs e) => { Keyboard.Focus(KeyboardFocusCapture); UnfocusRequested?.Invoke(this, new EventArgs()); }; ShortcutManager.Instance.AddOrReplace("FocusSearchBox", (Key)Properties.Settings.Default.shortcutKey, (ModifierKeys)Properties.Settings.Default.shortcutModifiers, FocusSearchBox); }
public void CopyPathToClipboard() { try { Clipboard.SetText(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to copy path."); MessageBox.Show("Failed to copy path.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CopyPathToClipboard() { try { Clipboard.SetText(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to copy path."); MessageBox.Show(Properties.Resources.MessageBoxFailedToCopyPath, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void OpenWith() { try { ShellUtils.OpenWithDialog(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open dialog."); MessageBox.Show(Properties.Resources.MessageBoxFailedToOpenDialog, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void OpenWith() { try { ShellUtils.OpenWithDialog(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open dialog."); MessageBox.Show("Failed to open dialog.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Open() { try { Process.Start(FullPathAndFileName); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open search result."); MessageBox.Show(Properties.Resources.MessageBoxFailedToOpen, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void OpenPath() { try { ShellUtils.OpenPathWithDefaultApp(FullPathAndFileName); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open path."); MessageBox.Show(Properties.Resources.MessageBoxFailedToOpenPath, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void OpenPath() { try { ShellUtils.CreateProcessFromCommandLine("explorer.exe /select,\"" + FullPathAndFileName + "\""); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open path."); MessageBox.Show("Failed to open path.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CopyToClipboard() { try { Clipboard.SetFileDropList(new StringCollection { FullPathAndFileName }); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to copy file."); MessageBox.Show(Properties.Resources.MessageBoxFailedToCopyFile, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void RunAsAdmin() { try { Process.Start(new ProcessStartInfo(FullPathAndFileName) { Verb = "runas", UseShellExecute = true }); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open search result."); MessageBox.Show(Properties.Resources.MessageBoxFailedToOpen, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Open() { try { Process.Start(new ProcessStartInfo(FullPathAndFileName) { UseShellExecute = true, WorkingDirectory = IsFile ? Path : FullPathAndFileName }); EverythingSearch.Instance.IncrementRunCount(FullPathAndFileName); EverythingSearch.Instance.SearchTerm = null; } catch (Exception e) { ToolbarLogger.GetLogger("EverythingToolbar").Error(e, "Failed to open search result."); MessageBox.Show(Properties.Resources.MessageBoxFailedToOpen, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } }
public ToolbarControl() { InitializeComponent(); ApplicationResources.Instance.ResourceChanged += (object sender, ResourcesChangedEventArgs e) => { try { Resources.MergedDictionaries.Add(e.NewResource); Properties.Settings.Default.Save(); } catch (Exception ex) { ToolbarLogger.GetLogger("EverythingToolbar").Error(ex, "Failed to apply resource."); } }; ApplicationResources.Instance.LoadDefaults(); SearchBox.LostKeyboardFocus += (object sender, KeyboardFocusChangedEventArgs e) => { Keyboard.Focus(KeyboardFocusCapture); UnfocusRequested?.Invoke(this, new EventArgs()); }; if (!ShortcutManager.Instance.AddOrReplace("FocusSearchBox", (Key)Properties.Settings.Default.shortcutKey, (ModifierKeys)Properties.Settings.Default.shortcutModifiers, FocusSearchBox)) { ShortcutManager.Instance.SetShortcut(Key.None, ModifierKeys.None); MessageBox.Show(Properties.Resources.MessageBoxFailedToRegisterHotkey, Properties.Resources.MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); } ShortcutManager.Instance.SetFocusCallback(FocusSearchBox); if (Properties.Settings.Default.isReplaceStartMenuSearch) { ShortcutManager.Instance.HookStartMenu(); } }
private EverythingSearch() { logger = ToolbarLogger.GetLogger("EverythingToolbar"); try { uint major = Everything_GetMajorVersion(); uint minor = Everything_GetMinorVersion(); uint revision = Everything_GetRevision(); if ((major > 1) || ((major == 1) && (minor > 4)) || ((major == 1) && (minor == 4) && (revision >= 1))) { logger.Info("Everything version: {major}.{minor}.{revision}", major, minor, revision); } else { logger.Error("Everything version {major}.{minor}.{revision} is not supported.", major, minor, revision); } } catch (Exception e) { logger.Error(e, "Everything64.dll could not be opened."); } }
public Task EnsureEverythingServiceStarted() { return(Task.Run(() => { Process[] processes = Process.GetProcessesByName("Everything"); if (processes.Length == 0) { if (!File.Exists(Properties.Settings.Default.everythingPath) && !EverythingSearch.SelectEverythingBinaries()) { ToolbarLogger.GetLogger("EverythingToolbar").Warn("Everything binaries could not be located. OpenFileDialog canceled."); } else { try { Process.Start(Properties.Settings.Default.everythingPath, "-startup -first-instance"); } catch (Exception ex) { ToolbarLogger.GetLogger("EverythingToolbar").Error(ex); } } } })); }
public Favorites() { logger = ToolbarLogger.GetLogger("EverythingToolbar"); }
public void Destroy() { ToolbarLogger.GetLogger("EverythingToolbar").Error("ToolbarControl killing popup: " + SearchResultsPopup.GetHashCode().ToString()); Content = null; }