示例#1
0
        void Dispose(bool fin)
        {
            if (renderingState == RenderingState.Disposed)
            {
                return;
            }

            manager.WindowDisposed(this);
            renderData.Dispose();

            if (!fin)
            {
                GC.SuppressFinalize(this);
                renderData = null;
                listener   = null;
                effects    = null;
                manager    = null;
            }

            Action <IWindow> t = onDisposing;

            if (t != null)
            {
                t(this);
            }
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public DefaultWindow(DefaultWindowManager manager, Guid resourceId, string title, string windowGroup,
                             IWindowBackend listener, WindowOptions options, Vector2i position, Vector2i size,
                             Vector2i minSize, Vector2i maxSize, WindowState windowState, IWindow parentWindow,
                             bool blockParentInput)
        {
            this.manager            = manager;
            this.renderDataId       = resourceId;
            this.title              = title;
            this.group              = windowGroup;
            this.listener           = listener;
            this.options            = options;
            this.position           = position;
            this.size               = size;
            this.minSize            = minSize;
            this.maxSize            = maxSize;
            this.windowState        = windowState;
            this.blockInputToParent = blockParentInput;
            this.parentWindow       = parentWindow;

            TypelessTexture texture = manager.Device.GetShared(resourceId);

            // We create texture view upon it.
            this.renderData = (texture as TypelessTexture2D).CreateTexture();
        }
示例#3
0
        public override int StartDocument(DocumentParameter[] parameters)
        {
            if (parameters.Length > 0)
            {
                throw new Exception("Shell application does not allow any parameters.");
            }

            // We first check if render target parameters are set.
            if (rtParameters == null)
            {
                rtParameters = new RenderTargetParameters();
                rtParameters.BackBufferCount          = 2;
                rtParameters.BackBufferWidth          = 1024;
                rtParameters.BackBufferHeight         = 768;
                rtParameters.DepthStencilCommonFormat = CommonPixelFormatLayout.D24_UNORM_S8_UINT;
                rtParameters.FormatCommon             = CommonPixelFormatLayout.X8Y8Z8W8_UNORM;
                rtParameters.MultiSampleQuality       = 0;
                rtParameters.MultiSampleType          = 1;
                rtParameters.RefreshRate = 0;
                rtParameters.Windowed    = true;
            }


            // We create graphics device.
            Window         window  = null;
            GraphicsDevice device  = null;
            IWindowManager manager = null;

            try {
                // 1) We create graphics device in owned mode.
                device = graphicsService.CreateDevice(true, graphicsDebug, rtParameters, out window);

                // 2) We initialize input.
                inputService.Initialize(window);

                // 3) We create window manager.
                manager = new Default.DefaultWindowManager(device, device.SwapChain, inputService, defaultTheme);

                // 4) We replace component directory (add new stuff in shell enviorment).
                IComponentDirectory newDirectory = new ComponentDirectory(componentDirectory, "Shell");
                newDirectory.Register(new Instance(true, "ShellFinishedConfiguring"));
                newDirectory.Register(new Instance(manager));
                newDirectory.Register(new Instance(defaultTheme));

                // 5) We replace console by Shell provided console.
                newDirectory.Register(new AlwaysNewConfiguredComponent(
                                          typeof(ShellTextConsole).FullName));

                // 6) We set the component directory.



                // 7) We unregister component directory.
            } finally {
                if (manager != null && manager is IDisposable)
                {
                    (manager as IDisposable).Dispose();
                }
                if (inputService != null)
                {
                    inputService.Dispose();
                }
                if (device != null)
                {
                    device.Dispose();
                }
            }

            return(0);
        }