Esempio n. 1
0
        private async void DisableRenderer()
        {
            if (_imageEx == null || VisibilityAnimation.GetVisible(Scene) == false)
            {
                return;
            }

            try {
                VisibilityAnimation.SetVisible(Scene, false);
                await Task.Delay(500);

                if (Model.Renderer != null)
                {
                    Model.Renderer.Dispose();
                    Model.Renderer = null;
                }

                CompositionTarget.Rendering -= OnRendering;

                Scene.Source = null;

                _imageEx.Lock();
                _imageEx.SetBackBufferEx(D3DResourceTypeEx.ID3D11Texture2D, IntPtr.Zero);
                _imageEx.Unlock();
                _imageEx = null;
            } catch (Exception e) {
                MessageBox.Show(e.ToString());
            }
        }
Esempio n. 2
0
        private void EnableRenderer(bool cameraHigher)
        {
            try {
                if (_imageEx != null)
                {
                    return;
                }

                var renderer = new DarkKn5ObjectRenderer(Model.Car);
                renderer.SelectSkin(null);
                renderer.Initialize();
                renderer.SetCameraHigher = cameraHigher;
                SetRendererSize(renderer);
                renderer.Draw();
                Model.Renderer = renderer;

                _imageEx     = new D3DImageEx();
                Scene.Source = _imageEx;
                _setCount    = 0;
                _lastTarget  = IntPtr.Zero;

                CompositionTarget.Rendering += OnRendering;
                VisibilityAnimation.SetVisible(Scene, true);
            } catch (Exception e) {
                MessageBox.Show(e.ToString());
            }
        }