Exemple #1
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;
            }
        }
Exemple #2
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
            {
            }
        }