Skip to content

Commit

Permalink
Update all hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
k3ldar committed Jan 11, 2024
1 parent 9f56b8f commit 46086bf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/GCSDesktop/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public partial class FormMain : BaseForm, IPluginHost, IOnlineStatusUpdate
private IMachine _selectedMachine = null;
private readonly IPluginHelper _pluginHelper;
private long _machineHashCombined = 0;
private readonly List<IPluginMessages> _pluginItemsWithClientMessages = [];

public FormMain(IGSendContext context, IGSendApiWrapper machineApiWrapper,
ICommandProcessor processCommand, GSendSettings settings)
Expand Down Expand Up @@ -131,6 +132,9 @@ private void ClientWebSocket_ProcessMessage(string message)
}

UpdateEnabledState();

// notify plugin items interested in messages
_pluginItemsWithClientMessages.ForEach(pcm => pcm.ClientMessageReceived(clientMessage));
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Major Code Smell", "S125:Sections of code should not be commented out", Justification = "Left in for now")]
Expand Down Expand Up @@ -576,7 +580,10 @@ public void UpdateOnlineStatus(bool isOnline, string server)

public void AddPlugin(IGSendPluginModule pluginModule)
{
// nothing special to do for this host
ArgumentNullException.ThrowIfNull(pluginModule);

if (pluginModule.ReceiveClientMessages)
_pluginItemsWithClientMessages.Add(pluginModule);
}

public IPluginMenu GetMenu(MenuParent menuParent)
Expand All @@ -600,17 +607,23 @@ public void AddMenu(IPluginMenu pluginMenu)
{
pluginMenu.UpdateHost(this as IPluginHost);
_pluginHelper.AddMenu(this, menuStripMain, pluginMenu, null);

if (pluginMenu.ReceiveClientMessages)
_pluginItemsWithClientMessages.Add(pluginMenu);
}

public void AddToolbar(IPluginToolbarButton toolbarButton)
{
toolbarButton.UpdateHost(this as IEditorPluginHost);
_pluginHelper.AddToolbarButton(this, toolStripMain, toolbarButton);

if (toolbarButton.ReceiveClientMessages)
_pluginItemsWithClientMessages.Add(toolbarButton);
}

public void AddControl(IPluginControl pluginControl)
{
// nothing to do here yet!
// nothing to do for this host!
}

public void AddMessage(InformationType informationType, string message)
Expand Down
7 changes: 6 additions & 1 deletion src/GSendEditor/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,12 @@ public void AddToolbar(IPluginToolbarButton toolbarButton)

public void AddControl(IPluginControl pluginControl)
{
// nothing to do here yet!
TabPage controlTabPage = new();
tabControlMain.TabPages.Add(controlTabPage);
controlTabPage.Controls.Add(pluginControl.Control);
pluginControl.Control.UpdatePosition(controlTabPage);

controlTabPage.Text = pluginControl.Name;
}

public void AddMessage(InformationType informationType, string message)
Expand Down

0 comments on commit 46086bf

Please sign in to comment.