예제 #1
0
        public static bool Load()
        {
            try
            {
                using (FileStream stream = File.OpenRead(DatFile))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    PlateConfigurations.Clear();
                    PlateChangeDays.Clear();
                    PressScheduleWindow.WeekControls?.Clear();

                    int plateCount = (int)formatter.Deserialize(stream);

                    for (; plateCount > 0; plateCount--)
                    {
                        PlateConfiguration plateConfiguration = (PlateConfiguration)formatter.Deserialize(stream);
                        PlateConfigurations.Add(plateConfiguration);
                    }

                    int daysCount = (int)formatter.Deserialize(stream);
                    for (; daysCount > 0; daysCount--)
                    {
                        DayOfWeek day = (DayOfWeek)formatter.Deserialize(stream);
                        PlateChangeDays.Add(day);
                    }

                    NumPlates = (int)formatter.Deserialize(stream);
                }

                //using (BinaryReader reader = new BinaryReader(new FileStream(DatFile, FileMode.Open)))
                //{
                //    return Load(reader);
                //}
            }
            catch (Exception exception)
            {
                return(false);
            }

            return(true);
        }