Exemplo n.º 1
0
        void OnClosed(object sender, EventArgs e)
        {
            if (graphicsDeviceService != null)
            {
                graphicsDeviceService.Release(true);
                graphicsDeviceService = null;
            }

            // ウィンドウの状態を設定として保存します。
            settings.WindowLeft = Left;
            settings.WindowTop = Top;
            settings.WindowWidth = Width;
            settings.WindowHeight = Height;
            settings.WindowMaximized = (WindowState == WindowState.Maximized);
            settings.Save();
        }
        /// <summary>
        /// Gets a reference to the singleton instance.
        /// </summary>
        public static GraphicsDeviceService AddRef(GraphicsProfile profile, IntPtr windowHandle, int width, int height)
        {
            // Increment the "how many controls sharing the device" reference count.
            if (Interlocked.Increment(ref referenceCount) == 1)
            {
                // If this is the first control to start using the
                // device, we must create the singleton instance.
                singletonInstance = new GraphicsDeviceService(profile, windowHandle, width, height);
            }

            return singletonInstance;
        }
Exemplo n.º 3
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (AppTraceListener.Current != null)
            {
                AppTraceListener.Current.DelegateDraw += ConsoleWindow.Console.Write;
                AppTraceListener.Current.TraceCacheEnabled = false;
                ConsoleWindow.Console.SetInitialMessage(AppTraceListener.Current.ConsumeTraceCache());
            }

            var source = HwndSource.FromVisual(this) as HwndSource;
            graphicsDeviceService = GraphicsDeviceService.AddRef(GraphicsProfile.HiDef, source.Handle, 0, 0);
            workspace.Services.AddService<IGraphicsDeviceService>(graphicsDeviceService);
        }