private void AddToPalette_Click(object sender, RoutedEventArgs e)
        {
            var   FirstWrapPanelInTabControl = FindVisualChildren <WrapPanel>(TabControl1).FirstOrDefault();
            Brush newBrush = TopRectangle.Fill;

            ColorHM.Properties.UserControl1 rec = CreateRectangle(newBrush);
            FirstWrapPanelInTabControl.Children.Add(rec);
            SavePalette(); // New or old palette
        }
        //! Maybe move to class later.
        public ColorHM.Properties.UserControl1 CreateRectangle(Brush newBrush)
        {
            ContextMenu recContextMenu = RecContextMenu();
            var         rec            = new ColorHM.Properties.UserControl1();

            rec.rectangleUC.Fill        = newBrush;
            rec.ToolTip                 = newBrush.ToString();
            rec.rectangleUC.ContextMenu = recContextMenu;
            return(rec);
        }
        //! Get all palettes, create new if none exist.
        public void GetPalettes()
        {
            SQLiteConnection conn       = Connect();
            SQLiteCommand    sqlite_cmd = conn.CreateCommand();

            sqlite_cmd.CommandText = "SELECT id, palette_name, colors from palettes";
            SQLiteDataAdapter dt         = new SQLiteDataAdapter(sqlite_cmd);
            DataTable         palettesDT = new DataTable();

            dt.Fill(palettesDT);

            //! If there are no palettes, create one and rerun the query.
            if (palettesDT.Rows.Count == 0)
            {
                sqlite_cmd.CommandText = "INSERT INTO palettes (palette_name) VALUES ('Palette 1')";
                sqlite_cmd.ExecuteNonQuery();
                sqlite_cmd.CommandText = "SELECT id, palette_name, colors from palettes";
                dt         = new SQLiteDataAdapter(sqlite_cmd);
                palettesDT = new DataTable();
                dt.Fill(palettesDT);
            }

            foreach (DataRow row in palettesDT.Rows)
            {
                var ti  = new TabItem();
                var wcp = new WrapPanel();

                ContextMenu contextMenu = PaletteContextMenu();
                Thickness   thickness   = new Thickness
                {
                    Bottom = 0,
                    Top    = 0,
                    Left   = 0,
                    Right  = 0
                };

                TextBox newPaletteTextBox = new TextBox
                {
                    BorderThickness = thickness,

                    Background = Brushes.Transparent,
                    Text       = row["palette_name"].ToString(),
                };

                string        paletteID = row["id"].ToString();
                string        colors    = row["colors"].ToString();
                List <string> colorList = colors.Split(null).ToList();

                //! Create a rectangle for each color per palette
                foreach (string color in colorList)
                {
                    //! make sure color is in fact a color before processing
                    //! because whitespace may exist at the end of the color string in the db
                    if (color.Contains('#'))
                    {
                        Color newColor = (Color)ColorConverter.ConvertFromString(color);
                        Brush newBrush = new SolidColorBrush(newColor);
                        ColorHM.Properties.UserControl1 rec = CreateRectangle(newBrush);
                        wcp.Children.Add(rec);
                    }
                }
                ti.Content = wcp;
                // MessageBox.Show(colors);
                ti.Header      = newPaletteTextBox;
                ti.ContextMenu = contextMenu;
                ti.Tag         = row["id"];
                TabControl1.Items.Add(ti);
            }
            conn.Close();
            NewPalette();
        }