public void SetPlayer(FrameworkElement Player)
        {
            player = Player as IPlayer;

            var adapter = new MastAdapter(player);
            Mainsail = new Mainsail(adapter);
            Mainsail.ActivateTrigger += new EventHandler<TriggerEventArgs>(Mainsail_ActivateTrigger);
            Mainsail.DeactivateTrigger += new EventHandler<TriggerEventArgs>(Mainsail_DeactivateTrigger);
            Mainsail.TriggerEvaluationFailed += new EventHandler<TriggerFailureEventArgs>(Mainsail_TriggerEvaluationFailed);
        }
 /// <summary>
 /// Unloads the plug-in.
 /// </summary>
 public virtual void Unload()
 {
     try
     {
         Mainsail.ActivateTrigger -= new EventHandler<TriggerEventArgs>(Mainsail_ActivateTrigger);
         Mainsail.DeactivateTrigger -= new EventHandler<TriggerEventArgs>(Mainsail_DeactivateTrigger);
         Mainsail.TriggerEvaluationFailed -= new EventHandler<TriggerFailureEventArgs>(Mainsail_TriggerEvaluationFailed);
         Mainsail.Dispose();
         if (Mainsail.MastInterface is IDisposable) ((IDisposable)Mainsail.MastInterface).Dispose();
         Mainsail = null;
         Source = null;
         StopRetrievingMarkers();
         player = null;
         IsLoaded = false;
         PluginUnloaded.IfNotNull(i => i(this));
         SendLogEntry(LogEntryTypes.Unloaded, message: MastMarkerProviderResources.MastMarkerProviderUnloadedLogMessage);
     }
     catch (Exception ex)
     {
         PluginUnloadFailed.IfNotNull(i => i(this, ex));
     }
 }