예제 #1
0
 public void Enable()
 {
     if (this.Enabled)
     {
         return;
     }
     try
     {
         ToastNotificationHelper.Install();
         ToastNotificationHelper.Invoke(new Action(
                                            () =>
         {
             if (Publication.IsPortable)
             {
                 this.ToastNotifier = ToastNotificationManager.CreateToastNotifier(ToastNotificationHelper.ID);
             }
             else
             {
                 this.ToastNotifier = ToastNotificationManager.CreateToastNotifier();
             }
         }
                                            ), null);
         this.PlaybackManager.CurrentStreamChanged += this.OnCurrentStreamChanged;
     }
     catch (Exception e)
     {
         Logger.Write(this, LogLevel.Warn, "Failed to enable: {0}", e.Message);
     }
 }
예제 #2
0
        protected virtual void ShowNotification()
        {
            var outputStream = this.PlaybackManager.CurrentStream;

            if (outputStream == null)
            {
                return;
            }
            try
            {
                var notification = this.CreateNotification(outputStream);
                ToastNotificationHelper.Invoke(new Action(() => this.ToastNotifier.Show(notification)), null);
            }
            catch (Exception e)
            {
                Logger.Write(this, LogLevel.Warn, "Failed to show notification: {0}", e.Message);
            }
        }
예제 #3
0
 public override void InitializeComponent(ICore core)
 {
     if (ToastNotificationManagerBehaviourConfiguration.IsPlatformSupported)
     {
         this.PlaylistManager = core.Managers.Playlist;
         this.PlaybackManager = core.Managers.Playback;
         this.ArtworkProvider = core.Components.ArtworkProvider;
         this.Configuration   = core.Components.Configuration;
         this.Configuration.GetElement <BooleanConfigurationElement>(
             ToastNotificationManagerBehaviourConfiguration.SECTION,
             ToastNotificationManagerBehaviourConfiguration.ENABLED_ELEMENT
             ).ConnectValue(value =>
         {
             if (value)
             {
                 this.Enable();
             }
             else
             {
                 this.Disable();
                 ToastNotificationHelper.Uninstall(false);
             }
         });
         this.Configuration.GetElement <BooleanConfigurationElement>(
             ToastNotificationManagerBehaviourConfiguration.SECTION,
             ToastNotificationManagerBehaviourConfiguration.POPUP_ELEMENT
             ).ConnectValue(value => this.Popup = value);
         this.Configuration.GetElement <BooleanConfigurationElement>(
             ToastNotificationManagerBehaviourConfiguration.SECTION,
             ToastNotificationManagerBehaviourConfiguration.LARGE_ARTWORK_ELEMENT
             ).ConnectValue(value => this.LargeArtwork = value);
     }
     else
     {
         Logger.Write(this, LogLevel.Warn, "Platform is not supported.");
     }
     base.InitializeComponent(core);
 }