lepoco / lepoco/wpfui

Improvements to WPF-UI.Tray NotifyIconService Functionality

Open
#1,668 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
9.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe

The NotifyIconService allows activating a NotifyIcon independently without requiring a XAML file.
Currently, the method used to automate the disposal of InternalNotifyIconManager is to register a parent window so that InternalNotifyIconManager is disposed when the window’s Closing event occurs.
However, users often rely on the Window.Closing event to determine whether the window should actually be closed, and they may decide to either proceed or cancel the operation.
Therefore, if NotifyIconService intends to dispose InternalNotifyIconManager through the parent window, it seems more appropriate to use the Closed event rather than Closing.

Describe the solution you'd like

Wpf.Ui.Tray(4.2.0.0)
Wpf.Ui.Tray.NotifyIconService

AS-IS

public void SetParentWindow(Window parentWindow)
{
    if (ParentWindow is not null)
    {
        ParentWindow.Closing -= OnParentWindowClosing;
    }

    ParentWindow = parentWindow;
    ParentWindow.Closing += OnParentWindowClosing;
}
private void OnParentWindowClosing(object? sender, CancelEventArgs e)
{
    internalNotifyIconManager.Dispose();
}

TO-BE

public void SetParentWindow(Window parentWindow)
{
    if (ParentWindow is not null)
    {
        ParentWindow.Closed -= OnParentWindowClosed;
    }

    ParentWindow = parentWindow;
    ParentWindow.Closed += OnParentWindowClosed;
}
private void OnParentWindowClosed(object? sender, EventArgs e)
{
    internalNotifyIconManager.Dispose();
}
Describe alternatives you've considered

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Wpf.Ui.Tray NotifyIconService implementation and inspect SetParentWindow and its parent-window event handler. Change the disposal trigger to the parent window's Closed event, then verify that disposal occurs after the window closes rather than when closing is cancelled.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.