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)); }
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); } }
public void AddFromTemplate(List <DetectorModel> items) { try { foreach (DetectorModel dm in items) { if ((Integrity.IntegrityChecker.IsElementDefineUnique(dm.Define) && Integrity.IntegrityChecker.IsElementNaamUnique(dm.Naam))) { DetectorViewModel dvm = new DetectorViewModel(dm); dvm.FaseVM = DetectorenFasenLijstVM?.SelectedFase; switch (SelectedTab?.Name) { case "PerFaseTab": DetectorenFasenLijstVM?.Detectoren?.Add(dvm); break; case "ExtraTab": DetectorenExtraLijstVM?.Detectoren?.Add(dvm); break; } } } } catch { throw new NotImplementedException(); } }
/// <summary> /// Sets the value of the property indicated by propName to the value it has /// for the parsed instance of DetectorViewModel for all selected detectors /// </summary> /// <param name="o">The instance of DetectorViewModel to take as the base case</param> /// <param name="propName">The property to set</param> public void SetAllSelectedDetectorenValue(DetectorViewModel o, string propName) { IList dets = null; switch (SelectedTab.Name) { case "PerFaseTab": dets = DetectorenFasenLijstVM.SelectedDetectoren; break; case "ExtraTab": dets = DetectorenExtraLijstVM.SelectedDetectoren; break; case "AllesTab": dets = DetectorenAllesLijstVM.SelectedDetectoren; break; } if (dets != null) { foreach (DetectorViewModel dvm in dets) { object value = o.GetType().GetProperty(propName).GetValue(o); dvm.GetType().GetProperty(propName).SetValue(dvm, value); } } }
void AddNewDetectorCommand_Executed(object prm) { DetectorModel dm = new DetectorModel(); string newname = "1"; int inewname = 1; foreach (DetectorViewModel dvm in SelectedFase.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(); while (!Integrity.IntegrityChecker.IsElementNaamUnique(SelectedFase.Naam + newname)) { inewname++; newname = inewname.ToString(); } } } } dm.Define = SettingsProvider.Instance.GetDetectorDefinePrefix() + SelectedFase.Naam + newname; dm.Naam = SelectedFase.Naam + newname; DetectorViewModel dvm1 = new DetectorViewModel(dm); dvm1.FaseVM = SelectedFase; SelectedFase.Detectoren.Add(dvm1); }
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); } }
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(""); }
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; }
public int CompareTo(object obj) { DetectorViewModel fcvm = obj as DetectorViewModel; if (fcvm == null) { throw new NotImplementedException(); } else { string myName = Naam; string hisName = fcvm.Naam; 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)); } }
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()); }
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; }