コード例 #1
0
        public WorldController(IWorldView view, IControllerFactory controllerFactory, IMessageBus messageBus, IConfigFile <Config> configFile, IFileSystem fileSystem)
            : base(view)
        {
            messageBus.ThrowIfNull(nameof(messageBus));

            _controllerFactory = controllerFactory.EnsureNotNull(nameof(controllerFactory));
            _configFile        = configFile.EnsureNotNull(nameof(configFile));
            _fileSystem        = fileSystem.EnsureNotNull(nameof(fileSystem));

            AddDisposables(
                messageBus.GetObservable <WorldChangedMessage>().Subscribe(ReceiveMessage),
                View.FileCloseWorldRequested.Subscribe(x => CloseWorld()),
                View.FileExitRequested.Subscribe(x => Exit()),
                View.FileNewWorldRequested.Subscribe(x => NewWorld()),
                View.FileOpenWorldRequested.Subscribe(x => OpenWorld()),
                View.FileSaveWorldAsRequested.Subscribe(x => SaveWorldAs()),
                View.FileSaveWorldRequested.Subscribe(x => SaveWorld()),
                View.HelpAboutRequested.Subscribe(x => About()),
                View.ToolsOptionsRequested.Subscribe(x => Options()),
                View.ViewClosing.Subscribe(x => x.Cancel = !ViewClosing(x.CloseReason == CloseReason.UserClosing)),
                View.WorldVariablesRequested.Subscribe(x => Variables()));

            View.RestoreBounds(_configFile.Config.Views.World.Bounds);
            View.SetTitle(ViewTitle);
            View.HideWorldToolStrips();
            View.DisableCloseWorldToolStripItems();
            View.DisableSaveWorldToolStripItems();
            View.DisableSaveWorldAsToolStripItems();
        }