Esempio n. 1
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null) return;
            if (!CanDraw()) return;
            Components.Logics.VoltageGraphLogics l = (Components.Logics.VoltageGraphLogics)parent.Logics;

            UpdateFBO();

            switch (parent.ComponentRotation)
            {
                case Component.Rotation.cw0:
                    renderer.Draw(texture0cw,
                        new Rectangle((int)Position.X, (int)Position.Y,
                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                            Color.White);
                    break;
                case Component.Rotation.cw90:
                    renderer.Draw(texture90cw,
                        new Rectangle((int)Position.X, (int)Position.Y,
                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                            Color.White);
                    break;
                case Component.Rotation.cw180:
                    renderer.Draw(texture180cw,
                        new Rectangle((int)Position.X, (int)Position.Y,
                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                            Color.White);
                    break;
                case Component.Rotation.cw270:
                    renderer.Draw(texture270cw,
                        new Rectangle((int)Position.X, (int)Position.Y,
                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                            Color.White);
                    break;
                default:
                    break;
            }

            if (parent.ComponentRotation == Component.Rotation.cw0 || parent.ComponentRotation == Component.Rotation.cw180)
                renderer.Draw(fbo, new Rectangle((int)Position.X + 15, (int)Position.Y + 11, 39, 23), null, Color.White);
            else
                renderer.Draw(fbo, new Rectangle((int)Position.X + 29, (int)Position.Y + 15, 39, 23), null, Color.White, (float)Math.PI / 2, Vector2.Zero);

            renderer.End();
            renderer.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone,
                null, Matrix.CreateScale(0.25f), true);
            if (parent.ComponentRotation == Component.Rotation.cw0 || parent.ComponentRotation == Component.Rotation.cw180)
            {
                renderer.DrawStringRight(font, l.max.ToString(), new Rectangle((int)Position.X * 4 + 42, (int)Position.Y * 4 + 47, 12, 8), Color.Gray);
                renderer.DrawStringRight(font, l.min.ToString(), new Rectangle((int)Position.X * 4 + 42, (int)Position.Y * 4 + 125, 12, 8), Color.Gray);
            }
            else
            {
                renderer.DrawStringLeft(font, l.min.ToString(), Position * 4 + new Vector2(26, 44), Color.Gray);
                renderer.DrawStringRight(font, l.max.ToString(), new Rectangle((int)Position.X * 4 + 102, (int)Position.Y * 4 + 44, 12, 8), Color.Gray);
            }
            renderer.End();
            renderer.Begin();
        }