private void SetSetts(SavingLoadsClass setts) { foreach (ReleaseTable item in ReleaseIdWPF.Items) { if (item.ID == setts.releaseId) { ReleaseIdWPF.SelectedItem = item; break; } } foreach (MachineTable item in CutterWPF.Items) { if (item.ID == setts.cutterId) { CutterWPF.SelectedItem = item; break; } } foreach (MachineTable item in PainterWPF.Items) { if (item.ID == setts.painterId) { PainterWPF.SelectedItem = item; break; } } foreach (MachineTable item in ConveyorWPF.Items) { if (item.ID == setts.conveyorId) { ConveyorWPF.SelectedItem = item; break; } } foreach (MachineTable item in StackerWPF.Items) { if (item.ID == setts.stackerId) { StackerWPF.SelectedItem = item; break; } } foreach (MachineTable item in WrapperWPF.Items) { if (item.ID == setts.wrapperId) { WrapperWPF.SelectedItem = item; break; } } TransferInfo.releaseId = setts.releaseId; TransferInfo.cutterId = setts.cutterId; TransferInfo.painterId = setts.painterId; TransferInfo.conveyorId = setts.conveyorId; TransferInfo.stackerId = setts.stackerId; TransferInfo.wrapperId = setts.wrapperId; }
public void LoadAndSet() { if (File.Exists(settsPath)) { string txt = File.ReadAllText(settsPath); SavingLoadsClass loadedSaveObject = JsonSerializer.Deserialize <SavingLoadsClass>(txt); SetSetts(loadedSaveObject); } else { Save(); } }
private void Save() { SavingLoadsClass setts = new SavingLoadsClass() { releaseId = TransferInfo.releaseId, cutterId = TransferInfo.cutterId, painterId = TransferInfo.painterId, conveyorId = TransferInfo.conveyorId, stackerId = TransferInfo.stackerId, wrapperId = TransferInfo.wrapperId, }; string json = JsonSerializer.Serialize(setts); File.WriteAllText(settsPath, json); OnChanged(); }