public void AddTabItem(object rpItem) { if (!TabItems.Contains(rpItem)) { TabItems.Add(rpItem); } SelectedItem = rpItem; }
private void OnTabItemClose(TabItemModel model) { if (model == null) { return; } if (string.IsNullOrWhiteSpace(model.ItemNamespace)) { return; } var hasItem = HasItemByNamespace(model.ItemNamespace); if (hasItem == null) { return; } if (TabItems.Contains(hasItem)) { TabItems.Remove(hasItem); } }
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; }