/// <summary>
        /// Displays the splash screen (whose presenter builds up most of the objects used by the program) and then the
        /// main view once the splash screen has finished. When the main view quits the program shuts down.
        /// </summary>
        /// <param name="args"></param>
        private static void StartApplication(string[] args)
        {
            IUniversalPlugAndPlayManager uPnpManager                  = null;
            IBaseStationAircraftList     baseStationAircraftList      = null;
            ISimpleAircraftList          flightSimulatorXAircraftList = null;
            bool loadSucceded = false;

            using (var splashScreen = new SplashView()) {
                splashScreen.Initialise(args, BackgroundThread_ExceptionCaught);
                splashScreen.ShowDialog();

                loadSucceded                 = splashScreen.LoadSucceeded;
                uPnpManager                  = splashScreen.UPnpManager;
                baseStationAircraftList      = splashScreen.BaseStationAircraftList;
                flightSimulatorXAircraftList = splashScreen.FlightSimulatorXAircraftList;
            }

            try {
                if (loadSucceded)
                {
                    using (var mainWindow = new MainView()) {
                        _MainView = mainWindow;
                        mainWindow.Initialise(uPnpManager, baseStationAircraftList, flightSimulatorXAircraftList);
                        mainWindow.ShowDialog();
                    }
                }
            } finally {
                using (var shutdownWindow = new ShutdownView()) {
                    shutdownWindow.Initialise(uPnpManager, baseStationAircraftList);
                    shutdownWindow.ShowDialog();
                    Thread.Sleep(1000);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="baseStationAircraftList"></param>
 /// <param name="flightSimulatorAircraftList"></param>
 /// <param name="uPnpManager"></param>
 /// <param name="webSite"></param>
 public PluginStartupParameters(IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorAircraftList, IUniversalPlugAndPlayManager uPnpManager, IWebSite webSite)
 {
     AircraftList = baseStationAircraftList;
     FlightSimulatorAircraftList = flightSimulatorAircraftList;
     UPnpManager = uPnpManager;
     WebSite     = webSite;
 }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="baseStationAircraftList"></param>
 /// <param name="flightSimulatorAircraftList"></param>
 /// <param name="uPnpManager"></param>
 /// <param name="webSite"></param>
 public PluginStartupParameters(IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorAircraftList, IUniversalPlugAndPlayManager uPnpManager, IWebSite webSite)
 {
     AircraftList = baseStationAircraftList;
     FlightSimulatorAircraftList = flightSimulatorAircraftList;
     UPnpManager = uPnpManager;
     WebSite = webSite;
 }
Beispiel #4
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="uPnpManager"></param>
        /// <param name="baseStationAircraftList"></param>
        /// <param name="flightSimulatorXAircraftList"></param>
        public void Initialise(IUniversalPlugAndPlayManager uPnpManager, IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorXAircraftList)
        {
            _BaseStationAircraftList      = baseStationAircraftList;
            _FlightSimulatorXAircraftList = flightSimulatorXAircraftList;
            _UPnpManager = uPnpManager;

            webServerStatusControl.UPnpIsSupported = true; // IsSupported was in the original UPnP code but was dropped in the re-write. Keeping UI elements for it in case I decide to put it back.
        }
Beispiel #5
0
        /// <summary>
        /// Displays the splash screen (whose presenter builds up most of the objects used by the program) and then the
        /// main view once the splash screen has finished. When the main view quits the program shuts down.
        /// </summary>
        /// <param name="args"></param>
        private static void StartApplication(string[] args)
        {
            IUniversalPlugAndPlayManager uPnpManager                  = null;
            IBaseStationAircraftList     baseStationAircraftList      = null;
            ISimpleAircraftList          flightSimulatorXAircraftList = null;
            bool loadSucceded = false;

            using (var splashScreen = Factory.Singleton.Resolve <ISplashView>()) {
                splashScreen.Initialise(args, BackgroundThread_ExceptionCaught);
                splashScreen.ShowView();

                loadSucceded                 = splashScreen.LoadSucceeded;
                uPnpManager                  = splashScreen.UPnpManager;
                baseStationAircraftList      = splashScreen.BaseStationAircraftList;
                flightSimulatorXAircraftList = splashScreen.FlightSimulatorXAircraftList;
            }

            try {
                if (loadSucceded)
                {
                    var pluginManager = Factory.Singleton.Resolve <IPluginManager>().Singleton;
                    foreach (var plugin in pluginManager.LoadedPlugins)
                    {
                        try {
                            plugin.GuiThreadStartup();
                        } catch (Exception ex) {
                            var log = Factory.Singleton.Resolve <ILog>().Singleton;
                            log.WriteLine("Caught exception in {0} plugin while calling GuiThreadStartup: {1}", plugin.Name, ex);
                        }
                    }

                    using (var mainWindow = Factory.Singleton.Resolve <IMainView>()) {
                        _MainView = mainWindow;
                        mainWindow.Initialise(uPnpManager, flightSimulatorXAircraftList);
                        mainWindow.ShowView();
                    }
                }
            } finally {
                using (var shutdownWindow = Factory.Singleton.Resolve <IShutdownView>()) {
                    shutdownWindow.Initialise(uPnpManager, baseStationAircraftList);
                    shutdownWindow.ShowView();
                    Thread.Sleep(1000);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="uPnpManager"></param>
 /// <param name="baseStationAircraftList"></param>
 public void Initialise(IUniversalPlugAndPlayManager uPnpManager, IBaseStationAircraftList baseStationAircraftList)
 {
     _UPnpManager             = uPnpManager;
     _BaseStationAircraftList = baseStationAircraftList;
 }
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="baseStationAircraftList"></param>
 /// <param name="flightSimulatorAircraftList"></param>
 /// <param name="webServer"></param>
 public void Initialise(IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorAircraftList, IWebServer webServer)
 {
     _BaseStationAircraftList = baseStationAircraftList;
     _FlightSimulatorAircraftList = flightSimulatorAircraftList;
     _WebServer = webServer;
 }
Beispiel #8
0
        /// <summary>
        /// Displays the splash screen (whose presenter builds up most of the objects used by the program) and then the
        /// main view once the splash screen has finished. When the main view quits the program shuts down.
        /// </summary>
        /// <param name="args"></param>
        public static void StartApplication(string[] args)
        {
            IUniversalPlugAndPlayManager uPnpManager                  = null;
            IBaseStationAircraftList     baseStationAircraftList      = null;
            ISimpleAircraftList          flightSimulatorXAircraftList = null;
            bool loadSucceded = false;

            try {
                using (var splashScreen = Factory.Resolve <ISplashView>()) {
                    splashScreen.Initialise(args, BackgroundThread_ExceptionCaught);
                    splashScreen.ShowView();

                    loadSucceded                 = splashScreen.LoadSucceeded;
                    uPnpManager                  = splashScreen.UPnpManager;
                    baseStationAircraftList      = splashScreen.BaseStationAircraftList;
                    flightSimulatorXAircraftList = splashScreen.FlightSimulatorXAircraftList;
                }

                var shutdownSignalHandler = Factory.ResolveSingleton <IShutdownSignalHandler>();
                try {
                    if (loadSucceded)
                    {
                        var pluginManager = Factory.ResolveSingleton <IPluginManager>();
                        foreach (var plugin in pluginManager.LoadedPlugins)
                        {
                            try {
                                plugin.GuiThreadStartup();
                            } catch (Exception ex) {
                                var log = Factory.ResolveSingleton <ILog>();
                                log.WriteLine($"Caught exception in {plugin.Name} plugin while calling GuiThreadStartup: {ex}");
                            }
                        }

                        try {
                            using (var mainWindow = Factory.Resolve <IMainView>()) {
                                MainView = mainWindow;
                                mainWindow.Initialise(uPnpManager, flightSimulatorXAircraftList);

                                shutdownSignalHandler.CloseMainViewOnShutdownSignal();

                                mainWindow.ShowView();
                            }
                        } finally {
                            MainView = null;
                        }
                    }
                } finally {
                    shutdownSignalHandler.Cleanup();

                    using (var shutdownWindow = Factory.Resolve <IShutdownView>()) {
                        shutdownWindow.Initialise(uPnpManager, baseStationAircraftList);
                        shutdownWindow.ShowView();
                        Thread.Sleep(1000);
                    }

                    Factory.ResolveSingleton <ILog>().WriteLine("Clean shutdown complete");
                }
            } finally {
                _ShutdownCompleteWaitHandle.Set();
            }
        }
Beispiel #9
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="baseStationAircraftList"></param>
 /// <param name="flightSimulatorAircraftList"></param>
 /// <param name="webServer"></param>
 public void Initialise(IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorAircraftList, IWebServer webServer)
 {
     _BaseStationAircraftList     = baseStationAircraftList;
     _FlightSimulatorAircraftList = flightSimulatorAircraftList;
     _WebServer = webServer;
 }
        public void TestInitialise()
        {
            _BackgroundException = null;

            _ClassFactorySnapshot = Factory.TakeSnapshot();

            _RuntimeEnvironment = TestUtilities.CreateMockSingleton<IRuntimeEnvironment>();
            _RuntimeEnvironment.Setup(r => r.IsTest).Returns(true);

            _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>();
            _Configuration = new Configuration();
            _ConfigurationStorage.Setup(m => m.Load()).Returns(_Configuration);

            _AircraftPictureManager = TestUtilities.CreateMockSingleton<IAircraftPictureManager>();
            _HeartbeatService = TestUtilities.CreateMockSingleton<IHeartbeatService>();
            _AutoConfigPictureFolderCache = TestUtilities.CreateMockSingleton<IAutoConfigPictureFolderCache>();
            _PictureDirectoryCache = new Mock<IDirectoryCache>() { DefaultValue = DefaultValue.Mock }.SetupAllProperties();
            _AutoConfigPictureFolderCache.Setup(a => a.DirectoryCache).Returns(_PictureDirectoryCache.Object);

            _AircraftList = Factory.Singleton.Resolve<IBaseStationAircraftList>();
            _AircraftList.ExceptionCaught += AircraftListExceptionCaughtHandler;

            _Provider = new Mock<IBaseStationAircraftListProvider>().SetupAllProperties();
            _Provider.Setup(m => m.UtcNow).Returns(DateTime.UtcNow);

            _Port30003Listener = new Mock<IListener>().SetupAllProperties();

            _BaseStationDatabase = new Mock<IBaseStationDatabase>().SetupAllProperties();
            _StandingDataManager = TestUtilities.CreateMockSingleton<IStandingDataManager>();

            _AircraftList.Provider = _Provider.Object;
            _AircraftList.Listener = _Port30003Listener.Object;
            _AircraftList.BaseStationDatabase = _BaseStationDatabase.Object;
            _AircraftList.StandingDataManager = _StandingDataManager.Object;

            _BaseStationMessage = new BaseStationMessage();
            _BaseStationMessage.MessageType = BaseStationMessageType.Transmission;
            _BaseStationMessage.Icao24 = "4008F6";
            _BaseStationMessageEventArgs = new BaseStationMessageEventArgs(_BaseStationMessage);

            _BaseStationAircraft = new BaseStationAircraft();
            _BaseStationDatabase.Setup(m => m.GetAircraftByCode("4008F6")).Returns(_BaseStationAircraft);

            _Heathrow = new Airport() { IcaoCode = "EGLL", IataCode = "LHR", Name = "Heathrow", Country = "UK", };
            _JohnFKennedy = new Airport() { IcaoCode = "KJFK", IataCode = "JFK", Country = "USA", };
            _Helsinki = new Airport() { IataCode = "HEL", };
            _Boston = new Airport() { IcaoCode = "KBOS", };
            _Route = new Route() { From = _Heathrow, To = _JohnFKennedy, Stopovers = { _Helsinki }, };

            _ExceptionCaughtEvent = new EventRecorder<EventArgs<Exception>>();
            _CountChangedEvent = new EventRecorder<EventArgs>();
        }
        public void BaseStationAircraftList_ExceptionCaught_Is_Not_Raised_When_Background_Thread_Stops()
        {
            // A ThreadAbortExecption should just stop the background thread silently

            _AircraftList.ExceptionCaught -= AircraftListExceptionCaughtHandler;
            _AircraftList.ExceptionCaught += _ExceptionCaughtEvent.Handler;
            InvalidOperationException exception = new InvalidOperationException();

            _AircraftList.Dispose();
            _AircraftList = null;

            Assert.AreEqual(0, _ExceptionCaughtEvent.CallCount);
        }
        public void BaseStationAircraftList_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            _AircraftList.Dispose();
            _AircraftList = Factory.Singleton.Resolve<IBaseStationAircraftList>();
            Assert.IsNotNull(_AircraftList.Provider);

            TestUtilities.TestProperty(_AircraftList, r => r.BaseStationDatabase, null, _BaseStationDatabase.Object);
            TestUtilities.TestProperty(_AircraftList, r => r.Listener, null, _Port30003Listener.Object);
            TestUtilities.TestProperty(_AircraftList, r => r.Provider, _AircraftList.Provider, _Provider.Object);
            Assert.AreEqual(AircraftListSource.BaseStation, _AircraftList.Source);
            TestUtilities.TestProperty(_AircraftList, r => r.StandingDataManager, null, _StandingDataManager.Object);
            Assert.AreEqual(0, _AircraftList.Count);
        }
        public void TestCleanup()
        {
            Factory.RestoreSnapshot(_ClassFactorySnapshot);

            if(_AircraftList != null) _AircraftList.Dispose();
            _AircraftList = null;
            Assert.IsNull(_BackgroundException, _BackgroundException == null ? "" : _BackgroundException.ToString());
        }
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="uPnpManager"></param>
        /// <param name="baseStationAircraftList"></param>
        /// <param name="flightSimulatorXAircraftList"></param>
        public void Initialise(IUniversalPlugAndPlayManager uPnpManager, IBaseStationAircraftList baseStationAircraftList, ISimpleAircraftList flightSimulatorXAircraftList)
        {
            _BaseStationAircraftList = baseStationAircraftList;
            _FlightSimulatorXAircraftList = flightSimulatorXAircraftList;
            _UPnpManager = uPnpManager;

            webServerStatusControl.UPnpIsSupported = true; // IsSupported was in the original UPnP code but was dropped in the re-write. Keeping UI elements for it in case I decide to put it back.
        }
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="uPnpManager"></param>
 /// <param name="baseStationAircraftList"></param>
 public void Initialise(IUniversalPlugAndPlayManager uPnpManager, IBaseStationAircraftList baseStationAircraftList)
 {
     _UPnpManager = uPnpManager;
     _BaseStationAircraftList = baseStationAircraftList;
 }