private void ImageTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SourceImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
            MedianImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
            HSVImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
            ContoursImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
            TabItem currentTab = ImageTabControl.SelectedItem as TabItem;

            if (currentTab == ImageTabControlSource)
            {
                Console.WriteLine("Source tab selected.");
                //CapturedImageBox.Width = width;
                //SourceCanvas.MaxWidth = width;
                //CapturedImageBox.Height = height;
                //SourceCanvas.MaxHeight = height;
            }
            else if (currentTab == ImageTabControlMedian)
            {
                Console.WriteLine("Median tab selected.");
                MedianImageBox.Width = width;
                //MedianCanvas.MaxWidth = width;
                MedianImageBox.Height = height;
                //MedianCanvas.MaxHeight = height;
            }
            else if (currentTab == ImageTabControlHSV)
            {
                selectionCountHSV++;
                if (selectionCountHSV >= 2)
                {
                    //Canvas.SetTop(HSVHost, -120);
                    //Canvas.SetLeft(HSVHost, -160);
                }
                Console.WriteLine("HSV tab selected. Count: {0}", selectionCountHSV);
                HSVImageBox.Width = width;
                //HSVImageCanvas.Width = width;
                HSVImageBox.Height = height;
                //HSVImageCanvas.Height = height;
            }
            else if (currentTab == ContoursTab)
            {
                //ContoursImageBox.Width = 320;
                //ContoursImageBox.Height = 240;
                Console.WriteLine("Contours Image Box");
            }
        }
        private void setDimensions()
        {
            //Defines a ratio. > 1 reduces the total size, < 1 enlarges.
            ratio = 2;
            Mat frame = new Mat();

            camManager.Retrieve(frame, 0);
            if (frame.Width != 0)
            {
                int ratioWidth  = frame.Width / ratio;
                int ratioHeight = frame.Height / ratio;

                SourceImageBox.Width  = ratioWidth;
                SourceCol.Width       = new GridLength(ratioWidth);
                SourceImageBox.Height = ratioHeight;
                SourceRow.Height      = new GridLength(ratioHeight);

                MedianImageBox.Width  = ratioWidth;
                MedianCol.Width       = new GridLength(ratioWidth);
                MedianImageBox.Height = ratioHeight;
                MedianRow.Height      = new GridLength(ratioHeight);

                HSVImageBox.Width  = ratioWidth;
                HSVImageBox.Height = ratioHeight;
                height             = frame.Height / ratio;
                width = frame.Width / ratio;

                TextBoxConsole.MaxHeight = ratioHeight;

                SourceImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
                MedianImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
                HSVImageBox.SetZoomScale(0.5, new System.Drawing.Point(0, 0));
            }
            else
            {
                if (!System.IO.Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CocoNuts Vision Processing"))
                {
                    System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CocoNuts Vision Processing");
                }
                string[] lines = { DateTime.Now.ToString(), "Oh no! No camera was detected! :(", "", "====================" };
                System.IO.File.AppendAllLines(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CocoNuts Vision Processing\\Log.txt", lines);
                Environment.Exit(0);
            }
        }