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 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);
        }
        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));
        }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 6
0
        void RemoveDetectorCommand_Executed(object prm)
        {
            bool changed = false;
            var  remDets = new List <DetectorModel>();

            if (SelectedDetectoren != null && SelectedDetectoren.Count > 0)
            {
                changed = true;
                foreach (DetectorViewModel dvm in SelectedDetectoren)
                {
                    remDets.Add(dvm.Detector);
                    Integrity.TLCGenControllerModifier.Default.RemoveDetectorFromController(dvm.Naam);
                }
            }
            else if (SelectedDetector != null)
            {
                changed = true;
                remDets.Add(SelectedDetector.Detector);
                Integrity.TLCGenControllerModifier.Default.RemoveDetectorFromController(SelectedDetector.Naam);
            }
            RebuildDetectorenList();
            MessengerInstance.Send(new ControllerDataChangedMessage());

            if (changed)
            {
                Messenger.Default.Send(new DetectorenChangedMessage(_Controller, null, remDets));
                Detectoren.BubbleSort();
            }
        }
 public DetectorenExtraTabViewModel() : base()
 {
     MessengerInstance.Register <Messaging.Requests.PrepareForGenerationRequest>(this, (msg) =>
     {
         Detectoren.BubbleSort();
     });
 }
        public void UpdateAfterApplyTemplate(DetectorModel item)
        {
            var d = Detectoren.First(x => x.Detector == item);

            d.RaisePropertyChanged("");
            Messenger.Default.Send(new DetectorenChangedMessage(new List <DetectorModel> {
                item
            }, null));
        }
 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("");
 }
Exemplo n.º 10
0
 public DetectorenExtraTabViewModel() : base()
 {
     MessengerInstance.Register <Messaging.Requests.PrepareForGenerationRequest>(this, (msg) =>
     {
         Detectoren.BubbleSort();
     });
     MessengerInstance.Register <Messaging.Messages.NameChangedMessage>(this, (msg) =>
     {
         if (msg.ObjectType == TLCGenObjectTypeEnum.Detector)
         {
             Detectoren.BubbleSort();
         }
     });
 }
Exemplo n.º 11
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;
        }
Exemplo n.º 12
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));
     }
 }
Exemplo n.º 14
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));
     }
 }
 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));
     }
 }
Exemplo n.º 16
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());
            }
        }
 void RemoveDetectorCommand_Executed(object prm)
 {
     if (SelectedDetectoren != null && SelectedDetectoren.Count > 0)
     {
         // Create temporary List cause we cannot directly remove the selection,
         // as it will cause the selection to change while we loop it
         List <DetectorViewModel> ldvm = new List <DetectorViewModel>();
         foreach (DetectorViewModel dvm in SelectedDetectoren)
         {
             ldvm.Add(dvm);
         }
         foreach (DetectorViewModel dvm in ldvm)
         {
             Detectoren.Remove(dvm);
         }
     }
     else if (SelectedDetector != null)
     {
         Detectoren.Remove(SelectedDetector);
     }
 }
Exemplo n.º 18
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());
        }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
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));
                    }
                }
            }
        }
Exemplo n.º 21
0
 void RemoveDetectorCommand_Executed(object prm)
 {
     Detectoren.Remove(SelectedDetector);
     SelectedDetector = null;
 }