Наследование: IDisposable
Пример #1
0
        protected override void OnStartup( StartupEventArgs e )
        {
            base.OnStartup( e );

            mMainWindow = new MainWindow();

            var windowDescriptions = new ObservableDictionary<string, D3D11HwndDescription>
                                     {
                                         {
                                             "TileManager2D",
                                             new D3D11HwndDescription
                                             {
                                                 Handle = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Handle,
                                                 Width = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Width,
                                                 Height = mMainWindow.TileManager2DViewerContext.D3D11RenderingPaneHost.Height
                                             }
                                             },
                                     };

            mEngine = new Engine( windowDescriptions );

            mUpdateTimer = new DispatcherTimer( DispatcherPriority.Input ) { Interval = TimeSpan.FromMilliseconds( Settings.Default.TargetFrameTimeMilliseconds ) };
            mUpdateTimer.Tick += TickHandler;
            mUpdateTimer.Start();

            var engineDataContext = new EngineDataContext( mEngine, new TileManagerDataContext( mEngine.TileManager ) );

            mMainWindow.DataContext = engineDataContext;

            mMainWindow.Closing += OnMainWindowClosing;

            mMainWindow.Show();
        }
Пример #2
0
        protected override void OnExit( ExitEventArgs e )
        {
            ((EngineDataContext) mMainWindow.DataContext).Dispose();
            mMainWindow.DataContext = null;

            mUpdateTimer.Stop();
            mUpdateTimer.Tick -= TickHandler;

            Settings.Default.Save();

            if ( mEngine != null )
            {
                mEngine.Dispose();
                mEngine = null;
            }

            if ( mMainWindow != null )
            {
                mMainWindow.Dispose();
                mMainWindow = null;
            }

            base.OnExit( e );
        }