コード例 #1
0
        public DeviceViewModel()
        {
            _deviceService = ServiceFactory.CreateDeviceService;
            _deviceService.DevicesChange   += UpdateDevices;
            _deviceService.OnDeviceChanged += UpdateDevice;
            _devices    = new ObservableCollection <DeviceDTO>();
            _editDevice = false;

            NavigationViewModel.ConnectionEstablishedEvent += RequestDevices;
            NavigationViewModel.ConnectionLostEvent        += CleanDevices;

            NewDeviceCommand    = new NewDeviceCommand(this);
            ToggleDeviceCommand = new ToggleDeviceCommand(this);
            SaveDeviceCommand   = new AddDeviceCommand(this);
            EditDeviceCommand   = new EditDeviceCommand(this);
            DeleteDeviceCommand = new MessageBoxCommand(new DeleteDeviceCommand(this), null, "Do you really want to delete this device?");
        }
コード例 #2
0
 protected override void InitializeView(IClientController clientController, ICrossViewManager crossViewManager)
 {
     _messageBoxCommand = clientController.Commander.GetCommand <MessageBoxCommand>();
 }
コード例 #3
0
        public override void RunCommand(object sender)
        {
            var engine = (Core.Automation.Engine.AutomationEngineInstance)sender;


            if (engine.tasktEngineUI == null)
            {
                engine.ReportProgress("UserInput Supported With UI Only");
                System.Windows.Forms.MessageBox.Show("UserInput Supported With UI Only", "UserInput Command", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return;
            }


            //create clone of original
            var clonedCommand = taskt.Core.Common.Clone(this);

            //translate variable
            clonedCommand.v_InputHeader     = clonedCommand.v_InputHeader.ConvertToUserVariable(sender);
            clonedCommand.v_InputDirections = clonedCommand.v_InputDirections.ConvertToUserVariable(sender);

            //translate variables for each label
            foreach (DataRow rw in clonedCommand.v_UserInputConfig.Rows)
            {
                rw["Label"] = rw["Label"].ToString().ConvertToUserVariable(sender);

                var targetVariable = rw["ApplyToVariable"] as string;

                if (string.IsNullOrEmpty(targetVariable))
                {
                    var newMessage = new MessageBoxCommand();
                    newMessage.v_Message        = "User Input question '" + rw["Label"] + "' is missing variables to apply results to! Results for the item will not be tracked.  To fix this, assign a variable in the designer!";
                    newMessage.v_AutoCloseAfter = 10;
                    newMessage.RunCommand(sender);
                }
            }


            //invoke ui for data collection
            var result = engine.tasktEngineUI.Invoke(new Action(() =>
            {
                //get input from user
                var userInputs = engine.tasktEngineUI.ShowInput(clonedCommand);

                //check if user provided input
                if (userInputs != null)
                {
                    //loop through each input and assign
                    for (int i = 0; i < userInputs.Count; i++)
                    {
                        //get target variable
                        var targetVariable = v_UserInputConfig.Rows[i]["ApplyToVariable"] as string;


                        //if engine is expected to create variables, the user will not expect them to contain start/end markers
                        //ex. {vAge} should not be created, vAge should be created and then called by doing {vAge}
                        if ((!string.IsNullOrEmpty(targetVariable)) && (engine.engineSettings.CreateMissingVariablesDuringExecution))
                        {
                            //remove start markers
                            if (targetVariable.StartsWith(engine.engineSettings.VariableStartMarker))
                            {
                                targetVariable = targetVariable.TrimStart(engine.engineSettings.VariableStartMarker.ToCharArray());
                            }

                            //remove end markers
                            if (targetVariable.EndsWith(engine.engineSettings.VariableEndMarker))
                            {
                                targetVariable = targetVariable.TrimEnd(engine.engineSettings.VariableEndMarker.ToCharArray());
                            }
                        }


                        //store user data in variable
                        if (!string.IsNullOrEmpty(targetVariable))
                        {
                            userInputs[i].StoreInUserVariable(sender, targetVariable);
                        }
                    }
                }
            }

                                                                ));
        }