using System; using JD.Application.Program; using JD.Core.ProjectManaging; using JD.Interfaces.Remoting; using JD.Remoting; namespace JD.Application.Plugin { /// /// Base class for plugins. /// public class BasePlugin : Remoting.Plugin { public BasePlugin(string name, IConnection connection = null) : base(name, connection) { AllowConnectionToIncompatibleTarget = false; DispatchOnMainThread = action => TeaBox.ObjectModel.Application.Main.Dispatcher.DispatchAsync(action); //ReportQueryTimeout = () => MessageService.ShowBalloon(TimeSpan.FromSeconds(10), "No engine response", "Timeout to join the engine expired.", ToolTipIcon.Warning); ConnectedToIncompatibleTarget += OnConnectedToIncompatibleTarget; } /// /// Asks the engine for the currently playing wave. /// public void SendGetWave() { this.Send(CommandNames.GetTrack); } void OnConnectedToIncompatibleTarget(object sender, System.ComponentModel.CancelEventArgs e) { Stop(); TeaBox.ObjectModel.Application.Main.Dispatcher.DispatchAsync(() => { MessageService.MessageService.ShowError( $"{ProgramIdentity.Instance.Name} ({ProjectManager.Instance.GetCurrentProjectId()}) is not compatible with engine ({ProjectId}).", "Tool incompatibility" ); }, true); } } }