Пример #1
0
        /// <summary>
        /// validtes the input if entre
        /// is pressed the <see cref="CustomColor"/>
        /// is updated
        /// </summary>
        /// <param name="e"></param>
        private void NumericValidation(KeyEventArgs e)
        {
            string input = e.Key.ToString().Substring(1);

            try
            {
                if (e.Key == Key.Enter)
                {
                    CustomColor = ColorPickerHelper.MakeColorFromRGB(
                        _txtAlpha.Text,
                        _txtRed.Text,
                        _txtGreen.Text,
                        _txtBlue.Text
                        );

                    //CustomColor = ColorPickerHelper.MakeColorFromRGB(
                    //    _alphaValue,
                    //    _redValue,
                    //    _greenValue,
                    //    _blueValue
                    //    );

                    Reposition();
                }
                int inputDigit = Int32.Parse(input);
            }
            catch
            {
                e.Handled = true;
            }
        }
Пример #2
0
 /// <summary>
 /// calls <see cref="MovePointerDuringReposition(int, int)"/> if the color is similr
 /// </summary>
 private void Reposition()
 {
     for (int i = 0; i < _canvasColor.Width; i++)
     {
         bool flag = false;
         for (int j = 0; j < _canvasColor.Height; j++)
         {
             try
             {
                 Color Colorfromimagepoint = ColorPickerHelper.GetColorFromImage(_image, i, j);
                 if (ColorPickerHelper.SimmilarColor(Colorfromimagepoint, _customColor))
                 {
                     MovePointerDuringReposition(i, j);
                     flag = true;
                     break;
                 }
             }
             catch
             {
             }
         }
         if (flag)
         {
             break;
         }
     }
 }
Пример #3
0
        /// <summary>
        /// handles the txtAll key down
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtAll_KeyDown(object sender, Avalonia.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                try
                {
                    if (string.IsNullOrEmpty(((TextBox)sender).Text))
                    {
                        return;
                    }

                    string allTextResult = string.Empty;
                    CustomColor  = ColorPickerHelper.MakeColorFromHex(sender, CustomColor, out allTextResult);
                    _txtAll.Text = allTextResult;

                    Reposition();
                }
                catch
                {
                }
            }
            else if (e.Key == Key.Tab)
            {
                _txtAlpha.Focus();
            }

            string input = e.Key.ToString().Substring(1);

            if (string.IsNullOrEmpty(input))
            {
                input = e.Key.ToString();
            }
            if (input == "3" && _shift == true)
            {
                input = "#";
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                _shift = true;
            }
            else
            {
                _shift = false;
            }

            if (!(input == "#" || (input[0] >= 'A' && input[0] <= 'F') || (input[0] >= 'a' && input[0] <= 'F') || (input[0] >= '0' && input[0] <= '9')))
            {
                e.Handled = true;
            }
            if (input.Length > 1)
            {
                e.Handled = true;
            }
        }
Пример #4
0
        /// <summary>
        /// tries the color from the color-image
        /// </summary>
        /// <param name="e"></param>
        private void ChangeColor(PointerEventArgs e)
        {
            try
            {
                CustomColor = ColorPickerHelper.
                              GetColorFromImage(_image,
                                                (int)e.GetPosition(_canvasColor).X,
                                                (int)e.GetPosition(_canvasColor).Y);

                MovePointer(e);
            }
            catch
            {
            }
        }
Пример #5
0
        /// <summary>
        /// handles the txtAll textchanged
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtAll_TextChanged(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(((TextBox)sender).Text))
                {
                    return;
                }

                string allTextResult = string.Empty;
                CustomColor  = ColorPickerHelper.MakeColorFromHex(sender, CustomColor, out allTextResult);
                _txtAll.Text = allTextResult;
                Reposition();
            }
            catch
            {
            }
        }