static bool CompareDocuments(MagicDocument a, MagicDocument b)
        {
            if (a.version != b.version) return false;
            if (a.Bodies.Count != b.Bodies.Count) return false;
            if (a.Mechanisms.Count != b.Mechanisms.Count) return false;
            if (a.xml_Ink != b.xml_Ink) return false;

            for (int i=0; i < a.Bodies.Count; ++i)
            {
                RigidBodyBase a1 = ((RigidBodyBase)a.Bodies[i]);
                RigidBodyBase b1 = ((RigidBodyBase)b.Bodies[i]);
                if (a1.GetType() != b1.GetType()) return false;
                if (a1.strokeid != b1.strokeid) return false;
                if (a1.anchored != b1.anchored) return false;
                if (a1.cfriction != b1.cfriction) return false;
                if (a1.density != b1.density) return false;
            }

            for (int i=0; i < a.Mechanisms.Count; ++i)
            {
                MechanismBase a1 = ((MechanismBase)a.Mechanisms[i]);
                MechanismBase b1 = ((MechanismBase)b.Mechanisms[i]);
                if (a1.GetType() != b1.GetType()) return false;
                if (a1 is ForceMechanismBase)
                {
                    ForceMechanismBase a2 = (ForceMechanismBase)a1;
                    ForceMechanismBase b2 = (ForceMechanismBase)b1;
                    if (a2.Body.strokeref != b2.Body.strokeref) return false;
                    if (a2.Body.attachloc != b2.Body.attachloc ) return false;
                    if (a2.vector != b2.vector) return false;
                }
            }

            return true;
        }
Example #2
0
    public static MagicDocument LoadDocument(System.IO.TextReader reader)
    {
        MagicDocument newdoc = xmlSerializer.Deserialize(reader) as MagicDocument;

        foreach (MechanismBase mech in newdoc.Mechanisms)
        {
            mech.CompleteDeserialization(newdoc);
        }

        return(newdoc);
    }
Example #3
0
        //[UnitTest]
        static bool TestCloneability()
        {
            MagicDocument fixture = CreateDocumentFixture();
            MagicDocument result  = fixture.Clone();

            if (Object.ReferenceEquals(fixture, result))
            {
                Console.Error.WriteLine("dude, come on...");
            }

            return(CompareDocuments(fixture, result));
        }
Example #4
0
    //
    // Menu item handlers

    private void hover_FileNewClicked(object sender, System.EventArgs e)
    {
        if (!IsUserSure())
        {
            return;
        }

        doc = new MagicDocument();
        HookupOverlayToNewInk();
        savedfilename = null;

        Invalidate();
    }
Example #5
0
        //[UnitTest]
        static bool TestBasicReadingWritingAndRithmetic()
        {
            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
            System.IO.StringWriter    writer = new System.IO.StringWriter(buffer);

            MagicDocument fixture = CreateDocumentFixture();

            fixture.WriteDocument(writer);

            //Console.WriteLine(buffer.ToString());

            System.IO.StringReader reader = new System.IO.StringReader(buffer.ToString());
            MagicDocument          result = MagicDocument.LoadDocument(reader);

            return(CompareDocuments(fixture, result));
        }
Example #6
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics g = e.Graphics;

        // Set "world" transform == ink-to-pixel space transform.
        Rectangle rect = new Rectangle(0, 0, 10000, 10000);

        Point[] plgpts = new Point[] {
            new Point(0, 0),
            new Point(10000, 0),
            new Point(0, 10000)
        };
        inkoverlay.Renderer.InkSpaceToPixel(g, ref plgpts);
        using (Matrix world = new Matrix(rect, plgpts))
        {
            g.Transform = world;
        }

        // Use actual doc when editing; throwaway clone when animating.
        MagicDocument doc = this.doc;

        if (!inkoverlay.Enabled && engine != null && engine.Document != null)
        {
            doc = engine.Document;
        }

        // Draw gravity vector in background.
        if (doc.Gravity != null)
        {
            doc.Gravity.Render(g);
        }

        // Draw bodies.
        foreach (RigidBodyBase body in doc.Bodies)
        {
            body.Render(g);
        }

        // Draw mechs.
        foreach (MechanismBase mech in doc.Mechanisms)
        {
            mech.Render(g);
        }
    }
        static MagicDocument CreateDocumentFixture()
        {
            MagicDocument doc = new MagicDocument();

            RigidBodyBase body;

            body = new EllipticalBody();
            body.strokeid = 1;
            doc.Bodies.Add(body);

            body = new EllipticalBody();
            body.strokeid = 2;
            doc.Bodies.Add(body);

            body = new PolygonalBody();
            body.strokeid = 3;
            doc.Bodies.Add(body);
            ((PolygonalBody)body).Vertices = new Point[] {
                                                             new Point(120,340),
                                                             new Point(560,340),
                                                             new Point(560,780),
                                                             new Point(120,780)
                                                         };

            BindingMechanismBase mech;

            mech = new RodMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[0],Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[1],Point.Empty);
            doc.Mechanisms.Add(mech);

            mech = new RopeMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[1],Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[2],Point.Empty);
            doc.Mechanisms.Add(mech);

            mech = new SpringMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[2],Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[0],Point.Empty);
            doc.Mechanisms.Add(mech);

            return doc;
        }
Example #8
0
        static MagicDocument CreateDocumentFixture()
        {
            MagicDocument doc = new MagicDocument();

            RigidBodyBase body;

            body          = new EllipticalBody();
            body.strokeid = 1;
            doc.Bodies.Add(body);

            body          = new EllipticalBody();
            body.strokeid = 2;
            doc.Bodies.Add(body);

            body          = new PolygonalBody();
            body.strokeid = 3;
            doc.Bodies.Add(body);
            ((PolygonalBody)body).Vertices = new Point[] {
                new Point(120, 340),
                new Point(560, 340),
                new Point(560, 780),
                new Point(120, 780)
            };

            BindingMechanismBase mech;

            mech           = new RodMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[0], Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[1], Point.Empty);
            doc.Mechanisms.Add(mech);

            mech           = new RopeMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[1], Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[2], Point.Empty);
            doc.Mechanisms.Add(mech);

            mech           = new SpringMech();
            mech.EndpointA = BodyRef.For((RigidBodyBase)doc.Bodies[2], Point.Empty);
            mech.EndpointB = BodyRef.For((RigidBodyBase)doc.Bodies[0], Point.Empty);
            doc.Mechanisms.Add(mech);

            return(doc);
        }
Example #9
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();
        }
    }
Example #10
0
    //
    // Interface

    public void Start(MagicDocument doc, Control wnd)
    {
        this.doc = doc;
        this.wnd = wnd;

        running = true;

        // Mark any object that is initially at rest if it overlaps with something
        // anchored or something else at rest.
        MarkInitialAtRest();

        int then = Environment.TickCount - 50;

        while (running)
        {
            // Relax the CPU if we're running better than 20fps (50ms); also
            // guard against any period longer than 50ms.
            int now = Environment.TickCount;
            if (now - then < 50)
            {
                int delay = 50 - (now - then);
                delay -= delay % 10;
                if (delay > 0)
                {
                    System.Threading.Thread.Sleep(delay);
                }
            }

            // Run the engine for 50 milliseconds before refresh.
            Tick(50);

            // Render the new frame of animation.
            wnd.Refresh();

            // Service the message queue.
            Application.DoEvents();

            // Continue.
            then = now;
            continue;
        }
    }
Example #11
0
    //
    // ICloneable implementation

    object ICloneable.Clone()
    {
        bool wasdirty = Ink.Dirty;

        try         // to remember to restore dirty flag
        {
            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
            using (System.IO.StringWriter writer = new System.IO.StringWriter(buffer))
            {
                this.WriteDocument(writer);
                using (System.IO.StringReader reader = new System.IO.StringReader(buffer.ToString()))
                {
                    return(MagicDocument.LoadDocument(reader));
                }
            }
        }
        finally
        {
            // Cloning != saving; don't lose the dirty bit.
            Ink.Dirty = wasdirty;
        }
    }
Example #12
0
    public void OpenDocument(string filename)
    {
        try
        {
            using (System.IO.TextReader reader = File.OpenText(filename))
            {
                // Load it!  And hook up the new Ink object.
                doc           = MagicDocument.LoadDocument(reader);
                savedfilename = filename;
                doc.Ink.Dirty = false;

                HookupOverlayToNewInk();
            }
        }
        catch (IOException ex)
        {
            MessageBox.Show(
                ex.Message,
                Application.ProductName,
                MessageBoxButtons.OK,
                MessageBoxIcon.Warning);
        }
    }
 internal override void CompleteDeserialization(MagicDocument doc)
 {
     EndpointA.Object = doc.LookupBody(EndpointA.strokeref);
     EndpointB.Object = doc.LookupBody(EndpointB.strokeref);
 }
    //
    // Interface

    #region Start()
    public void Start(MagicDocument doc, Control wnd)
    {
        // System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;

        this.doc = doc;
        this.wnd = wnd;

        running = true;
        paused  = false;

        // Mark any object that is initially at rest if it overlaps with something
        // anchored or something else at rest.
        MarkInitialAtRest();

        // Testes de pause
        // int pause = 0;

        int then = Environment.TickCount - 50;

        Application.DoEvents();
        while (running)
        {
            // Relax the CPU if we're running better than 20fps (50ms); also
            // guard against any period longer than 50ms.
            int now = Environment.TickCount;
            if (now - then < 50)
            {
                int delay = 50 - (now - then);
                delay -= delay % 10;
                if (delay > 0)
                {
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(delay);
                }
            }

            while (paused)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(5);
                then = now;
            }

            // Run the engine for 50 milliseconds before refresh.
            Tick(50);

            // Render the new frame of animation.
            wnd.Refresh();

            // Service the message queue.
            Application.DoEvents();

            /// System.Diagnostics.Debug.WriteLine(Global.clienteEnvia.tClienteRecebe.ThreadState.ToString());


            // Application.Run();

            // System.Threading.ManualResetEvent

            // Continue.
            then = now;
            continue;
        }
    }
Example #15
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

            Graphics g = e.Graphics;

            // Set "world" transform == ink-to-pixel space transform.
            Rectangle rect = new Rectangle(0,0,10000,10000);
            Point[] plgpts = new Point[] {
                                             new Point(0,0),
                                             new Point(10000,0),
                                             new Point(0,10000)
                                         };
            inkoverlay.Renderer.InkSpaceToPixel(g, ref plgpts);
            using (Matrix world = new Matrix(rect,plgpts))
            {
                g.Transform = world;
            }

            // Use actual doc when editing; throwaway clone when animating.
            MagicDocument doc = this.doc;

            if (!inkoverlay.Enabled && engine != null && engine.Document != null)
                doc = engine.Document;

            // Draw gravity vector in background.
            if (doc.Gravity != null)
                doc.Gravity.Render(g);

            // Draw bodies.
            foreach (RigidBodyBase body in doc.Bodies)
            {
                body.Render(g);
            }

            // Draw mechs.
            foreach (MechanismBase mech in doc.Mechanisms)
            {
                mech.Render(g);
            }
    }
Example #16
0
    public void OpenForCollaboration(TextWriter x)
    {
        try
            {
                StringReader y = new StringReader(x.ToString());

                doc = MagicDocument.LoadDocument(y);
                doc.Ink.Dirty = false;

                HookupOverlayToNewInk();
            }
           		catch (IOException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    Application.ProductName,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
    }
 internal override void CompleteDeserialization(MagicDocument doc)
 {
     EndpointA.Object = doc.LookupBody(EndpointA.strokeref);
     EndpointB.Object = doc.LookupBody(EndpointB.strokeref);
 }
Example #18
0
        static bool CompareDocuments(MagicDocument a, MagicDocument b)
        {
            if (a.version != b.version)
            {
                return(false);
            }
            if (a.Bodies.Count != b.Bodies.Count)
            {
                return(false);
            }
            if (a.Mechanisms.Count != b.Mechanisms.Count)
            {
                return(false);
            }
            if (a.xml_Ink != b.xml_Ink)
            {
                return(false);
            }

            for (int i = 0; i < a.Bodies.Count; ++i)
            {
                RigidBodyBase a1 = ((RigidBodyBase)a.Bodies[i]);
                RigidBodyBase b1 = ((RigidBodyBase)b.Bodies[i]);
                if (a1.GetType() != b1.GetType())
                {
                    return(false);
                }
                if (a1.strokeid != b1.strokeid)
                {
                    return(false);
                }
                if (a1.anchored != b1.anchored)
                {
                    return(false);
                }
                if (a1.cfriction != b1.cfriction)
                {
                    return(false);
                }
                if (a1.density != b1.density)
                {
                    return(false);
                }
            }

            for (int i = 0; i < a.Mechanisms.Count; ++i)
            {
                MechanismBase a1 = ((MechanismBase)a.Mechanisms[i]);
                MechanismBase b1 = ((MechanismBase)b.Mechanisms[i]);
                if (a1.GetType() != b1.GetType())
                {
                    return(false);
                }
                if (a1 is ForceMechanismBase)
                {
                    ForceMechanismBase a2 = (ForceMechanismBase)a1;
                    ForceMechanismBase b2 = (ForceMechanismBase)b1;
                    if (a2.Body.strokeref != b2.Body.strokeref)
                    {
                        return(false);
                    }
                    if (a2.Body.attachloc != b2.Body.attachloc)
                    {
                        return(false);
                    }
                    if (a2.vector != b2.vector)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #19
0
    private void hover_FileNewClicked(object sender, System.EventArgs e)
    {
        if (!IsUserSure())
            return;

        doc = new MagicDocument();
        HookupOverlayToNewInk();
        savedfilename = null;

        Invalidate();
    }
    public void Start(MagicDocument doc, Control wnd)
    {
        // System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;

        this.doc = doc;
        this.wnd = wnd;

        running = true;
        paused= false;

        // Mark any object that is initially at rest if it overlaps with something
        // anchored or something else at rest.
        MarkInitialAtRest();

        // Testes de pause
        // int pause = 0;

        int then = Environment.TickCount-50;

        Application.DoEvents();
        while (running)
        {
            // Relax the CPU if we're running better than 20fps (50ms); also
            // guard against any period longer than 50ms.
            int now = Environment.TickCount;
            if (now-then < 50)
            {
                int delay = 50 - (now-then);
                delay -= delay%10;
                if (delay > 0)
                {
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(delay);
                }
            }

            while(paused)
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(5);
                then = now;
            }

            // Run the engine for 50 milliseconds before refresh.
            Tick(50);

            // Render the new frame of animation.
            wnd.Refresh();

            // Service the message queue.
            Application.DoEvents();

            /// System.Diagnostics.Debug.WriteLine(Global.clienteEnvia.tClienteRecebe.ThreadState.ToString());

            // Application.Run();

            // System.Threading.ManualResetEvent

            // Continue.
            then = now;
            continue;

        }
    }
 internal override void CompleteDeserialization(MagicDocument doc)
 {
     Body.Object = doc.LookupBody(Body.strokeref);
 }
 // Post-deserialization callback, to dereference back-pointers in the XML.
 internal abstract void CompleteDeserialization(MagicDocument doc);
 // Post-deserialization callback, to dereference back-pointers in the XML.
 internal abstract void CompleteDeserialization(MagicDocument doc);
Example #24
0
    public MainForm()
    {
        // Required for Windows Form Designer support.
        InitializeComponent();

        // Load our icon.
        this.Icon = new Icon(typeof(MainForm),"PhysicsIllustrator.ico");

        // Initialize the per-item smart tag.
        bodytag = new PhysicsIllustrator.SmartTag.SmartTag();
        bodytag.Image = Global.LoadImage("Resources.PenMenu.ico");
        bodytag.Visible = false;

        bodytag.ContextMenu = new ContextMenu();
        bodytag.ContextMenu.MenuItems.Add("Clone", new EventHandler(hover_EditCloneClicked));
        bodytag.ContextMenu.MenuItems.Add("Delete", new EventHandler(hover_EditDeleteClicked));
        bodytag.ContextMenu.MenuItems.Add("-");
        bodytag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(hover_EditStraightenClicked));
        bodytag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(hover_EditPropertiesClicked));

        this.Controls.Add(bodytag);

        // Go fullscreen.  Note: this works even with the taskbar set
        // to "keep on top of other windows".
        this.WindowState = System.Windows.Forms.FormWindowState.Normal;
        // this.Bounds = Screen.PrimaryScreen.Bounds;

        // Declare repaint optimizations.
        base.SetStyle(
            ControlStyles.UserPaint|
            ControlStyles.AllPaintingInWmPaint|
            ControlStyles.DoubleBuffer,
            true);

        // Init inkoverlay.
        inkoverlay = new InkOverlay(this.Handle,true);
        inkoverlay.CollectionMode = CollectionMode.InkOnly; // no gestures

        inkoverlay.AutoRedraw = false; // Dynamic rendering only; we do all the painting.

        DrawingAttributes da = new DrawingAttributes();
        da.AntiAliased = false;
        inkoverlay.DefaultDrawingAttributes = da;

        inkoverlay.Stroke += new InkCollectorStrokeEventHandler(inkoverlay_Stroke);

        inkoverlay.CursorInRange += new InkCollectorCursorInRangeEventHandler(inkoverlay_CursorInRange);
        inkoverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkoverlay_StrokesDeleting);

        inkoverlay.SelectionChanging += new InkOverlaySelectionChangingEventHandler(inkoverlay_SelectionChanging);
        inkoverlay.SelectionChanged += new InkOverlaySelectionChangedEventHandler(inkoverlay_SelectionChanged);
        inkoverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(inkoverlay_SelectionMoved);
        inkoverlay.SelectionResized += new InkOverlaySelectionResizedEventHandler(inkoverlay_SelectionResized);

        // inkoverlay.
        declaredmode = inkoverlay.EditingMode;

        // Spin up SDI model (ink+doc).
        doc = new MagicDocument();
        inkoverlay.Ink = doc.Ink;

        inkoverlay.Enabled = !DesignMode;

        inkoverlay.Ink.InkAdded += new StrokesEventHandler(inkoverlay_Ink_InkAdded);
    }
Example #25
0
    public void OpenDocument(string filename)
    {
        try
        {
            using (System.IO.TextReader reader = File.OpenText(filename))
            {
                // Load it!  And hook up the new Ink object.
                doc = MagicDocument.LoadDocument(reader);
                savedfilename = filename;
                doc.Ink.Dirty = false;

                HookupOverlayToNewInk();
            }
        }
        catch (IOException ex)
        {
            MessageBox.Show(
                ex.Message,
                Application.ProductName,
                MessageBoxButtons.OK,
                MessageBoxIcon.Warning);
        }
    }
Example #26
0
    //
    // Initialization

    public MainForm()
    {
        // Required for Windows Form Designer support.
        InitializeComponent();

        // Load our icon.
        this.Icon = new Icon(typeof(MainForm), "PhysicsIllustrator.ico");

        // Initialize the per-item smart tag.
        bodytag         = new PhysicsIllustrator.SmartTag.SmartTag();
        bodytag.Image   = Global.LoadImage("Resources.PenMenu.ico");
        bodytag.Visible = false;

        bodytag.ContextMenu = new ContextMenu();
        bodytag.ContextMenu.MenuItems.Add("Clone", new EventHandler(hover_EditCloneClicked));
        bodytag.ContextMenu.MenuItems.Add("Delete", new EventHandler(hover_EditDeleteClicked));
        bodytag.ContextMenu.MenuItems.Add("-");
        bodytag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(hover_EditStraightenClicked));
        bodytag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(hover_EditPropertiesClicked));

        this.Controls.Add(bodytag);

        // Go fullscreen.  Note: this works even with the taskbar set
        // to "keep on top of other windows".
        this.WindowState = System.Windows.Forms.FormWindowState.Normal;
        this.Bounds      = Screen.PrimaryScreen.Bounds;

        // Declare repaint optimizations.
        base.SetStyle(
            ControlStyles.UserPaint |
            ControlStyles.AllPaintingInWmPaint |
            ControlStyles.DoubleBuffer,
            true);

        // Init inkoverlay.
        inkoverlay = new InkOverlay(this.Handle, true);
        inkoverlay.CollectionMode = CollectionMode.InkOnly; // no gestures

        inkoverlay.AutoRedraw = false;                      // Dynamic rendering only; we do all the painting.

        DrawingAttributes da = new DrawingAttributes();

        da.AntiAliased = false;
        inkoverlay.DefaultDrawingAttributes = da;

        inkoverlay.Stroke += new InkCollectorStrokeEventHandler(inkoverlay_Stroke);

        inkoverlay.CursorInRange   += new InkCollectorCursorInRangeEventHandler(inkoverlay_CursorInRange);
        inkoverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkoverlay_StrokesDeleting);

        inkoverlay.SelectionChanging += new InkOverlaySelectionChangingEventHandler(inkoverlay_SelectionChanging);
        inkoverlay.SelectionChanged  += new InkOverlaySelectionChangedEventHandler(inkoverlay_SelectionChanged);
        inkoverlay.SelectionMoved    += new InkOverlaySelectionMovedEventHandler(inkoverlay_SelectionMoved);
        inkoverlay.SelectionResized  += new InkOverlaySelectionResizedEventHandler(inkoverlay_SelectionResized);

        declaredmode = inkoverlay.EditingMode;

        // Spin up SDI model (ink+doc).
        doc            = new MagicDocument();
        inkoverlay.Ink = doc.Ink;

        inkoverlay.Enabled = !DesignMode;

        inkoverlay.Ink.InkAdded += new StrokesEventHandler(inkoverlay_Ink_InkAdded);
    }
 internal override void CompleteDeserialization(MagicDocument doc)
 {
     Body.Object = doc.LookupBody(Body.strokeref);
 }