Esempio n. 1
0
 /// <summary>
 /// 这个id是否已经完成
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool isReached(int id)
 {
     for (int i = 0; i < reachedConditions.Count; i++)
     {
         if (!reachedConditions[i].isMeetTheConditions)
         {
             throw new Exception("曾经的已达成与未达成操作错误");
         }
         if (reachedConditions[i] is FreeCondition)
         {
             FreeCondition fc = reachedConditions[i] as FreeCondition;
             if (fc.pid == id)
             {
                 return(true);
             }
         }
         else if (reachedConditions[i] is PenDrawCondition)
         {
             PenDrawCondition pc = reachedConditions[i] as PenDrawCondition;
             if (pc.iid == id)
             {
                 return(true);
             }
         }
         else if (reachedConditions[i] is OnTheTreeCondition)
         {
             OnTheTreeCondition oc = reachedConditions[i] as OnTheTreeCondition;
             if (oc.pid == id)
             {
                 return(true);
             }
         }
         else if (reachedConditions[i] is IntersectCondition)
         {
             IntersectCondition ic = reachedConditions[i] as IntersectCondition;
             if (ic.pid == id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
        /// <summary>
        /// 复制
        /// </summary>
        public ConditionsList Copy()
        {
            ConditionsList result = new ConditionsList();

            if (reachedConditions != null)
            {
                result.reachedConditions = new List <Condition>();
                for (int i = 0; i < reachedConditions.Count; i++)
                {
                    if (reachedConditions[i] is FreeCondition)
                    {
                        FreeCondition fc = reachedConditions[i] as FreeCondition;
                        result.reachedConditions.Add(new FreeCondition()
                        {
                            isMeetTheConditions = fc.isMeetTheConditions, pid = fc.pid, point = fc.point
                        });
                    }
                    else if (reachedConditions[i] is PenDrawCondition)
                    {
                        PenDrawCondition pc = reachedConditions[i] as PenDrawCondition;
                        result.reachedConditions.Add(new PenDrawCondition()
                        {
                            isMeetTheConditions = pc.isMeetTheConditions, iid = pc.iid, p1 = pc.p1, p1id = pc.p1id, p2 = pc.p2, p2id = pc.p2id, pointSet = pc.pointSet, type = pc.type
                        });
                    }
                    else if (reachedConditions[i] is OnTheTreeCondition)
                    {
                        OnTheTreeCondition oc = reachedConditions[i] as OnTheTreeCondition;
                        result.reachedConditions.Add(new OnTheTreeCondition()
                        {
                            isMeetTheConditions = oc.isMeetTheConditions, pid = oc.pid, point = oc.point
                        });
                    }
                    else if (reachedConditions[i] is IntersectCondition)
                    {
                        IntersectCondition ic = reachedConditions[i] as IntersectCondition;
                        result.reachedConditions.Add(new IntersectCondition()
                        {
                            isMeetTheConditions = ic.isMeetTheConditions, i1id = ic.i1id, i2id = ic.i2id, pid = ic.pid, point = ic.point, pointSet1 = ic.pointSet1, pointSet2 = ic.pointSet2, clock = ic.clock
                        });
                    }
                }
            }
            if (unmetConditions != null)
            {
                result.unmetConditions = new List <Condition>();
                for (int i = 0; i < unmetConditions.Count; i++)
                {
                    if (unmetConditions[i] is FreeCondition)
                    {
                        FreeCondition fc = unmetConditions[i] as FreeCondition;
                        result.unmetConditions.Add(new FreeCondition()
                        {
                            isMeetTheConditions = fc.isMeetTheConditions, pid = fc.pid, point = fc.point
                        });
                    }
                    else if (unmetConditions[i] is PenDrawCondition)
                    {
                        PenDrawCondition pc = unmetConditions[i] as PenDrawCondition;
                        result.unmetConditions.Add(new PenDrawCondition()
                        {
                            isMeetTheConditions = pc.isMeetTheConditions, iid = pc.iid, p1 = pc.p1, p1id = pc.p1id, p2 = pc.p2, p2id = pc.p2id, pointSet = pc.pointSet, type = pc.type
                        });
                    }
                    else if (unmetConditions[i] is OnTheTreeCondition)
                    {
                        OnTheTreeCondition oc = unmetConditions[i] as OnTheTreeCondition;
                        result.unmetConditions.Add(new OnTheTreeCondition()
                        {
                            isMeetTheConditions = oc.isMeetTheConditions, pid = oc.pid, point = oc.point, iid = oc.iid, pointSet = oc.pointSet
                        });
                    }
                    else if (unmetConditions[i] is IntersectCondition)
                    {
                        IntersectCondition ic = unmetConditions[i] as IntersectCondition;
                        result.unmetConditions.Add(new IntersectCondition()
                        {
                            isMeetTheConditions = ic.isMeetTheConditions, i1id = ic.i1id, i2id = ic.i2id, pid = ic.pid, point = ic.point, pointSet1 = ic.pointSet1, pointSet2 = ic.pointSet2, clock = ic.clock
                        });
                    }
                }
            }
            return(result);
        }