Ejemplo n.º 1
0
        protected override async Task InitializeViewModelAsync(Alarm dataSource)
        {
            AlarmName = dataSource.Name;
            MapScreen = await _screenshotManager.OpenScreenFromPathAsync(dataSource.MapScreenPath)
                        .ConfigureAwait(true);

            SelectedNotificationSound = SystemSounds.TrimPrefix(dataSource.AlarmSound);
            SelectedDays = ParseActiveDays(dataSource.ActiveDays);
        }
Ejemplo n.º 2
0
        public static void PlaySystemSound(SystemSounds systemSounds, int volumePerc, int repeats)
        {
            uint oldVolume;

            waveOutGetVolume(IntPtr.Zero, out oldVolume);
            // Calculate the volume that's being set. BTW: this is a trackbar!
            int newVolume = ((ushort.MaxValue / 100) * volumePerc);
            // Set the same volume for both the left and the right channels
            uint newVolumeAllChannels = (((uint)newVolume & 0x0000ffff) | ((uint)newVolume << 16));

            // Set the volume
            waveOutSetVolume(IntPtr.Zero, newVolumeAllChannels);

            try
            {
                System.Media.SystemSound ss;
                switch (systemSounds)
                {
                case SystemSounds.Asterisk:
                    ss = System.Media.SystemSounds.Asterisk;
                    break;

                case SystemSounds.Beep:
                    ss = System.Media.SystemSounds.Beep;
                    break;

                case SystemSounds.Exclamation:
                    ss = System.Media.SystemSounds.Exclamation;
                    break;

                case SystemSounds.Hand:
                    ss = System.Media.SystemSounds.Hand;
                    break;

                case SystemSounds.Question:
                    ss = System.Media.SystemSounds.Question;
                    break;

                default:
                    ss = System.Media.SystemSounds.Exclamation;
                    break;
                }
                ss.Play();
                if (repeats > 1)
                {
                    for (int i = 1; i < repeats; i++)
                    {
                        System.Threading.Thread.Sleep(500);
                        PlaySystemSound(systemSounds, volumePerc, 1);
                    }
                }
            }
            finally
            {
                waveOutSetVolume(IntPtr.Zero, oldVolume);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Play a system sound
 /// </summary>
 /// <param name="systemSound">Value from the SystemSounds enum</param>
 public static void PlaySystemSound(SystemSounds systemSound)
 {
     PlaySound(systemSound.ToString(), UIntPtr.Zero, SoundSettings.AliasId | SoundSettings.Async);
 }
Ejemplo n.º 4
0
 private string GetNameFromSystemSound(SystemSounds sound)
 {
     string name = string.Empty;
     switch (sound)
     {
         case SystemSounds.InputKeypress:
             name = "input_keypress";
             break;
         case SystemSounds.NotificationGeneral:
             name = "notification_general";
             break;
         case SystemSounds.NotificationSapphire:
             name = "notification_sapphire";
             break;
         case SystemSounds.AlarmBattery:
             name = "alarm_battery";
             break;
         case SystemSounds.EventBrowserStart:
             name = "event_browser_start";
             break;
         case SystemSounds.EventCameraShutter:
             name = "event_camera_shutter";
             break;
         case SystemSounds.EventRecordingStart:
             name = "event_recording_start";
             break;
         case SystemSounds.EventRecordingStop:
             name = "event_recording_stop";
             break;
         case SystemSounds.EventDeviceLock:
             name = "event_device_lock";
             break;
         case SystemSounds.EventDeviceUnlock:
             name = "event_device_unlock";
             break;
         case SystemSounds.EventDeviceTether:
             name = "event_device_tether";
             break;
         case SystemSounds.EventDeviceUntether:
             name = "event_device_untether";
             break;
         case SystemSounds.EventVideoCall:
             name = "event_video_call";
             break;
         case SystemSounds.EventVideoCallOutgoing:
             name = "event_video_call_outgoing";
             break;
         case SystemSounds.SystemMasterVolumeReference:
             name = "system_master_volume_reference";
             break;
         default:
             name = "notification_general";
             break;
     }
     return name;
 }
Ejemplo n.º 5
0
 public SoundPlayer(SystemSounds fileName)
 {
     _fileName = this.GetNameFromSystemSound(fileName);
 }