Exemplo n.º 1
0
        /// <summary>
        ///     This runs everytime the app is launched, even after suspension, so we use this to initialize stuff
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override async Task OnInitializeAsync(IActivatedEventArgs args)
        {
#if DEBUG
            // Init logger
            Logger.SetLogger(new ConsoleLogger(LogLevel.Info));
#endif

            // If we have a phone contract, hide the status bar
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
            {
                var statusBar = StatusBar.GetForCurrentView();
                await statusBar.HideAsync();
            }

            // Enter into full screen mode
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

            // Forces the display to stay on while we play
            _displayRequest.RequestActive();

            // Init vibration device
            if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
            {
                _vibrationDevice = VibrationDevice.GetDefault();
            }

            // Respond to changes in inventory and Pokemon in the immediate viscinity.
            GameClient.PokemonsInventory.CollectionChanged += PokemonsInventory_CollectionChanged;
            GameClient.CatchablePokemons.CollectionChanged += CatchablePokemons_CollectionChanged;

            await Task.CompletedTask;
        }
Exemplo n.º 2
0
        /*
         ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         + Open restaurant website pop up
         ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         */
        private void RestaurantName_Clicked(object sender, RoutedEventArgs e)
        {
            // Do not fire up the MessageBox if user is scrolling horizontally
            if (Canvas.GetLeft(this.ChildCanvas) != -LeftView.Width)
            {
                return;
            }

            WebsitePrompt_PopUp.IsOpen = true;

            // Begin animation
            Storyboard showPopUp = this.AnimateMove(WebsitePrompt_PopUp, -450, -60, 900, "elastic");

            showPopUp.Begin();

            // Vibrate
            var vibrationDevice = VibrationDevice.GetDefault();

            vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(200));

            // Darken the background
            PopUpOverlayGrid.Visibility = Visibility.Visible;

            // Set properties
            Restaurant clickedRestaurant = (Restaurant)(sender as Button).DataContext;

            this.uriToLaunch = clickedRestaurant.HomeUrl;
            NavigationPrompt_Textblock.Text = "Haluatko varmasti poistua sovelluksesta " +
                                              "ja avata ravintolan " + clickedRestaurant.Name + " verkkosivun selaimessa?";
        }
Exemplo n.º 3
0
 public static void VibrateDevice(TimeSpan length)
 {
     if (CanVibrate)
     {
         VibrationDevice.GetDefault()?.Vibrate(length);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a VibrateService instance.
 /// </summary>
 public VibrateService()
 {
     if (IsSupported)
     {
         _virationDevice = VibrationDevice.GetDefault();
     }
 }
Exemplo n.º 5
0
        public GamePage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Disabled;

            uBlip      = new Uri("ms-appx:///Assets/Blip.mp3");
            uCount     = new Uri("ms-appx:///Assets/ALARMCLK.mp3");
            uLaser     = new Uri("ms-appx:///Assets/Laser_Gun.mp3");
            uLevelUp   = new Uri("ms-appx:///Assets/Explosion_Hiss_Bop_Bang.mp3");
            uLevelDown = new Uri("ms-appx:///Assets/PHAZER.mp3");

            qQuestion           = null;
            dptTimer            = new DispatcherTimer();
            dtmFinishTime       = new DateTime();
            gDifficulty         = null;
            vbVibrate           = VibrationDevice.GetDefault();
            sPlayerScore        = null;
            lScoreList          = new List <Score>();
            ppPointerPress      = null;
            ppPointerRelease    = null;
            bAddCorrect         = false;
            bSubtractCorrect    = false;
            bMultiplyCorrect    = false;
            bDivideCorrect      = false;
            bQuestionAttempted  = false;
            bCountdownCompleted = false;
        }
Exemplo n.º 6
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
     {
         _vibration = VibrationDevice.GetDefault();
     }
 }
Exemplo n.º 7
0
        async void EndGame()
        {
            isEnd = true;
            var settings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            //MessageDialog msg = new MessageDialog("Permainan berakhir. Skor Anda: " + Model.DataPlayer.MyScore);
            //msg.Commands.Add(new UICommand("Yes") { Id = 0});

            //var result = await msg.ShowAsync();
            //msg.DefaultCommandIndex = 0;

            //if((int) result.Id == 0)
            //{

            //}

            if ((string)settings.Values["currentVibrate"] == "on" && ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
            {
                VibrationDevice.GetDefault().Vibrate(TimeSpan.FromMilliseconds(1000));
            }
            pagePlay.IsEnabled = false;
            await Task.Delay(2000);

            try
            {
                this.Frame.Navigate(typeof(ResultPage));
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }
        }
Exemplo n.º 8
0
 private void NumberTextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     if (NumberTextBox.Text.Length != 11)
     {
         Storyboard storyboard = NumberMessageFlipStoryboard;
         storyboard.Begin();
         VibrationDevice vibration = VibrationDevice.GetDefault();
         vibration.Vibrate(TimeSpan.FromMilliseconds(30));
         PhoneValidationMessage.Text = "Номер набран не полностью";
         IsNumberValidated           = false;
     }
     else if (NumberTextBox.Text[0] != '7' || NumberTextBox.Text[1] != '9')
     {
         Storyboard storyboard = NumberMessageFlipStoryboard;
         storyboard.Begin();
         VibrationDevice vibration = VibrationDevice.GetDefault();
         vibration.Vibrate(TimeSpan.FromMilliseconds(30));
         PhoneValidationMessage.Text = "Неверный формат ввода номера";
         IsNumberValidated           = false;
     }
     else
     {
         Storyboard storyboard = NumberMessageFlipBackStoyboard;
         storyboard.Begin();
         IsNumberValidated = true;
     }
     if (NumberTextBox.Text.Length == 0)
     {
         PhoneGrid.ColumnDefinitions[1].Width = new GridLength(0);
         NumberTextBox.Padding        = NameTextBox.Padding;
         PlusSymbloTextBox.Visibility = Visibility.Collapsed;
     }
 }
 public void cancel()
 {
     if (_isMobile)
     {
         var vibrationDevice = VibrationDevice.GetDefault();
         vibrationDevice.Cancel();
     }
 }
Exemplo n.º 10
0
 static void VibrateDevice(TimeSpan VibrationTime)
 {
     if (DeviceDetection.DetectDeviceType() == DeviceType.Phone)
     {
         var vibrator = VibrationDevice.GetDefault();
         vibrator.Vibrate(VibrationTime);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Vibrates the device for the given timespan if the device supports phone vibration.
 /// </summary>
 /// <param name="duration">How long should the vibration persist. Max 5 seconds.</param>
 public static void VibratePress(TimeSpan duration)
 {
     if (DeviceFamilyHelper.SupportsVibration())
     {
         VibrationDevice.GetDefault().Vibrate(duration);
     }
     Logger.Debug("Vibration not supported.");
 }
Exemplo n.º 12
0
 public void vibrate(int duration)
 {
     if (_isMobile)
     {
         var vibrationDevice = VibrationDevice.GetDefault();
         vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(duration));
     }
 }
Exemplo n.º 13
0
 private void GoToBackButton_Click(object sender, RoutedEventArgs e)
 {
     VibrationDevice vibration = VibrationDevice.GetDefault();
     vibration.Vibrate(TimeSpan.FromMilliseconds(20));
     if (Frame.CanGoBack)
     {
         Frame.GoBack();
     }
 }
Exemplo n.º 14
0
        private void Vibrate_Tap(object sender, RoutedEventArgs e)
        {
            var vibrationDevice = VibrationDevice.GetDefault();

            if (vibrationDevice != null)
            {
                vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(500));
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Stops the vibration of the device.
        /// </summary>
        public void Cancel()
        {
#if WINDOWS_PHONE
            VibrateController.Default.Stop();
#elif WINDOWS_PHONE_APP
            VibrationDevice.GetDefault().Cancel();
#else
            throw new NotSupportedException();
#endif
        }
Exemplo n.º 16
0
        /// <summary>
        /// Vibrates the device for the specified duration (from 0 to 5000 milliseconds).
        /// </summary>
        /// <param name="duration">The duration (from 0 to 5000 milliseconds) for which the device vibrates.</param>
        public void Vibrate(TimeSpan duration)
        {
#if WINDOWS_PHONE
            VibrateController.Default.Start(duration);
#elif WINDOWS_PHONE_APP
            VibrationDevice.GetDefault().Vibrate(duration);
#else
            throw new NotSupportedException();
#endif
        }
Exemplo n.º 17
0
 public void HabilitarControles()
 {
     mandoActivo               = true;
     lblTurno.Text             = "En Turno";
     panelEncendido.Background = Convertidor.GetSolidColorBrush(Constantes.COLORMANDOACTIVO);
     if (App.DetectPlatform() == Platform.WindowsPhone)
     {
         var vibration = VibrationDevice.GetDefault();
         vibration.Vibrate(TimeSpan.FromMilliseconds(500));
     }
 }
Exemplo n.º 18
0
        internal NepAppUIManagerNotifier()
        {
            toastNotifier = ToastNotificationManager.CreateToastNotifier();
            tileUpdater   = TileUpdateManager.CreateTileUpdaterForApplication();


            if (Crystal3.DeviceInformation.GetDevicePlatform() == Crystal3.Core.Platform.Mobile)
            {
                vibrationDevice = VibrationDevice.GetDefault();
            }
        }
Exemplo n.º 19
0
        public static void Vibrate(double timeMilliseconds)
        {
            string VibrateBool = localSettings.Values["vibrate"].ToString();

            if (VibrateBool == "1" &&
                ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
            {
                var device = VibrationDevice.GetDefault();
                device.Vibrate(TimeSpan.FromMilliseconds(timeMilliseconds));
            }
        }
Exemplo n.º 20
0
 /// <summary>
 ///     Creates a task to send a sound notification.
 /// </summary>
 /// <returns> The task to send a vibration notification. </returns>
 public static void SendVibrationNotificationAsync()
 {
     try
     {
         VibrationDevice.GetDefault().Vibrate(TimeSpan.FromSeconds(5));
     }
     catch
     {
         Debug.WriteLine(
             "BRRRRRRRRRRRRRRRRRRRRRRRRRRRR BRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR BRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
     }
 }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="mode"></param>
        /// <param name="suspensionState"></param>
        /// <returns></returns>
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            // Prevent from going back to other pages
            NavigationService.ClearHistory();
            if (parameter is bool && mode != NavigationMode.Back)
            {
                // First time navigating here, we need to initialize data updating but only if we have GPS access
                await Dispatcher.DispatchAsync(async() =>
                {
                    var accessStatus = await Geolocator.RequestAccessAsync();
                    switch (accessStatus)
                    {
                    case GeolocationAccessStatus.Allowed:
                        await GameClient.InitializeDataUpdate();
                        break;

                    default:
                        Logger.Write("Error during GPS activation");
                        await new MessageDialog("We need GPS permissions to run the game, please enable it and try again.").ShowAsyncQueue();
                        BootStrapper.Current.Exit();
                        break;
                    }
                });
            }
            // Restarts map timer
            GameClient.ToggleUpdateTimer();
            if (suspensionState.Any())
            {
                // Recovering the state
                PlayerProfile = (PlayerData)suspensionState[nameof(PlayerProfile)];
                PlayerStats   = (PlayerStats)suspensionState[nameof(PlayerStats)];
            }
            else
            {
                // No saved state, get them from the client
                PlayerProfile  = (await GameClient.GetProfile()).PlayerData;
                InventoryDelta = (await GameClient.GetInventory()).InventoryDelta;
                var tmpStats = InventoryDelta.InventoryItems.First(item => item.InventoryItemData.PlayerStats != null).InventoryItemData.PlayerStats;
                if (PlayerStats != null && PlayerStats.Level != tmpStats.Level)
                {
                    // TODO: report level increase
                }
                PlayerStats = tmpStats;
                RaisePropertyChanged(nameof(ExperienceValue));
            }
            // Setup vibration and sound
            if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice") && _vibrationDevice == null)
            {
                _vibrationDevice = VibrationDevice.GetDefault();
            }
            GameClient.MapPokemonUpdated += GameClientOnMapPokemonUpdated;
            await Task.CompletedTask;
        }
Exemplo n.º 22
0
        public static void Vibrate()
        {
            if (!App.Context.AllowVibrate)
            {
                return;
            }

            if ("Windows.Mobile".Equals(AnalyticsInfo.VersionInfo.DeviceFamily, StringComparison.OrdinalIgnoreCase))
            {
                VibrationDevice v = VibrationDevice.GetDefault();
                v.Vibrate(TimeSpan.FromMilliseconds(50));
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Invoked when nfc message was published.
        /// </summary>
        /// <param name="sender">The nfc device the message was subscribed with</param>
        /// <param name="messageId">The id of the written message</param>
        private void PublishedHandler(ProximityDevice sender, long messageId)
        {
            // Let the device vibrate to indicate that a new message was written
            var vibrationDevice = VibrationDevice.GetDefault();

            if (vibrationDevice != null)
            {
                vibrationDevice.Vibrate(TimeSpan.FromSeconds(0.2));
            }

            // Stops the publishing of the current message
            sender.StopPublishingMessage(messageId);
        }
Exemplo n.º 24
0
        /// <summary>
        ///     This runs everytime the app is launched, even after suspension, so we use this to initialize stuff
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override async Task OnInitializeAsync(IActivatedEventArgs args)
        {
#if DEBUG
            // Init logger
            Logger.SetLogger(new ConsoleLogger(LogLevel.Info));
#endif
            // If we have a phone contract, hide the status bar
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                var statusBar = StatusBar.GetForCurrentView();
                await statusBar.HideAsync();
            }

            // Enter into full screen mode
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();
            ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
            ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard;

            // Forces the display to stay on while we play
            //_displayRequest.RequestActive();
            WindowWrapper.Current().Window.VisibilityChanged += WindowOnVisibilityChanged;

            // Initialize Map styles
            await MapStyleHelpers.Initialize();

            // Turn the display off when the proximity stuff detects the display is covered (battery saver)
            if (SettingsService.Instance.IsBatterySaverEnabled)
            {
                _proximityHelper.EnableDisplayAutoOff(true);
            }

            // Init vibration device
            if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
            {
                _vibrationDevice = VibrationDevice.GetDefault();
            }

            if (SettingsService.Instance.LiveTileMode == LiveTileModes.Peek)
            {
                LiveTileUpdater.EnableNotificationQueue(true);
            }

            // Check for network status
            NetworkInformation.NetworkStatusChanged += NetworkInformationOnNetworkStatusChanged;

            // Respond to changes in inventory and Pokemon in the immediate viscinity.
            GameClient.PokemonsInventory.CollectionChanged += PokemonsInventory_CollectionChanged;
            GameClient.CatchablePokemons.CollectionChanged += CatchablePokemons_CollectionChanged;

            await Task.CompletedTask;
        }
 private void Vibrate()
 {
     try
     {
         if (_appSettings.Get <bool>(StorageKey.VibrationEnabled))
         {
             VibrationDevice v = VibrationDevice.GetDefault();
             v.Vibrate(TimeSpan.FromMilliseconds(500));
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 26
0
        private static void popToastReduced()
        {
            // Vibrate:
            if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice") && !Settings.getSettingBoolean(SettingsConsts.DISABLE_VIBRATION_FOR_NEW_CHAT_MESSAGES))
            {
                VibrationDevice.GetDefault().Vibrate(VIBRATE_TS);
            }

            // Play sound:
            if (!Settings.getSettingBoolean(SettingsConsts.DISABLE_PLAY_SOUND_FOR_NEW_CHAT_MESSAGES))
            {
                SharedUtils.PlaySoundFromUri("ms-winsoundevent:Notification.Default");
            }
        }
Exemplo n.º 27
0
        private void MostrarResultadoFinalJuego(string mensaje)
        {
            if (App.DetectPlatform() == Platform.WindowsPhone)
            {
                var vibration = VibrationDevice.GetDefault();
                vibration.Vibrate(TimeSpan.FromMilliseconds(500));
            }

            btnMensaje.Content = mensaje;

            panelRegresar.Visibility   = Windows.UI.Xaml.Visibility.Collapsed;
            Contenido.Visibility       = Windows.UI.Xaml.Visibility.Collapsed;
            panelTurno.Visibility      = Windows.UI.Xaml.Visibility.Collapsed;
            mensajeFinJuego.Visibility = Windows.UI.Xaml.Visibility.Visible;
        }
Exemplo n.º 28
0
        private void GoToBackButton_Click(object sender, RoutedEventArgs e)
        {
            if (!App.WebService.IsInternetAvailable())
            {
                Frame.BackStack.Clear();
                Frame.Navigate(typeof(MainPage));
            }
            VibrationDevice vibration = VibrationDevice.GetDefault();

            vibration.Vibrate(TimeSpan.FromMilliseconds(20));
            if (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Stops the vibration of the device.
        /// </summary>
        public virtual void Cancel()
        {
#if WINDOWS_PHONE || WINDOWS_PHONE_81
            VibrateController.Default.Stop();
#elif WINDOWS_PHONE_APP
            VibrationDevice.GetDefault().Cancel();
#elif WINDOWS_UWP
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice"))
            {
                VibrationDevice.GetDefault().Cancel();
            }
#else
            ExceptionHelper.ThrowNotSupported();
#endif
        }
Exemplo n.º 30
0
 private void vibratePhone()
 {
     try // if device can vibrate
     {
         VibrationDevice v = VibrationDevice.GetDefault();
         v.Vibrate(TimeSpan.FromMilliseconds(100));
     }
     catch (System.TypeLoadException)
     {
         //Debug.WriteLine("Vibration not supported");
     }
     catch (System.Exception) {
         //ignore
     }
 }