private void UpdateDetectoren()
 {
     foreach (var d in Detectoren)
     {
         d.PropertyChanged -= Detector_PropertyChanged;
     }
     Detectoren.Clear();
     foreach (var fcm in _Controller.Fasen)
     {
         foreach (var dm in fcm.Detectoren)
         {
             var dvm = new DetectorViewModel(dm)
             {
                 FaseCyclus = fcm.Naam
             };
             dvm.PropertyChanged += Detector_PropertyChanged;
             Detectoren.Add(dvm);
         }
     }
     Detectoren.BubbleSort();
     foreach (var dm in _Controller.Detectoren)
     {
         var dvm = new DetectorViewModel(dm);
         dvm.PropertyChanged += Detector_PropertyChanged;
         Detectoren.Add(dvm);
     }
 }
        void AddDetectorCommand_Executed(object prm)
        {
            DetectorModel dm       = new DetectorModel();
            string        newname  = "001";
            int           inewname = 1;

            foreach (DetectorViewModel dvm in Detectoren)
            {
                if (Regex.IsMatch(dvm.Naam, @"[0-9]+"))
                {
                    Match  m    = Regex.Match(dvm.Naam, @"[0-9]+");
                    string next = m.Value;
                    if (Int32.TryParse(next, out inewname))
                    {
                        newname = inewname.ToString("000");
                        while (!TLCGenModelManager.Default.IsElementIdentifierUnique(TLCGenObjectTypeEnum.Detector, newname))
                        {
                            inewname++;
                            newname = inewname.ToString("000");
                        }
                    }
                }
            }
            dm.Naam = newname;
            DefaultsProvider.Default.SetDefaultsOnModel(dm, dm.Type.ToString());
            dm.AanvraagDirect = false; // Not possible / allowed on loose detector
            DetectorViewModel dvm1 = new DetectorViewModel(dm);

            Detectoren.Add(dvm1);
            Messenger.Default.Send(new DetectorenChangedMessage(new List <DetectorModel> {
                dm
            }, null));
        }
Esempio n. 3
0
        private void AddDetectorCommand_Executed(object prm)
        {
            DetectorModel d = new DetectorModel();

            d.Naam = Replace + "_" + (Detectoren.Count + 1);
            Detectoren.Add(d);
        }
 private void UpdateDetectoren()
 {
     foreach (var d in Detectoren)
     {
         d.PropertyChanged -= Detector_PropertyChanged;
     }
     Detectoren.Clear();
     foreach (FaseCyclusModel fcm in _Controller.Fasen)
     {
         foreach (DetectorModel dm in fcm.Detectoren)
         {
             var dvm = new DetectorViewModel(dm);
             dvm.PropertyChanged += Detector_PropertyChanged;
             Detectoren.Add(dvm);
         }
     }
     foreach (DetectorModel dm in _Controller.Detectoren)
     {
         var dvm = new DetectorViewModel(dm);
         dvm.PropertyChanged += Detector_PropertyChanged;
         Detectoren.Add(dvm);
     }
     foreach (DetectorModel dm in _Controller.SelectieveDetectoren)
     {
         var dvm = new DetectorViewModel(dm);
         dvm.PropertyChanged += Detector_PropertyChanged;
         Detectoren.Add(dvm);
     }
 }
        void AddNewDetectorCommand_Executed(object prm)
        {
            DetectorModel dm       = new DetectorModel();
            string        newname  = "001";
            int           inewname = 1;

            foreach (DetectorViewModel dvm in Detectoren)
            {
                if (Regex.IsMatch(dvm.Naam, @"[0-9]+"))
                {
                    Match  m    = Regex.Match(dvm.Naam, @"[0-9]+");
                    string next = m.Value;
                    if (Int32.TryParse(next, out inewname))
                    {
                        inewname++;
                        newname = inewname.ToString();
                        newname = (inewname < 10 ? "0" : "") + newname;
                        newname = (inewname < 100 ? "0" : "") + newname;
                        while (!Integrity.IntegrityChecker.IsElementNaamUnique(newname))
                        {
                            inewname++;
                            newname = inewname.ToString();
                            newname = (inewname < 10 ? "0" : "") + newname;
                            newname = (inewname < 100 ? "0" : "") + newname;
                        }
                    }
                }
            }
            dm.Naam   = newname;
            dm.Define = SettingsProvider.Instance.GetDetectorDefinePrefix() + newname;
            DetectorViewModel dvm1 = new DetectorViewModel(dm);

            Detectoren.Add(dvm1);
        }
 private void RebuildDetectorenList()
 {
     Detectoren.CollectionChanged -= Detectoren_CollectionChanged;
     Detectoren.Clear();
     foreach (DetectorModel dm in base.Controller.Detectoren)
     {
         var dvm = new DetectorViewModel(dm);
         dvm.PropertyChanged += Detector_PropertyChanged;
         Detectoren.Add(dvm);
     }
     Detectoren.CollectionChanged += Detectoren_CollectionChanged;
     RaisePropertyChanged("");
 }
Esempio n. 7
0
        public FaseCyclusViewModel(FaseCyclusModel fasecyclus)
        {
            _FaseCyclus = fasecyclus;

            // Add data from the Model to the ViewModel structure
            foreach (DetectorModel dm in _FaseCyclus.Detectoren)
            {
                DetectorViewModel dvm = new DetectorViewModel(dm);
                dvm.FaseVM = this;
                Detectoren.Add(dvm);
            }

            Detectoren.CollectionChanged += _Detectoren_CollectionChanged;
        }
Esempio n. 8
0
 public override void Selected()
 {
     foreach (FaseCyclusModel fcm in Controller.Fasen)
     {
         foreach (DetectorModel dm in fcm.Detectoren)
         {
             Detectoren.Add(dm.Naam);
         }
     }
     foreach (DetectorModel dm in Controller.Detectoren)
     {
         Detectoren.Add(dm.Naam);
     }
 }
 public void InsertItemsFromTemplate(List <DetectorModel> items)
 {
     foreach (var d in items)
     {
         if (!Integrity.TLCGenIntegrityChecker.IsElementNaamUnique(_Controller, d.Naam, TLCGenObjectTypeEnum.Detector))
         {
             MessageBox.Show("Error bij toevoegen van detector met naam " + d.Naam + ".\nDe detector naam is niet uniek in de regeling.", "Error bij toepassen template");
             return;
         }
     }
     foreach (var d in items)
     {
         Detectoren.Add(new DetectorViewModel(d));
     }
 }
 public void SetDetectorenChanged()
 {
     Detectoren.Clear();
     foreach (FaseCyclusModel fcm in _Controller.Fasen)
     {
         foreach (DetectorModel dm in fcm.Detectoren)
         {
             Detectoren.Add(new DetectorViewModel(dm));
         }
     }
     foreach (DetectorModel dm in _Controller.Detectoren)
     {
         Detectoren.Add(new DetectorViewModel(dm));
     }
 }
Esempio n. 11
0
 private void UpdateDetectoren()
 {
     Detectoren.Clear();
     foreach (FaseCyclusModel fcm in _Controller.Fasen)
     {
         foreach (DetectorModel dm in fcm.Detectoren)
         {
             Detectoren.Add(new DetectorViewModel(dm));
         }
     }
     foreach (DetectorModel dm in _Controller.Detectoren)
     {
         Detectoren.Add(new DetectorViewModel(dm));
     }
 }
Esempio n. 12
0
        public DetectorTemplateViewModel(TLCGenTemplateModel <DetectorModel> template)
        {
            _Template = template;
            foreach (var fc in template.Items)
            {
                Detectoren.Add(fc);
            }
            Detectoren.CollectionChanged += Detectoren_CollectionChanged;

            DetectorTypeOpties.Clear();
            var descs = Enum.GetValues(typeof(DetectorTypeEnum));

            foreach (DetectorTypeEnum d in descs)
            {
                DetectorTypeOpties.Add(d.GetDescription());
            }
        }
Esempio n. 13
0
        void AddDetectorCommand_Executed(object prm)
        {
            DetectorModel dm       = new DetectorModel();
            string        newname  = "001";
            int           inewname = 1;

            foreach (DetectorViewModel dvm in Detectoren)
            {
                if (Regex.IsMatch(dvm.Naam, @"[0-9]+"))
                {
                    Match  m    = Regex.Match(dvm.Naam, @"[0-9]+");
                    string next = m.Value;
                    if (Int32.TryParse(next, out inewname))
                    {
                        IsElementIdentifierUniqueRequest message;
                        do
                        {
                            newname = inewname.ToString("000");
                            message = new IsElementIdentifierUniqueRequest(newname, ElementIdentifierType.Naam);
                            Messenger.Default.Send(message);
                            if (!message.IsUnique)
                            {
                                inewname++;
                            }
                        }while (!message.IsUnique);
                    }
                }
            }
            dm.Naam = newname;
            DefaultsProvider.Default.SetDefaultsOnModel(dm, dm.Type.ToString());
            dm.AanvraagDirect = false; // Not possible / allowed on loose detector
            DetectorViewModel dvm1 = new DetectorViewModel(dm);

            Detectoren.Add(dvm1);
            Messenger.Default.Send(new DetectorenChangedMessage());
        }
Esempio n. 14
0
        private void CollectAllIO()
        {
            Fasen.Clear();
            Detectoren.Clear();
            OverigeUitgangen.Clear();
            OverigeIngangen.Clear();

            bool[] done = new bool[20];
            for (int d = 0; d < 20; ++d)
            {
                done[d] = false;
            }
            foreach (var per in _Controller.PeriodenData.Perioden)
            {
                switch (per.Type)
                {
                case PeriodeTypeEnum.Groentijden:
                case PeriodeTypeEnum.Overig:
                    per.BitmapDataRelevant = true;
                    per.BitmapNaam         = per.Naam;
                    break;

                default:
                    per.BitmapDataRelevant = false;
                    break;
                }
            }

            foreach (var i in GetAllIOElements(_Controller))
            {
                switch (i.IOType)
                {
                case BitmappedItemTypeEnum.Fase:
                    Fasen.Add(i);
                    break;

                case BitmappedItemTypeEnum.Detector:
                    Detectoren.Add(i);
                    break;

                case BitmappedItemTypeEnum.Uitgang:
                    OverigeUitgangen.Add(i);
                    break;

                case BitmappedItemTypeEnum.Ingang:
                    OverigeIngangen.Add(i);
                    break;
                }
            }

            // IO from plugins
            foreach (var v in TLCGenPluginManager.Default.ApplicationPlugins)
            {
                if ((v.Item1 & TLCGenPluginElems.IOElementProvider) == TLCGenPluginElems.IOElementProvider)
                {
                    var pl       = v.Item2 as ITLCGenElementProvider;
                    var initems  = pl.GetInputItems();
                    var outitems = pl.GetOutputItems();
                    foreach (var i in initems)
                    {
                        OverigeIngangen.Add(new BitmappedItemViewModel(i, i.Naam, BitmappedItemTypeEnum.Ingang));
                    }
                    foreach (var o in outitems)
                    {
                        OverigeUitgangen.Add(new BitmappedItemViewModel(o, o.Naam, BitmappedItemTypeEnum.Uitgang));
                    }
                }
            }
            foreach (var v in TLCGenPluginManager.Default.ApplicationParts)
            {
                if ((v.Item1 & TLCGenPluginElems.IOElementProvider) == TLCGenPluginElems.IOElementProvider)
                {
                    var pl       = v.Item2 as ITLCGenElementProvider;
                    var initems  = pl.GetInputItems();
                    var outitems = pl.GetOutputItems();
                    foreach (var i in initems)
                    {
                        OverigeIngangen.Add(new BitmappedItemViewModel(i, i.Naam, BitmappedItemTypeEnum.Ingang));
                    }
                    foreach (var o in outitems)
                    {
                        OverigeUitgangen.Add(new BitmappedItemViewModel(o, o.Naam, BitmappedItemTypeEnum.Uitgang));
                    }
                }
            }
        }
Esempio n. 15
0
        public ControllerViewModel(MainWindowViewModel mainwindowvm, ControllerModel controller)
        {
            _MainWindowVM = mainwindowvm;
            _Controller   = controller;

            // Add data from the Model to the ViewModel structure
            foreach (FaseCyclusModel fcm in _Controller.Fasen)
            {
                FaseCyclusViewModel fcvm = new FaseCyclusViewModel(fcm);
                Fasen.Add(fcvm);
            }
            foreach (DetectorModel dm in _Controller.Detectoren)
            {
                DetectorViewModel dvm = new DetectorViewModel(dm);
                Detectoren.Add(dvm);
            }
            foreach (GroentijdenSetModel mgm in _Controller.GroentijdenSets)
            {
                GroentijdenSetViewModel mgvm = new GroentijdenSetViewModel(mgm);
                MaxGroentijdenSets.Add(mgvm);
            }

            MessageManager.Instance.Subscribe(this, new Action <ControllerDataChangedMessage>(OnControllerDataChanged));
            MessageManager.Instance.Subscribe(this, new Action <NameChangedMessage>(OnNameChanged));
            MessageManager.Instance.Subscribe(this, new Action <DefineChangedMessage>(OnDefineChanged));
            MessageManager.Instance.Subscribe(this, new Action <UpdateTabsEnabledMessage>(OnUpdateTabsEnabled));
            MessageManager.Instance.Subscribe(this, new Action <GetDetectorListReqeust <List <DetectorModel>, object> >(OnDetectorListRequested));

            // Connect CollectionChanged event handlers
            MaxGroentijdenSets.CollectionChanged += MaxGroentijdenSets_CollectionChanged;

            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == AlgemeenTabVM.DisplayName).Any())
            {
                TabItems.Add(AlgemeenTabVM as ITLCGenTabItem);
            }
            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == FasenTabVM.DisplayName).Any())
            {
                TabItems.Add(FasenTabVM as ITLCGenTabItem);
            }
            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == DetectorenTabVM.DisplayName).Any())
            {
                TabItems.Add(DetectorenTabVM as ITLCGenTabItem);
            }
            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == CoordinatiesTabVM.DisplayName).Any())
            {
                TabItems.Add(CoordinatiesTabVM as ITLCGenTabItem);
            }
            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == ModulesTabVM.DisplayName).Any())
            {
                TabItems.Add(ModulesTabVM as ITLCGenTabItem);
            }
            if (!_MainWindowVM.TabItems.Where(x => x.GetPluginName() == BitmapTabVM.DisplayName).Any())
            {
                TabItems.Add(BitmapTabVM as ITLCGenTabItem);
            }
            foreach (ITLCGenTabItem item in _MainWindowVM.TabItems)
            {
                if (!TabItems.Contains(item))
                {
                    TabItems.Add(item);
                }
            }

            SelectedTab      = AlgemeenTabVM as ITLCGenTabItem;
            SelectedTabIndex = 0;
        }