public void Stop()
 {
     if (_virationDevice != null)
     {
         _virationDevice.Cancel();
     }
 }
Beispiel #2
0
 private void Cancel_Click(object sender, RoutedEventArgs e)
 {
     if (int.TryParse(VibrationDurationTextBox.Text, out int milliseconds))
     {
         try
         {
             _vibrationDevice?.Cancel();
         }
         catch (Exception ex)
         {
             ErrorMessage.Text = ex.Message;
         }
     }
 }
        // 提示框返回结果 处理方法
        void messageBox_Dismissed(object sender, DismissedEventArgs e)
        {
            if (effectInstance != null)
            {
                // 暂停提示音
                effectInstance.Stop();
            }

            if (vibrationThread != null)
            {
                // 关闭振动线程
                vibrationThread.Abort();
                // 暂停振动
                vibrationDevice.Cancel();
            }

            loopPlay = false;

            // 处理用户点击选择的按钮
            switch (e.Result)
            {
            case CustomMessageBoxResult.LeftButton:
                var szoozeSeconds = SzoozeTimes.GetSeconds(selectedSzoozeTime);
                var newSzoozeTime = DateTime.Parse("00:00:00").AddSeconds(szoozeSeconds);
                new Thread(() =>
                {
                    Thread.Sleep(500);
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        NavigateToTimingPage(newSzoozeTime, TextBoxName.Text);
                    });
                }).Start();
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

            if (!(Window.Current.Content is Border) && !e.PrelaunchActivated)
            {
                Button button = new Button
                {
                    Style = (Style)Resources["VibrateButton"]
                };

                button.Click += (buttonClickSender, buttonClickE) =>
                {
                    if (isVibrating)
                    {
                        vibrationDevice.Cancel();
                        resetEvent.Reset();
                    }
                    else
                    {
                        resetEvent.Set();
                    }

                    isVibrating = !isVibrating;
                };

                Window.Current.Content = new Border
                {
                    Background = new SolidColorBrush(Colors.Purple),
                    Child      = button
                };

                Window.Current.Activate();
            }
        }
Beispiel #5
0
 public static void cancelVibration()
 {
     _vibrationDevice.Cancel();
 }
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     testVibrationDevice.Cancel();
 }