public static CoatingSchedule LoadSchedule() { CoatingSchedule schedule = null; if (MessageBox.Show("Load default schedule?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { schedule = Load(datFile); if (schedule == null) { MessageBox.Show("Failed to load default. Please select a backup."); } } if (schedule == null) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.DefaultExt = DefaultExtension; openFileDialog.Title = "Open schedule file"; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == true) { schedule = Load(openFileDialog.FileName); } } return(schedule); }
private void LoadButton_OnClick(object sender, RoutedEventArgs e) { // force focus change to force validation on child controls Keyboard.Focus(this); var schedule = CoatingSchedule.LoadSchedule(); if (schedule != null) { Schedule.Clear(); Schedule = schedule; Schedule.Control = this; Schedule.ReconnectToControls(); } }
public static CoatingSchedule Load(string file = "") { if (file == "") { file = datFile; } CoatingSchedule schedule = null; try { using (FileStream stream = new FileStream(file, FileMode.Open)) { IFormatter formatter = new BinaryFormatter(); schedule = (CoatingSchedule)formatter.Deserialize(stream); } } catch (Exception exception) { } return(schedule); }
public CoatingScheduleWindow(CoatingSchedule schedule = null) { InitializeComponent(); CurrentCoatingScheduleWindow = this; if (schedule != null) { schedule.Control = this; Connect(schedule); schedule.ReconnectToControls(); TrackingStackPanel.DataContext = TrackingLabels; // PopulateControlList(); SchedulerListView.DataContext = typeof(DayControl); SchedulerListView.ItemsSource = DayControls; LoadInstructions(schedule.InstructionSets); if (!ShiftHandler.CoatingInstance.LoadShifts()) { MessageBox.Show("Could not load shift information"); } } }