예제 #1
0
 public Division(Polygon Shape, int subs=0)
 {
     _shape = Shape;
       _subdivisions = new Division[subs];
       _field = new Field("solid", new string[]{"argent"});
       _chargeGroups = new List<ChargeGroup> {};
 }
예제 #2
0
 public void Test_Division_and_ChargeGroup_Fess()
 {
     List<Point> points = new List<Point> {new Point(0F,0F), new Point(100F,10F), new Point(10F,100F)};
       Polygon testPoly = new Polygon(points, 100F, 100F, 0F, 0F);
       Division div = new Division(testPoly);
       Field fFess = new Field("solid", new string[] {"argent"});
       Field fShield = new Field("solid", new string[] {"gules"});
       div.field = fShield;
       ChargeGroup cg = new ChargeGroup(div, "fess", 1, fFess);
       div.chargeGroups.Add(cg);
       Assert.Equal(4, div.chargeGroups[0].chargeDivs[0].shape.vertices.Count);
 }
예제 #3
0
 public Division[] ExecuteCommand(List<string> command, string commandType)
 {
     if(commandType=="tincture")
       {
     if(command[0]=="ermine" || (command[0]=="vair" || command[0]=="potent"))
     {
       _field = new Field("fur", command.ToArray());
     }
     else
     {
       _field = new Field("solid", command.ToArray());
     }
       }
       if(commandType=="charge")
       {
     ChargeGroup cg = new ChargeGroup(this, command[1], Int32.Parse(command[0]));
     _chargeGroups.Add(cg);
     return cg.chargeDivs;
       }
       if(commandType=="division")
       {
     string divType;
     if(command[0]=="quarterly")
     {
       divType = "quarterly";
     }
     else
     {
       divType = command[1];
     }
     List<Polygon> shapes = this.shape.PartyPer(divType);
     _subdivisions = new Division[shapes.Count];
     for(int i=0; i<shapes.Count; i++)
     {
       _subdivisions[i] = new Division(shapes[i]);
     }
     return _subdivisions;
       }
       return new Division[] {};
 }
예제 #4
0
        public ChargeGroup(Division Parent, string chargeDevice, int Number=1, Field inputField=null, string Layout="unspecified")
        {
            _parent = Parent;
              _layout = Layout;
              _chargesDivs = new Division[Number];
              Point center = _parent.shape.GetCenter();
              float centerOffsetX = center.X-(_parent.shape.width/2);
              float centerOffsetY = center.Y-(_parent.shape.height/2);
              int numberOfDisplayRows;
              Line[] displayRows;
              if(Layout=="unspecified")
              {
            numberOfDisplayRows = (int)Math.Floor(Math.Sqrt(Number));
            displayRows = parent.shape.GetSectionLines(numberOfDisplayRows, true);
              }
              else // if(Layout=="fess")
              {
            numberOfDisplayRows = 1;
            displayRows = parent.shape.GetSectionLines(numberOfDisplayRows, true);
              }
              float totalDisplayLength = 0F;
              foreach(Line l in displayRows)
              {
            totalDisplayLength += l.GetLength();
              }
              int chargesPerRow = (int)Math.Floor(totalDisplayLength/Number);
              bool leftoverCharge = numberOfDisplayRows*chargesPerRow != Number;
              float paddingX = totalDisplayLength/(float)(Number+1);
              float paddingY = parent.shape.height/(numberOfDisplayRows+1);

              for(int i=0; i<_chargesDivs.Length; i++)
              {
            Polygon newChargeDivShape = null;
            Point parentCenter = _parent.shape.GetCenter();
            if(chargeDevice=="fess")
            {
              newChargeDivShape = new Polygon(new List<Point> {new Point(0F,0F),new Point(100F,0F),new Point(100F,100F),new Point(0F,100F)}, 100F, 25F, 0F, parentCenter.Y-12.5F);
            }
            else if(chargeDevice=="chief")
            {
              newChargeDivShape = new Polygon(new List<Point> {new Point(0F,0F),new Point(100F,0F),new Point(100F,100F),new Point(0F,100F)}, 100F, 25F, 0F, 0F);
            }
            else if(chargeDevice=="pile")
            {
              newChargeDivShape = new Polygon(new List<Point> {new Point(0F,0F),new Point(center.X,100F),new Point(100F,0F)}, 100F, 80F, 0F, 0F);
            }
            else if(chargeDevice=="pale")
            {
              newChargeDivShape = new Polygon(new List<Point> {new Point(0F,0F),new Point(100F,0F),new Point(100F,100F),new Point(0F,100F)}, 25F, 100F, parentCenter.X-12.5F, 0F);
            }
            else if(chargeDevice=="bend")
            {
              float size = 20F;
              Line bendLine = new Line(center, new Point(center.X+1, center.Y+1));
              Point left = new Point(bendLine.GetXAtYPos(0F), 0F);
              Point right = new Point(bendLine.GetXAtYPos(100F), 100F);
              newChargeDivShape = new Polygon(new List<Point> {new Point(left.X-size,100F),new Point(left.X+size,100F),new Point(right.X+size,0F),new Point(right.X-size,0F)}, 100F, 100F, 0F, 0F);
            }
            else if(chargeDevice=="bend-sinister")
            {
              float size = 20F;
              Line bendLine = new Line(center, new Point(center.X+1, center.Y-1));
              Point left = new Point(bendLine.GetXAtYPos(0F), 0F);
              Point right = new Point(bendLine.GetXAtYPos(100F), 100F);
              newChargeDivShape = new Polygon(new List<Point> {new Point(left.X-size,100F),new Point(left.X+size,100F),new Point(right.X+size,0F),new Point(right.X-size,0F)}, 100F, 100F, 0F, 0F);
            }
            else if(chargeDevice=="saltire")
            {
              float size = 15F;
              Line bendLine = new Line(center, new Point(center.X+1, center.Y+1));
              Line bendSinisterLine = new Line(center, new Point(center.X-1, center.Y+1));
              Point lowerLeft = new Point(bendLine.GetXAtYPos(100F) ,100F);
              Point lowerRight = new Point(bendSinisterLine.GetXAtYPos(100F) ,100F);
              Point upperRight = new Point(bendLine.GetXAtYPos(0F) ,0F);
              Point upperLeft = new Point(bendSinisterLine.GetXAtYPos(0F) ,0F);

              newChargeDivShape = new Polygon(new List<Point> {new Point(lowerLeft.X-size,lowerLeft.Y),new Point(lowerLeft.X+size,lowerLeft.Y),new Point(center.X,center.Y-size),new Point(lowerRight.X-size,lowerRight.Y), new Point(lowerRight.X+size,lowerRight.Y),new Point(center.X+size,center.Y),new Point(upperRight.X+size,upperRight.Y),new Point(upperRight.X-size,upperRight.Y),new Point(center.X,center.Y+size),new Point(upperLeft.X+size,upperLeft.Y),new Point(upperLeft.X-size,upperLeft.Y),new Point(center.X-size,center.Y)}, 100F, 100F, 0F, 0F);
            }
            else if(chargeDevice=="cross")
            {
              float size = 15F;
              newChargeDivShape = new Polygon(new List<Point> {new Point(center.X-size,0F),new Point(center.X+size,0F),new Point(center.X+size,center.Y-size),new Point(100F,center.Y-size),new Point(100F,center.Y+size),new Point(center.X+size,center.Y+size),new Point(center.X+size,100F),new Point(center.X-size,100F),new Point(center.X-size,center.Y+size),new Point(0F,center.Y+size),new Point(0F,center.Y-size),new Point(center.X-size,center.Y-size)}, 100F, 100F, 0F, 0F);
            }
            else if(chargeDevice=="chevron")
            {
              float size = 50F;
              newChargeDivShape = new Polygon(new List<Point> {new Point(0F,100F),new Point(0F,100F-size), new Point(50F,0F),new Point(100F,100F-size),new Point(100F,100F), new Point(50F,size)}, 100F, 30F, 0F, center.Y-15F);
            }
            else if(chargeDevice=="pall")
            {
              float size = 15F;
              Line bendLine = new Line(center, new Point(center.X+1, center.Y+1));
              Line bendSinisterLine = new Line(center, new Point(center.X-1, center.Y+1));
              Point upperRight = new Point(bendLine.GetXAtYPos(0F) ,0F);
              Point upperLeft = new Point(bendSinisterLine.GetXAtYPos(0F) ,0F);

              newChargeDivShape = new Polygon(new List<Point> {new Point(upperLeft.X+size,upperLeft.Y),new Point(upperLeft.X-size,upperLeft.Y),new Point(center.X,center.Y-size),new Point(upperRight.X+size,upperRight.Y),new Point(upperRight.X-size,upperRight.Y),new Point(center.X-size,center.Y),new Point(center.X-size,100F),new Point(center.X+size,100F),new Point(center.X+size,center.Y)}, 100F, 100F, 0F, 0F);//
            }
            else if(chargeDevice=="pall-reversed")
            {
              float size = 15F;
              Line bendLine = new Line(center, new Point(center.X+1, center.Y+1));
              Line bendSinisterLine = new Line(center, new Point(center.X-1, center.Y+1));
              Point left = new Point(bendLine.GetXAtYPos(100F) ,100F);
              Point right = new Point(bendSinisterLine.GetXAtYPos(100F) ,100F);

              newChargeDivShape = new Polygon(new List<Point> {new Point(right.X+size,right.Y),new Point(right.X-size,right.Y),new Point(center.X,center.Y-size),new Point(left.X+size,left.Y),new Point(left.X-size,left.Y),new Point(center.X-size,center.Y),new Point(center.X-size,0F),new Point(center.X+size,0F),new Point(center.X+size,center.Y)}, 100F, 100F, 0F, 0F);
            }
            else
            {
              float position = paddingX*(float)(i+1);
              float addPosition = 0F;
              Line displayRow = displayRows[0];
              for(int j=0; addPosition<position; j++)
              {
            addPosition += displayRows[j].GetLength();
            displayRow = displayRows[j];
              }
              if(displayRow.GetLength()%paddingX < 0.01F && Number > displayRow.GetLength()/paddingX)
              {
            position -= paddingX/2;
              }
              float positionOnRow = displayRow.GetLength() - (addPosition-position);
              Point displayPoint = new Point(displayRow.P1.X+positionOnRow, displayRow.P1.Y);
              if(chargeDevice == "lozenge")
              {
            newChargeDivShape = new Polygon(new List<Point> {new Point(0F,50F),new Point(50F,100F),new Point(100F,50F),new Point(50F,0F)}, paddingX*.6F, paddingY*.8F, displayPoint.X-(paddingX*.6F)/2F, displayPoint.Y-(paddingY*.8F)/2F);
              }
              if(chargeDevice == "mullet")
              {
            float chargeWidth = Math.Min(paddingX*.7F,paddingY*.7F);
            float chargeHeight = Math.Min(paddingX*.5F,paddingY*.5F)*(_parent.shape.width/_parent.shape.height);
            newChargeDivShape = new Polygon(new List<Point> {new Point(0F,40F),new Point(33.333F,62F),new Point(20F,100F),new Point(50F,80F),new Point(80F,100F),new Point(66.6666F,62F),new Point(100F,40F),new Point(62F,40F),new Point(50F,0F),new Point(38F,40F)}, chargeWidth, chargeHeight, displayPoint.X-chargeWidth/2F, displayPoint.Y-chargeHeight/2F);
              }
              if(chargeDevice == "inescutcheon" || chargeDevice == "escutcheon")
              {
            float chargeWidth = Math.Min(paddingX*.6F,paddingY*.6F);
            float chargeHeight = Math.Min(paddingX*.6F,paddingY*.6F)*(_parent.shape.width/_parent.shape.height);
            newChargeDivShape = new Polygon(new List<Point> {new Point(0F,0F), new Point(0F,80F), new Point(50F,100F), new Point(100F,80F), new Point(100F,0F)}, chargeWidth, chargeHeight, displayPoint.X-chargeWidth/2F, displayPoint.Y-chargeHeight/2F);
              }
            }
            _chargesDivs[i] = new Division(newChargeDivShape);
            _chargesDivs[i].field = inputField ?? new Field("solid", new string[]{"argent"});
              }
        }