Ejemplo n.º 1
0
        internal LinearGradientBrush(Direct2DRenderTarget renderTargetOwner, 
                                     GradientStop[] gradientStops, 
                                     ExtendMode extendMode, 
                                     PointF startPoint, 
                                     PointF endPoint)
        {
            m_renderTargetOwner = renderTargetOwner;

            var gradientStopList = new List<SlimDX.Direct2D.GradientStop>(gradientStops.Length);

            for (int i = 0; i < gradientStops.Length; i++)
            {
                gradientStopList.Add(gradientStops[i].InternalGradientStop);
            }

            var props = new LinearGradientBrushProperties();
            props.StartPoint = startPoint.InternalPointF;
            props.EndPoint = endPoint.InternalPointF;

            m_startPoint = startPoint;
            m_endPoint = endPoint;

            var internalRt = m_renderTargetOwner.InternalRenderTarget;

            m_internalGradientStopCollection = new GradientStopCollection(internalRt, 
                                                                          gradientStopList.ToArray(), 
                                                                          Gamma.Linear, 
                                                                          (SlimDX.Direct2D.ExtendMode)extendMode);

            m_internalLinearGradientBrush = new SlimDX.Direct2D.LinearGradientBrush(internalRt,
                                                                                    m_internalGradientStopCollection, 
                                                                                    props);
        }
Ejemplo n.º 2
0
        private void initializeGraphics()
        {
            factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, D2D.DebugLevel.None);

            //Create the render target
            renderTarget = new D2D.WindowRenderTarget(factory, new D2D.WindowRenderTargetProperties()
            {
                Handle         = this.Handle,
                PixelSize      = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Position = 0f, Color = new Color4(Color.White)
                },
                new D2D.GradientStop()
                {
                    Position = 1f, Color = new Color4(Color.White)
                }
            };
            backBrushGradient = new D2D.GradientStopCollection(renderTarget, gradientStops);
            backBrushEx       = new D2D.LinearGradientBrush(renderTarget, backBrushGradient, new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, this.Height), EndPoint = new PointF(0, 0)
            });

            //Update initialization flag
            this.FinishedInit = true;
        }
Ejemplo n.º 3
0
        // Entlädt alle graphicken
        private void UnloadGraphics()
        {
            if (m_backBrushEx != null)
            {
                m_backBrushEx.Dispose();
            }
            if (m_backBrushGradient != null)
            {
                m_backBrushGradient.Dispose();
            }
            if (m_renderTarget != null)
            {
                m_renderTarget.Dispose();
            }
            if (m_factory != null)
            {
                m_factory.Dispose();
            }

            m_backBrushEx       = null;
            m_backBrushGradient = null;
            m_renderTarget      = null;
            m_factory           = null;
        }
Ejemplo n.º 4
0
        //Ladet alle graphicken
        private void InitializeGraphics()
        {
            //Get requested debug level
            D2D.DebugLevel debugLevel = D2D.DebugLevel.None;
            if (m_debugMode)
            {
                debugLevel = D2D.DebugLevel.Error;
            }

            //Create factory object
            m_factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, debugLevel);
            //  m_factoryText = new SlimDX.DirectWrite.Factory();
            //Create the render target
            m_renderTarget = new D2D.WindowRenderTarget(m_factory, new D2D.WindowRenderTargetProperties()
            {
                Handle         = this.Handle,
                PixelSize      = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Position = 0f, Color = new Color4(Color.LightGray)
                },
                new D2D.GradientStop()
                {
                    Position = 1f, Color = new Color4(Color.Black)
                }
            };
            m_backBrushGradient = new D2D.GradientStopCollection(m_renderTarget, gradientStops);
            m_backBrushEx       = new D2D.LinearGradientBrush(
                m_renderTarget,
                m_backBrushGradient,
                new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, this.Height),
                EndPoint   = new PointF(0, 0)
            });

            //Create gdi backbrush
            if (m_backBrushGdi != null)
            {
                m_backBrushGdi.Dispose();
            }
            m_backBrushGdi = new LinearGradientBrush(
                new Point(0, this.Height),
                new Point(0, 0),
                Color.LightGray,
                Color.LightSteelBlue);

            //Load the bitmap

            backGroundBitmap = LoadBitmap(Resources.Resource.skyline);
            groundBitmap     = LoadBitmap(Resources.Resource.ground);
            pipeLowerBitmap  = LoadBitmap(Resources.Resource.pipe_up);
            pipeUperBitmap   = LoadBitmap(Resources.Resource.pipe_down);
            birdBitmap       = LoadBitmap(Resources.Resource.bird_one);
            //Update initialization flag
            m_initialized = true;
        }
Ejemplo n.º 5
0
        private void initializeGraphics()
        {
            factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, D2D.DebugLevel.None);

            //Create the render target
            renderTarget = new D2D.WindowRenderTarget(factory, new D2D.WindowRenderTargetProperties()
            {
                Handle = this.Handle,
                PixelSize = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
               new D2D.GradientStop(){ Position = 0f, Color = new Color4(Color.White) },
                new D2D.GradientStop(){ Position = 1f, Color = new Color4(Color.White) }
            };
            backBrushGradient = new D2D.GradientStopCollection(renderTarget, gradientStops);
            backBrushEx = new D2D.LinearGradientBrush(renderTarget, backBrushGradient, new D2D.LinearGradientBrushProperties() { StartPoint = new PointF(0, this.Height), EndPoint = new PointF(0, 0) });

            //Update initialization flag
            this.FinishedInit = true;
        }
Ejemplo n.º 6
0
        // Ladet alle Graphischen ressoursen
        private void InitializeGraphics()
        {
            //Get requested debug level
            D2D.DebugLevel debugLevel = D2D.DebugLevel.None;
            if (m_debugMode)
            {
                debugLevel = D2D.DebugLevel.Error;
            }

            //Create factory object
            m_factory = new D2D.Factory(D2D.FactoryType.SingleThreaded, debugLevel);

            //Create the render target
            m_renderTarget = new D2D.WindowRenderTarget(m_factory, new D2D.WindowRenderTargetProperties()
            {
                Handle         = this.Handle,
                PixelSize      = this.Size,
                PresentOptions = D2D.PresentOptions.Immediately
            });

            //Create linear gradient brush
            D2D.GradientStop[] gradientStops = new D2D.GradientStop[]
            {
                new D2D.GradientStop()
                {
                    Position = 0f, Color = new Color4(Color.LightGray)
                },
                new D2D.GradientStop()
                {
                    Position = 1f, Color = new Color4(Color.Black)
                }
            };
            m_backBrushGradient = new D2D.GradientStopCollection(m_renderTarget, gradientStops);
            m_backBrushEx       = new D2D.LinearGradientBrush(
                m_renderTarget,
                m_backBrushGradient,
                new D2D.LinearGradientBrushProperties()
            {
                StartPoint = new PointF(0, this.Height),
                EndPoint   = new PointF(0, 0)
            });

            //Create gdi backbrush
            if (m_backBrushGdi != null)
            {
                m_backBrushGdi.Dispose();
            }
            m_backBrushGdi = new LinearGradientBrush(
                new Point(0, this.Height),
                new Point(0, 0),
                Color.LightGray,
                Color.LightSteelBlue);

            //Load the bitmap
            level.Backgroundgdi = Resources.Resources.SpaceBackground1;
            level.Background    = LoadBitmap(level.Backgroundgdi);

            spaceshipBitmapGDI         = Resources.Resources.GreenSpaceShip;
            spaceShipBitmap            = LoadBitmap(spaceshipBitmapGDI);
            _Player                    = new PlayerShip(spaceShipBitmap);
            projektileBitmapGdi        = Resources.Resources.greenProjectile;
            projektileBitmap           = LoadBitmap(projektileBitmapGdi);
            projektileHostileBitmapGdi = Resources.Resources.greenprojectile1;
            projektileHostileBitmap    = LoadBitmap(projektileHostileBitmapGdi);
            level.Backgroundlvl1       = LoadBitmap(Resources.Resources.SpaceBackground1);
            level.Backgroundlvl2       = LoadBitmap(Resources.Resources.sewer);
            level.BackgroundGameOver   = LoadBitmap(Resources.Resources.GameOver);
            level.BackgroundNextLevel  = LoadBitmap(Resources.Resources.NextLevel);
            enenyShipBitmap            = LoadBitmap(Resources.Resources.cartoonship_red);
            //Update initialization flag
            m_initialized = true;
        }