private void Add_Click(object sender, RoutedEventArgs e) { if (Trays.Where(t => t.Category == TrayViewModel.Category && t.TrayNb == TrayViewModel.TrayNb).Count() != 0) { return; } Tray tray = new Tray() { Id = Trays.Count + 1, // 表示未放置到料架上 Status = TrayStatus.TS_Idle, UseCmmNo = -1, Category = TrayViewModel.Category, TrayNb = TrayViewModel.TrayNb, CmmNo = TrayViewModel.CmmNo, SlotNb = -1, ColumnCount = TrayViewModel.ColumnCount, RowCount = TrayViewModel.RowCount, ColumnOffset = TrayViewModel.ColumnOffset, RowOffset = TrayViewModel.RowOffset, BaseColumnOffset = TrayViewModel.BaseColumnOffset, BaseRowOffset = TrayViewModel.BaseRowOffset, Placed = false, Parts = new ObservableCollection <Part>() }; for (int i = 0; i < tray.ColumnCount * tray.RowCount; i++) { tray.Parts.Add(new Part() { Id = i, SlotNb = i + 1, Status = PartStatus.PS_Empty }); } Trays.Add(tray); }
public void TrayIn() { if (NowTrayId != null) { TrayOut(); } NowTrayId = Guid.NewGuid().ToString(); var tray = new Tray(NowTrayId); Trays.Add(tray); }
private void UnloadTrays() { if (SelectedTrayInRack == null) { return; } if (SelectedTrayInRack.Status == TrayStatus.TS_Empty) { return; } int index = SelectedTrayInRack.SlotNb; SelectedTrayInRack.Status = TrayStatus.TS_Idle; SelectedTrayInRack.SlotNb = -1; SelectedTrayInRack.Placed = false; Trays.Add(SelectedTrayInRack); Rack.Trays[index - 1] = new Tray() { Status = TrayStatus.TS_Empty, SlotNb = index, }; }