public void setThreadDirection(int dir)
        {
            CodeBehind.ShapeEditor.ShapeEdShapeView    ShapeEdShapeView    = "ShapeEdShapeView";
            CodeBehind.ShapeEditor.ShapeEdThreadWindow ShapeEdThreadWindow = "ShapeEdThreadWindow";

            GuiBitmapButtonCtrl pauseBtn    = ShapeEdThreadWindow.FOT("pauseBtn");
            GuiBitmapButtonCtrl playBkwdBtn = ShapeEdThreadWindow.FOT("playBkwdBtn");
            GuiBitmapButtonCtrl playFwdBtn  = ShapeEdThreadWindow.FOT("playFwdBtn");

            // Update thread direction
            ShapeEdShapeView["threadDirection"] = dir.AsString();

            // Sync the controls in the thread window
            switch (dir)
            {
            case -1:
                playBkwdBtn.setStateOn(true);
                break;

            case 0:
                pauseBtn.setStateOn(true);
                break;

            case 1:
                playFwdBtn.setStateOn(true);
                break;
            }
        }
        public void setKeyframe(float frame)
        {
            CodeBehind.ShapeEditor.ShapeEdSeqSlider    ShapeEdSeqSlider    = "ShapeEdSeqSlider";
            CodeBehind.ShapeEditor.ShapeEdThreadSlider ShapeEdThreadSlider = "ShapeEdThreadSlider";
            CodeBehind.ShapeEditor ShapeEditor = "ShapeEditor";
            CodeBehind.ShapeEditor.ShapeEdShapeView    ShapeEdShapeView    = "ShapeEdShapeView";
            CodeBehind.ShapeEditor.ShapeEdThreadWindow ShapeEdThreadWindow = "ShapeEdThreadWindow";
            GuiPopUpMenuCtrl transitionTo = ShapeEdThreadWindow.FOT("transitionTo");

            ShapeEdSeqSlider.setValue(frame, true);
            if (transitionTo.getText() == "synched position")
            {
                ShapeEdThreadSlider.setValue(frame, true);
            }

            // Update the position of the active thread => if outside the in/out range,
            // need to switch to the proxy sequence
            if (!this.usingProxySeq)
            {
                if ((frame < this.seqStartFrame) || (frame > this.seqEndFrame))
                {
                    this.usingProxySeq = true;
                    string proxyName = ShapeEditor.getProxyName(ShapeEdShapeView.getThreadSequence());
                    ShapeEdShapeView.setThreadSequence(proxyName, 0, 0, false);
                }
            }

            ShapeEdShapeView["threadPos"] = this.keyframeToThreadPos(frame).AsString();
        }
        public void setNoProxySequence()
        {
            CodeBehind.ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";
            CodeBehind.ShapeEditor ShapeEditor = "ShapeEditor";
            CodeBehind.ShapeEditor.ShapeEdSeqSlider ShapeEdSeqSlider = "ShapeEdSeqSlider";

            // no need to use the proxy sequence during playback
            if (this.usingProxySeq)
            {
                this.usingProxySeq = false;
                string seqName = ShapeEditor.getUnproxyName(ShapeEdShapeView.getThreadSequence());
                ShapeEdShapeView.setThreadSequence(seqName, 0, 0, false);
                ShapeEdShapeView["threadPos"] = this.keyframeToThreadPos(ShapeEdSeqSlider.getValue()).AsString();
            }
        }
        public void togglePingPong()
        {
            GuiBitmapButtonCtrl pingpong    = this.FOT("pingpong");
            GuiBitmapButtonCtrl playBkwdBtn = this.FOT("playBkwdBtn");
            GuiBitmapButtonCtrl playFwdBtn  = this.FOT("playFwdBtn");

            CodeBehind.ShapeEditor.ShapeEdShapeView ShapeEdShapeView = "ShapeEdShapeView";

            ShapeEdShapeView["threadPingPong"] = pingpong.getValue();
            if (playFwdBtn.getValue().AsBool())
            {
                playFwdBtn.performClick();
            }
            else if (playBkwdBtn.getValue().AsBool())
            {
                playBkwdBtn.performClick();
            }
        }
        public void setSequence(string seqName)
        {
            CodeBehind.ShapeEditor.ShapeEdThreadWindow ShapeEdThreadWindow = "ShapeEdThreadWindow";
            GuiCheckBoxCtrl  useTransitions   = ShapeEdThreadWindow.FOT("useTransitions");
            GuiTextEditCtrl  transitionTime   = ShapeEdThreadWindow.FOT("transitionTime");
            GuiPopUpMenuCtrl transitionTo     = ShapeEdThreadWindow.FOT("transitionTo");
            GuiPopUpMenuCtrl transitionTarget = ShapeEdThreadWindow.FOT("transitionTarget");

            CodeBehind.ShapeEditor.ShapeEdThreadSlider ShapeEdThreadSlider = "ShapeEdThreadSlider";
            CodeBehind.ShapeEditor.ShapeEdShapeView    ShapeEdShapeView    = "ShapeEdShapeView";
            CodeBehind.ShapeEditor ShapeEditor = "ShapeEditor";

            float transPos;
            float transTime;
            bool  transPlay;

            this.usingProxySeq = false;

            if (useTransitions.getValue().AsBool())
            {
                transTime = transitionTime.getText().AsFloat();
                if (transitionTo.getText() == "synched position")
                {
                    transPos = -1;
                }
                else
                {
                    transPos = this.keyframeToThreadPos(ShapeEdThreadSlider.getValue());
                }
                transPlay = (transitionTarget.getText() == "plays during transition");
            }
            else
            {
                transTime = 0;
                transPos  = 0;
                transPlay = false;
            }

            // No transition when sequence is not changing
            if (seqName == ShapeEdShapeView.getThreadSequence())
            {
                transTime = 0;
            }

            if (seqName != "")
            {
                // To be able to effectively scrub through the animation, we need to have all
                // frames available, even if it was added with only a subset. If that is the
                // case, then create a proxy sequence that has all the frames instead.
                string sourceData = ShapeEditor.getSequenceSource(seqName);
                string from       = Util.rtrim(Util.getFields(sourceData, 0, 1));
                int    startFrame = Util.getField(sourceData, 2).AsInt();
                int    endFrame   = Util.getField(sourceData, 3).AsInt();
                int    frameCount = Util.getField(sourceData, 4).AsInt();

                if ((startFrame != 0) || (endFrame != (frameCount - 1)))
                {
                    string proxyName = ShapeEditor.getProxyName(seqName);
                    if (ShapeEditor.shape.getSequenceIndex(proxyName) != -1)
                    {
                        ShapeEditor.shape.removeSequence(proxyName);
                        ShapeEdShapeView.refreshThreadSequences();
                    }
                    ShapeEditor.shape.addSequence(from, proxyName);

                    // Limit the transition position to the in/out range
                    transPos = Util.mClamp(transPos, 0, 1);
                }
            }

            ShapeEdShapeView.setThreadSequence(seqName, transTime, transPos, transPlay);
        }