Exemplo n.º 1
0
 public void parse(string text)
 {
     String[] lines = text.Split('\n');
     foreach (String line in lines)
     {
         if (line.Contains(":"))
         {
             String[] items = line.Split(':');
             if (items[0] == "Rectangle")
             {
                 LayerRectangle layer = new LayerRectangle();
                 layer.Points = buildPointArray(items[1]);
                 layer.Color  = colorFromHex(items[2]);
                 this.Layers.Add(layer);
             }
             else if (items[0] == "Oval")
             {
                 LayerOval layer = new LayerOval();
                 layer.Points = buildPointArray(items[1]);
                 layer.Color  = colorFromHex(items[2]);
                 this.Layers.Add(layer);
             }
             else if (items[0] == "Horizontal Stripe")
             {
                 LayerHorizontalStripe layer = new LayerHorizontalStripe();
                 layer.NumberOfStripes = Int32.Parse(items[1]);
                 layer.StripeSize      = float.Parse(items[2]);
                 layer.SpaceSize       = float.Parse(items[3]);
                 layer.StartOnStripe   = (items[4] == "1");
                 layer.EndOnStripe     = (items[5] == "1");
                 layer.Color           = colorFromHex(items[6]);
                 this.Layers.Add(layer);
             }
             else if (items[0] == "Vertical Stripe")
             {
                 LayerVerticalStripe layer = new LayerVerticalStripe();
                 layer.NumberOfStripes = Int32.Parse(items[1]);
                 layer.StripeSize      = float.Parse(items[2]);
                 layer.SpaceSize       = float.Parse(items[3]);
                 layer.StartOnStripe   = (items[4] == "0");
                 layer.EndOnStripe     = (items[5] == "0");
                 layer.Color           = colorFromHex(items[6]);
                 this.Layers.Add(layer);
             }
             else
             {
                 this.Name       = items[0];
                 this.Background = colorFromHex(items[1].Trim());
             }
         }
     }
 }
Exemplo n.º 2
0
        private void setupSampleFlags()
        {
            Flag f1 = new Flag("2 Horz Stripes");

            f1.Background = Color.White;
            LayerHorizontalStripe f1l1 = new LayerHorizontalStripe();

            f1l1.Color           = Color.Red;
            f1l1.NumberOfStripes = 2;
            f1.Layers.Add(f1l1);
            _flags.Add(f1);

            Flag f2 = new Flag("4 Vert Stripes");

            f2.Background = Color.Black;
            LayerVerticalStripe f2l1 = new LayerVerticalStripe();

            f2l1.Color           = Color.LightBlue;
            f2l1.NumberOfStripes = 4;
            f2l1.StartOnStripe   = false;
            f2l1.EndOnStripe     = false;
            f2.Layers.Add(f2l1);
            _flags.Add(f2);

            Flag f3 = new Flag("Rect");

            f3.Background = Color.White;
            LayerRectangle f3l1 = new LayerRectangle(new RectangleF(0f, 0f, 0.5f, 0.5f));

            f3l1.Color = Color.Blue;
            f3.Layers.Add(f3l1);
            _flags.Add(f3);

            Flag f4 = new Flag("American");

            f4.Background = Color.White;
            LayerHorizontalStripe f4l1 = new LayerHorizontalStripe();

            f4l1.NumberOfStripes = 7;
            f4l1.Color           = Color.Red;
            f4.Layers.Add(f4l1);
            LayerRectangle f4l2 = new LayerRectangle(new RectangleF(0f, 0f, 0.5f, 0.539f));

            f4l2.Color = Color.Blue;
            f4.Layers.Add(f4l2);
            _flags.Add(f4);
        }