public TabControlViewModel() { TabCollection.Add(new MeetingsCentresAndRoomsViewModel()); TabCollection.Add(new MeetingsPlanningViewModel()); TabCollection.Add(new AccessoriesViewModel()); SelectedTabIndex = 0; SelectedTab = TabCollection.FirstOrDefault(); }
/// <summary> /// Opens esc file /// </summary> private void Open(string filename) { var initialDirectory = string.Empty; if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.RecentLocationProject)) { initialDirectory = Properties.Settings.Default.RecentLocationProject; } if (string.IsNullOrWhiteSpace(filename) || filename == "open") { filename = FileManagement.OpenFileDialog(initialDirectory).FileName; } if (string.IsNullOrWhiteSpace(filename)) { return; } FuturamaSysModel t; try { t = FileManagement.OpenSystemFile(filename); } catch (Exception e) { MessageBox.Show(e.Message, "Could't open file", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); return; } Properties.Settings.Default.RecentLocationProject = Path.GetDirectoryName(filename); if (LibraryData.SystemIsOpen) { if (!Close()) { return; } } FileName = filename; LibraryData.OpenSystem(t); _comViewModel.UpdateConnections(); RaisePropertyChanged(() => InstallerVersion); _recentFilesLogic.AddFile(filename); AddMainUnitsToTab(); AddConnections(); SelectedTab = TabCollection.FirstOrDefault(i => i.Id == 0); }
private bool AreConnections() { if (TabCollection.OfType <MainUnitViewModel>().Any(model => model.ConnectType != ConnectType.None)) { return(true); } MessageBox.Show(Main.MessageBoxNoConnectionText, Main.MessageBoxNoConnectionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); SelectedTab = TabCollection.FirstOrDefault(n => n is CommunicationViewModel); return(false); }
public override void OnLoad() { Version = Globals.Assembly.EXE_VERSION; if (_appUser != null && _appUser.RoleId == Role.ADMIN) { TabCollection.Add(AppuserVM); } TabCollection.Add(HardwareVM); TabCollection.Add(UserVM); TabCollection.Add(SupplierVM); TabCollection.Add(ReportVM); TabCollection.Add(BbSearchVM); TabCollection.Add(BbCircularVM); SelectedTab = TabCollection.FirstOrDefault(); }
/// <summary> /// Adds al the mainunits and the matrix tab /// </summary> private async void AddMainUnitsToTab() { if (!LibraryData.SystemIsOpen) { return; } TabCollection.Clear(); await Task.Delay(150); foreach (var m in LibraryData.FuturamaSys.MainUnits) { TabCollection.Add(new MainUnitViewModel(m, this)); } SelectedTab = TabCollection.FirstOrDefault(i => i.Id == 0); TabCollection.Add(new PanelViewModel(this)); TabCollection.Add(_comViewModel); }