}//mouseEnter

        private void mouseLeave(object sender, MouseEventArgs e)
        {
            int queee = que.Count;

            for (int i = 0; i < queee; i++)
            {
                rektangelInfo rekinfo = new rektangelInfo();
                rekinfo = (rektangelInfo)que.Dequeue();
                Brush     color = rekinfo.br;
                Rectangle rekt  = rekinfo.rekt;
                rekt.Fill = color;
            }
        }//mouseLeave
        }//fallDown

        public void connectedColors(ImageBrush pressedColor, double ptX, double ptY)
        {
            Point  pt  = new Point();
            object obj = new object();

            pt.X = ptX;
            pt.Y = ptY;

            if (pt.X < maxX && pt.X > minX && pt.Y < maxY && pt.Y > minY)
            {
                HitTestResult hr = VisualTreeHelper.HitTest(window.canvas1, pt);
                obj = hr.VisualHit;
            }

            if (obj is Rectangle)
            {
                Rectangle  figur              = (Rectangle)obj;
                ImageBrush figurImage         = (ImageBrush)figur.Fill;
                string     pressedImagestring = Convert.ToString(pressedColor.ImageSource);
                string     figurImageString   = Convert.ToString(figurImage.ImageSource);
                if (figurImageString == pressedImagestring)
                {
                    rektangelInfo rekinfo = new rektangelInfo();
                    rekinfo.br   = pressedColor;
                    rekinfo.rekt = figur;
                    que.Enqueue(rekinfo);
                    double top  = Canvas.GetTop(figur);
                    double left = Canvas.GetLeft(figur);
                    string str  = "";
                    str        = figurImageString.Remove(figurImageString.Length - 4, 4) + "H.png";
                    figur.Fill = new ImageBrush(new BitmapImage(new Uri(@str, UriKind.Relative)));
                    connectedColors(pressedColor, pt.X + _rectSize, pt.Y);
                    connectedColors(pressedColor, pt.X - _rectSize, pt.Y);
                    connectedColors(pressedColor, pt.X, pt.Y + _rectSize);
                    connectedColors(pressedColor, pt.X, pt.Y - _rectSize);
                }
            }
        }//connectedColors
        }//figur_Click

        private void mouseEnter(object sender, MouseEventArgs e)
        {
            IsHover = true;
            Rectangle  entered      = (Rectangle)sender;
            double     top          = Canvas.GetTop(entered);
            double     left         = Canvas.GetLeft(entered);
            ImageBrush enteredImage = (ImageBrush)entered.Fill;

            connectedColors(enteredImage, left + _rectSize / 2, top + _rectSize / 2);
            if (que.Count < 3)
            {
                object obj   = new object();
                int    queee = que.Count;
                for (int i = 0; i < queee; i++)
                {
                    rektangelInfo rekinfo = new rektangelInfo();
                    rekinfo = (rektangelInfo)que.Dequeue();
                    Brush     color = rekinfo.br;
                    Rectangle rekt  = rekinfo.rekt;
                    rekt.Fill = color;
                    IsHover   = false;
                }
            }
        }//mouseEnter
        }//connectedColors

        //tar bort blocken som man håller över och flyttar ner blocken som är över.
        private void figur_Click(object sender, RoutedEventArgs e)
        {
            if (IsHover)
            {
                window.BlockClicks.Visibility = Visibility.Visible;
                window.Points.Content         = scorePoints(que.Count);
                window._time += addTime(que.Count);
            }

            List <Rectangle> columRek = new List <Rectangle>();
            rektangelInfo    rekinfo  = new rektangelInfo();

            for (int i = 0; i < que.Count; i++)
            {
                rekinfo = (rektangelInfo)que.Dequeue();
                Brush     color = rekinfo.br;
                Rectangle rekt  = rekinfo.rekt;
                que.Enqueue(rekinfo);
                window.canvas1.Children.Remove(rekt);
            }
            double rekLeft = 0;
            int    queee   = que.Count;

            while (que.Count != 0)
            {
                for (int i = 0; i < queee; i++)
                {
                    rekinfo = (rektangelInfo)que.Dequeue();
                    Rectangle rekt = rekinfo.rekt;

                    if (columRek.Count == 0 || rekLeft == Canvas.GetLeft(rekt))
                    {
                        rekLeft = Canvas.GetLeft(rekt);
                        columRek.Add(rekt);
                    }
                    else
                    {
                        que.Enqueue(rekinfo);
                    }
                }
                queee = que.Count;
                int    columnCount = columRek.Count;
                double bottom      = 0;
                for (int i = 0; i < columnCount; i++)
                {
                    Rectangle tangel = columRek[i];

                    if (bottom < Canvas.GetTop(tangel))
                    {
                        bottom = Canvas.GetTop(tangel);
                    }
                }
                Point pt = new Point(rekLeft + 1, bottom - _rectSize + 1);
                columRek.Clear();
                while (pt.X < maxX && pt.X > minX && pt.Y < maxY && pt.Y > minY)
                {
                    HitTestResult hr = VisualTreeHelper.HitTest(window.canvas1, pt);

                    if (hr.VisualHit is Rectangle)
                    {
                        Rectangle  re = (Rectangle)hr.VisualHit;
                        Storyboard sb = new Storyboard();
                        fallDown(Canvas.GetTop(re), Canvas.GetLeft(re), sb, re, bottom, 0.15);
                        sb.Begin();
                        bottom -= _rectSize;
                        pt.Y   -= _rectSize;
                    }
                    else
                    {
                        pt.Y -= _rectSize;
                    }
                }
            }

            if (IsHover)
            {
                var mChanger = new System.Threading.Thread(new System.Threading.ThreadStart(Blockclickproperly));
                mChanger.Start();
            }
            IsHover = false;
        }//figur_Click