public void CreateFruit(string name, string hex_color)
        {
            SolidColorBrush brush = new SolidColorBrush
            {
                Opacity = 0.8,
                Color   = Colors.White
            };

            TextBlock textBlock = new TextBlock
            {
                Text       = name,
                Background = brush,
                Margin     = new Thickness(8),
                Padding    = new Thickness(3, 0, 0, 0)
            };

            Border border = new Border
            {
                BorderBrush     = Brushes.White,
                Background      = SoufTools.GetColor(hex_color),
                BorderThickness = new Thickness(2),
                Child           = textBlock,
                Margin          = new Thickness(5)
            };

            listView.Items.Add(border);
            fruitNames.Add(name);
        }
Example #2
0
 public void Check()
 {
     if (selectedPlank == id)
     {
         r.Stroke = SoufTools.GetColor("#00FF00");
     }
     else
     {
         r.Stroke = SoufTools.GetColor("#000000");
     }
 }
Example #3
0
        public void Change(int selectedFruit)
        {
            currentFruit = selectedFruit;
            if (selectedFruit < 0)
            {
                r.Fill = standard_color;
                return;
            }

            string hex = fruit_info[selectedFruit][1];

            r.Fill = SoufTools.GetColor(hex);
        }
 private void Switch_editmode_onclick(object sender, MouseButtonEventArgs e)
 {
     if (plankEditMode)
     {
         plankEditMode = false;
         btn_switch_editmode.Content = "Planken veranderen";
         canvasBorder.BorderBrush    = SoufTools.GetColor("#90ee90");
     }
     else
     {
         plankEditMode = true;
         btn_switch_editmode.Content = "Fruit veranderen";
         canvasBorder.BorderBrush    = SoufTools.GetColor("#654321");
     }
 }
Example #5
0
        private Ellipse CreateCircle(int x, int y, int diameter)
        {
            // chooses a random color from the list and applies it to the circle
            int i = rng.Next(colors.Count);

            Ellipse c = new Ellipse()
            {
                Fill   = SoufTools.GetColor(colors[i]),
                Width  = diameter,
                Height = diameter
            };

            Canvas.SetLeft(c, x);
            Canvas.SetTop(c, y);

            return(c);
        }
Example #6
0
        public Fruit(int id_, int fruitId, Plank plank_)
        {
            id = id_;


            // parent
            plank = plank_;


            // creating the rectangle
            r = new Rectangle {
                Width  = GRID_SIZE - GRID_SIZE / 5,
                Height = GRID_SIZE - GRID_SIZE / 5
            };

            //TEMP
            r.Stroke = SoufTools.GetColor("#FF0000");

            double plank_x = Canvas.GetLeft(plank.r);
            double plank_y = Canvas.GetTop(plank.r);

            // get coordinates inside plank
            x_on_plank = id % plank.cols * GRID_SIZE;
            y_on_plank = id / plank.cols * GRID_SIZE;

            Move(plank_x, plank_y);



            // als hij geen null fruit is dan moet je kleur instellen
            if (fruitId != -1)
            {
                Change(fruitId);
            }
            else
            {
                r.Fill = standard_color;
            }

            c.Children.Add(r);
        }
Example #7
0
        private Rectangle CreateSquare(int x, int y, int size)
        {
            // chooses a random color from the list and applies it to the rectangle

            int i = new Random().Next(colors.Count);

            Rectangle r = new Rectangle()
            {
                Fill    = SoufTools.GetColor(colors[i]),
                Width   = size,
                Height  = size,
                RadiusX = 5,
                RadiusY = 5
            };

            Canvas.SetLeft(r, x);
            Canvas.SetTop(r, y);



            return(r);
        }
 public void SetColor(string code)
 {
     currentFill = SoufTools.GetColor(code);
 }