Skip to content

Add some extra cleanup #36

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions SamplePlugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ public Plugin(
HelpMessage = "A useful message to display in /xlhelp"
});

PluginInterface.UiBuilder.Draw += DrawUI;
// Tell the UI system that we want our windows to be drawn throught he window system
PluginInterface.UiBuilder.Draw += WindowSystem.Draw;

// This adds a button to the plugin installer entry of this plugin which allows
// to toggle the display status of the configuration ui
PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUI;
PluginInterface.UiBuilder.OpenConfigUi += ConfigWindow.Toggle;

// Adds another button that is doing the same but for the main ui of the plugin
PluginInterface.UiBuilder.OpenMainUi += ToggleMainUI;
}

public void Dispose()
{
// Unregister all actions to not leak anythign during disposal of plugin
PluginInterface.UiBuilder.Draw -= WindowSystem.Draw;
PluginInterface.UiBuilder.OpenConfigUi -= ConfigWindow.Toggle;
PluginInterface.UiBuilder.OpenMainUi -= ToggleMainUI;

WindowSystem.RemoveAllWindows();

ConfigWindow.Dispose();
Expand All @@ -74,8 +80,5 @@ private void OnCommand(string command, string args)
ToggleMainUI();
}

private void DrawUI() => WindowSystem.Draw();

public void ToggleConfigUI() => ConfigWindow.Toggle();
public void ToggleMainUI() => MainWindow.Toggle();
}