| | |
| | | /// 圆盘选择的颜色显示控件(内框)
|
| | | /// </summary>
|
| | | private IconViewControl wheelSelectIcon2 = null;
|
| | | /// <summary>
|
| | | /// 是否是颜色选择
|
| | | /// </summary>
|
| | | private bool isColorSelect = false;
|
| | | /// <summary>
|
| | | /// 颜色值输入控件
|
| | | /// </summary>
|
| | | private TextInputControl txtColorInput = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="i_R">R</param>
|
| | | /// <param name="i_G">G</param>
|
| | | /// <param name="i_B">B</param>
|
| | | public void ShowForm(int i_R,int i_G,int i_B)
|
| | | public void ShowForm(int i_R, int i_G, int i_B)
|
| | | {
|
| | | this.ScrollEnabled = false;
|
| | |
|
| | |
| | | /// </summary>
|
| | | private void InitColorPictrueControl()
|
| | | {
|
| | | //圆盘控件的FrameLayout
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Y = Application.GetRealHeight(66);
|
| | | frameBack.Height = Application.GetRealHeight(1204);
|
| | | bodyFrameLayout.AddChidren(frameBack);
|
| | | //初始化颜色输入控件
|
| | | this.txtColorInput = this.InitColorInputControl();
|
| | |
|
| | | var framePic = new FrameLayout();
|
| | | framePic.Width = this.GetPictrueRealSize(588);
|
| | | framePic.Height = this.GetPictrueRealSize(588);
|
| | | framePic.Gravity = Gravity.Center;
|
| | | frameBack.AddChidren(framePic);
|
| | | framePic.Gravity = Gravity.CenterHorizontal;
|
| | | framePic.Y = Application.GetRealHeight(192);
|
| | | bodyFrameLayout.AddChidren(framePic);
|
| | |
|
| | | //圆盘控件
|
| | | var colorPic = new ColorPicker();
|
| | |
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(eColor[2])));
|
| | |
|
| | | //显示选择颜色的控件
|
| | | if (nowSelectIcon1 != null)
|
| | | {
|
| | | nowSelectIcon1.BorderColor = UserCenterColor.Current.White;
|
| | | }
|
| | | wheelSelectIcon2.BackgroundColor = this.GetColorByRGB(eColor[0], eColor[1], eColor[2]);
|
| | | wheelSelectIcon1.BorderColor = 0xffcccccc;
|
| | | wheelSelectIcon1.Name = listRGB[0] + "-" + listRGB[1] + "-" + listRGB[2];
|
| | | nowSelectIcon1 = wheelSelectIcon1;
|
| | | this.ShowNowSelectColorControl(eColor);
|
| | |
|
| | | //获取颜色的翻译文本
|
| | | isColorSelect = true;
|
| | | this.txtColorInput.Text = this.GetColorTextTranslate(listRGB[0], listRGB[1], listRGB[2]);
|
| | | };
|
| | | colorPic.MouseDownEventHandler += (sender, e) =>
|
| | | {
|
| | |
| | | //当鼠标点下事件处理
|
| | | colorPic.MouseDownEventHandler(sender, e);
|
| | | };
|
| | |
|
| | | //手动输入值改变事件
|
| | | this.txtColorInput.TextChangeEventHandler += (sender, value) =>
|
| | | {
|
| | | if (isColorSelect == true)
|
| | | {
|
| | | //这里是由点击色盘进行赋值触发
|
| | | isColorSelect = false;
|
| | | return;
|
| | | }
|
| | | //检测输入的颜色值
|
| | | var byteColor = this.CheckInputColorValue(value);
|
| | | if (byteColor == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (btnWhiteView.Visible == true)
|
| | | {
|
| | | //白点隐藏
|
| | | btnWhiteView.Visible = false;
|
| | | }
|
| | |
|
| | | //记录缓存
|
| | | listRGB = new List<int>();
|
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[0])));
|
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[1])));
|
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(byteColor[2])));
|
| | |
|
| | | //显示选择颜色的控件
|
| | | this.ShowNowSelectColorControl(byteColor);
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化颜色输入控件
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private TextInputControl InitColorInputControl()
|
| | | {
|
| | | //自定义色值的外框
|
| | | var frameInput = new NormalFrameLayout();
|
| | | frameInput.Width = Application.GetRealWidth(458);
|
| | | frameInput.Height = Application.GetRealHeight(104);
|
| | | frameInput.Y = Application.GetRealHeight(1103);
|
| | | frameInput.Gravity = Gravity.CenterHorizontal;
|
| | | frameInput.BorderColor = 0xffcccccc;
|
| | | frameInput.Radius = (uint)Application.GetRealWidth(17);
|
| | | frameInput.BorderWidth = Application.GetRealWidth(3) == 0 ? 1 : (uint)Application.GetRealWidth(3);
|
| | | bodyFrameLayout.AddChidren(frameInput);
|
| | | var btnMark = new NormalViewControl(100, 58, true);
|
| | | btnMark.X = Application.GetRealWidth(35);
|
| | | btnMark.Gravity = Gravity.CenterVertical;
|
| | | btnMark.IsBold = true;
|
| | | btnMark.Text = "# ";
|
| | | btnMark.Width = btnMark.GetRealWidthByText();
|
| | | btnMark.TextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | frameInput.AddChidren(btnMark);
|
| | | //自定义色值输入框
|
| | | var txtInput = new TextInputControl(400, 58, true);
|
| | | txtInput.X = btnMark.Right;
|
| | | txtInput.Gravity = Gravity.CenterVertical;
|
| | | txtInput.TextSize = 16;
|
| | | txtInput.FrameBorder = frameInput;
|
| | | frameInput.AddChidren(txtInput);
|
| | | //色值号为6位(由任意数字+字母组合)
|
| | | var btnTipView = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(55), false);
|
| | | btnTipView.Y = frameInput.Bottom + Application.GetRealHeight(20);
|
| | | btnTipView.IsBold = true;
|
| | | btnTipView.TextAlignment = TextAlignment.Center;
|
| | | btnTipView.TextColor = UserCenterColor.Current.TextGrayColor2;
|
| | | btnTipView.TextSize = 12;
|
| | | btnTipView.TextID = R.MyInternationalizationString.uColorLengthMsg;
|
| | | bodyFrameLayout.AddChidren(btnTipView);
|
| | |
|
| | | return txtInput;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 显示选择颜色的控件
|
| | | /// </summary>
|
| | | /// <param name="eColor"></param>
|
| | | private void ShowNowSelectColorControl(byte[] eColor)
|
| | | {
|
| | | //显示选择颜色的控件
|
| | | if (nowSelectIcon1 != null)
|
| | | {
|
| | | nowSelectIcon1.BorderColor = UserCenterColor.Current.White;
|
| | | }
|
| | | var uintColor = this.GetColorByRGB(eColor[0], eColor[1], eColor[2]);
|
| | | wheelSelectIcon2.BackgroundColor = uintColor;
|
| | | wheelSelectIcon1.BorderColor = 0xffcccccc;
|
| | | wheelSelectIcon1.Name = listRGB[0] + "-" + listRGB[1] + "-" + listRGB[2];
|
| | | nowSelectIcon1 = wheelSelectIcon1;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | btnFrame.Width = this.GetPictrueRealSize(80);
|
| | | btnFrame.Radius = (uint)this.GetPictrueRealSize(80) / 2;
|
| | | btnFrame.X = Xdefult + i * this.GetPictrueRealSize(80 + 24);
|
| | | btnFrame.Y = Application.GetRealHeight(1054);
|
| | | btnFrame.Y = Application.GetRealHeight(880);
|
| | | btnFrame.BackgroundColor = UserCenterColor.Current.White;
|
| | | btnFrame.BorderWidth = 1;
|
| | | btnFrame.BorderColor = UserCenterColor.Current.White;
|
| | |
| | | wheelSelectIcon1 = btnFrame;
|
| | | wheelSelectIcon2 = btnIcon;
|
| | | nowSelectIcon1 = btnFrame;
|
| | |
|
| | | //获取颜色的翻译文本
|
| | | isColorSelect = true;
|
| | | this.txtColorInput.Text = this.GetColorTextTranslate(i_R, i_G, i_B);
|
| | | }
|
| | |
|
| | | btnFrame.ButtonClickEvent += (sender, e) =>
|
| | |
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(Arry[1])));
|
| | | listRGB.Add(Convert.ToInt32(Convert.ToString(Arry[2])));
|
| | | }
|
| | | //获取颜色的翻译文本
|
| | | isColorSelect = true;
|
| | | this.txtColorInput.Text = this.GetColorTextTranslate(listRGB[0], listRGB[1], listRGB[2]);
|
| | | };
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 检测输入的颜色值
|
| | | /// </summary>
|
| | | /// <param name="colorText"></param>
|
| | | /// <returns></returns>
|
| | | private byte[] CheckInputColorValue(string colorText)
|
| | | {
|
| | | //只有长度为6才处理
|
| | | if (colorText.Length != 6) { return null; }
|
| | |
|
| | | colorText = colorText.ToUpper();
|
| | | foreach (var c in colorText)
|
| | | {
|
| | | if (char.IsNumber(c) == true)
|
| | | {
|
| | | //数字的话,OK
|
| | | continue;
|
| | | }
|
| | | if ('A' <= c && c <= 'F')
|
| | | {
|
| | | //A-F的话,OK
|
| | | continue;
|
| | | }
|
| | | return null;
|
| | | }
|
| | | int R = Convert.ToInt32(colorText.Substring(0, 2), 16);
|
| | | int G = Convert.ToInt32(colorText.Substring(2, 2), 16);
|
| | | int B = Convert.ToInt32(colorText.Substring(4, 2), 16);
|
| | | return new byte[] { (byte)R, (byte)G, (byte)B };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取颜色的翻译文本
|
| | | /// </summary>
|
| | | /// <param name="i_R"></param>
|
| | | /// <param name="i_G"></param>
|
| | | /// <param name="i_B"></param>
|
| | | /// <returns></returns>
|
| | | private string GetColorTextTranslate(int i_R, int i_G, int i_B)
|
| | | {
|
| | | return Convert.ToString(i_R, 16).ToUpper().PadLeft(2, '0')
|
| | | + Convert.ToString(i_G, 16).ToUpper().PadLeft(2, '0')
|
| | | + Convert.ToString(i_B, 16).ToUpper().PadLeft(2, '0');
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 将RGB转换为颜色
|
| | | /// </summary>
|
| | | /// <param name="R"></param>
|