Esempio n. 1
0
        public void Render()
        {
            Draw.Fill(20);
            Draw.Stroke(200);
            Draw.StrokeWidth(4);
            Draw.Rect(pos, dim);
            Vector2 imageSize = Vector2.One * 40;

            Draw.Image(Image, pos + (dim / 2) - (imageSize / 2), imageSize);

            float distOut = dim.y / (Outputs.Count + 1);
            float distInp = dim.y / (Inputs.Count + 1);
            float maxOut  = Outputs.Count * 32;
            float maxinp  = Inputs.Count * 32;

            for (int i = 1; i <= Outputs.Count; i++)
            {
                OutputPort outp = Outputs[i - 1];
                outp.pos.Set(pos.x + dim.x, ((dim.y / 2) - (maxOut / 2)) + (pos.y + (i * 32)) - 16);
                outp.Render();
            }
            for (int i = 1; i <= Inputs.Count; i++)
            {
                InputPort inp = Inputs[i - 1];
                inp.pos.Set(pos.x, ((dim.y / 2) - (maxinp / 2)) + (pos.y + (i * 32)) - 16);
                inp.Render();
            }
            if (Mouse.Pos.Inside(pos, pos + dim) && ScreenSurface.CurrentWorktable.SelectedComp == null)
            {
                if (Mouse.Lbutton)
                {
                    ScreenSurface.CurrentWorktable.SelectedComp      = this;
                    ScreenSurface.CurrentWorktable.MouseDisplacement = Mouse.Pos - pos;
                }
                else if (Mouse.Rdown)
                {
                    ScreenSurface.CurrentWorktable.propMenu.Open(this);
                }
            }
        }