Exemplo n.º 1
0
 public FirmwareUpdate()
 {
     InitializeComponent();
     updateClickCommand = UpdateCommand.AttachCommand(ExecuteUpdateFirmware, CanUpdateFirmware);
     ConsoleOutput.ProcessInterface.OnProcessExit  += ProcessInterface_OnProcessExit;
     ConsoleOutput.ProcessInterface.OnProcessError += ProcessInterface_OnProcessError;
 }
Exemplo n.º 2
0
        private void SetupDialogForm_Load(object sender, EventArgs e)
        {
            var observableClientStatus = Observable.FromEventPattern <EventArgs>(
                handler => SharedResources.ConnectionManager.ClientStatusChanged += handler,
                handler => SharedResources.ConnectionManager.ClientStatusChanged -= handler);

            updateClickCommand = FirmwareUpdateCommand.AttachCommand(ExecuteFirmwareUpdate, CanUpdateFirmware);
            observableClientStatus.ObserveOn(SynchronizationContext.Current)
            .Subscribe(item => updateClickCommand.CanExecuteChanged());
            int  onlineClients = SharedResources.ConnectionManager.OnlineClientCount;
            bool enableDisconnectedControls = onlineClients == 0;

            if (onlineClients == 0)
            {
                communicationSettingsControl1.Enabled = true;
                ConnectionErrorProvider.SetError(communicationSettingsControl1, string.Empty);
            }
            else
            {
                communicationSettingsControl1.Enabled = false;
                ConnectionErrorProvider.SetError(
                    communicationSettingsControl1,
                    "Connection settings cannot be changed while there are connected clients");
            }

            RotatorParametersGroup.Enabled       = enableDisconnectedControls;
            ShutterParametersGroup.Enabled       = enableDisconnectedControls;
            RotatorRampTimeCurrentValue.Text     = RotatorRampTimeTrackBar.Value.ToString();
            RotatorSpeedCurrentValue.Text        = RotatorMaximumSpeedTrackBar.Value.ToString();
            ShutterMaximumSpeedCurrentValue.Text = ShutterMaximumSpeedTrackBar.Value.ToString();
            ShutterRampTimeCurrentValue.Text     = ShutterAccelerationRampTimeTrackBar.Value.ToString();
            SetControlAppearance();
        }
Exemplo n.º 3
0
        public static ClickCommand AttachCommand(
            this Control clickableControl,
            Action execute,
            Func <bool> canExecute = null)
        {
            var command = new ClickCommand(clickableControl, execute, canExecute);

            command.CanExecuteChanged();
            return(command);
        }