Esempio n. 1
0
        /// <summary>
        /// creates the three views, the controller and the model
        /// </summary>
        public void StartNewAquarium()
        {
            if (theController != null)
            {
                theController = null;
            }
            if (theModel != null)
            {
                theModel = null;
            }

            theTextForm?.Dispose();
            theReadableGraphicsForm?.Dispose();

            /* These lines are
             * if (theWriteableGraphicsForm != null)
             * {
             *  theWriteableGraphicsForm.Dispose();
             * }
             */
            theWriteableGraphicsForm?.Dispose();
            //Uses the null propagation operator introduced in C# 6.0

            theController = new controller();
            theModel      = new model(theController);

            theTextForm = new textForm();
            theWriteableGraphicsForm               = new graphicsForm();
            theReadableGraphicsForm                = new graphicsForm_2();
            theTextForm.TheModel                   = theModel;
            theWriteableGraphicsForm.TheModel      = theModel;
            theReadableGraphicsForm.TheModel       = theModel;
            theTextForm.TheController              = theController;
            theWriteableGraphicsForm.TheController = theController;
            theReadableGraphicsForm.TheController  = theController;

            theTextForm?.Show();
            theWriteableGraphicsForm?.Show();
            theReadableGraphicsForm?.Show();

            theController.AddView(theTextForm);
            theController.AddView(theWriteableGraphicsForm);
            theController.AddView(theReadableGraphicsForm);
        }