private void CheckBoxRandom_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (CheckBoxRandom.IsChecked == true)
            {
                _isRandomMode = true;
                RectangleRandomColor1.SetBinding(Shape.FillProperty, _randomColorBinding);
                RectangleRandomColor2.SetBinding(Shape.FillProperty, _randomColorBinding);
            }
            else
            {
                _isRandomMode = false;
                CheckBoxIncrement.IsChecked = false;
                SliderA2.Value = SliderA1.Value;
                SliderB2.Value = SliderB1.Value;
                SliderC2.Value = SliderC1.Value;
                SliderD2.Value = SliderD1.Value;
                RandomColor    = ColorSpace.OpaqueBlack;
                RectangleRandomColor1.SetBinding(Shape.FillProperty, _currentColor1Binding);
                RectangleRandomColor2.SetBinding(Shape.FillProperty, _currentColor2Binding);
            }

            e.Handled = true;
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize controls
            CheckBoxRandom.IsChecked = false;
            ComboBoxColorSpace.Items.Add(Cmy.FriendlyName);
            ComboBoxColorSpace.Items.Add(Cmyk.FriendlyName);
            ComboBoxColorSpace.Items.Add(Hsl.FriendlyName);
            ComboBoxColorSpace.Items.Add(Hsv.FriendlyName);
            ComboBoxColorSpace.Items.Add(HunterLab.FriendlyName);
            ComboBoxColorSpace.Items.Add(Lab.FriendlyName);
            ComboBoxColorSpace.Items.Add(Lch.FriendlyName);
            ComboBoxColorSpace.Items.Add(Luv.FriendlyName);
            ComboBoxColorSpace.Items.Add(Rgb.FriendlyName);
            ComboBoxColorSpace.Items.Add(Rgba.FriendlyName);
            ComboBoxColorSpace.Items.Add(Xyz.FriendlyName);
            ComboBoxColorSpace.Items.Add(Yxy.FriendlyName);
            ComboBoxColorSpace.SelectedValue = Rgba.FriendlyName;
            ListBoxColorSet.ItemsSource      = Colors;

            // Configure bindings (enable / disable)
            var binding =
                new Binding("SelectedItems.Count")
            {
                Source = ListBoxColorSet, Converter = new PositiveIntegerToBoolConverter()
            };

            ButtonRemove.SetBinding(IsEnabledProperty, binding);

            // Configure bindings (Random = true)
            binding = new Binding("IsChecked")
            {
                Source = CheckBoxRandom, Converter = new BooleanToVisibilityConverter()
            };
            TextBlockLabelA2.SetBinding(VisibilityProperty, binding);
            TextBlockLabelAMin.SetBinding(VisibilityProperty, binding);
            TextBlockLabelAMax.SetBinding(VisibilityProperty, binding);
            TextBoxValueA2.SetBinding(VisibilityProperty, binding);
            SliderA2.SetBinding(VisibilityProperty, binding);
            TextBlockLabelB2.SetBinding(VisibilityProperty, binding);
            TextBlockLabelBMin.SetBinding(VisibilityProperty, binding);
            TextBlockLabelBMax.SetBinding(VisibilityProperty, binding);
            TextBoxValueB2.SetBinding(VisibilityProperty, binding);
            SliderB2.SetBinding(VisibilityProperty, binding);
            TextBlockLabelC2.SetBinding(VisibilityProperty, binding);
            TextBlockLabelCMin.SetBinding(VisibilityProperty, binding);
            TextBlockLabelCMax.SetBinding(VisibilityProperty, binding);
            TextBoxValueC2.SetBinding(VisibilityProperty, binding);
            SliderC2.SetBinding(VisibilityProperty, binding);
            CheckBoxIncrement.SetBinding(VisibilityProperty, binding);
            ButtonRandomize.SetBinding(VisibilityProperty, binding);

            // Configure bindings (ColorSpace = CMYK)
            binding = new Binding("SelectedValue")
            {
                Source    = ComboBoxColorSpace,
                Converter = new ColorSpaceToVisibilityConverter()
            };
            TextBlockLabelD1.SetBinding(VisibilityProperty, binding);
            TextBoxValueD1.SetBinding(VisibilityProperty, binding);
            SliderD1.SetBinding(VisibilityProperty, binding);

            // Configure bindings (Random = true && ColorSpace = CMYK)
            var bindings = new[]
            {
                new Binding("SelectedValue")
                {
                    Source = ComboBoxColorSpace
                }, new Binding("IsChecked")
                {
                    Source = CheckBoxRandom
                }
            };
            var multiBinding = new MultiBinding()
            {
                Converter = new ColorSpaceToVisibilityMultiConverter()
            };

            foreach (var bindingPart in bindings)
            {
                multiBinding.Bindings.Add(bindingPart);
            }

            TextBlockLabelD2.SetBinding(VisibilityProperty, multiBinding);
            TextBlockLabelDMin.SetBinding(VisibilityProperty, multiBinding);
            TextBlockLabelDMax.SetBinding(VisibilityProperty, multiBinding);
            TextBoxValueD2.SetBinding(VisibilityProperty, multiBinding);
            SliderD2.SetBinding(VisibilityProperty, multiBinding);

            // Configure bindings (Current color rectangles)
            _currentColor1Binding =
                new Binding("CurrentColor1")
            {
                Source = this, Converter = new ColorSpaceToSolidColorBrushConverter()
            };
            RectangleCurrentColor1.SetBinding(Shape.FillProperty, _currentColor1Binding);

            _currentColor2Binding =
                new Binding("CurrentColor2")
            {
                Source = this, Converter = new ColorSpaceToSolidColorBrushConverter()
            };
            RectangleCurrentColor2.SetBinding(Shape.FillProperty, _currentColor2Binding);

            _randomColorBinding =
                new Binding("RandomColor")
            {
                Source = this, Converter = new ColorSpaceToSolidColorBrushConverter()
            };
            RectangleRandomColor1.SetBinding(Shape.FillProperty, _currentColor1Binding);
            RectangleRandomColor2.SetBinding(Shape.FillProperty, _currentColor2Binding);
        }