private async void timing() { do { await Task.Delay(TimeSpan.FromSeconds(1)); time--; TFtimer.DataContext = time; } while (time > 0); if (time <= 0) { testVibrationDevice.Vibrate(TimeSpan.FromSeconds(3)); IMlife1.DataContext = dead; IMlife2.DataContext = dead; IMlife3.DataContext = dead; IMlife1.Visibility = Visibility.Collapsed; IMlife2.Visibility = Visibility.Collapsed; IMlife3.Visibility = Visibility.Collapsed; RP1.Visibility = Visibility.Collapsed; RP2.Visibility = Visibility.Collapsed; RP3.Visibility = Visibility.Collapsed; RP4.Visibility = Visibility.Collapsed; //TFquestion.Visibility = Visibility.Collapsed; BTContinue.Visibility = Visibility.Visible; score = 2548 + RPVrais * 250 - RPFaux * 600; IsolatedStorageHelper.SaveObject(SharedInformation.sharedType, score); TFquestion.Text = "Game Over"; TFaccuse.Text = "Score = " + score; } }
public void Vibrate(int millis) { if (_virationDevice != null) { _virationDevice.Vibrate(TimeSpan.FromMilliseconds(millis)); } }
private void BtnStart_Click(object sender, RoutedEventArgs e) { if (_vibration != null) { _vibration.Vibrate(TimeSpan.FromSeconds(1)); } }
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; } }
private void VibrateButton_Click(object sender, RoutedEventArgs e) { int vibrationDuration = 0; Int32.TryParse(this.VibrateTextBox.Text, out vibrationDuration); testVibrationDevice.Vibrate(TimeSpan.FromSeconds(vibrationDuration)); }
private void GoToBackButton_Click(object sender, RoutedEventArgs e) { VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(20)); if (Frame.CanGoBack) { Frame.GoBack(); } }
public void VibrateClick() { if ((bool)NepApp.Settings.GetSetting(AppSettings.UseHapticFeedbackForNavigation)) { if (vibrationDevice != null) { vibrationDevice?.Vibrate(TimeSpan.FromMilliseconds(32)); } } }
/// <summary> /// Vibrates and/or plays a sound when new pokemons are in the area /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private async void GameClientOnMapPokemonUpdated(object sender, EventArgs eventArgs) { if (SettingsService.Instance.IsVibrationEnabled) { _vibrationDevice?.Vibrate(TimeSpan.FromMilliseconds(500)); } if (SettingsService.Instance.IsMusicEnabled) { await AudioUtils.PlaySound(@"pokemon_found_ding.wav"); } }
/// <summary> /// Vibrates and/or plays a sound when new pokemons are in the area /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void CatchablePokemons_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action != NotifyCollectionChangedAction.Add) { return; } if (SettingsService.Instance.IsVibrationEnabled) { _vibrationDevice?.Vibrate(TimeSpan.FromMilliseconds(500)); } await AudioUtils.PlaySound(@"pokemon_found_ding.wav"); }
/// <summary> /// Vibrates and/or plays a sound when new pokemons are in the area /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CatchablePokemons_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action != NotifyCollectionChangedAction.Add) { return; } if (SettingsService.Instance.IsVibrationEnabled) { _vibrationDevice?.Vibrate(TimeSpan.FromMilliseconds(500)); } AudioUtils.PlaySound(AudioUtils.POKEMON_FOUND_DING); }
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)); } }
private void Vibrate() { try { if (_appSettings.Get <bool>(StorageKey.VibrationEnabled)) { VibrationDevice v = VibrationDevice.GetDefault(); v.Vibrate(TimeSpan.FromMilliseconds(500)); } } catch (Exception) { } }
private void Vibrate_Click(object sender, RoutedEventArgs e) { if (int.TryParse(VibrationDurationTextBox.Text, out int milliseconds)) { try { _vibrationDevice?.Vibrate(TimeSpan.FromMilliseconds(milliseconds)); } catch (Exception ex) { ErrorMessage.Text = ex.Message; } } }
public static void VibratePhone(int seconds = 1) { // IsTypePresent( "Windows.Phone.UI.Input.HardwareButtons" ) // IsTypePresent( "Windows.Phone.Devices.Notification.VibrationDevice" ) // IsTypePresent( "Windows.UI.ViewManagement.StatusBar" ) // IsTypePresent( "Windows.UI.Core.AnimationMetrics.AnimationDescription" ) // IsTypePresent( "Windows.Devices.SmartCards.SmartCardConnection" ) // .... if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice")) { VibrationDevice vibrationDevice = VibrationDevice.GetDefault(); vibrationDevice.Vibrate(TimeSpan.FromSeconds(seconds)); } }
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 } }
public static void vibrate([ReadOnlyArray()] object[] args) { // set default int duration = 200; try { duration = Convert.ToInt32(args[0]); } catch { } _vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(duration)); }
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(); } }
public async Task Scanned(Windows.Devices.PointOfService.BarcodeScannerDataReceivedEventArgs args) { try { VibrationDevice testVibrationDevice = VibrationDevice.GetDefault(); testVibrationDevice.Vibrate(TimeSpan.FromTicks(500000)); string scannedCode = await GetData(args.Report.ScanDataLabel, args.Report.ScanDataType); string scannedSymbology = Windows.Devices.PointOfService.BarcodeSymbologies.GetName(args.Report.ScanDataType); MessagingCenter.Send <xx.App, string>((xx.App)obj.xxApp, "scannedValue", scannedCode + "###" + scannedSymbology); } catch (Exception ex) { MessagingCenter.Send <xx.App, string>((xx.App)obj.xxApp, "exception", "ScrannerInit/Scanned: " + ex.Message); } }
private void NameTextBox_LostFocus(object sender, RoutedEventArgs e) { if (NameTextBox.Text.Length == 0) { Storyboard storyboard = NameMessageFlipStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); IsNameValidated = false; NameValidationMessage.Text = "Введите имя"; } else { Storyboard storyboard = NameMessageFlipBackStoyboard; storyboard.Begin(); IsNameValidated = true; } }
private void button_Shoot_Click(object sender, RoutedEventArgs e) { if (canShoot) { try { testVibrationDevice.Vibrate(TimeSpan.FromSeconds(0.5)); // testVibrationDevice.Cancel(); canShoot = false; _videoEngine.Messenger.FrameRequestId = ColorPickFrameRequestId; canShoot = true; } catch (Exception ex) { text_exeption.Text = "Erreur capture:" + ex; } } }
private async void WebViewControl_ScriptNotify(object sender, NotifyEventArgs e) { if (e.CallingUri.Scheme == "ms-appx-web") { if (e.Value.Contains("dex")) { string s = e.Value; string output = s.Substring(s.IndexOf(',') + 1); int valor = int.Parse(output); Debug.WriteLine("dex " + valor); if (valor % 2 != 0) { VibrationDevice testVibrationDevice = VibrationDevice.GetDefault(); testVibrationDevice.Vibrate(TimeSpan.FromSeconds(1)); //testVibrationDevice.Cancel(); } } if (e.Value.Contains("ant")) { string s = e.Value; string output = s.Substring(s.IndexOf(',') + 1); ant_value = output;//int.Parse(output); Debug.WriteLine("ant " + ant_value); DataTransferManager.ShowShareUI(); //DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); //dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(MainPage_DataRequested); DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += MainPage_DataRequested; } if (e.Value.Contains("data")) { String x = e.Value; data = x.Replace("data:image/png;base64,", ""); await Base64StringToBitmap(data); alpha.Source = bmp; Debug.WriteLine("data " + data); } } }
private void shoot(object sender, KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { if (canShoot) { try { testVibrationDevice.Vibrate(TimeSpan.FromSeconds(0.7)); canShoot = false; _videoEngine.Messenger.FrameRequestId = ColorPickFrameRequestId; canShoot = true; } catch (Exception ex) { //text_exeption.Text = "Erreur capture"; } } } }
private async void SubmitButton_Click(object sender, RoutedEventArgs e) { if (!App.WebService.IsInternetAvailable()) { Messages.ShowInternetAvailableMessage(); return; } if (!IsNameValidated && !IsNumberValidated) { VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); return; } var response = await App.WebService.UserRegistrJsonResponse(NumberTextBox.Text, NameTextBox.Text); var answer = await App.Deserializer.Execute <SimpleAnswer>(response.GetResponseStream()); if (answer.Answer == JsonAnswers.ALREADYHAVE) { Storyboard storyboard = NumberMessageFlipStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); PhoneValidationMessage.Text = "Номер телефона уже зарегистрирован"; return; } if (answer.Answer == JsonAnswers.OK) { App.AppRepository.User.Insert(new User { Name = NameTextBox.Text, Number = NumberTextBox.Text, LastLogin = DateTime.UtcNow }); Frame.Navigate(typeof(MainPage)); } }
/// <summary> /// Occurs whe the player gets the answer incorrect /// </summary> private async void showCross() { Frame.IsEnabled = false; // Update the score display tbkScore.Text = string.Format("Score: {0,3:##0} / {1:##0}", sPlayerScore.TotalCorrect, sPlayerScore.TotalQuestions); if ((dtmFinishTime - DateTime.Now).TotalMilliseconds > 0) { // Show the correct operator tbkQuestion.Text = string.Format("{0} {1} {2} = {3}", qQuestion.Operand1, qQuestion.Operator, qQuestion.Operand2, qQuestion.Answer); tbkSwipeHori.Visibility = Visibility.Collapsed; tbkSwipeVert.Visibility = Visibility.Collapsed; // Show a cross image imgCross.Opacity = 1.0; vbVibrate.Vibrate(TimeSpan.FromMilliseconds(250)); // Fade the cross and the question for (int i = 100; i >= 0; i--) { tbkQuestion.Opacity = i / 100.0; imgCross.Opacity = i / 20.0; await Task.Delay(1); } tbkSwipeHori.Visibility = Visibility.Visible; tbkSwipeVert.Visibility = Visibility.Visible; // Make a new question if ((dtmFinishTime - DateTime.Now).TotalMilliseconds > 99) { makeQuestion(); } } }
void OnTimeOut() { ShowCustomMessageBox(); loopPlay = true; if (soundId == -1) // 振动 { vibrationDevice = VibrationDevice.GetDefault(); vibrationThread = new Thread(() => { for (int i = 0; i < 15; i++) { vibrationDevice.Vibrate(TimeSpan.FromSeconds(1)); Thread.Sleep(3000); } }); vibrationThread.Start(); } else { Ring(); } }
private void vibrate() { VibrationDevice vibrationDevice = VibrationDevice.GetDefault(); vibrationDevice.Vibrate(TimeSpan.FromMilliseconds(50)); }
/// <summary> /// Запустить вибрацию указанной длительности. /// </summary> /// <param name="duration">Длительность вибрации.</param> public Task Vibrate(TimeSpan duration) { return(Task.Run(() => device.Vibrate(duration))); }
/// <summary> /// Handle a new message being created /// </summary> private async void App_MessageCreatedHandler(object sender, App.MessageCreatedArgs e) { if (ChannelId != e.Message.ChannelId) { return; } // Run on UI thread await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (e.Message.Type == 3 && e.Message.User.Id != LocalState.CurrentUser.Id) { // Show call notification NotificationManager.CreateCallNotification(e.Message); } // True if new message should show header bool showheader = false; // True if the next message is unread bool nextIsUnread = false; // The id of the last message read by user string lastmessageid = LocalState.RPC[ChannelId].LastMessageId; // Add message list if (MessageList.Items.Count > 0) { Message last = null; for (int i = 0; i < MessageList.Items.Count; i++) { MessageContainer container = (MessageContainer)MessageList.Items[i]; if (!App.IsFocused) { if (nextIsUnread) { container.LastRead = true; nextIsUnread = false; } else { container.LastRead = false; if (container.Message.Id == lastmessageid) { nextIsUnread = true; if (i == MessageList.Items.Count - 1) { showheader = true; } } } } if (i == MessageList.Items.Count - 1) { last = container.Message; } } MessageList.Items.Add(MessageManager.MakeMessage(e.Message, MessageManager.ShouldContinuate(e.Message, last), showheader)); } else { MessageList.Items.Add(MessageManager.MakeMessage(e.Message)); } // RPC data if (e.Message.User.Id == LocalState.CurrentUser.Id) { //do something???? } else { if (App.IsFocused) { App.MarkMessageAsRead(e.Message.Id, ChannelId); } else { App.ReadWhenFocused(e.Message.Id, ChannelId, CurrentGuildId); } } // Vibrate if (Storage.Settings.Vibrate && e.Message.User.Id != LocalState.CurrentUser.Id) { TimeSpan vibrationDuration = TimeSpan.FromMilliseconds(200); if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification")) { VibrationDevice phonevibrate = VibrationDevice.GetDefault(); phonevibrate.Vibrate(vibrationDuration); } //This will be for another time, it isn't working right now /* var gamepad = Windows.Gaming.Input.Gamepad.Gamepads.FirstOrDefault(); * if(gamepad!=null) * { * GamepadVibration vibration = new GamepadVibration(); * await Task.Run(async () => * { * vibration.RightMotor = 0.5; * gamepad.Vibration = vibration; * await Task.Delay(vibrationDuration); * vibration.RightMotor = 0; * }); * }*/ } // Text to speech if (e.Message.TTS) { MediaElement mediaplayer = new MediaElement(); using (SpeechSynthesizer speech = new SpeechSynthesizer()) { speech.Voice = SpeechSynthesizer.AllVoices.First(gender => gender.Gender == VoiceGender.Male); string ssml = @"<speak version='1.0' " + "xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>" + e.Message.User.Username + "said" + e.Message.Content + "</speak>"; SpeechSynthesisStream stream = await speech.SynthesizeSsmlToStreamAsync(ssml); mediaplayer.SetSource(stream, stream.ContentType); mediaplayer.Play(); } } }); }
/// <summary> /// Callback for LinphoneCoreListener /// </summary> public void MessageReceived(LinphoneChatMessage message) { if (BaseModel.UIDispatcher == null) { return; } BaseModel.UIDispatcher.BeginInvoke(() => { LinphoneAddress fromAddress = message.From; string sipAddress = String.Format("{0}@{1}", fromAddress.UserName, fromAddress.Domain); Logger.Msg("[LinphoneManager] Message received from " + sipAddress + ": " + message.Text + "\r\n"); //Vibrate ChatSettingsManager settings = new ChatSettingsManager(); settings.Load(); if ((bool)settings.VibrateOnIncomingMessage) { VibrationDevice vibrator = VibrationDevice.GetDefault(); vibrator.Vibrate(TimeSpan.FromSeconds(1)); } if (MessageListener != null && MessageListener.GetSipAddressAssociatedWithDisplayConversation() != null && MessageListener.GetSipAddressAssociatedWithDisplayConversation().Equals(sipAddress)) { MessageListener.MessageReceived(message); } else { DateTime date = new DateTime(message.Time * TimeSpan.TicksPerSecond, DateTimeKind.Utc).AddYears(1969).ToLocalTime(); DateTime now = DateTime.Now; string dateStr; if (now.Year == date.Year && now.Month == date.Month && now.Day == date.Day) { dateStr = String.Format("{0:HH:mm}", date); } else if (now.Year == date.Year) { dateStr = String.Format("{0:ddd d MMM, HH:mm}", date); } else { dateStr = String.Format("{0:ddd d MMM yyyy, HH:mm}", date); } //TODO: Temp hack to remove string url = message.ExternalBodyUrl; url = url.Replace("\"", ""); //Displays the message as a popup if (MessageReceivedNotification != null) { MessageReceivedNotification.Dismiss(); } MessageReceivedNotification = new CustomMessageBox() { Title = dateStr, Caption = url.Length > 0 ? AppResources.ImageMessageReceived : AppResources.MessageReceived, Message = url.Length > 0 ? "" : message.Text, LeftButtonContent = AppResources.Close, RightButtonContent = AppResources.Show }; MessageReceivedNotification.Dismissed += (s, e) => { switch (e.Result) { case CustomMessageBoxResult.RightButton: BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/Chat.xaml?sip=" + Utils.ReplacePlusInUri(message.PeerAddress.AsStringUriOnly()), UriKind.RelativeOrAbsolute)); break; } }; MessageReceivedNotification.Show(); } }); }
async void SendCode() { var response = await App.WebService.AddSaleJsonResponse(App.AppRepository.User.Data.Number, PasswordTextBox.Password); var json = await App.Deserializer.Execute <SimpleAnswer>(response.GetResponseStream()); if (json.Answer == JsonAnswers.OK) { Storyboard storyboard = CodeMessageFlipBackStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); var response1 = await App.WebService.UserSaleJsonResponse(App.AppRepository.User.Data.Number); var json1 = await App.Deserializer.Execute <SaleAnswer>(response1.GetResponseStream()); if (json1.Answer == JsonAnswers.OK) { App.AppRepository.User.Data.Discount = json1.Answer; } if (Frame.CanGoBack) { Frame.GoBack(); } } else { if (json.Answer == JsonAnswers.MAXSALE) { Storyboard storyboard = CodeMessageFlipStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); CodeValidationMessage.Text = "Достигнута максимальная скидка"; PasswordTextBox.Password = ""; PasswordTextBox.Focus(FocusState.Programmatic); return; } if (json.Answer == JsonAnswers.INCORRECTCODE) { Storyboard storyboard = CodeMessageFlipStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); CodeValidationMessage.Text = "Код введен не верно"; PasswordTextBox.Password = ""; PasswordTextBox.Focus(FocusState.Programmatic); return; } if (json.Answer == JsonAnswers.WRONGCODE) { Storyboard storyboard = CodeMessageFlipStoryboard; storyboard.Begin(); VibrationDevice vibration = VibrationDevice.GetDefault(); vibration.Vibrate(TimeSpan.FromMilliseconds(30)); CodeValidationMessage.Text = "Код неверен"; PasswordTextBox.Password = ""; PasswordTextBox.Focus(FocusState.Programmatic); return; } } }