public ConnectionConfigurationViewModel(IApplicationServices applicationServices)
        {
            _hartCommunicationService = applicationServices.HartCommunicationService;
            PossiblePortNames         = new ObservableCollection <string>(_hartCommunicationService.PossiblePortNames);

            _selectedPortName = new DataWrapper <string>(this, _selectedPortChangeArgs, () =>
            {
                if (_selectedPortName != null)
                {
                    _hartCommunicationService.PortName = _selectedPortName.DataValue;
                }
            })
            {
                DataValue = _hartCommunicationService.PortName
            };

            _cachedListOfDataWrappers = DataWrapperHelper.GetWrapperProperties(this);

            SaveCommand = new SimpleCommand <object, object>(item =>
            {
                EndEdit();
                CloseActivePopUpCommand.Execute(true);
            });

            CancelCommand = new SimpleCommand <object, object>(item =>
            {
                CancelEdit();
                CloseActivePopUpCommand.Execute(true);
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Executes the save command.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        protected virtual void ExecuteSaveCommand()
        {
            bool saveResult = false;

            try
            {
                if (_item.IsNew)
                {
                    saveResult = this.CreateItem();

                    if (saveResult)
                    {
                        _item.MarkOld();
                        ((IEditableObject)_item).EndEdit();
                        //_item.ApplyEdit();
                        CloseActivePopUpCommand.Execute(true);
                        this.MessageBoxService.ShowInformation("Successfully created new " + typeof(T).Name.ToLower() + ".");

                        // Use the Mediator to send a message to specific data type
                        Mediator.Instance.NotifyColleagues <T>("Created" + typeof(T).Name + "Successfully", (T)_item);
                    }
                    else
                    {
                        throw new Exception("There is problem when saving data!");
                    }
                }
                else
                {
                    if (this.MessageBoxService.ShowYesNo(
                            "Would you like to update item information?",
                            CustomDialogIcons.Question) == CustomDialogResults.Yes)
                    {
                        saveResult = this.UpdateItem();
                        if (saveResult)
                        {
                            ((IEditableObject)_item).EndEdit();
                            //_item.ApplyEdit();
                            CloseActivePopUpCommand.Execute(true);
                            this.MessageBoxService.ShowInformation("Successfully updated " + typeof(T).Name.ToLower() + " information.");

                            // Use the Mediator to send a message to specific data type
                            Mediator.Instance.NotifyColleagues <T>("Updated" + typeof(T).Name + "Successfully", (T)_item);
                        }
                        else
                        {
                            throw new Exception("There is problem when saving data!");
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// ExecuteOkCommand
 /// </summary>
 private void ExecuteOkCommand()
 {
     try
     {
         CloseActivePopUpCommand.Execute(true);
     }
     catch (Exception ex)
     {
         messageBoxService.ShowError("ExecuteOkCommand: " + ex.Message);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// ExecuteCancelCommand
 /// </summary>
 private void ExecuteCancelCommand()
 {
     try
     {
         SelectedPrinter = null;
         CloseActivePopUpCommand.Execute(false);
     }
     catch (Exception ex)
     {
         this.messageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
     }
 }
Esempio n. 5
0
 private void ExecuteSaveImageRatingCommand(Object args)
 {
     if (IsValid)
     {
         CloseActivePopUpCommand.Execute(true);
     }
     else
     {
         NotifyPropertyChanged(isValidChangeArgs);
         RaiseFocusEvent("ImageRating");
         messageBoxService.ShowError("The Rating entered is invalid it must be between 1-5");
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Executes the AddOrderCommand
        /// </summary>
        private void ExecuteAddOrderCommand()
        {
            AddOrderCommand.CommandSucceeded = false;
            addEditOrderVM.CurrentViewMode   = ViewMode.AddMode;
            addEditOrderVM.CurrentCustomer   = CurrentCustomer;
            bool?result = uiVisualizerService.ShowDialog("AddEditOrderPopup", addEditOrderVM);

            if (result.HasValue && result.Value)
            {
                CloseActivePopUpCommand.Execute(true);
            }
            AddOrderCommand.CommandSucceeded = true;
        }
Esempio n. 7
0
        /// <summary>
        /// Executes the cancel command.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        protected virtual void ExecuteCancelCommand()
        {
            try
            {
                (_item as ISupportUndo).CancelEdit();

                (_item as ISupportUndo).BeginEdit();
                //NotifyObjectChanged();
                CloseActivePopUpCommand.Execute(false);
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
        /// <summary>
        /// Executes the CancelOrderCommand
        /// </summary>
        private void ExecuteCancelOrderCommand()
        {
            CancelOrderCommand.CommandSucceeded = false;
            switch (CurrentViewMode)
            {
            case ViewMode.EditMode:
                this.CurrentCustomerOrder.CancelEdit();
                CloseActivePopUpCommand.Execute(false);
                CancelOrderCommand.CommandSucceeded = true;
                break;

            default:
                this.CurrentCustomerOrder.CancelEdit();
                CancelOrderCommand.CommandSucceeded = true;
                break;
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Send command execute.
 /// </summary>
 /// <param name="obj">The obj.</param>
 private void SendCommandExecute(object obj)
 {
     Response = true;
     CloseActivePopUpCommand.Execute(Response);
 }
Esempio n. 10
0
 /// <summary>
 /// Inits the commands.
 /// </summary>
 private void InitCommands()
 {
     SendCommand      = new SimpleCommand <object, object>(CanExecuteSendCommand, SendCommandExecute);
     CancelCommand    = new SimpleCommand <object, object>(obj => CloseActivePopUpCommand.Execute(false));
     ClearDataCommand = new SimpleCommand <object, object>(ClearRawDataCommand);
 }