/// <summary>
        /// Default constructor - sets the version number and creates empty objects for deep properties.
        /// </summary>
        public TimetableDocument()
        {
            Version = 2;

            TrainClassList = new TrainClassCollection();
            TrainClassList.TrainClassAdd    += TrainClassChangedHandler;
            TrainClassList.TrainClassRemove -= TrainClassChangedHandler;
            TrainList                                   = new TrainCollection();
            TrainList.TrainAdd                         += TrainAddHandler;
            TrainList.TrainRemove                      += TrainRemoveHandler;
            LocationList                                = new LocationCollection();
            LocationList.LocationAdd                   += LocationChangedHandler;
            LocationList.LocationRemove                += LocationChangedHandler;
            DownTrainsDisplay                           = new TimetableSectionModel(Direction.Down, LocationList);
            UpTrainsDisplay                             = new TimetableSectionModel(Direction.Up, LocationList);
            Signalboxes                                 = new SignalboxCollection();
            Signalboxes.SignalboxAdd                   += SignalboxChangedHandler;
            Signalboxes.SignalboxRemove                += SignalboxChangedHandler;
            SignalboxHoursSets                          = new SignalboxHoursSetCollection();
            SignalboxHoursSets.SignalboxHoursSetAdd    += SignalboxHoursSetChangedHandler;
            SignalboxHoursSets.SignalboxHoursSetRemove += SignalboxHoursSetChangedHandler;
            Options                     = new DocumentOptions();
            NoteDefinitions             = new NoteCollection();
            NoteDefinitions.NoteAdd    += NoteChangedHandler;
            NoteDefinitions.NoteRemove += NoteChangedHandler;
            ExportOptions               = new DocumentExportOptions();
        }
Exemple #2
0
        public void TimetableSectionModelClass_AddMethod_ThrowsArgumentNullExceptionIfParameterIsNull()
        {
            TimetableSectionModel testObject = GetTimetableSectionModel();

            testObject.Add(null);

            Assert.Fail();
        }
Exemple #3
0
        public void TimetableSectionModelClass_AddMethod_ThrowsArgumentNullExceptionWithCorrectParamNamePropertyIfParameterIsNull()
        {
            TimetableSectionModel testObject = GetTimetableSectionModel();

            try
            {
                testObject.Add(null);
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("segment", ex.ParamName);
            }
        }
        /// <summary>
        /// Constructor which sets read-only properties.
        /// </summary>
        /// <param name="model">The data model.</param>
        /// <param name="view">The view.</param>
        public TimetableSectionModelDataAdapter(TimetableSectionModel model, DataGridView view)
        {
            Model = model ?? throw new ArgumentNullException(nameof(model));
            View  = view ?? throw new ArgumentNullException(nameof(view));

            Model.TrainSegments.TrainSegmentModelAdd    += SegmentAdded;
            Model.TrainSegments.TrainSegmentModelRemove += SegmentRemoved;
            Model.Locations.LocationDisplayModelAdd     += LocationAdded;
            Model.Locations.LocationDisplayModelRemove  += LocationRemoved;

            SetGridLayoutMode(GridLayoutMode.Frozen);
            InitialiseView();
            PopulateInitialData();
            SetGridLayoutMode(GridLayoutMode.Automatic);
        }