Exemplo n.º 1
0
        private void DrawTexture2(Classes.Rendering.TextureExt image, Rectangle srcRect, Vector3 center, Vector3 position, Color color)
        {
            if (image == null)
            {
                return;
            }
            var dx_color = new SharpDX.Color(color.R, color.G, color.B, color.A);
            var dx_rec   = new SharpDX.Rectangle(srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height);

            sprite2.Draw(image, dx_color, dx_rec, center, position);
        }
Exemplo n.º 2
0
        public void DisposeDeviceResources()
        {
            if (tx != null)
            {
                tx.Dispose();
                tx = null;
            }
            if (hvcursor != null)
            {
                hvcursor.Dispose();
                hvcursor = null;
            }
            if (vcursor != null)
            {
                vcursor.Dispose();
                vcursor = null;
            }
            if (hcursor != null)
            {
                hcursor.Dispose();
                hcursor = null;
            }

            if (FontDX != null)
            {
                FontDX.Dispose();
                FontDX = null;
            }
            if (FontDX_Bold != null)
            {
                FontDX_Bold.Dispose();
                FontDX_Bold = null;
            }

            if (sprite != null)
            {
                sprite.Dispose();
                sprite = null;
            }
            if (sprite2 != null)
            {
                sprite2.Dispose();
                sprite2 = null;
            }
            if (tx_ellipses != null)
            {
                foreach (var tx_ellipse in tx_ellipses)
                {
                    tx_ellipses[tx_ellipse.Key].Dispose();
                }
                tx_ellipses.Clear();
                tx_ellipses = null;
            }
        }
Exemplo n.º 3
0
        public void InitDeviceResources()
        {
            Bitmap txb = new Bitmap(1, 1);

            using (Graphics g = Graphics.FromImage(txb))
                g.Clear(Color.White);

            Bitmap hcursorb = new Bitmap(32, 32);

            using (Graphics g = Graphics.FromImage(hcursorb))
                Cursors.NoMoveHoriz.Draw(g, new Rectangle(0, 0, 32, 32));
            MakeGray(hcursorb);

            Bitmap vcursorb = new Bitmap(32, 32);

            using (Graphics g = Graphics.FromImage(vcursorb))
                Cursors.NoMoveVert.Draw(g, new Rectangle(0, 0, 32, 32));
            MakeGray(vcursorb);

            Bitmap hvcursorb = new Bitmap(32, 32);

            using (Graphics g = Graphics.FromImage(hvcursorb))
                Cursors.NoMove2D.Draw(g, new Rectangle(0, 0, 32, 32));
            MakeGray(hvcursorb);

            sprite  = new Sprite(_device);
            sprite2 = new Sprite(_device);

            tx_ellipses = new Dictionary <EllipseKey, TextureExt>();

            tx       = Methods.Drawing.TextureCreator.FromBitmap(_device, txb);
            hcursor  = Methods.Drawing.TextureCreator.FromBitmap(_device, hcursorb);
            vcursor  = Methods.Drawing.TextureCreator.FromBitmap(_device, vcursorb);
            hvcursor = Methods.Drawing.TextureCreator.FromBitmap(_device, hvcursorb);

            FontDX      = new Font(_device, FontDescription);
            FontDX_Bold = new Font(_device, FontDescription_Bold);

            FPS_Clock = Stopwatch.StartNew();
        }
Exemplo n.º 4
0
        public void DrawBitmap(Classes.Rendering.TextureExt image, int x, int y, int rect_x, int rect_y, int width, int height, bool selected, int Transparency, bool fliph = false, bool flipv = false, int rotation = 0, Color?color = null)
        {
            var LastTransform = sprite.Transform;

            Rectangle screen = _parent.GetScreen();
            double    zoom   = _parent.GetZoom();

            sprite.Transform = Matrix.Scaling((float)zoom, (float)zoom, 1f);

            Rectangle boundBox = new Rectangle(rect_x, rect_y, width, height);
            Vector3   position = new Vector3(x - (int)(screen.X / zoom), y - (int)(screen.Y / zoom), 0);
            Vector3   center   = new Vector3(new float[] { 0, 0, 0 });

            if (fliph || flipv || rotation != 0)
            {
                float negatedZoom = -(float)zoom;
                float normalZoom  = (float)zoom;
                if (rotation != 0)
                {
                    float center_x   = (fliph ? (float)(width / 2) : (float)(width / 2));
                    float center_y   = (flipv ? (float)(height / 2) : (float)(height / 2));
                    float position_x = (fliph ? position.X : position.X);
                    float position_y = (flipv ? position.Y : position.Y);

                    var scalingCenter   = new Vector2(0, 0);
                    var scalingRotation = 1f;
                    var scaling         = new Vector2(1f, 1f);
                    var rotationCenter  = new Vector2(center_x, center_y);
                    var Rotation        = (float)(rotation * (Math.PI / 180.0));
                    var translation     = new Vector2(position_x, position_y);
                    sprite.Transform = Matrix.Transformation2D(scalingCenter, scalingRotation, scaling, rotationCenter, Rotation, translation);
                    position         = Vector3.Zero;
                    center           = Vector3.Zero;
                    //sprite.Transform *= Matrix.Scaling((fliph ? negatedZoom : normalZoom), (flipv ? negatedZoom : normalZoom), 1f);
                    sprite.Transform *= Matrix.Scaling(normalZoom, normalZoom, 1f);
                }
                else
                {
                    if (fliph)
                    {
                        position.X = -position.X;
                    }
                    if (flipv)
                    {
                        position.Y = -position.Y;
                    }

                    if (fliph)
                    {
                        center.X = boundBox.Width;
                    }
                    if (flipv)
                    {
                        center.Y = boundBox.Height;
                    }
                    sprite.Transform = Matrix.Scaling((fliph ? negatedZoom : normalZoom), (flipv ? negatedZoom : normalZoom), 1f);
                }
            }

            if (color != null)
            {
                DrawTexture(image, boundBox, center, position, Color.FromArgb(Transparency, color.Value));
            }
            else
            {
                DrawTexture(image, boundBox, center, position, (selected) ? Color.BlueViolet : Color.FromArgb(Transparency, Color.White));
            }

            sprite.Transform = LastTransform;
        }
Exemplo n.º 5
0
 public void DrawBitmap(Classes.Rendering.TextureExt image, int x, int y, int width, int height, bool selected, int transparency)
 {
     DrawBitmap(image, x, y, 0, 0, width, height, selected, transparency);
 }