예제 #1
0
        public ModuleViewModel(ControllerModel c, ModuleModel module)
        {
            _Module = module;

            foreach (ModuleFaseCyclusModel mfcm in module.Fasen)
            {
                // Create ViewModel
                ModuleFaseCyclusViewModel mfcvm = new ModuleFaseCyclusViewModel(mfcm);

                // Find the friendly name of the FaseCyclus
                foreach (FaseCyclusModel fcm in c.Fasen)
                {
                    if (fcm.Define == mfcvm.FaseCyclusDefine)
                    {
                        mfcvm.FaseCyclusNaam = fcm.Naam;
                        break;
                    }
                }

                // Add to list
                Fasen.Add(mfcvm);
            }
            Fasen.BubbleSort();
            Fasen.CollectionChanged += Fasen_CollectionChanged;
        }
        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();
            }
        }
예제 #3
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());
        }
예제 #4
0
        public ModuleViewModel(ModuleModel module)
        {
            _Module = module;

            foreach (ModuleFaseCyclusModel mfcm in module.Fasen)
            {
                // Create ViewModel
                ModuleFaseCyclusViewModel mfcvm = new ModuleFaseCyclusViewModel(mfcm);

                // Add to list
                Fasen.Add(mfcvm);
            }
            Fasen.BubbleSort();
            Fasen.CollectionChanged += Fasen_CollectionChanged;
        }
예제 #5
0
        public void RemoveFase(string fcdefine)
        {
            ModuleFaseCyclusViewModel _fc = null;

            foreach (ModuleFaseCyclusViewModel fc1 in Fasen)
            {
                if (fc1.FaseCyclusNaam == fcdefine)
                {
                    _fc = fc1;
                }
            }
            if (_fc != null)
            {
                Fasen.Remove(_fc);
            }
        }
        public int CompareTo(object obj)
        {
            ModuleFaseCyclusViewModel fcvm = obj as ModuleFaseCyclusViewModel;

            if (fcvm == null)
            {
                throw new NotImplementedException();
            }
            else
            {
                string myName  = FaseCyclusDefine;
                string hisName = fcvm.FaseCyclusDefine;
                if (myName.Length < hisName.Length)
                {
                    myName = myName.PadLeft(hisName.Length, '0');
                }
                else if (hisName.Length < myName.Length)
                {
                    hisName = hisName.PadLeft(myName.Length, '0');
                }
                return(myName.CompareTo(hisName));
            }
        }
예제 #7
0
 public void SetSelectedModuleFase(ModuleFaseCyclusViewModel mvm)
 {
     _FasenLijstVM.SelectedModuleFase = mvm;
 }