コード例 #1
0
        private async void NavigateToExit()
        {
            ViewModelLocator.ResetViewModels();
            await startButtons.Dispose();

            ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
        }
コード例 #2
0
        private void UpdateTime(object sender, object e)
        {
            _Time       = _Time - 2;
            state.Text += ".";

            shbo.SetBrightnessLevel(_Time / 100, DisplayBrightnessOverrideOptions.None);
            if (_Time > MaxTime)
            {
                return;
            }


            try
            {
                this.timerProgress.Stop();
                timerProgress.Tick -= UpdateTime;

                shbo.SetBrightnessLevel(0, DisplayBrightnessOverrideOptions.None);
                //shbo.StopOverride();
                if (_shutdown)
                {
                    ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5));
                }
                if (_reboot)
                {
                    ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0.5));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("UpdateTime Error :" + ex.Message);
            }
        }
コード例 #3
0
 private void ShutdownHelper(ShutdownKind kind)
 {
     new System.Threading.Tasks.Task(() =>
     {
         ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0));
     }).Start();
 }
コード例 #4
0
 /// <summary>
 /// Usually when the signal (RPi) battery is in a critical state. Shuts down the unit in the event of a critical
 /// system failure and sets the robot state.
 /// </summary>
 public static void EmergencyShutdown(TimeSpan delay)
 {
     NetworkUtils.LogNetwork(string.Format("CRITICAL SYSTEM MESSAGE: The device is shutting down in {0} seconds, use" +
                                           " ShutdownManager.CancelShutdown() to cancel", delay.TotalSeconds), MessageType.Warning);
     //completly shut down the robot
     ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, delay);
 }
コード例 #5
0
ファイル: POS_finishing.xaml.cs プロジェクト: milk57618/Dear
        private void btn_finishing2_Click(object sender, RoutedEventArgs e)
        {
            new DBConn_SaleSearch().Finish();
            //영수증 출력 후 시스템 종료

            /*시스템 즉시 종료*/
            ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.Zero);
        }
        private async Task <MethodResponse> RestartAsync(MethodRequest methodRequest, object userContext)
        {
            this.logging.LogEvent("Reboot initiated");

            ShutdownManager.BeginShutdown(ShutdownKind.Restart, this.deviceRebootDelayPeriod);

            return(new MethodResponse(200));
        }
コード例 #7
0
 private void ButtonpinValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     // Just shutdown on one edge
     if (args.Edge == GpioPinEdge.RisingEdge)
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5));
     }
 }
コード例 #8
0
        private void SetFinishing()
        {
            /*마감 처리에 필요한 기능 중지*/
            new DBConn_MemberTime().UpdateMemberTime(POS_main.managerName);
            new DBConn_SaleSearch().Finish();

            /*시스템 종료*/
            ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(2));
        }
コード例 #9
0
        private async void Btn_system_beenden_Click(object sender, RoutedEventArgs e)
        {
            await User_Check("Soll Windows wirklich heruntergefahren werden?", "Windows herunterfahren");

            if (result)
            {
                ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
            }
        }
コード例 #10
0
        private async void Btn_system_neustart_Click(object sender, RoutedEventArgs e)
        {
            await User_Check("Soll Windows wirklich neu gestartet werden?", "Windows neu starten");

            if (result)
            {
                ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0));
            }
        }
コード例 #11
0
        private async void shutdownButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new MessageDialog("Are you sure you want to shutdown the device? You can't turn it on remotely.", "IoTHelpers");

            dialog.Commands.Add(new UICommand("Yes", (cmd) => ShutdownManager.Shutdown()));
            dialog.Commands.Add(new UICommand("No"));
            dialog.CancelCommandIndex = 1;

            await dialog.ShowAsync();
        }
コード例 #12
0
        private async void restartButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new MessageDialog("Are you sure you want to restart the device?", "IoTHelpers");

            dialog.Commands.Add(new UICommand("Yes", (cmd) => ShutdownManager.Restart()));
            dialog.Commands.Add(new UICommand("No"));
            dialog.CancelCommandIndex = 1;

            await dialog.ShowAsync();
        }
コード例 #13
0
 private void PowerButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
     }
     catch (Exception ex)
     {
         new MessageDialog("Are you running on an IoT core device? Shutdown only works there.\n" + ex.Message, "Could not shhutdown").ShowAsync().AsTask().Wait();
     }
 }
コード例 #14
0
#pragma warning disable 1998
        private async Task <MethodResponse> RestartAsync(MethodRequest methodRequest, object userContext)
        {
            if (bme280InputPollingTimer != null)
            {
                bme280InputPollingTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }

            ShutdownManager.BeginShutdown(ShutdownKind.Restart, deviceRestartPeriod);

            return(new MethodResponse(200));
        }
コード例 #15
0
 private void RestartSystem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0));
     }
     catch (Exception ex)
     {
         Info_field.Visibility = Visibility.Visible;
         Info_field.Text       = ex.Message;
     }
 }
コード例 #16
0
ファイル: MainPage.xaml.cs プロジェクト: Ellerbach/Sprinkler
        private void RebootTimer_Tick(object sender, object e)
        {
            // Save the programs
            Task <bool> t = SprinklerManagement.SavePrograms();

            while (!t.IsCompleted)
            {
                ;
            }
            //reboot the device
            ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0, 0, 5));
        }
コード例 #17
0
        protected override void OnKeyDown(KeyRoutedEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Key == VirtualKey.Home)
            {
                exitCounter++;
                if (exitCounter >= 3)
                {
                    ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
                }
            }

            if (e.Key == VirtualKey.Up)
            {
                isOnRoundTime = true;
            }

            if (e.Key == VirtualKey.Down)
            {
                isOnRoundTime = false;
            }

            if (e.Key == VirtualKey.Enter)
            {
                StartOrPauseTimer();
            }

            if (btnDecreaseTime.IsEnabled && e.Key == VirtualKey.Left && isOnRoundTime)
            {
                DecreaseRoundTime();
            }

            if (btnDecreaseRestTime.IsEnabled && e.Key == VirtualKey.Left && !isOnRoundTime)
            {
                DecreaseRestTime();
            }

            if (btnIncreaseTime.IsEnabled && e.Key == VirtualKey.Right && isOnRoundTime)
            {
                IncreaseRoundTime();
            }

            if (btnIncreaseRestTime.IsEnabled && e.Key == VirtualKey.Right && !isOnRoundTime)
            {
                IncreaseRestTime();
            }

            if (e.Key == VirtualKey.Application)
            {
                ResetTimer();
            }
        }
コード例 #18
0
ファイル: MainPage.xaml.cs プロジェクト: sycomix/Win10Bot
 /// <summary>
 /// IComputerManager implementation
 /// </summary>
 public void ShutdownComputer()
 {
     try
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(1.0));
         Speak("shutting down");
     }
     catch
     {
         Speak("Cannot shut down this computer");
     }
 }
コード例 #19
0
        public async void ShowPowerDialog(ShutdownKind kind)
        {
            var dialog = (kind == ShutdownKind.Restart ? RestartDialog : ShutdownDialog);
            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary && IsIoTDeviceFamily)
            {
                await CommService.DisconnectAsync();

                ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0));
            }
        }
コード例 #20
0
 private void ShutdownHelper(ShutdownKind kind)
 {
     try
     {
         ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0.5));
     }
     catch (Exception e)
     {
         // Catching the exception ensures this doesn't crash the app on non-IOT devices
         Debug.WriteLine("Couldn't begin shutdown: " + e.Message);
     }
 }
コード例 #21
0
        // Browser sends something back
        void OnDataReceived(WebSocket socket, string frame)
        {
            switch (frame)
            {
            case "Client Connected":
                break;

            case "shutdown":
                ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, new TimeSpan(0));
                break;
            }
        }
コード例 #22
0
 /// <summary>
 /// Cancels a pending shutdown or reboot, if one exists
 /// </summary>
 public static void CancelShutdown()
 {
     try
     {
         ShutdownManager.CancelShutdown();
         NetworkUtils.LogNetwork("Shutdown/reboot canceled", MessageType.Warning);
     }
     catch
     {
         NetworkUtils.LogNetwork("Failed to cancel shutdown/reboot: no command exists", MessageType.Warning);
     }
 }
コード例 #23
0
        public void RebootComputer(object target, RoutedEventArgs args)
        {
            Debug.WriteLine("Reboot");

            this.gpio = GpioController.GetDefault();
            if (gpio == null)
            {
                Debug.WriteLine("No ShutdownManager available.");
            }
            else
            {
                ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0));
            }
        }
コード例 #24
0
                #pragma warning disable 1998
        private async Task <MethodResponse> DeviceRebootAsync(MethodRequest methodRequest, object userContext)
        {
            this.logging.LogEvent("Reboot initiated");

            // Stop the image capture timer before reboot
            if (this.imageUpdatetimer != null)
            {
                this.imageUpdatetimer.Change(Timeout.Infinite, Timeout.Infinite);
            }

            ShutdownManager.BeginShutdown(ShutdownKind.Restart, this.deviceRebootDelayPeriod);

            return(new MethodResponse(200));
        }
コード例 #25
0
 private void Btn_SaveIP_Click(object sender, RoutedEventArgs e)
 {
     FindAdapterName();
     ChangePORT();
     ChangeIPAddress(TxtBx_IPChoix.Text);
     if (ChangementEffectue == true)
     {
         ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(5));
         MsgALERTAsync("Le Raspberry va redémarrer dans 5 secondes.");
     }
     else
     {
         MsgALERTAsync("Aucunes modifications n'ont été éffectuées.\nPour Quitter, cliquez sur la croix en haut a droite.");
     }
 }
コード例 #26
0
 private void Shutdown()
 {
     try
     {
         // Shutdowns the device immediately.
         if (ApiInformation.IsTypePresent("Windows.System.ShutdownManager"))
         {
             SoundPlayer.Instance.Play(Sounds.Shutdown);
             ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(3));
         }
     }
     catch
     {
     }
 }
コード例 #27
0
        private async void shutdownPiCommandButton_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog shutdownConfirmDialog = new ContentDialog
            {
                Title             = "Shutdown?",
                Content           = "Do you want to shutdown this RaspberryPi device? (The slider will continue to operate.)",
                PrimaryButtonText = "Shutdown",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await shutdownConfirmDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
            }
        }
コード例 #28
0
        // Button Listener
        private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            if (e.Edge == GpioPinEdge.FallingEdge)
            {
                // This test is here because the user *might* have another HAT plugged in or another circuit that produces a
                // falling-edge signal on another GPIO pin.
                if (sender != clockPin)
                {
                    return;
                }

                // We can get the state of a pin with GPIO.input even when it is currently configured as an output
                // Python: self.sqwave = not GPIO.input(PULSE_PIN)
                GpioPinValue initialValue = (pulsePin.Read() == GpioPinValue.High
                    ? GpioPinValue.Low
                    : GpioPinValue.High);

                // Set pulse pin low before changing it to input to look for shutdown signal
                // Python: GPIO.output(PULSE_PIN, False)
                pulsePin.Write(GpioPinValue.Low);

                // Python: GPIO.setup(PULSE_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
                pulsePin.SetDriveMode(clockPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp)
                    ? GpioPinDriveMode.InputPullUp
                    : GpioPinDriveMode.Input);

                if (pulsePin.Read() == GpioPinValue.Low)
                {
                    counter = counter++;
                    Debug.WriteLine("Lost power, starting shutdown");
                    Task.Delay(new TimeSpan(0, 0, 2));

                    Debug.WriteLine("Shutting down...");

                    // Shutdown the device immediately
                    ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0));
                }
                else
                {
                    counter = 0;
                }

                pulsePin.SetDriveMode(GpioPinDriveMode.Output);
                pulsePin.Write(initialValue);
            }
        }
コード例 #29
0
ファイル: MainPage.xaml.cs プロジェクト: asv850/NADHatWin
        private async void EteindreBTN_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog confirmationExtinction = new ContentDialog()
            {
                Title = "Eteindre ?", PrimaryButtonText = "OK", SecondaryButtonText = "Annuler"
            };

            if (await confirmationExtinction.ShowAsync() == ContentDialogResult.Primary)
            {
                await _nadHat.Eteindre(false);

#if DEBUG
                App.Current.Exit();
#else
                ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, new TimeSpan(0));
#endif
            }
        }
コード例 #30
0
        private async void ShutDown_Click(object sender, RoutedEventArgs e)
        {
            MessageDialog dialog = new MessageDialog("Are you sure you want to Shutdown?");

            dialog.Title = "Shutting Down?";
            dialog.Commands.Add(new UICommand("Yes", null));
            dialog.Commands.Add(new UICommand("No", null));
            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex  = 1;

            var cmd = await dialog.ShowAsync();

            if (cmd.Label == "Yes")
            {
                // Shutdowns the device immediately:
                ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(5));
            }
        }
コード例 #31
0
        public void Shutdown_WhenDetailsHasUnsavedChanges_ReturnsMessage()
        {
            //Arrange
            var mainViewModelMock = Mock.Create<IShell>();
            var detailVM = Mock.Create<IDetailsViewModel>(Behavior.CallOriginal);
            Mock.Arrange(() => detailVM.NeedsExitConfirmation).Returns(true);
            mainViewModelMock.Windows.Add(detailVM);

            var commService = Mock.Create<ICommunicationService>();
            
            var shutdownManager = new ShutdownManager(true) {MainViewModel = mainViewModelMock, CommunicationService = commService};

            //Act
            var result = shutdownManager.Shutdown();

            //Assert
            Assert.IsTrue(result != "false");

        }