예제 #1
0
    private void hover_AnimateClicked(object sender, EventArgs e)
    {
        dbg.WriteLine("----- hover_AnimateClicked -----");

        PhysicsIllustrator.SmartTag.SmartTag tag = sender as PhysicsIllustrator.SmartTag.SmartTag;

        // Running or stopping?
        if (inkoverlay.Enabled)
        {
            // Lock down all editing operations.
            DisableInkOverlay();
            if (bodytag.Visible)
            {
                bodytag.Hide();
            }

            // Change tag to red x.
            hover.Enabled = false;
            tag.Image     = Global.LoadImage("Resources.StopAnimation.ico");
            menuttip.SetToolTip(tag, "Stop!");
            tag.Show();

            // Fork the document for animation.
            MagicDocument animedoc = doc.Clone();

            // Run the animation!
            engine = new AnimationEngine();
            engine.Start(animedoc, this);
        }
        else         // stopping
        {
            engine.Stop();

            inkoverlay.Enabled = true;

            tag.Image = Global.LoadImage("Resources.Animate.ico");
            menuttip.SetToolTip(tag, "Animate!");
            hover.Enabled = true;
            hover.DisplayInitial();
            Invalidate();
        }
    }
예제 #2
0
    private void ShowBodyTag(RigidBodyBase body)
    {
        // Establish point on lower-right of selected body's bbox.
        Point p = new Point(body.BoundingBox.Right, body.BoundingBox.Bottom);

        using (Graphics g = this.CreateGraphics())
        {
            // Convert to pixel-space.
            inkoverlay.Renderer.InkSpaceToPixel(g, ref p);
        }

        // Make sure we're not off the edge of the screen.
        if (p.X > this.Right - bodytag.Width)
        {
            p.X = this.Right - bodytag.Width;
        }
        if (p.Y > this.Bottom - bodytag.Height)
        {
            p.Y = this.Bottom - bodytag.Height;
        }

        bodytag.Show(p);
    }