private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var combobox = (ComboBox)sender;

            //handle selection of item from combobox
            switch (combobox.SelectedItem.ToString().Split(new[] { ": " }, StringSplitOptions.None).Last())
            {
            case "Czerwony":
                HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramTools.HistogramR);
                HistogramRed.Fill   = Brushes.Red;
                _option             = 0;
                break;

            case "Zielony":
                HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramTools.HistogramG);
                HistogramRed.Fill   = Brushes.Green;
                _option             = 1;

                break;

            case "Niebieski":
                HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramTools.HistogramB);
                HistogramRed.Fill   = Brushes.Blue;
                _option             = 2;
                break;

            case "Uśredniony":
                HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramTools.HistogramU);
                HistogramRed.Fill   = Brushes.Gray;
                _option             = 3;
                break;
            }

            PreviewImageUpdate();
        }
        private void PreviewImageUpdate()
        {
            try
            {
                //get lut for stretching - preview image
                var lut = HistogramTools.GetLutStretching(int.Parse(TextBoxMin.Text), int.Parse(TextBoxMax.Text));
                //set new image after histogram stretching
                PreviewImage.Source = HistogramTools.StretchHistogram(lut, _option);
                //recalculate histogram after stretching
                CalculateHistograms();
                //update polygon graphs for visual representation of histograms
                switch (_option)
                {
                case 0:
                    HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramR);
                    break;

                case 1:
                    HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramG);
                    break;

                case 2:
                    HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramB);
                    break;

                case 3:
                    HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramU);
                    break;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
            }
        }
 private void InitHandle()
 {
     HistogramRed.Points = HistogramWindow.ConvertToPointCollection(HistogramTools.HistogramR);
 }