Ejemplo n.º 1
0
        /// <summary>
        /// Called internally to configure pass notification parameters
        /// </summary>
        /// <param name="data">The configuration data to setup the notification UI</param>
        internal void SetData(BannerData data)
        {
            if (this.timerHide == null)
            {
                this.timerHide          = new Timer();
                this.timerHide.Interval = 3000;
                this.timerHide.Tick    += TimerHide_Tick;
            }
            else
            {
                this.timerHide.Enabled = false;
            }

            if (data.Image != null)
            {
                this.pbxLogo.Image = data.Image;
            }

            DestroySound();

            if (data.SoundFile != null)
            {
                PrepareSound(data);
            }

            this.hiding            = false;
            this.Opacity           = .8;
            this.lblTop.Text       = data.Title;
            this.lblTitle.Text     = data.Text;
            this.timerHide.Enabled = true;

            this.Show();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called internally to configure pass notification parameters
        /// </summary>
        /// <param name="data">The configuration data to setup the notification UI</param>
        internal void SetData(BannerData data)
        {
            if (this.timerHide == null)
            {
                this.timerHide          = new Timer();
                this.timerHide.Interval = 3000;
                this.timerHide.Tick    += TimerHide_Tick;
            }
            else
            {
                this.timerHide.Enabled = false;
            }

            if (data.Image != null)
            {
                this.pbxLogo.Image = data.Image;
            }

            DestroySound();

            if (!string.IsNullOrEmpty(data.SoundFilePath))
            {
                this.player          = new System.Media.SoundPlayer();
                player.SoundLocation = data.SoundFilePath;
                player.Play();
            }

            this.hiding            = false;
            this.Opacity           = .8;
            this.lblTop.Text       = data.Title;
            this.lblTitle.Text     = data.Text;
            this.timerHide.Enabled = true;

            this.Show();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Show a banner notification with the given data
 /// </summary>
 /// <param name="data"></param>
 public void ShowNotification(BannerData data)
 {
     // Execute the banner in the context of the UI thread
     syncContext.Post((d) =>
     {
         if (banner == null)
         {
             banner           = new BannerForm();
             banner.Disposed += (s, e) => banner = null;
         }
         banner.SetData(data);
     }, null);
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        private void PrepareSound(BannerData data)
        {
            _player = new WasapiOut();
            var task = new Task(() =>
            {
                using var waveStream = new CachedSoundWaveStream(data.SoundFile);
                _player.Init(waveStream);
                _player.Play();
                while (_player.PlaybackState == PlaybackState.Playing)
                {
                    Thread.Sleep(500);
                }
            });

            task.Start();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called internally to configure pass notification parameters
        /// </summary>
        /// <param name="data">The configuration data to setup the notification UI</param>
        internal void SetData(BannerData data)
        {
            if (_currentData != null && _currentData.Priority > data.Priority)
            {
                return;
            }

            _currentData = data;
            if (_timerHide == null)
            {
                _timerHide = new Timer {
                    Interval = 3000
                };
                _timerHide.Tick += TimerHide_Tick;
            }
            else
            {
                _timerHide.Enabled = false;
            }

            if (data.Image != null)
            {
                pbxLogo.Image = data.Image;
            }

            DestroySound();

            if (data.SoundFile != null)
            {
                PrepareSound(data);
            }

            _hiding            = false;
            Opacity            = .8;
            lblTop.Text        = data.Title;
            lblTitle.Text      = data.Text;
            _timerHide.Enabled = true;

            Show();
        }