Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feature/custom tab controls #58

Merged
merged 6 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update all hosts
  • Loading branch information
k3ldar committed Jan 11, 2024
commit 46086bf352a9baf31a4305bfc2357d732290d03f
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
Loading