Skip to content

Commit

Permalink
Fix windows startup
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Dec 29, 2024
1 parent d240f31 commit 9c9d0ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
2 changes: 2 additions & 0 deletions src/PoeLurker.Core/KeyboardLurker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_keyboardHook.RemoveAllHandlers();
_keyboardHook.Uninstall();
_keyboardHook.Dispose();
}

Expand Down
2 changes: 2 additions & 0 deletions src/PoeLurker.Core/MouseLurker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ protected virtual void Dispose(bool disposing)
try
{
_mouseHook.LeftButtonUp -= MouseHook_LeftButtonUp;
_mouseHook.RemoveAllHandlers();
_mouseHook.Uninstall();
_mouseHook.Dispose();
}
catch
Expand Down
55 changes: 30 additions & 25 deletions src/PoeLurker.UI/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,21 @@ public void OnTrayOpen()

_eventAggregator.PublishOnUIThreadAsync(message);
}

/// <summary>
/// Gets the assembly version.
/// </summary>
/// <returns>The assembly version.</returns>
private static string GetAssemblyVersion()
public void DisposeHooks()
{
var assembly = Assembly.GetExecutingAssembly();
var information = FileVersionInfo.GetVersionInfo(assembly.Location);
var version = information.FileVersion.Remove(information.FileVersion.Length - 2);
return version;
if (_mouseLurker != null)
{
_mouseLurker.ItemDetails -= ShowItemDetails;
_mouseLurker.ItemIdentified -= ItemIdentified;
_mouseLurker.Dispose();
_mouseLurker = null;
}

if (_keyboardLurker != null)
{
_keyboardLurker.BuildToggled -= KeyboardLurker_BuildToggled;
_keyboardLurker.Dispose();
}
}

/// <summary>
Expand All @@ -339,7 +343,7 @@ public async void Update()
};

await _eventAggregator.PublishOnUIThreadAsync(message);
//CleanUp();
DisposeHooks();

ShowInTaskBar = false;
var updateManager = IoC.Get<PoeLurkerUpdateManager>();
Expand Down Expand Up @@ -383,11 +387,23 @@ private void CreateLink()
{
var link = (IShellLink)new ShellLink();
link.SetDescription("PoeLurker");
link.SetPath(System.Reflection.Assembly.GetExecutingAssembly().Location);
link.SetPath(Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, ".exe"));
var file = (IPersistFile)link;
file.Save(ShortcutFilePath, false);
}

/// <summary>
/// Gets the assembly version.
/// </summary>
/// <returns>The assembly version.</returns>
private static string GetAssemblyVersion()
{
var assembly = Assembly.GetExecutingAssembly();
var information = FileVersionInfo.GetVersionInfo(assembly.Location);

return information.FileVersion.Remove(information.FileVersion.Length - 2); ;
}

/// <summary>
/// Handles the OnSave event of the SettingsService control.
/// </summary>
Expand Down Expand Up @@ -625,19 +641,8 @@ private void CleanUp()
_afkService = null;
}

if (_mouseLurker != null)
{
_mouseLurker.ItemDetails -= ShowItemDetails;
_mouseLurker.ItemIdentified -= ItemIdentified;
_mouseLurker.Dispose();
_mouseLurker = null;
}

if (_keyboardLurker != null)
{
_keyboardLurker.BuildToggled -= KeyboardLurker_BuildToggled;
_keyboardLurker.Dispose();
}
DisposeHooks();

if (_stashTabGrid != null)
{
Expand All @@ -648,7 +653,7 @@ private void CleanUp()
{
_incomingTradeBarOverlay.Dispose();
}
}
}

/// <summary>
/// Waits for poe.
Expand Down

0 comments on commit 9c9d0ce

Please sign in to comment.