private void UpdateSaturationBar(HSLColor color)
 {
     DrawSaturationGradient(color);
 }
        private void DrawSaturationGradient(HSLColor color)
        {
            var dis = saturationPanel.DisplayRectangle;
            var screenRec = saturationPanel.RectangleToScreen(dis);
            var rec = saturationPanel.Parent.RectangleToClient(screenRec);
            saturationPanel.Visible = false;
            LinearGradientBrush brush = new LinearGradientBrush(
                rec,
                Color.Transparent,
                Color.Transparent,
                LinearGradientMode.Horizontal);
            ColorBlend blend = new ColorBlend();
            Color[] blendColors = 
            {
                new HSLColor(
                color.Hue,
                0,
                color.Luminosity),
                new HSLColor(
                color.Hue,
                120,
                color.Luminosity),
                new HSLColor(
                color.Hue,
                240,
                color.Luminosity)
            };
            float[] positions = { 0.0f, 0.5f, 1.0f };
            blend.Colors = blendColors;
            blend.Positions = positions;

            brush.InterpolationColors = blend;

            using (Graphics g = this.CreateGraphics())
            {
                g.FillRectangle(brush, rec);
            }
        }
 private void UpdateBrightnessBar(HSLColor color)
 {
     DrawBrightnessGradient(color);
 }
        private void SaturationBar_ValueChanged(object sender, EventArgs e)
        {
            float newSaturation = saturationBar.Value;
            var newColor = new HSLColor();
            try
            {
                newColor.Hue = dataSource.SelectedColor.Hue;
                newColor.Saturation = newSaturation;
                newColor.Luminosity = dataSource.SelectedColor.Luminosity;

                brightnessBar.ValueChanged -= BrightnessBar_ValueChanged;
                saturationBar.ValueChanged -= SaturationBar_ValueChanged;

                dataSource.SelectedColor = newColor;
                UpdateBrightnessBar(newColor);
                UpdateSaturationBar(newColor);
                
                brightnessBar.ValueChanged += BrightnessBar_ValueChanged;
                saturationBar.ValueChanged += SaturationBar_ValueChanged;
            }
            catch (Exception)
            {
            }
        }
        private void ColorSelectedShapesWithColor(HSLColor selectedColor)
        {
            SelectShapes();
            if (_selectedShapes != null
                && PowerPointCurrentPresentationInfo.CurrentSelection.Type == PpSelectionType.ppSelectionShapes)
            {
                foreach (PowerPoint.Shape s in _selectedShapes)
                {
                    try
                    {
                        var r = ((Color)selectedColor).R;
                        var g = ((Color)selectedColor).G;
                        var b = ((Color)selectedColor).B;

                        var rgb = (b << 16) | (g << 8) | (r);
                        ColorShapeWithColor(s, rgb, currMode);
                    }
                    catch (Exception)
                    {
                        RecreateCorruptedShape(s);
                    }  
                }
            }
            if (_selectedText != null
                && PowerPointCurrentPresentationInfo.CurrentSelection.Type == PpSelectionType.ppSelectionText)
            {
                try
                {
                    var r = ((Color)selectedColor).R;
                    var g = ((Color)selectedColor).G;
                    var b = ((Color)selectedColor).B;

                    var rgb = (b << 16) | (g << 8) | (r);
                    ColorShapeWithColor(_selectedText, rgb, currMode);
                }
                catch (Exception)
                {
                }  
            }
        }
 private static double GetTemp2(HSLColor hslColor)
 {
     double temp2;
     if (hslColor.luminosity < 0.5)  //<=??
         temp2 = hslColor.luminosity * (1.0 + hslColor.saturation);
     else
         temp2 = hslColor.luminosity + hslColor.saturation - (hslColor.luminosity * hslColor.saturation);
     return temp2;
 }
Exemple #7
0
        private void brightnessBar_ValueChanged(object sender, EventArgs e)
        {
            if (!timer1.Enabled)
            {
                float newBrightness = brightnessBar.Value;
                var newColor = new HSLColor();
                try
                {
                    newColor.Hue = dataSource.selectedColor.Hue;
                    newColor.Saturation = dataSource.selectedColor.Saturation;
                    newColor.Luminosity = newBrightness;

                    brightnessBar.ValueChanged -= brightnessBar_ValueChanged;
                    saturationBar.ValueChanged -= saturationBar_ValueChanged;

                    dataSource.selectedColor = newColor;
                    UpdateSaturationBar(newColor);
                    UpdateBrightnessBar(newColor);

                    brightnessBar.ValueChanged += brightnessBar_ValueChanged;
                    saturationBar.ValueChanged += saturationBar_ValueChanged;
                }
                catch (Exception)
                {
                }
            }
        }
Exemple #8
0
 private void UpdateSaturationBar(HSLColor color)
 {
     DrawSaturationGradient(color);
 }
Exemple #9
0
 private void UpdateBrightnessBar(HSLColor color)
 {
     DrawBrightnessGradient(color);
 }