Skip to content

Commit

Permalink
Fix duplicate instances on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
srwi committed Dec 19, 2020
1 parent 928ca57 commit 14e0bfa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
15 changes: 11 additions & 4 deletions EverythingToolbar/Deskband.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using EverythingToolbar;
using NHotkey;
using NLog;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;

namespace CSDeskBand
{
Expand All @@ -15,10 +12,13 @@ namespace CSDeskBand
[CSDeskBandRegistration(Name = "Everything Toolbar")]
public class Deskband : CSDeskBandWpf
{
protected override UIElement UIElement => new ToolbarControl();
private static ToolbarControl toolbarControl;
protected override UIElement UIElement => toolbarControl;

public Deskband()
{
toolbarControl = new ToolbarControl();

Options.MinHorizontalSize = new Size(18, 30);
Options.MinVerticalSize = new Size(30, 40);
TaskbarInfo.TaskbarEdgeChanged += OnTaskbarEdgeChanged;
Expand All @@ -36,5 +36,12 @@ private void OnTaskbarEdgeChanged(object sender, TaskbarEdgeChangedEventArgs e)
{
SearchResultsPopup.taskbarEdge = e.Edge;
}

protected override void DeskbandOnClosed()
{
base.DeskbandOnClosed();
toolbarControl.Destroy();
toolbarControl = null;
}
}
}
5 changes: 0 additions & 5 deletions EverythingToolbar/Helpers/ShellUtils.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace EverythingToolbar.Helpers
{
Expand Down
3 changes: 0 additions & 3 deletions EverythingToolbar/Helpers/ShortcutManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
using NHotkey.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace EverythingToolbar.Helpers
Expand Down
3 changes: 1 addition & 2 deletions EverythingToolbar/SearchBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

Expand Down
7 changes: 7 additions & 0 deletions EverythingToolbar/ToolbarControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ public ToolbarControl()
(Key)Properties.Settings.Default.shortcutKey,
(ModifierKeys)Properties.Settings.Default.shortcutModifiers,
FocusSearchBox);

}

public void Destroy()
{
ToolbarLogger.GetLogger("EverythingToolbar").Error("ToolbarControl killing popup: " + SearchResultsPopup.GetHashCode().ToString());
Content = null;
}

private void OnKeyPressed(object sender, KeyEventArgs e)
Expand Down

0 comments on commit 14e0bfa

Please sign in to comment.