コード例 #1
0
        /// <summary>Immediately releases all resources used the GUI manager</summary>
        public void Dispose()
        {
            // Unregister the service if we have registered it before
            if (_gameServices != null)
            {
                var registeredService = _gameServices.GetService(typeof(IGuiService));

                if (ReferenceEquals(registeredService, this))
                {
                    _gameServices.RemoveService(typeof(IGuiService));
                }
            }

            // Dispose the input capturer, if necessary
            if (_inputCapturer != null)
            {
                var disposableInputCapturer = _inputCapturer as IDisposable;

                disposableInputCapturer?.Dispose();

                _updateableInputCapturer = null;
                _inputCapturer           = null;
            }

            // Dispose the GUI visualizer, if necessary
            if (_guiVisualizer != null)
            {
                var disposableguiVisualizer = _guiVisualizer as IDisposable;

                disposableguiVisualizer?.Dispose();

                _updateableGuiVisualizer = null;
                _guiVisualizer           = null;
            }
        }
コード例 #2
0
ファイル: GuiManager.Test.cs プロジェクト: minskowl/MY
        public void TestVisualizerUpdate()
        {
            using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) {
                DummyVisualizer dummy = new DummyVisualizer();

                IGuiVisualizer visualizer = guiManager.Visualizer;
                guiManager.Visualizer = dummy;
                tryDispose(visualizer);

                Assert.AreEqual(0, dummy.UpdateCallCount);
                guiManager.Update(new GameTime());
                Assert.AreEqual(1, dummy.UpdateCallCount);
            }
        }
コード例 #3
0
ファイル: GuiManager.Test.cs プロジェクト: minskowl/MY
        public void TestDrawing()
        {
            using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) {
                DummyVisualizer dummy = new DummyVisualizer();

                IGuiVisualizer visualizer = guiManager.Visualizer;
                guiManager.Visualizer = dummy;
                tryDispose(visualizer);

                guiManager.Screen = new Screen();

                Assert.AreEqual(0, dummy.DrawCallCount);
                guiManager.Draw(new GameTime());
                Assert.AreEqual(1, dummy.DrawCallCount);
            }
        }
コード例 #4
0
ファイル: GuiManager.Test.cs プロジェクト: minskowl/MY
        public void TestVisualizerAssignment()
        {
            using (GuiManager guiManager = new GuiManager(new GameServiceContainer())) {
                IGuiVisualizer visualizer = new DummyVisualizer();
                try {
                    IGuiVisualizer newVisualizer = visualizer;

                    Assert.AreNotSame(newVisualizer, guiManager.Visualizer);
                    {
                        IGuiVisualizer oldVisualizer = guiManager.Visualizer;
                        guiManager.Visualizer = newVisualizer;
                        visualizer            = oldVisualizer;
                    }
                    Assert.AreSame(newVisualizer, guiManager.Visualizer);
                }
                finally {
                    tryDispose(visualizer);
                }
            }
        }
コード例 #5
0
 public override void LoadContent(DeviceContext context)
 {
     _guiVisualizer = ToDispose(FlatGuiVisualizer.FromFile(_d3DEngine, _skinPath, _plugInComponentAssemblies));
 }