예제 #1
0
        public void Process(PaperParser paperParser)
        {
            MainRect = paperParser.HeaderRect.GetInnerRect(LeftOffset, TopOffset, RightOffset, BottomOffset);

            SetARegion = MainRect.GetInnerRect(0, 0, 1.0 / 3.0, 1);
            SetBRegion = MainRect.GetInnerRect(1.0 / 3.0, 0, 2.0 / 3.0, 1);
            SetCRegion = MainRect.GetInnerRect(2.0 / 3.0, 0, 1, 1);

            isSetAShaded   = false;
            isSetBShaded   = false;
            isSetCShaded   = false;
            ShadeSet       = null;
            shadedSetCount = 0;
            foreach (Shade s in paperParser.HeaderShades)
            {
                if (SetARegion.IsInside(s.Center))
                {
                    isSetAShaded = true;
                    ShadeSet     = s;
                }
                else if (SetBRegion.IsInside(s.Center))
                {
                    isSetBShaded = true;
                    ShadeSet     = s;
                }
                else if (SetCRegion.IsInside(s.Center))
                {
                    isSetCShaded = true;
                    ShadeSet     = s;
                }
            }

            shadedSetCount += isSetAShaded ? 1 : 0;
            shadedSetCount += isSetBShaded ? 1 : 0;
            shadedSetCount += isSetCShaded ? 1 : 0;

            if (shadedSetCount == 0)
            {
                SetParserResult = SetParserResult.Unshaded;
            }
            else if (shadedSetCount > 1)
            {
                SetParserResult = SetParserResult.Multishaded;
            }
            else if (isSetAShaded)
            {
                SetParserResult     = SetParserResult.SetA;
                AssessmentSetResult = AssessmentSet.SetA;
            }
            else if (isSetBShaded)
            {
                SetParserResult     = SetParserResult.SetB;
                AssessmentSetResult = AssessmentSet.SetB;
            }
            else if (isSetCShaded)
            {
                SetParserResult     = SetParserResult.SetC;
                AssessmentSetResult = AssessmentSet.SetC;
            }
        }
예제 #2
0
 internal ItemParser(double leftOffset, double topOffset, double rightOffset, double bottomOffset, int itemStart, int itemCount)
 {
     LeftOffset   = leftOffset;
     TopOffset    = topOffset;
     RightOffset  = rightOffset;
     BottomOffset = bottomOffset;
     ItemStart    = itemStart;
     ItemCount    = itemCount;
     ItemRegion   = new Arbitary3DRect[itemCount];
     ItemKeys     = new List <ShadeItemKey>();
     borders      = new List <System.Drawing.Point>();
 }
예제 #3
0
        internal void Process(List <Shade> shades)
        {
            l.Clear();
            r.Clear();
            tl.Clear();
            tr.Clear();
            bl.Clear();
            br.Clear();
            MainReady = false;

            foreach (Shade shade in shades)
            {
                if (AnchorRect.AnchorL.Contains(shade.Center))
                {
                    l.Add(shade);
                }
                if (AnchorRect.AnchorR.Contains(shade.Center))
                {
                    r.Add(shade);
                }
                if (AnchorRect.AnchorTL.Contains(shade.Center))
                {
                    tl.Add(shade);
                }
                if (AnchorRect.AnchorTR.Contains(shade.Center))
                {
                    tr.Add(shade);
                }
                if (AnchorRect.AnchorBL.Contains(shade.Center))
                {
                    bl.Add(shade);
                }
                if (AnchorRect.AnchorBR.Contains(shade.Center))
                {
                    br.Add(shade);
                }
            }

            if (tl.Count > 0 && tr.Count > 0 && bl.Count > 0 && br.Count > 0)
            {
                if (l.Count < 4 && r.Count < 4)
                {
                    return;
                }

                HeaderShades.Clear();
                BodyShades.Clear();

                if (!AssertSideWithCL(l, tl, bl, out TLPoint, out HLPoint, out CLPoint, out BLPoint) ||
                    !AssertSideWithCL(r, tr, br, out TRPoint, out HRPoint, out CRPoint, out BRPoint))
                {
                    return;
                }

                aspectRatio = ((Extension.GetDistance(TLPoint.Center, BLPoint.Center) + Extension.GetDistance(TRPoint.Center, BRPoint.Center)) / 2) /
                              ((Extension.GetDistance(TLPoint.Center, TRPoint.Center) + Extension.GetDistance(BLPoint.Center, BRPoint.Center)) / 2);

                if (aspectRatio > AnchorRect.AspectRatio + AspectRatioMargin ||
                    aspectRatio < AnchorRect.AspectRatio - AspectRatioMargin)
                {
                    return;
                }

                HeaderRect = new Arbitary3DRect(TLPoint.Center, TRPoint.Center, HLPoint.Center, HRPoint.Center);
                BodyRect   = new Arbitary3DRect(HLPoint.Center, HRPoint.Center, BLPoint.Center, BRPoint.Center);

                foreach (Shade shade in shades)
                {
                    if (HeaderRect.IsInside(shade.Center))
                    {
                        HeaderShades.Add(shade);
                    }
                    if (BodyRect.IsInside(shade.Center))
                    {
                        BodyShades.Add(shade);
                    }
                }
                MainReady = true;
            }
        }
예제 #4
0
        internal void Process(PaperParser paperParser)
        {
            MainRect = paperParser.BodyRect.GetInnerRect(LeftOffset, TopOffset, RightOffset, BottomOffset);

            ARegion = MainRect.GetInnerRect(0, 0, 1.0 / 5.0, 1);
            BRegion = MainRect.GetInnerRect(1.0 / 5.0, 0, 2.0 / 5.0, 1);
            CRegion = MainRect.GetInnerRect(2.0 / 5.0, 0, 3.0 / 5.0, 1);
            DRegion = MainRect.GetInnerRect(3.0 / 5.0, 0, 4.0 / 5.0, 1);
            ERegion = MainRect.GetInnerRect(4.0 / 5.0, 0, 1, 1);

            for (int i = 0; i < ItemCount; i++)
            {
                ItemRegion[i] = MainRect.GetInnerRect(0, (double)i / ItemCount, 1, (double)(i + 1) / ItemCount);
            }

            num = 0;
            ItemKeys.Clear();
            foreach (Shade s in paperParser.BodyShades)
            {
                num = 0;
                for (int i = 0; i < ItemCount; i++)
                {
                    if (ItemRegion[i].IsInside(s.Center))
                    {
                        num = i + ItemStart;
                    }
                }

                if (num == 0)
                {
                    continue;
                }

                if (ARegion.IsInside(s.Center))
                {
                    key = Key.A;
                }
                else if (BRegion.IsInside(s.Center))
                {
                    key = Key.B;
                }
                else if (CRegion.IsInside(s.Center))
                {
                    key = Key.C;
                }
                else if (DRegion.IsInside(s.Center))
                {
                    key = Key.D;
                }
                else if (ERegion.IsInside(s.Center))
                {
                    key = Key.E;
                }
                else
                {
                    continue;
                }

                ItemKeys.Add(new ShadeItemKey(s, num, key));
            }
        }