private void Add_new_fruit(object sender, MouseButtonEventArgs e)
        {
            add_new_fruit dialog = new add_new_fruit();

            if (dialog.ShowDialog() == true)
            {
                string[] rgb = new string[] {
                    dialog.Inp_red,
                    dialog.Inp_blue,
                    dialog.Inp_green
                };

                string hexColor = "#";
                for (int i = 0; i < rgb.Length; i++)
                {
                    string hex = SoufTools.DecimalToHexadecimal(Convert.ToInt32(rgb[i]));

                    // low numbers only have 1 digit
                    if (hex.Length < 2)
                    {
                        hex += "0";
                    }


                    hexColor += hex;
                }

                CreateNewItem(dialog.Inp_naam, hexColor);
            }
        }
        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);
        }
        public void ReloadFruits()
        {
            string[][] fruit_info = SoufTools.GetAllFruits();

            ReloadFruitsMainScreen(fruit_info);

            Fruit.fruit_info = fruit_info;
        }
Esempio n. 4
0
 public void Check()
 {
     if (selectedPlank == id)
     {
         r.Stroke = SoufTools.GetColor("#00FF00");
     }
     else
     {
         r.Stroke = SoufTools.GetColor("#000000");
     }
 }
        public void randomFruit()
        {
            Random r = new Random();

            for (int p = 0; p < planks.Count; p++)
            {
                for (int f = 0; f < planks[p].fruits.Count; f++)
                {
                    planks[p].fruits[f].Change(r.Next(0, SoufTools.GetAllFruits().Count()));
                }
            }
        }
Esempio n. 6
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");
     }
 }
Esempio n. 8
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);
        }
        public void save_Composition(object sender, MouseButtonEventArgs e)
        {
            save_popup popup = new save_popup();

            if (popup.ShowDialog() == true)
            {
                string path_filename = Path.Combine(SoufTools.compositions_path, popup.FileName);


                // Creating the JSON file
                PlankInfo[] plankinfos = new PlankInfo[planks.Count];
                for (int i = 0; i < planks.Count; i++)
                {
                    Rectangle r       = planks[i].r;
                    var       width   = r.Width / SoufTools.GRID_SIZE;
                    var       height  = r.Height / SoufTools.GRID_SIZE;
                    double    plank_x = Canvas.GetLeft(r);
                    double    plank_y = Canvas.GetTop(r);
                    plankinfos[i] = new PlankInfo()
                    {
                        Width  = width,
                        Height = height,
                        X      = plank_x,
                        Y      = plank_y
                    };
                }
                string strResultJson = JsonConvert.SerializeObject(plankinfos);
                SoufTools.CreateFile(path_filename + ".json", strResultJson);


                // Creating an Image
                RenderTargetBitmap rtb = new RenderTargetBitmap((int)canvas.ActualWidth, (int)canvas.ActualHeight, 96, 96, PixelFormats.Pbgra32);
                rtb.Render(canvas);
                using (FileStream stream = new FileStream(path_filename + ".png", FileMode.Create))
                {
                    PngBitmapEncoder encoder5 = new PngBitmapEncoder();
                    encoder5.Frames.Add(BitmapFrame.Create(rtb));
                    encoder5.Save(stream);
                }
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private void UpdateList()
        {
            listView.Items.Clear();

            string[] files = SoufTools.GetAllCompositions();
            composition_names = new string[files.Length / 2];


            for (int i = 0, j = 0; i < files.Length; i++)
            {
                if (Path.GetExtension(files[i]) == ".json")
                {
                    composition_names[j++] = Path.GetFileNameWithoutExtension(files[i]);
                }
            }

            // for every file get the filename and add it to
            foreach (string name in composition_names)
            {
                AddListViewItem(name);
            }
        }
 public void SetColor(string code)
 {
     currentFill = SoufTools.GetColor(code);
 }
Esempio n. 14
0
        public MainWindow()
        {
            InitializeComponent();

            if (Settings1.Default.Font8 == true)
            {
                btn.FontSize      = 8;
                settings.FontSize = 8;
                oldcomp.FontSize  = 8;
                stats.FontSize    = 8;
            }

            if (Settings1.Default.Font10 == true)
            {
                btn.FontSize      = 10;
                settings.FontSize = 10;
                oldcomp.FontSize  = 10;
                stats.FontSize    = 10;
            }

            if (Settings1.Default.Font12 == true)
            {
                btn.FontSize      = 12;
                settings.FontSize = 12;
                oldcomp.FontSize  = 12;
                stats.FontSize    = 12;
            }

            if (Settings1.Default.Font14 == true)
            {
                btn.FontSize      = 14;
                settings.FontSize = 14;
                oldcomp.FontSize  = 14;
                stats.FontSize    = 14;
            }

            if (Settings1.Default.Font16 == true)
            {
                btn.FontSize      = 16;
                settings.FontSize = 16;
                oldcomp.FontSize  = 16;
                stats.FontSize    = 16;
            }

            if (Settings1.Default.Stilstaan == false)
            {
                CreateTimer();
            }



            SoufShape.canvas = canvas;

            // gets all custom fruit and adds it's colors to the list
            string[][] fruits = SoufTools.GetAllFruits();
            for (int i = 0; i < fruits.Length; i++)
            {
                colors.Add(fruits[i][1]);
            }

            if (Settings1.Default.verdwijnen == false)
            {
                // for every color there exists there is a shape
                for (int i = 0; i < shapeAmount; i++)
                {
                    Shape s;
                    int   x    = rng.Next(width);
                    int   y    = rng.Next(height);
                    int   size = rng.Next(30, 50);


                    if (rng.NextDouble() < 0.5)
                    {
                        s = CreateSquare(x, y, size);
                    }
                    else
                    {
                        s = CreateCircle(x, y, size);
                    }

                    shapes.Add(new SoufShape(s));
                }
            }


            if (Settings1.Default.lightmode == true)
            {
                canvas.Background = new SolidColorBrush(Colors.White);
            }

            if (Settings1.Default.lightblue == true)
            {
                canvas.Background = new SolidColorBrush(Colors.LightBlue);
            }

            if (Settings1.Default.blue == true)
            {
                canvas.Background = new SolidColorBrush(Colors.Blue);
            }

            if (Settings1.Default.darkblue == true)
            {
                canvas.Background = new SolidColorBrush(Colors.DarkBlue);
            }

            if (Settings1.Default.darkmodehome == true)

            {
                canvas.Background = new SolidColorBrush(Colors.Black);
            }
        }
Esempio n. 15
0
 public void ReloadFoods()
 {
     fruit_info = SoufTools.GetAllFruits();
 }
Esempio n. 16
0
 public void ReloadFruits()
 {
     Fruit.fruit_info = SoufTools.GetAllFruits();
 }