Esempio n. 1
0
        public NotificationSoundViewModel(ChooseSoundViewModel parent, NotificationSound notificationSound, bool selected)
        {
            _parent = parent;

            _notificationSound = notificationSound;
            _isSelected        = selected;
        }
Esempio n. 2
0
        public void PlayNotification(NotificationSound notificationSound)
        {
            SystemSE sound;

            switch (notificationSound)
            {
            case NotificationSound.Success:
#if KKS
                sound = SystemSE.ok_l;
#else
                sound = SystemSE.result_single;
#endif
                break;

            case NotificationSound.Error:
                sound = SystemSE.cancel;
                break;

            default:
                sound = SystemSE.result_end;
                break;
            }

            Utils.Sound.Play(sound);
        }
Esempio n. 3
0
        public void PlaySound(NotificationSound sound, bool forceCustom = false)
        {
            try
            {
                var focused = false;

                App.MainForm.Invoke(() => focused = App.MainForm.ContainsFocus);

                if (!focused)
                {
                    SoundPlayer player = null;

                    if (forceCustom || AppSettings.ChatCustomHighlightSound)
                    {
                        try
                        {
                            var fileInfo = new FileInfo(Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav"));
                            if (fileInfo.Exists)
                            {
                                if (fileInfo.LastWriteTime != highlightTimeStamp)
                                {
                                    HighlightSound?.Dispose();

                                    try
                                    {
                                        using (var stream = new FileStream(Path.Combine(Util.GetUserDataPath(), "Custom", "Ping.wav"), FileMode.Open))
                                        {
                                            HighlightSound = new SoundPlayer(stream);
                                            HighlightSound.Load();
                                        }

                                        player = HighlightSound;
                                        Console.WriteLine("loaded");
                                    }
                                    catch
                                    {
                                        HighlightSound.Dispose();
                                    }
                                }
                            }
                            else
                            {
                                player = HighlightSound;
                            }
                        }
                        catch { }
                    }

                    if (player == null)
                    {
                        player = defaultHighlightSound;
                    }

                    player.Play();
                }
            }
            catch { }
        }
Esempio n. 4
0
        public static void PlaySound(NotificationSound sound)
        {
            IWavePlayer waveOutDevice;
            AudioFileReader audioFileReader;
            waveOutDevice = new WaveOut();

            audioFileReader = new AudioFileReader("resources/sounds/message.mp3");
            waveOutDevice.Init(audioFileReader);
            waveOutDevice.Play();
        }
Esempio n. 5
0
        // play a notification sound every NOTIFYTIME seconds until signalled
        void IntervalNotify()
        {
            while (!NotifyBlocker.WaitOne(NOTIFYTIME))  // while not signalled
            {
                NotificationSound.Play();
            }

            // reset signal for next notifyblock
            NotifyBlocker.Reset();
        }
Esempio n. 6
0
        /// <summary>
        ///     Plays the notification sound.
        /// </summary>
        /// <param name="notificationSound">The notification sound to play </param>
        /// <param name="guid">The plugin GUID. If provided will check the per-plugin config if sounds are enabled.</param>
        public void PlayNotificationSound(NotificationSound notificationSound, string guid = null)
        {
            if (!string.IsNullOrEmpty(guid))
            {
                if (NotificationSoundsEnabled.TryGetValue(guid, out var soundEnabled) && !soundEnabled)
                {
                    return;
                }
            }

            PlayNotification(notificationSound);
        }
Esempio n. 7
0
        NotificationSound GetSound()
        {
            switch (this.SelectedSoundType)
            {
            case "Default": return(NotificationSound.Default);

            //case "Priority" : return NotificationSound.Default;
            case "Custom": return(NotificationSound.FromCustom("notification.mp3"));

            default: return(NotificationSound.None);
            }
        }
Esempio n. 8
0
        private void ClientSocket_OnMessagereceived(SocketMessage e)
        {
            string dataString = e.GetValue("DataType") == null ? "" : e.GetValue("DataType").ToString();

            Reply.ContentType dataType = (Reply.ContentType)Enum.Parse(typeof(Reply.ContentType), dataString);

            string[] urls = null;

            if (e.Data.ContainsKey("Links"))
            {
                urls = JsonConvert.DeserializeObject <string[]>(JsonConvert.SerializeObject(e.Data["Links"]));
            }

            MessageBlock block;

            if (dataType == Reply.ContentType.Picture && urls != null)
            {
                block = new MessageBlock(urls, e.GetValue("Message").ToString());
            }
            else
            {
                block = new MessageBlock();
            }

            string timeStamp = e.GetValue("TimeStamp").ToString();

            timeStamp = DateTime.Parse(timeStamp).ToString("h:mm tt");

            block.Message     = e.GetValue("Message").ToString();
            block.Sender      = e.GetValue("Sender").ToString();
            block.Date        = timeStamp;
            block.MaximumSize = new Size(((InnerChatContainer.Width - 20) / 2) - 20, int.MaxValue);

            Invoke(new MethodInvoker(() =>
            {
                block.FormatSize();

                InnerChatContainer.Controls.Add(block);

                SelectedChat.LastMessage = e.GetValue("Message").ToString();
                SelectedChat.TimeStamp   = timeStamp;
            }));

            if ((DateTime.Now - lastNotification).TotalSeconds > 5 && block.Sender != CurrentUser.UserName && !Activated)
            {
                lastNotification = DateTime.Now;
                NotificationSound.Play();
            }

            ResizeChat();
        }
Esempio n. 9
0
        public void PlayNotification(NotificationSound notificationSound)
        {
            SoundPack.SystemSE sound;
            switch (notificationSound)
            {
            case NotificationSound.Success:
                sound = SoundPack.SystemSE.OK_L;
                break;

            case NotificationSound.Error:
                sound = SoundPack.SystemSE.Error;
                break;

            default:
                sound = SoundPack.SystemSE.Cancel;
                break;
            }

            Singleton <Resources> .Instance.SoundPack.Play(sound);
        }
Esempio n. 10
0
        public void PlayNotification(NotificationSound notificationSound)
        {
            SystemSE sound;

            switch (notificationSound)
            {
            case NotificationSound.Success:
                sound = SystemSE.ok_l;
                break;

            case NotificationSound.Error:
                sound = SystemSE.cancel;
                break;

            default:
                sound = SystemSE.ok_s;
                break;
            }

            Utils.Sound.Play(sound);
        }
Esempio n. 11
0
 private void SetNotificationSound(NotificationSound value)
 {
     Windows.Storage.ApplicationData.Current.LocalSettings.Values[NOTIFICATION_SOUND_STORAGE] = (int)value;
 }
Esempio n. 12
0
 private static void PlayNotificationSound(NotificationSound notificationSound)
 {
     GeBoAPI.Instance.PlayNotificationSound(notificationSound, GUID);
 }
Esempio n. 13
0
 private void SetNotificationSound(NotificationSound value)
 {
     Windows.Storage.ApplicationData.Current.LocalSettings.Values[NOTIFICATION_SOUND_STORAGE] = (int)value;
 }
        void ShowCore(string rpTitle, string rpBody, NotificationSound rpSound, string rpCustomSoundFilename, string rpSecondLine = null)
        {
            var rBody = rpBody;
            if (rpSecondLine != null)
                rBody = $"{rBody}{Environment.NewLine}{rpSecondLine}";

            r_NotifyIcon.ShowBalloonTip(1000, rpTitle, rBody, ToolTipIcon.None);

            if (rpSound == NotificationSound.SystemSound)
                NativeMethods.WinMM.PlaySoundW("SystemNotification", IntPtr.Zero, NativeEnums.SND.SND_ALIAS | NativeEnums.SND.SND_ASYNC);

            if (rpSound == NotificationSound.Custom)
                DispatcherUtil.UIDispatcher.BeginInvoke(new Action<string>(PlayCustomSound), rpCustomSoundFilename);
        }
Esempio n. 15
0
 public Notification()
 {
     icon  = new NotificationIcon();
     sound = new NotificationSound();
 }
 public PlayNotificationMessage(NotificationSound sound)
 {
     NotificationSound = sound;
 }
Esempio n. 17
0
 public FluentNotificationBuilder AddSound(NotificationSound sound)
 {
     notification.sound = sound;
     return(this);
 }
Esempio n. 18
0
        void Timer()
        {
            string   periodLabel = "";
            int      periodTime = 0;
            bool     isWorkPeriod = true, wasPaused = false, wasRestarted = false;
            DateTime currentTime, periodEndTime;

            while (Command != QUIT)
            {
                currentTime = DateTime.Now;

                if (wasPaused)
                {
                    // do not reset label or time, use saved periodTime
                    wasPaused     = false;
                    periodEndTime = currentTime.AddMilliseconds(periodTime);

                    Console.WriteLine("[{0}] Resumed: {1} | End: {2} ({3})", periodLabel,
                                      currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"),
                                      (periodEndTime - currentTime).ToString(@"mm\:ss"));
                }
                else if (wasRestarted)
                {
                    // do not reset label or time, use existing or modified periodTime
                    wasRestarted  = false;
                    periodEndTime = currentTime.AddMilliseconds(periodTime);

                    Console.WriteLine("[{0}] Restarted: {1} | End: {2} ({3})", periodLabel,
                                      currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"),
                                      (periodEndTime - currentTime).ToString(@"mm\:ss"));
                }
                else // normal flow
                {
                    if (isWorkPeriod)
                    {
                        periodLabel = "WORK";
                        periodTime  = WORKTIME;
                    }
                    else
                    {
                        periodLabel = "REST";
                        periodTime  = RESTTIME;
                    }
                    periodEndTime = currentTime.AddMilliseconds(periodTime);

                    Console.WriteLine("[{0}] Start: {1} | End: {2} ({3})", periodLabel,
                                      currentTime.ToString("h:mm:ss tt"), periodEndTime.ToString("h:mm:ss tt"),
                                      (periodEndTime - currentTime).ToString(@"mm\:ss"));
                }

                // block thread for periodTime
                if (TimerBlocker.WaitOne(periodTime))   // if signalled
                {
                    // manually signalled, reset signal for next timerblock
                    TimerBlocker.Reset();

                    // handle commands
                    if (Command == PAUSE)
                    {
                        TimeSpan remainingPeriod = periodEndTime - DateTime.Now;
                        periodTime = (int)remainingPeriod.TotalMilliseconds;

                        Console.Write("Period paused, press enter to resume ");
                        WaitForReadLineInput();

                        wasPaused = true;
                    }
                    else if (Command == NEXT)
                    {
                        isWorkPeriod = !isWorkPeriod;
                    }
                    else if (Command.Contains(RESTART))
                    {
                        wasRestarted = true;

                        // checking if "MM:SS" setting option present
                        MatchCollection numsInCommand = new Regex(@"\d+").Matches(Command);
                        if (numsInCommand.Count >= 2)
                        {
                            int minsTemp = Int32.Parse(numsInCommand[0].Value);
                            int secsTemp = Int32.Parse(numsInCommand[1].Value);

                            // converting to milliseconds
                            minsTemp *= 60000;
                            secsTemp *= 1000;

                            periodTime = minsTemp + secsTemp;
                        }
                        else
                        {
                            // else restart with normal period time
                            periodTime = isWorkPeriod ? WORKTIME : RESTTIME;
                        }
                    }
                    // else Command == "quit" -> do nothing, while condition will handle it
                }
                else // if not signalled (timeout)
                {
                    isWorkPeriod = !isWorkPeriod;
                    PeriodEndSound.Play();

                    Thread notifyThread = new Thread(IntervalNotify);
                    notifyThread.Start();

                    Console.WriteLine("Period end, press Insert to resume");

                    // blocks until Insert is pressed
                    InterceptKeys.Start(KeyPressCallback);

                    // end notifyThread
                    NotifyBlocker.Set();

                    // play a confirmation
                    NotificationSound.Play();
                }
            }
        }
Esempio n. 19
0
 public void PlaySound(NotificationSound sound, bool forceCustom = false)
 {
 }
Esempio n. 20
0
 public void PlaySound(NotificationSound sound, bool forceCustom = false)
 {
     throw new NotImplementedException();
 }
Esempio n. 21
0
 public void PlaySound(NotificationSound sound)
 {
     //throw new NotImplementedException();
 }
 public PlayNotificationMessage(NotificationSound sound)
 {
     NotificationSound = sound;
 }
 public void Notify(NotificationSound type)
 {
 }