Exemple #1
0
        private void StartConverting()
        {
            isLoadingImage = true;
            if (currentRunningTask != null && !currentRunningTask.IsCanceled)
            {
                tokenSource.Cancel();
            }
            tokenSource = new CancellationTokenSource();
            CancellationToken token = tokenSource.Token;

            currentRunningTask = new Task(() =>
            {
                if (CConverter.Convert(token))
                {
                    CConverter.Image.Freeze();
                    currentRunningTask      = null;
                    isLoadingImage          = false;
                    ConvertButtonVisibility = Visibility.Collapsed;
                    if (_Lightness == 0)                                                          //якщо немає змін в яскравості
                    {
                        Dispatcher.CurrentDispatcher.Invoke(() => ImageRight = CConverter.Image); //просто встановити зображення
                    }
                    else //якщо ж є
                    {
                        Lightness = Lightness; //то викликаємо зміни яскравості ще раз, щоб виконалась функція StartAdjusting
                    }
                }
            }, token);
            currentRunningTask.Start();
        }
Exemple #2
0
        void SetColor(Color color, bool setColorPicker)
        {
            if (setColorPicker)
            {
                sequenceColorWheel.PickedColor = color;
            }
            sequenceRgb.Text = color.R + "," + color.G + "," + color.B;
            HSVcolor hsvColor = CConverter.ColorToHSV(color);

            sequenceHsv.Text        = Math.Round(hsvColor.Hue, 0) + "," + Math.Round(hsvColor.Saturation, 2) + "," + Math.Round(hsvColor.Value, 2);
            sequenceHex.Text        = CConverter.HexFromColor(color);
            sequencePanel.BackColor = color;
            sequenceMaker1.SetSelectedPointColor(color);
        }
Exemple #3
0
        void SetColor(Color color, bool setColorPicker)
        {
            if (setColorPicker)
            {
                staticColorWheel.PickedColor = color;
            }
            staticRgb.Text = color.R + "," + color.G + "," + color.B;
            HSVcolor hsvColor = CConverter.ColorToHSV(color);

            staticHsv.Text        = Math.Round(hsvColor.Hue, 0) + "," + Math.Round(hsvColor.Saturation, 2) + "," + Math.Round(hsvColor.Value, 2);
            staticHex.Text        = CConverter.HexFromColor(color);
            staticPanel.BackColor = color;
            this.color            = color;
            rgb = staticRgb.Text;
        }
Exemple #4
0
 private void staticHex_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         TextBox box = sender as TextBox;
         Color   color;
         try
         {
             color = CConverter.ColorFromHex(staticHex.Text);
         }
         catch
         {
             return;
         }
         staticPanel.Focus();
         e.SuppressKeyPress = true;
         SetColor(color, true);
     }
 }
Exemple #5
0
        private void StartAdjusting()
        {
            if (currentRunningTask != null && !currentRunningTask.IsCanceled)
            {
                tokenSource.Cancel();
            }
            tokenSource = new CancellationTokenSource();
            CancellationToken token = tokenSource.Token;

            currentRunningTask = new Task(() =>
            {
                if (CConverter.AdjustLightness(HueNumber, Lightness, token))
                {
                    CConverter.Image.Freeze();
                    Dispatcher.CurrentDispatcher.Invoke(() => ImageRight = CConverter.Image);
                    currentRunningTask = null;
                }
            }, token);
            currentRunningTask.Start();
        }
Exemple #6
0
        void SetColor(Color color, bool setColorPicker)
        {
            if (setColorPicker)
            {
                audioColorWheel.PickedColor = color;
            }
            audioRgb.Text = color.R + "," + color.G + "," + color.B;
            HSVcolor hsvColor = CConverter.ColorToHSV(color);

            audioHsv.Text         = Math.Round(hsvColor.Hue, 0) + "," + Math.Round(hsvColor.Saturation, 2) + "," + Math.Round(hsvColor.Value, 2);
            audioHex.Text         = CConverter.HexFromColor(color);
            targetPanel.BackColor = color;
            if (targetPanel == panelFrom)
            {
                colorFrom = color;
            }
            if (targetPanel == panelTo)
            {
                colorTo = color;
            }
        }
Exemple #7
0
 private void staticHsv_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Return)
     {
         TextBox box = sender as TextBox;
         if (box.Text.Length >= 5)
         {
             string[] args = box.Text.Split(',');
             HSVcolor hsvColor;
             try
             {
                 hsvColor = new HSVcolor(float.Parse(args[0]), float.Parse(args[1]), float.Parse(args[2]));
             }
             catch
             {
                 return;
             }
             staticPanel.Focus();
             e.SuppressKeyPress = true;
             SetColor(CConverter.ColorFromHSV(hsvColor), true);
         }
     }
 }
Exemple #8
0
        public void HandleMouseMove(int x, int y)
        {
            var rgb = CConverter.GetRGB(x, y);

            if (rgb == null)
            {
                RGBText = "";
            }
            else
            {
                RGBText = $"({rgb.Value.R}, {rgb.Value.G}, {rgb.Value.B})";
            }

            var hsl = CConverter.GetHSL(x, y);

            if (hsl == null)
            {
                HSLText = "";
            }
            else
            {
                HSLText = $"({hsl.H}°, {hsl.S}%, {hsl.L}%)";
            }
        }
Exemple #9
0
 internal static HandleRef getCPtr(CConverter obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #10
0
 internal static HandleRef getCPtr(CConverter obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }