void AddRemoveFaseCommand_Executed(object prm)
        {
            FaseCyclusModuleViewModel fcmvm = prm as FaseCyclusModuleViewModel;

            SelectedFaseCyclus = fcmvm;
            if (fcmvm.CanBeAddedToModule && !fcmvm.IsInModule)
            {
                ModuleFaseCyclusModel mfcm = new ModuleFaseCyclusModel();
                mfcm.FaseCyclus = fcmvm.Define;
                ModuleFaseCyclusViewModel mfcvm = new ModuleFaseCyclusViewModel(mfcm);
                mfcvm.FaseCyclusNaam = fcmvm.Naam;
                SelectedModule.Fasen.Add(mfcvm);
                SelectedModule.Fasen.BubbleSort();
            }
            else if (fcmvm.IsInModule)
            {
                // Use custom method instead of Remove method:
                // it removes based on Define instead of reference
                SelectedModule.RemoveFase(fcmvm.Define);
                SelectedModule.Fasen.BubbleSort();
            }
            foreach (FaseCyclusModuleViewModel _fcmvm in Fasen)
            {
                _fcmvm.UpdateModuleInfo();
            }
        }
Esempio n. 2
0
        void AddRemoveFaseCommand_Executed(object prm)
        {
            FaseCyclusModuleViewModel fcmvm = prm as FaseCyclusModuleViewModel;

            SelectedFaseCyclus = fcmvm;
            if (SelectedModule != null)
            {
                if (fcmvm.CanBeAdded && !fcmvm.IsIn)
                {
                    ModuleFaseCyclusModel mfcm = new ModuleFaseCyclusModel();
                    mfcm.FaseCyclus = fcmvm.Naam;
                    ModuleFaseCyclusViewModel mfcvm = new ModuleFaseCyclusViewModel(mfcm);
                    SelectedModule.Fasen.Add(mfcvm);
                    SelectedModule.Fasen.BubbleSort();
                }
                else if (fcmvm.IsIn)
                {
                    // Use custom method instead of Remove method:
                    // it removes based on Define instead of reference
                    SelectedModule.RemoveFase(fcmvm.Naam);
                    SelectedModule.Fasen.BubbleSort();
                }
            }
            else if (SelectedModuleFase != null)
            {
                if (fcmvm.CanBeAdded && !fcmvm.IsIn)
                {
                    ModuleFaseCyclusAlternatiefModel afcm = new ModuleFaseCyclusAlternatiefModel();
                    afcm.FaseCyclus = fcmvm.Naam;
                    SelectedModuleFase.Alternatieven.Add(new ModuleFaseCyclusAlternatiefViewModel(afcm));
                    SelectedModuleFase.Alternatieven.BubbleSort();
                }
                else if (fcmvm.IsIn)
                {
                    // Use custom method instead of Remove method:
                    // it removes based on Define instead of reference
                    var rafcm = SelectedModuleFase.Alternatieven.FirstOrDefault(x => x.FaseCyclus == fcmvm.Naam);
                    if (rafcm != null)
                    {
                        SelectedModuleFase.Alternatieven.Remove(rafcm);
                    }
                    SelectedModuleFase.Alternatieven.BubbleSort();
                }
            }
            foreach (FaseCyclusModuleViewModel _fcmvm in Fasen)
            {
                if (SelectedModuleFase != null ||
                    _Controller.ModuleMolen.Modules.Any(x => x.Fasen.Any(x2 => x2.FaseCyclus == _fcmvm.Naam)))
                {
                    _fcmvm.HasModule = true;
                }
                else
                {
                    _fcmvm.HasModule = false;
                }
                _fcmvm.UpdateModuleInfo();
            }
            MessengerInstance.Send(new ControllerDataChangedMessage());
        }