Exemple #1
0
        private async Task StartService(ServiceViewModel service, bool start)
        {
            try {
                var svc = service.Service;
                IsBusy = true;
                if (start)
                {
                    svc.Start();
                }
                else
                {
                    svc.Stop();
                }
                await Task.Run(() => {
                    svc.WaitForStatus(start ? ServiceControllerStatus.Running : ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(10));
                });
            }
            catch (System.ServiceProcess.TimeoutException) {
                UI.MessageBoxService.ShowMessage("Operation timed out.", Constants.AppName);
            }
            catch (Exception ex) {
                UI.MessageBoxService.ShowMessage($"Error: {ex.Message}", Constants.AppName);
            }
            finally {
                IsBusy = false;

                service.Refresh();
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            }
        }
Exemple #2
0
 private void RefreshCamCommands()
 {
     ScanCommand.RaiseCanExecuteChanged();
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     RefreshCommand.RaiseCanExecuteChanged();
 }
Exemple #3
0
 private void RaiseButtonsCommandsCanExecuteChanged()
 {
     RaisePropertyChanged(nameof(AreButtonsEnabled));
     PlayCommand.RaiseCanExecuteChanged();
     PauseCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
 }
Exemple #4
0
 private void StopwatchStateChanged()
 {
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     ResetCommand.RaiseCanExecuteChanged();
     LapCommand.RaiseCanExecuteChanged();
 }
        private void RefreshCommandExecuteStatus()
        {
            ConnectCommand.RaiseCanExecuteChanged();

            ClearAlarmCommand.RaiseCanExecuteChanged();

            SendGCodeFileCommand.RaiseCanExecuteChanged();
            StartProbeCommand.RaiseCanExecuteChanged();
            StartProbeHeightMapCommand.RaiseCanExecuteChanged();
            StopCommand.RaiseCanExecuteChanged();
            PauseCommand.RaiseCanExecuteChanged();

            SoftResetCommand.RaiseCanExecuteChanged();
            HomingCycleCommand.RaiseCanExecuteChanged();
            FeedHoldCommand.RaiseCanExecuteChanged();
            CycleStartCommand.RaiseCanExecuteChanged();

            EmergencyStopCommand.RaiseCanExecuteChanged();

            LaserOnCommand.RaiseCanExecuteChanged();
            LaserOffCommand.RaiseCanExecuteChanged();
            SpindleOnCommand.RaiseCanExecuteChanged();
            SpindleOffCommand.RaiseCanExecuteChanged();

            GotoFavorite1Command.RaiseCanExecuteChanged();
            GotoFavorite2Command.RaiseCanExecuteChanged();
            SetFavorite1Command.RaiseCanExecuteChanged();
            SetFavorite2Command.RaiseCanExecuteChanged();
            GotoWorkspaceHomeCommand.RaiseCanExecuteChanged();
            SetWorkspaceHomeCommand.RaiseCanExecuteChanged();
        }
 void StatusUpdate()
 {
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     Time   = _connectionController.TimeSeconds;
     Amount = _connectionController.Amount;
     Status = _connectionController.Status;
 }
        private void RaiseCanExecuteChanged()
        {
            StartCommand.RaiseCanExecuteChanged();
            StopCommand.RaiseCanExecuteChanged();
            SettingsCommand.RaiseCanExecuteChanged();

            RaiseCanExecuteIncrDecrChanged();
        }
Exemple #8
0
 private void pingable_PingStatsUpdated(object sender, EventArgs e)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         StartCommand.RaiseCanExecuteChanged();
         StopCommand.RaiseCanExecuteChanged();
     });
 }
Exemple #9
0
 private void RaiseCanExecute()
 {
     StartCommand.RaiseCanExecuteChanged();
     RestoreCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     SuspendCommand.RaiseCanExecuteChanged();
     ResumeCommand.RaiseCanExecuteChanged();
 }
Exemple #10
0
 private void RaiseCommandCanExecuteChanged()
 {
     PlayCommand.RaiseCanExecuteChanged();
     PauseCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     NextCommand.RaiseCanExecuteChanged();
     PreviousCommand.RaiseCanExecuteChanged();
     RaisePropertyChanged(nameof(CurrentMedia));
 }
Exemple #11
0
 private void Stop(object o)
 {
     IsNotStarted = true;
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     token.Cancel();
     token.Dispose();
     token = new CancellationTokenSource();
     //MessageBox.Show("Stop dupa");
 }
Exemple #12
0
        private void UpdateCommands()
        {
            RemoveSelectedVideoCommand.RaiseCanExecuteChanged();
            AddMarkerCommand.RaiseCanExecuteChanged();
            RemoveSelectedMarkerCommand.RaiseCanExecuteChanged();

            PlayCommand.RaiseCanExecuteChanged();
            PauseCommand.RaiseCanExecuteChanged();
            StopCommand.RaiseCanExecuteChanged();
            Plus5Command.RaiseCanExecuteChanged();
            Minus5Command.RaiseCanExecuteChanged();
        }
Exemple #13
0
 public void StartCounter()
 {
     Background = Brushes.White;
     Current    = StartTime;
     if (_cancelationSource == null)
     {
         _cancelationSource = new CancellationTokenSource();
         RunPeriodic(100, _cancelationSource.Token, UpdateCounter).ConfigureAwait(true);
         StopCommand.RaiseCanExecuteChanged();
         StartCommand.RaiseCanExecuteChanged();
     }
 }
Exemple #14
0
        private async void OnStop()
        {
            _captureStarted = false;
            capture.Dispose();
            capture = null;

            //PipelineResult = new PipelineResult();
            StartCommand.RaiseCanExecuteChanged();
            StopCommand.RaiseCanExecuteChanged();
            TakeScreenShotCommand.RaiseCanExecuteChanged();
            CalibrateColorSkinCommand.RaiseCanExecuteChanged();
            ActivateCalibrateColorSkinCommand.RaiseCanExecuteChanged();
        }
        internal void ExecuteTurnCard(object param = null)
        {
            var isCurrentCardVisibleBefore = IsCurrentCardVisible;
            var canExecuteStop             = CanExecuteStop();
            var canExecute = CanExecuteTurnCard(param);

            if (IsNoCardTurnedYet())
            {
                _timeTracker.Start();
            }
            else
            {
                CardsSeen.Add(CurrentCard);
            }


            if (_deck.HasMoreCards())
            {
                _deck.TurnCard();
                CurrentCard = _deck.CurrentCard;
            }
            else
            {
                CurrentCard = null;
            }


            RaisePropertyChanged("CardsNotSeenCount");

            if (canExecute != CanExecuteTurnCard(param))
            {
                TurnCardCommand.RaiseCanExecuteChanged();
            }

            if (isCurrentCardVisibleBefore != IsCurrentCardVisible)
            {
                RaisePropertyChanged("IsCurrentCardVisible");
            }

            if (canExecuteStop != CanExecuteStop())
            {
                StopCommand.RaiseCanExecuteChanged();
            }

            if (!_deck.HasMoreCards())
            {
                RaisePropertyChanged("IsLastCard");
            }
        }
Exemple #16
0
        private void Runner_ExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                switch (e.ExecutionState)
                {
                case ExecutionState.Stopped:
                    ProgramCode.HighlightedLineNumber = 0;
                    ProgramInteraction.HideInputPrompt();
                    break;

                case ExecutionState.Paused:
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = runner.LineNumber;
                        ProgramInteraction.HideInputPrompt();
                    }
                    else
                    {
                        // Want to run at full speed
                        runner.ExecuteNextLine();
                    }
                    break;

                case ExecutionState.Running:
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = 0;
                        ProgramInteraction.HideInputPrompt();
                    }
                    break;

                case ExecutionState.WaitingForInput:
                    ProgramInteraction.ShowInputPrompt(!string.IsNullOrWhiteSpace(runner.Prompt) ? runner.Prompt : "Please enter your response:");
                    if (SingleStepMode)
                    {
                        ProgramCode.HighlightedLineNumber = runner.LineNumber;
                    }
                    break;
                }

                OnPropertyChanged(nameof(ExecutionState));
                GoCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            });
        }
Exemple #17
0
 private async void Start(object o)
 {
     IsNotStarted = false;
     StopCommand.RaiseCanExecuteChanged();
     StartCommand.RaiseCanExecuteChanged();
     trigger.InputDevice  = selectedRecordDevice;
     trigger.OutputDevide = selectedPlayDevice;
     trigger.SetUpTrigger(selectedMode, selectedRecordDevice, selectedPlayDevice, treshold, minimalInterval, sameInterval, intervalCountEnabled, intervalCount, intervals, duration, delay, token.Token);
     try
     {
         await trigger.StartTrigger();
     }
     catch (OperationCanceledException)
     {
     }
     Stop(null);
     //MessageBox.Show("Dupa");
 }
Exemple #18
0
        public MainViewModel()
        {
            var app = App.Current as App;

            app.TimerEnableChanged += (s, a) =>
            {
                TimerEnabled = a.TimerEnabled;
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
                TimerStatusMessage = "Web Chacker: " + (TimerEnabled ? "Enabled" : "Disabled");
            };

            app.Pulsed += (s, a) =>
            {
                WorkingTimeMessage = a.WorkingMinutes != 1
                    ? $"Working: {a.WorkingMinutes} times (Last pulse: {DateTime.Now})"
                    : $"Working: {a.WorkingMinutes} time (Last pulse: {DateTime.Now})";
            };
        }
Exemple #19
0
        public async void ExecuteStartCommand()
        {
            BeginDialog dialog = new BeginDialog();
            await dialog.ShowAsync();

            if (dialog.DiagResult == ContentDialogResult.Primary)
            {
                CurrentTripDataRepo.DriveValue = EnumHelper.DeParse(DriveStateStatus.TripStarted);
                smartTimer.StopTimer();
                upTimer.Start();

                if (SelectedTripData.IsTripStarted != true)
                {
                    SelectedTripData.TripStartTime = CurrentTripDataRepo.StartTime = DateTime.Now;
                    SelectedTripData.IsTripStarted = CurrentTripDataRepo.IsTripStarted = true;
                    tripDataManager.SaveTrip(SelectedTripData);
                }

                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            }
        }
Exemple #20
0
        private async Task Load()
        {
            capture = new VideoCapture();
            capture.Open(0, VideoCaptureAPIs.ANY);
            if (!capture.IsOpened())
            {
                return;
            }
            else
            {
                //backSub = OpenCvSharp.BackgroundSubtractorMOG.Create();
                _currentFrame = (await ReadVideoStreamAsync());
                //EqualizeHistogramFilter filter = new EqualizeHistogramFilter(new EqualizeHistogramConfig { IsActive = true });
                //filter.Apply(colorMat);
                await GetBackground();

                _captureStarted = true;
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
                TakeScreenShotCommand.RaiseCanExecuteChanged();
                CalibrateBackgroundCommand.RaiseCanExecuteChanged();
                CalibrateColorSkinCommand.RaiseCanExecuteChanged();
                ActivateCalibrateColorSkinCommand.RaiseCanExecuteChanged();
                Tracker.RunAsync();
                while (_captureStarted)
                {
                    _currentFrame = await ReadVideoStreamAsync();


                    await Pipeline.RunAsync(_currentFrame);

                    //Tracker.Tracker.DetectHandFrom(Pipeline);

                    DisplayOutput(Pipeline, Tracker, _showDebug);
                    FrameRate.Tick();
                }
            }
        }
Exemple #21
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            if (suspensionState.Any())
            {
                // use cache value(s)
                if (suspensionState.ContainsKey(nameof(SelectedTripData)))
                {
                    SelectedTripData = suspensionState[nameof(SelectedTripData)] as TripData;
                }
                // clear any cache
                suspensionState.Clear();
            }
            else
            {
                // use navigation parameter
                if (parameter.GetType().Equals(typeof(TripData)))
                {
                    SelectedTripData = parameter as TripData;
                }
            }

            ApplicationView.GetForCurrentView().TryEnterFullScreenMode();

            if (SelectedTripData.IsTripStarted == true)
            {
                CurrentTripDataRepo.DriveValue  = EnumHelper.DeParse(DriveStateStatus.TripStarted);
                CurrentTripDataRepo.StartTime   = SelectedTripData.TripStartTime;
                CurrentTripDataRepo.CurrentUser = SelectedTripData.CustomerName;
                smartTimer.StopTimer();
                upTimer.Start();
                CurrentTripDataRepo.IsTripStarted = true;
                StartCommand.RaiseCanExecuteChanged();
                StopCommand.RaiseCanExecuteChanged();
            }
            else
            {
                CurrentTripDataRepo.CurrentUser          = SelectedTripData.CustomerName;
                CurrentTripDataRepo.CurrentPickupMunites = Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes) <= 0 ?
                                                           0.0 : Math.Round((SelectedTripData.TripStartTime - DateTime.Now).TotalMinutes);

                smartTimer.StartTimer(() =>
                {
                    if (CurrentTripDataRepo.CurrentPickupMunites != 0)
                    {
                        CurrentTripDataRepo.CurrentPickupMunites--;
                    }
                    else
                    {
                        smartTimer.StopTimer();
                    }
                });
            }

            geoLocationService.DesiredAccuracyInMeters = 10;
            geoLocationService.MovementThreshold       = 5;
            var initializationSuccessful = await geoLocationService.InitializeAsync();

            if (initializationSuccessful)
            {
                await geoLocationService.StartListeningAsync();

                CurrentTripDataRepo.CurrentUserPosition = geoLocationService.CurrentPosition;
                if (geoLocationService.IsGeolocationAvailable)
                {
                    CurrentTripDataRepo.IsPositonAvailable = true;
                }
            }

            if (geoLocationService.IsListening)
            {
                geoLocationService.PositionChanged += GeoLocationService_PositionChanged;
            }

            NavigationService.FrameFacade.BackRequested += FrameFacade_BackRequested;
            await Task.CompletedTask;
        }
 public void CommandsRaiseCanExecuteChanged(object sender, EventArgs e)
 {
     PlayCommand.RaiseCanExecuteChanged();
     PauseCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
 }
Exemple #23
0
 private void UpdateCommands()
 {
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
     ClearCommand.RaiseCanExecuteChanged();
 }
Exemple #24
0
 private void UpdateButtons()
 {
     PlayCommand.RaiseCanExecuteChanged();
     PauseCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
 }
Exemple #25
0
 private void ItemsView_CurrentChanged(object sender, EventArgs e)
 {
     StartCommand.RaiseCanExecuteChanged();
     StopCommand.RaiseCanExecuteChanged();
 }
Exemple #26
0
        private void UpdateCommandStatus()
        {
            switch (State)
            {
            default:
            case DeviceState.NotConnected:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.Idle:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.Disposed:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.LaunchingApplication:
                CanPlay = false; CanPause = false; CanStop = false;
                break;

            case DeviceState.LaunchedApplication:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.LoadingMedia:
                CanPlay = false; CanPause = false; CanStop = true;
                break;

            case DeviceState.Buffering:
                CanPlay = false; CanPause = false; CanStop = true;
                break;

            case DeviceState.Playing:
                CanPlay = false; CanPause = true; CanStop = true;
                break;

            case DeviceState.Paused:
                CanPlay = true; CanPause = false; CanStop = true;
                break;

            case DeviceState.ConnectError:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.LoadFailed:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.LoadCancelled:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.InvalidRequest:
                CanPlay = true; CanPause = false; CanStop = false;
                break;

            case DeviceState.Closed:
                CanPlay = true; CanPause = false; CanStop = false;
                break;
            }

            PlayCommand.RaiseCanExecuteChanged();
            StopCommand.RaiseCanExecuteChanged();
            PauseCommand.RaiseCanExecuteChanged();
        }