示例#1
0
        public static LoopExpression Loop(Func <ILoopControl, Expression> bodyBuilder)
        {
            var loop = new LoopControl();
            var body = bodyBuilder(loop);

            return(Expression.Loop(body, loop.BreakLabel, loop.ContinueLabel));
        }
        public void ShowAnimation(IList <Bitmap> bitmaps, IList <double> delays, bool startPlaying)
        {
            fpsTimer = new FpsTimer(60);

            LoopControl.FpsTimer = fpsTimer;
            LoopControl.SetAndStartAction(control1, Go);
            drawManager = null;
            var myDrawManager = new DrawManager(control1, fpsTimer);

            if (bitmaps.Count != delays.Count)
            {
                throw new ArgumentException("must have same number of bitmaps as delays");
            }
            IList <Bitmap> oldBitmaps = null;

            if (flipBook != null)
            {
                oldBitmaps = flipBook.Bitmaps;
            }

            spriteManager = new SpriteManager(fpsTimer);
            sprite        = new JustSitThereSprite(new Point(0, 0));

            if (flipBook != null)
            {
                flipBook.FrameChanged -= flipBook_FrameChanged;
            }

            flipBook               = new FlipBook(bitmaps, delays);
            flipBook.Loop          = true;
            flipBook.Paused        = true;
            flipBook.FrameChanged += new EventHandler(flipBook_FrameChanged);
            sprite.AddAlteration(flipBook);
            spriteManager.AddObject(sprite);
            myDrawManager.AddDrawable(spriteManager);
            playButton.Enabled = true;

            drawManager = myDrawManager;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = bitmaps.Count - 1;
            trackBar1.Value   = 0;

            if (startPlaying)
            {
                Play();
            }

            if (oldBitmaps != null)
            {
                foreach (Bitmap b in oldBitmaps)
                {
                    if (b != null)
                    {
                        b.Dispose();
                    }
                }
            }
        }
示例#3
0
 public APExecutionTracker(GenCtxProperties <AsyncPattern> props, AsyncHandoff abh, out bool isClipped)
 {
     looper        = new LoopControl <AsyncPattern>(props, abh.ch, out isClipped);
     this.abh      = abh;
     parent_done   = abh.done;
     abh.done      = () => { };
     elapsedFrames = 0f;
     wasPaused     = false;
 }
示例#4
0
 public SMExecutionTracker(GenCtxProperties <StateMachine> props, SMHandoff smh, out bool isClipped)
 {
     looper              = new LoopControl <StateMachine>(props, smh.ch, out isClipped);
     this.smh            = smh;
     this.smh.CanPrepend = true;
     waitChild           = props.waitChild;
     sequential          = props.sequential;
     checkIsChildDone    = null;
 }
示例#5
0
 public IPExecutionTracker(GenCtxProperties <AsyncPattern> props, AsyncHandoff abh, out bool isClipped)
 {
     looper           = new LoopControl <AsyncPattern>(props, abh.ch, out isClipped);
     this.abh         = abh;
     parent_done      = abh.done;
     abh.done         = () => { };
     elapsedFrames    = 0f;
     waitChild        = props.waitChild;
     sequential       = props.sequential;
     checkIsChildDone = null;
     wasPaused        = false;
 }
示例#6
0
        /// <summary>
        /// Executes the next command in the scenario, and then continues executing further commands until a command
        /// returns <see cref="LoopControl.Stop"/> as its return value.
        /// </summary>
        public void ExecuteCommand()
        {
            ScenarioCommand command = _commands[_nextCommand];

            _nextCommand++;
            LoopControl whatNext = command.Execute(this);

            _lastCommandExecuted = command;
            if (whatNext == LoopControl.Continue)
            {
                ExecuteCommand();
            }
        }
示例#7
0
        public static LoopExpression For(Expression test, Expression iterator,
                                         Func <ILoopControl, Expression> bodyBuilder)
        {
            var loop     = new LoopControl();
            var body     = bodyBuilder(loop);
            var bodyExpr = new[]
            {
                test == null ? null : Expression.IfThen(Expression.Not(test), loop.Break()),
                body,
                loop.ContinueLabel == null ? null : Expression.Label(loop.ContinueLabel),
                iterator
            };
            var loopBody = Expression.Block(bodyExpr.Where(x => x != null));

            return(Expression.Loop(loopBody, loop.BreakLabel));
        }
示例#8
0
 public SPExecutionTracker(GenCtxProperties <SyncPattern> props, SyncHandoff sbh, out bool isClipped)
 {
     looper   = new LoopControl <SyncPattern>(props, sbh.ch, out isClipped);
     this.sbh = sbh;
 }
示例#9
0
    /// <summary>
    /// Executes the next line of the spell
    /// </summary>
    /// <returns>A CastResult object containing information about the cast</returns>
    public CastResult CastNext()
    {
        string   aberration = "";
        Variable newVar     = null;

        try
        {
            newVar = lines[currentLine].Cast(memory);
        }
        catch (AberrationException ae)
        {
            aberration = ae.Message;
        }
        if (newVar == null)
        {
            currentLine += 1;
            if (currentLine == loopCheck)
            {
                currentLine = loopStart;
            }
        }
        else if (newVar.magicianType == Types.Loop)
        {
            LoopControl loopControl = (LoopControl)newVar;
            loopStart   = currentLine;
            loopCheck   = loopControl.loopCheckLine;
            currentLine = loopControl.goToLine;
        }
        else if (newVar.magicianType == Types.Conditional)
        {
            ConditionalControl condControl = (ConditionalControl)newVar;
            currentLine = condControl.goToLine;
        }
        else
        {
            AddToMemory(newVar);
            currentLine += 1;
            if (currentLine == loopCheck)
            {
                currentLine = loopStart;
            }
        }

        float storedMagic = 0;

        foreach (KeyValuePair <string, Variable> entry in memory)
        {
            if (entry.Value is Mana)
            {
                Mana m = (Mana)entry.Value;
                UnityEngine.Debug.Log(m.varName);
                UnityEngine.Debug.Log(m.gandalfs);
                storedMagic += m.gandalfs;
            }
        }

        if (currentLine == lines.Count || aberration != "")
        {
            Reset();
        }
        return(new CastResult(storedMagic, aberration));
    }
示例#10
0
 public bool DelLoop(LoopControl con)
 {
     if (this.WorkflowProcessCurrent.Loops.Remove(con.Loop))
     {
         UserControls.Remove(con.Id);
         canvas.Children.Remove(con);
         if (con.Loop.FromNode != null)
         {
             if (con.Loop.FromNode is Synchronizer)
             {
                 ((Synchronizer)con.Loop.FromNode).LeavingLoops.Remove(con.Loop);
             }
         }
         if (con.Loop.ToNode != null)
         {
             if (con.Loop.ToNode is Synchronizer)
             {
                 ((Synchronizer)con.Loop.ToNode).EnteringLoops.Remove(con.Loop);
             }
         }
         return true;
     }
     return false;
 }
示例#11
0
        //添加循环线
        private void LoopButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (mouseEnterNode != null && mouseEnterNode.Node is Synchronizer && !(mouseEnterNode.Node is StartNode))
            {
                if (IsLoop == false)
                {
                    Debug.WriteLine("增加LoopControl");
                    currentLoopControl = new LoopControl(this, null, false);
                    currentLoopControl.InitEdge();
                    currentLoopControl.Loop.FromNode = mouseEnterNode.Node;

                    mouseEnterNode = null;

                    Point p = e.GetPosition(canvas);

                    currentLoopControl.SetLoopPosition(p, null, p);

                    if (!canvas.Children.Contains(currentLoopControl))
                    {
                        //设置位置
                        canvas.Children.Add(currentLoopControl);
                        UserControls.Add(currentLoopControl.Id, currentLoopControl);
                        this.WorkflowProcessCurrent.Loops.Add(currentLoopControl.Loop);
                    }
                    IsLoop = true;
                    return;
                }
            }

            if (IsLoop)
            {
                System.Threading.Thread.Sleep(300);//还没有获取mouseEnterNode就执行了。进行稍微延时已保证获取到了mouseEnterNode;

                if (mouseEnterNode != null)
                {
                    //判断是否配对连接
                    if (!(mouseEnterNode.Node is Synchronizer))
                    {
                        //目标节点必须是Synchronizer;否则退出
                        Debug.WriteLine("配对失败!目标节点必须是Synchronizer;");
                        return;
                    }
                    else if (currentLoopControl.Loop.FromNode.Id == mouseEnterNode.Node.Id)
                    {
                        //节点相同退出
                        Debug.WriteLine("配对失败!节点相同。");
                        return;

                    }

                    currentLoopControl.Loop.ToNode = mouseEnterNode.Node;
                    ((Synchronizer)mouseEnterNode.Node).LeavingLoops.Add(currentLoopControl.Loop);

                    mouseEnterNode = null;

                    currentLoopControl.SavePoint();
                    currentLoopControl.LoadEdge();
                    this.AddHandle(currentLoopControl);
                    currentLoopControl = null;
                    IsLoop = false;

                }
                else
                {
                    Point p = e.GetPosition(canvas);
                    currentLoopControl.AddLinePoint(p);
                }
            }
        }
示例#12
0
        /// <summary>取消</summary>
        private void EscapeControl()
        {
            //取消绘制循环
            if (IsLoop)
            {
                if (DelLoop(currentLoopControl))
                {
                    currentLoopControl = null;
                    IsLoop = false;
                }
                return;
            }

            //取消绘制流程转移
            if (IsTransition)
            {
                if (DelTransition(currentTransitionControl))
                {
                    currentTransitionControl = null;
                    IsTransition = false;
                }
                return;
            }

            //取消选择
            ClearSelection();
        }
示例#13
0
 public static IEnumerator Wait(float elapsedFrames, float waitFrames, LoopControl <StateMachine> looper, Func <bool>?childAwaiter, Action <(float, LoopControl <StateMachine>)> cb, ICancellee cT)