Example #1
0
        /// <summary>
        /// Constructor sets up the command
        /// </summary>
        protected BaseEntityViewModel()
        {
            // can only commit if no errors
            CommitCommand = new ActionCommand <object>(
                obj =>
            {
                ValidateAll();

                if (HasErrors)
                {
                    return;
                }

                OnCommitted();

                Committed = true;
            },
                obj => !HasErrors && !Committed);

            // change validity for commit whenever the error condition changes
            ErrorsChanged += (o, e) => CommitCommand.RaiseCanExecuteChanged();

            // any time a property changes that is not the committed flag, reset committed
            PropertyChanged += (o, e) =>
            {
                if (Committed && !e.PropertyName.Equals(ExtractPropertyName(() => Committed)))
                {
                    Committed = false;
                }
            };
        }
Example #2
0
        private void OnStopCommand()
        {
            TimeLeft       = null;
            timer.Enabled  = false;
            IsPaused       = null;
            CanChangedTime = true;

            startCommand.RaiseCanExecuteChanged();
            pauseCommand.RaiseCanExecuteChanged();
            stopCommand.RaiseCanExecuteChanged();
        }
Example #3
0
        private void OnStartCommand()
        {
            try
            {
                if (SelectedHours > 0 || SelectedMinutes > 0)
                {
                    TimeLeft = new TimeSpan(SelectedHours, SelectedMinutes, 0);
                }

                timer.Enabled  = true;
                IsPaused       = false;
                CanChangedTime = false;

                startCommand.RaiseCanExecuteChanged();
                pauseCommand.RaiseCanExecuteChanged();
                stopCommand.RaiseCanExecuteChanged();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public ManipulateSeries3DMvvmViewModel()
        {
            RenderableSeries = new ObservableCollection <IRenderableSeries3DViewModel>();

            SeriesTypes = new ObservableCollection <string>
            {
                "Column Series",
                "Impulse Series",
                "Mountain Series",
                "PointLine Series",
                "SurfaceMesh Series",
                "Waterfall Series",
                "Scatter Series"
            };

            AddCommand = new ActionCommand(() =>
            {
                RenderableSeries.Add(ViewModelFactory3D.New(SelectedType));

                RemoveCommand.RaiseCanExecuteChanged();
                ClearCommand.RaiseCanExecuteChanged();
            });

            RemoveCommand = new ActionCommand(() =>
            {
                RenderableSeries.Remove(RenderableSeries.Last());

                ClearCommand.RaiseCanExecuteChanged();
                RemoveCommand.RaiseCanExecuteChanged();
            }, () => RenderableSeries.Any());

            ClearCommand = new ActionCommand(() =>
            {
                RenderableSeries.Clear();

                ClearCommand.RaiseCanExecuteChanged();
                RemoveCommand.RaiseCanExecuteChanged();
            }, () => RenderableSeries.Any());
        }
 private void RaiseUndoRedoCanExecute()
 {
     _undoCommand.RaiseCanExecuteChanged();
     _redoCommand.RaiseCanExecuteChanged();
 }
        /// <summary>
        /// Constructeur par défaut
        /// </summary>
        public Equipement_LEViewModel()
            : base()
        {
            RemoveSoutirageCommand = new ActionCommand<object>(
                obj => RemoveSoutirage(obj), obj => true);
            NavigateLiaisonCommand = new ActionCommand<object>(
                obj => NavigateToLiaison(obj), obj => true);
            NavigatePortionCommand = new ActionCommand<object>(
                obj => NavigateToPortion(obj), obj => true);
            NavigateSoutirageCommand = new ActionCommand<object>(
                obj => NavigateToSoutirage(obj), obj => true);
            NavigateDrainageCommand = new ActionCommand<object>(
                obj => NavigateToDrainage(obj), obj => true);
            AddSoutirageCommand = new ActionCommand<object>(
                obj => AddSoutirage(), obj => true);
            RemoveDrainageCommand = new ActionCommand<object>(
                obj => RemoveDrainage(obj), obj => true);
            AddDrainageCommand = new ActionCommand<object>(
                obj => AddDrainage(), obj => true);
            ManageSousTypeOuvrageCommand = new ActionCommand<object>(
                obj => ManageSousTypeOuvrage(), obj => GetCanGestionNomsTiers());

            this.OnViewActivated += (o, e) =>
            {
                if (!e.ViewParameter.Any(r => r.Key == "IsTopContainerLoaded"))
                {
                    EventAggregator.Publish("CustomTopContainer".AsViewNavigationArgs().AddNamedParameter("HideContainer", false));
                    EventAggregator.Publish("TypeEquipement".AsViewNavigationArgs().AddNamedParameter("IsTopContainerLoaded", true));
                }
                if (!e.ViewParameter.Any(p => p.Key == "IsExpanderLoaded"))
                {
                    EventAggregator.Publish("CustomExpander".AsViewNavigationArgs().AddNamedParameter("Title", Resources.Resource.EquipementExpanderTitle));
                    EventAggregator.Publish("Equipement_Expander".AsViewNavigationArgs().AddNamedParameter("IsExpanderLoaded", true).AddNamedParameter(Constants.SPECIFIC_VIEWMODEL_NAME, "Equipement_LE"));
                }
                LiaisonsCommunes = null;
            };

            this.OnDetailLoaded += (o, e) =>
            {
                Initialisation();
            };

            this.OnAddedEntity += (o, e) =>
            {
                Initialisation();
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };

            this.OnAllServicesLoaded += (o, e) =>
            {
                RaisePropertyChanged(() => this.TypeNomTiers);
                RaisePropertyChanged(() => this.TypeLiaisons);
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
                ((EqEquipementService)this.service).GetListSoutirageExt(ListSoutirageLoaded);
                ((EqEquipementService)this.service).GetListDrainageExt(ListDrainageLoaded);
            };

            this.OnSaveSuccess += (o, e) =>
            {
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
                ManageSousTypeOuvrageCommand.RaiseCanExecuteChanged();
            };

            this.OnDeleteSuccess += (o, e) =>
            {
                ((EqEquipementService)this.service).GetListPointCommun(ListPointCommunLoaded);
            };

            this.OnViewModeChanged += (o, e) =>
            {
                Initialisation();
            };

            this.OnCanceled += (o, e) =>
            {
                ManageSousTypeOuvrageCommand.RaiseCanExecuteChanged();
            };
        }