コード例 #1
0
ファイル: YT_TextBox.cs プロジェクト: 20154530/OS_CD
 private void YT_TextBox_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (!(bool)e.NewValue)
     {
         BindingExpression binding = GetBindingExpression(TextBox.TextProperty);
         binding?.UpdateSource();
         RoutedCommand rcmd = DisableCommand as RoutedCommand;
         if (rcmd != null)
         {
             if (rcmd.CanExecute(CommandParameter, CommandTarget))
             {
                 rcmd.Execute(CommandParameter, CommandTarget);
             }
         }
         else
         {
             if (DisableCommand != null)
             {
                 if (DisableCommand.CanExecute(CommandParameter))
                 {
                     DisableCommand.Execute(CommandParameter);
                 }
             }
         }
     }
 }
コード例 #2
0
        public async Task <IActionResult> Disable(string id, string elt, [FromBody] DisableCommand disableCommand, CancellationToken token)
        {
            try
            {
                disableCommand.CasePlanInstanceId        = id;
                disableCommand.CasePlanElementInstanceId = elt;
                await _mediator.Send(disableCommand, token);

                return(new OkResult());
            }
            catch (UnknownCasePlanInstanceException)
            {
                return(new NotFoundResult());
            }
            catch (UnknownCasePlanElementInstanceException)
            {
                return(this.ToError(new Dictionary <string, string>
                {
                    { "bad_request", "case instance element doesn't exist" }
                }, HttpStatusCode.NotFound, Request));
            }
            catch (AggregateValidationException ex)
            {
                return(this.ToError(ex.Errors, HttpStatusCode.BadRequest, Request));
            }
            catch (Exception ex)
            {
                return(this.ToError(new Dictionary <string, string>
                {
                    { "invalid_request", ex.Message }
                }, HttpStatusCode.BadRequest, Request));
            }
        }
コード例 #3
0
        public void Handle(ProjectionManagementMessage.Command.Disable message)
        {
            var command = new DisableCommand {
                Name  = message.Name,
                RunAs = message.RunAs,
            };

            _writer.PublishCommand("$disable", command);
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: zys0807/VirtualKD
 internal void InvalidateStatus()
 {
     EnableCommand.InvalidateStatus();
     DisableCommand.InvalidateStatus();
     if (PropertyChanged != null)
     {
         PropertyChanged(this, new PropertyChangedEventArgs("Status"));
         PropertyChanged(this, new PropertyChangedEventArgs("Integrated"));
     }
 }
コード例 #5
0
        public void CallsReset()
        {
            var viewModel = Mock.Of <IViewModel>();
            var settings  = Mock.Of <IBeamgunSettings>();
            var command   = new DisableCommand(viewModel, settings);

            command.Execute(null);

            Mock.Get(viewModel).Verify(x => x.Reset());
        }
コード例 #6
0
 private void Disable()
 {
     _pluginService.RemovePublicAssemblies(SelectedAPI.Assemblies);
     _pluginService.SavePluginConfig();
     SelectedAPI.Enabled          = false;
     DisableCommand.SetCanExecute = false;
     EnableCommand.SetCanExecute  = true;
     EnableCommand.RaiseCanExecuteChanged();
     DisableCommand.RaiseCanExecuteChanged();
 }
コード例 #7
0
        public BeamgunViewModel()
        {
            var dictionary      = new RegistryBackedDictionary();
            var beamgunSettings = new BeamgunSettings(dictionary);

            BeamgunState = new BeamgunState(beamgunSettings)
            {
                MainWindowVisibility = Visibility.Hidden
            };
            // TODO: This bi-directional relationship feels bad.
            dictionary.BadCastReport += BeamgunState.AppendToAlert;
            BeamgunState.Disabler     = new Disabler(BeamgunState);
            BeamgunState.Disabler.Enable();
            DisableCommand     = new DisableCommand(this, beamgunSettings);
            TrayIconCommand    = new TrayIconCommand(this);
            LoseFocusCommand   = new DeactivatedCommand(this);
            ResetCommand       = new ResetCommand(this);
            ExitCommand        = new ExitCommand(this);
            ClearAlertsCommand = new ClearAlertsCommand(this);
            _keystrokeHooker   = InstallKeystrokeHooker();
            _usbStorageGuard   = InstallUsbStorageGuard(beamgunSettings);
            _alarm             = InstallAlarm(beamgunSettings);
            _networkWatcher    = new NetworkWatcher(beamgunSettings,
                                                    new NetworkAdapterDisabler(),
                                                    x => BeamgunState.AppendToAlert(x),
                                                    x =>
            {
                _alarm.Trigger(x);
                BeamgunState.SetGraphicsLanAlert();
            },
                                                    () => BeamgunState.Disabler.IsDisabled);
            _keyboardWatcher = new KeyboardWatcher(beamgunSettings,
                                                   new WorkstationLocker(),
                                                   x => BeamgunState.AppendToAlert(x),
                                                   x =>
            {
                _alarm.Trigger(x);
                BeamgunState.SetGraphicsKeyboardAlert();
            },
                                                   () => BeamgunState.Disabler.IsDisabled);
            _mouseWatcher = new MouseWatcher(beamgunSettings,
                                             new WorkstationLocker(),
                                             x => BeamgunState.AppendToAlert(x),
                                             x =>
            {
                _alarm.Trigger(x);
                BeamgunState.SetGraphicsMouseAlert();
            },
                                             () => BeamgunState.Disabler.IsDisabled);
            var checker = new VersionChecker();

            _updateTimer = new VersionCheckerTimer(beamgunSettings,
                                                   checker,
                                                   x => BeamgunState.AppendToAlert(x));
        }
コード例 #8
0
        public void AccountTwoFactorDisable_Execute_ReturnsSuccessMessage()
        {
            _accountService.Setup(s => s.DisableTwoFactor()).Returns(Task.CompletedTask);

            var console = new TestConsole(_output, "y");
            var command = new DisableCommand(console, LoggerMock.GetLogger <DisableCommand>().Object, _accountService.Object);

            var resultMessage = command.Execute();

            Assert.Equal("2fa has been disabled", resultMessage);
        }
コード例 #9
0
        public void CallsDisable()
        {
            const double waitTime  = 100;
            var          viewModel = Mock.Of <IViewModel>();
            var          settings  = Mock.Of <IBeamgunSettings>(x => x.DisableTime == waitTime);
            var          command   = new DisableCommand(viewModel, settings);

            command.Execute(null);

            var lower = DateTime.Now.AddMinutes(waitTime - 1);
            var upper = DateTime.Now.AddMinutes(waitTime + 1);

            Mock.Get(viewModel).Verify(x => x.DisableUntil(It.IsInRange(lower, upper, Range.Exclusive)));
        }
コード例 #10
0
        private void Enable()
        {
            var termsDialog = new TermsDialog();

            var result = termsDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                _pluginService.AddPublicAssemblies(SelectedAPI.Assemblies);
                _pluginService.SavePluginConfig();
                SelectedAPI.Enabled          = true;
                EnableCommand.SetCanExecute  = false;
                DisableCommand.SetCanExecute = true;
                EnableCommand.RaiseCanExecuteChanged();
                DisableCommand.RaiseCanExecuteChanged();
            }
        }
コード例 #11
0
        public void Should_Disable_Unschedule_And_Save()
        {
            var settingsStore = Substitute.For <ISettingsStore>();
            var jobScheduler  = Substitute.For <IJobScheduler>();

            var item    = new Dummy();
            var command = new DisableCommand(item);
            var handler = new DisableCommandHandler(settingsStore, jobScheduler);

            handler.Handle(command);

            Assert.IsFalse(item.IsEnabled);

            settingsStore.Received().TrySave();

            jobScheduler.Received().Disable(item);
        }
コード例 #12
0
ファイル: App.cs プロジェクト: andersmandersen/harbor
 public App(ServicesCollector services,
            EnableCommand enableCommand,
            ListCommand listCommand,
            StopCommand stopCommand,
            StartCommand startCommand,
            HelpCommand helpCommand,
            DisableCommand disableCommand,
            LogCommand logCommand)
 {
     this.services       = services;
     this.enableCommand  = enableCommand;
     this.listCommand    = listCommand;
     this.stopCommand    = stopCommand;
     this.startCommand   = startCommand;
     this.helpCommand    = helpCommand;
     this.disableCommand = disableCommand;
     this.logCommand     = logCommand;
 }
コード例 #13
0
        public void Should_Disable_FolderItems()
        {
            var settingsStore = Substitute.For <ISettingsStore>();
            var jobScheduler  = Substitute.For <IJobScheduler>();

            var folder = new Folder();
            var item   = new Dummy();

            folder.Add(item);

            var command = new DisableCommand(folder);
            var handler = new DisableCommandHandler(settingsStore, jobScheduler);

            handler.Handle(command);

            Assert.IsTrue(item.IsDisabled);
            Assert.IsTrue(folder.IsDisabled);

            settingsStore.Received().TrySave();

            jobScheduler.Received(1).Disable(item);
            jobScheduler.DidNotReceive().Disable(folder);
        }
コード例 #14
0
        public BeamgunViewModel(Window mainWindow)
        {
            BeamgunState = new BeamgunState
            {
                MainWindowVisibility = Visibility.Hidden
            };
            BeamgunState.Disabler = new Disabler(BeamgunState);
            BeamgunState.Disabler.Enable();
            DisableCommand     = new DisableCommand(this);
            TrayIconCommand    = new TrayIconCommand(this);
            LoseFocusCommand   = new DeactivatedCommand(this);
            ResetCommand       = new ResetCommand(this);
            ExitCommand        = new ExitCommand(this);
            _workstationLocker = new WorkstationLocker();

            const uint repeatInterval = 10;
            var        converter      = new KeyConverter();

            _keystrokeHooker = new KeystrokeHooker();

            _alarm = new Alarm(repeatInterval, BeamgunState);
            _alarm.AlarmCallback += () =>
            {
                BeamgunState.MainWindowState      = WindowState.Normal;
                BeamgunState.MainWindowVisibility = Visibility.Visible;
                BeamgunState.SetGraphicsAlert();
                if (BeamgunState.StealFocus)
                {
                    StealFocus();
                }
            };

            var windowHandle = new WindowInteropHelper(mainWindow).Handle;

            _usbMonitor              = new UsbMonitor(windowHandle);
            _usbMonitor.DeviceAdded += () =>
            {
                BeamgunState.AppendToAlert("USB device inserted.");
                _alarm.Trigger("Alerting on USB device insertion.");
                if (!BeamgunState.LockWorkStation)
                {
                    return;
                }
                var result  = _workstationLocker.Lock();
                var message = result ? "Successfully locked the workstation." : "Could not lock the workstation.";
                BeamgunState.AppendToAlert(message);
            };
            _usbMonitor.DeviceRemoved += () =>
            {
                BeamgunState.AppendToAlert("USB device removed.");
            };

            _keystrokeHooker.Callback += key =>
            {
                if (!_alarm.Triggered)
                {
                    return;
                }
                BeamgunState.AppendToKeyLog(converter.Convert(key));
            };
        }
コード例 #15
0
 public Task <ICommandResponse <DisableCommand> > DisableCommand(DisableCommand command)
 {
     this.IsEnable = false;
     return(Task.FromResult <ICommandResponse <DisableCommand> >(new DisableCommandResponse()));
 }
コード例 #16
0
 public async Task <ActionResult <IdentityResult> > Disable([FromBody] DisableCommand command)
 {
     return(await Mediator.Send(command));
 }
コード例 #17
0
            public Task PublishExternalEvt(string evt, string casePlanInstanceId, string casePlanElementInstanceId, Dictionary <string, string> parameters, CancellationToken token)
            {
                IBaseRequest request = null;

                switch (evt)
                {
                case CMMNConstants.ExternalTransitionNames.AddChild:
                    request = new AddChildCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Close:
                    request = new CloseCommand(casePlanInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Complete:
                    request = new CompleteCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Disable:
                    request = new DisableCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Occur:
                    request = new OccurCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Reactivate:
                    request = new ReactivateCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Reenable:
                    request = new ReenableCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Resume:
                    request = new ResumeCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Suspend:
                    request = new SuspendCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.Terminate:
                    request = new TerminateCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;

                case CMMNConstants.ExternalTransitionNames.ManualStart:
                    request = new ActivateCommand(casePlanInstanceId, casePlanElementInstanceId)
                    {
                        Parameters = parameters
                    };
                    break;
                }

                return(_mediator.Send(request, token));
            }
コード例 #18
0
        public void IsExecutable()
        {
            var command = new DisableCommand(Mock.Of <IViewModel>(), Mock.Of <IBeamgunSettings>());

            command.CanExecute(null).ShouldBeTrue();
        }