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);
            });
        }
コード例 #2
0
ファイル: ItemViewModelBase.cs プロジェクト: xuanhnvt/XRMS
        /// <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);
            }
        }
コード例 #3
0
 /// <summary>
 /// ExecuteOkCommand
 /// </summary>
 private void ExecuteOkCommand()
 {
     try
     {
         CloseActivePopUpCommand.Execute(true);
     }
     catch (Exception ex)
     {
         messageBoxService.ShowError("ExecuteOkCommand: " + ex.Message);
     }
 }
コード例 #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);
     }
 }
コード例 #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");
     }
 }
コード例 #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;
        }
コード例 #7
0
ファイル: ItemViewModelBase.cs プロジェクト: xuanhnvt/XRMS
        /// <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);
            }
        }
コード例 #8
0
        /// <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;
            }
        }
コード例 #9
0
 /// <summary>
 /// Send command execute.
 /// </summary>
 /// <param name="obj">The obj.</param>
 private void SendCommandExecute(object obj)
 {
     Response = true;
     CloseActivePopUpCommand.Execute(Response);
 }
コード例 #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);
 }