public MainViewModel() { CreateCommands(); ConfigManager = new MainConfigManager(); ConfigManager.LoadConfigs(); ClientDirsManager.Inst.LoadDirs(); Racks = new ObservableCollection <Rack>(); Trays = new ObservableCollection <Tray>(); Parts = new ObservableCollection <Part>(); Categories = new ObservableCollection <string>(); Racks.Add(new Rack(3, 3)); CurrentSelectCategory = "All"; Parts = PartsFileRepository.LoadParts(); CategoriesRefresh(); SelectCategoryCommand.Execute(); LogicUnits = new ObservableCollection <LogicUnitViewModel>(); PcdmisClient = PcdmisClient.Inst; CalypsoClient = CalypsoClient.Inst; Trays = TraysRepository.LoadTrays(); Started = false; Stopped = true; RunLedIndex = -1; LogsManager = ClientLogs.Inst; PLCAccessor = PLCAccessor.Instance; LoadOrUnloadError = false; MyEventAggregator.Inst.GetEvent <PlcErrorEvent>().Subscribe(OnPlcError); MyEventAggregator.Inst.GetEvent <LoadEvent>().Subscribe(OnLoadActivity); MyEventAggregator.Inst.GetEvent <UnloadEvent>().Subscribe(OnUnloadActivity); }
private void AddPart() { CategoriesRefresh(); AddPartWindow addPartWindow = new AddPartWindow(); addPartWindow.Parts = Parts; addPartWindow.ShowDialog(); CategoriesRefresh(); PartsFileRepository.UpdateParts(Parts); }
private void DeletePart() { if (SelectedPart == null) { return; } //if (SelectedPart.Status != PartStatus.PS_Idle) //{ // return; //} if (SelectedPart.Placed) { return; } Parts.Remove(SelectedPart); SelectParts.Remove(SelectedPart); CategoriesRefresh(); PartsFileRepository.UpdateParts(Parts); }
private void DeleteAllParts() { //须判断是否放置在料盘中 foreach (var part in Parts) { if (part.Placed) { MessageBox.Show("有未卸载零件,无法清除", "警告", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); return; } } Parts.Clear(); if (SelectParts != null) { SelectParts.Clear(); } CategoriesRefresh(); PartsFileRepository.UpdateParts(Parts); }