コード例 #1
0
ファイル: EditorViewModel.cs プロジェクト: Tristyn/MCFire
        void Initialize([NotNull] World world, int dimension)
        {
            var view = _view;

            DisplayName = "Starting Up - Editor";

            var sharpDxElement = view.SharpDx;
            var game           = new EditorGameFactory().Create(sharpDxElement, IoC.GetAll <IGameComponent>(), world, dimension);

            _game = game;

            Deactivated += ExitGame;

            // this is an extremely dirty hack. SharpDxElement will dispose when Unloaded is called,
            // but that can be triggered by avalondock, while the control should still be kept alive.
            // We can't prevent disposing because SharpDxElement is sealed, and the methods are private.
            // The only option then is to remove the event handler via reflection.
            // We select the method with the matching name and remove it.
            var handlers = GetRoutedEventHandlers(sharpDxElement, FrameworkElement.UnloadedEvent);
            var sharpDxElementDisposer = handlers.FirstOrDefault(b => b.Handler.Method.Name == "HandleUnloaded");

            sharpDxElement.RemoveHandler(FrameworkElement.UnloadedEvent, sharpDxElementDisposer.Handler);
            _game = game;
            _aggregator.Publish(new EditorOpenedMessage(game));
            _aggregator.Publish(new EditorGainedFocusMessage(game));

            DisplayName = String.Format("{0} - Editor", world.Title);
        }
コード例 #2
0
 protected EditorMessage([NotNull] IEditorGameFacade editorGame)
 {
     if (editorGame == null)
     {
         throw new ArgumentNullException("editorGame");
     }
     EditorGame = editorGame;
 }
コード例 #3
0
 public EditorClosingMessage([NotNull] IEditorGameFacade editorGame) : base(editorGame)
 {
 }
コード例 #4
0
 public EditorOpenedMessage([NotNull] IEditorGameFacade editorViewModel) : base(editorViewModel)
 {
 }
コード例 #5
0
 public EditorGainedFocusMessage([NotNull] IEditorGameFacade editorGame) : base(editorGame)
 {
 }