private async void SetColorbar(int imageID) { if (_imageID != -1) { List <Model.ImageColorInfo> lst = await SqliteUtil.Current.QueryImageColorInfoByImageID(_imageID); foreach (ImageColorInfo color in lst) { BoxView box = new BoxView(); box.Color = Xamarin.Forms.Color.FromHex(color.HEXValue); box.CornerRadius = new CornerRadius(10); pickColorList.Children.Add(box); } if (lst.Count > 0) { ColorCode colorcd = new ColorCode(); string hex = lst[lst.Count - 1].HEXValue; btnColor.BackgroundColor = Xamarin.Forms.Color.FromHex(hex); lblSelected.Text = hex; lblHex.Text = hex; Rgb rgb = colorcd.getRgb(hex); lblRgb.Text = colorcd.getRgbString(rgb); lblHsl.Text = colorcd.getHslString(rgb); lblHsv.Text = colorcd.getHsvString(rgb); lblCmyk.Text = colorcd.getCmykString(rgb); lblLab.Text = colorcd.getLabString(rgb); lblMunsell.Text = colorcd.getMunsellString(rgb); lblPccs.Text = colorcd.getPCCSTone(rgb); lblJis.Text = JisUtil.getJisByMunsell(lblMunsell.Text); } } }
/// <summary> /// 選択した色リストを更新する /// </summary> /// <param name="lst"></param> private void updatecolorBar(List <ImageColorInfo> lst, string pickColor = "") { pickColorList.Children.Clear(); int colorcnt = lst.Count; double heightValue = pickColorList.Width / 10; ColorCode colorcd = new ColorCode(); foreach (ImageColorInfo color in lst) { BoxView box = new BoxView(); box.BackgroundColor = Xamarin.Forms.Color.FromHex(color.HEXValue); box.Color = Xamarin.Forms.Color.FromHex(color.HEXValue); double widthHeight = pickColorList.Width / colorcnt; box.WidthRequest = widthHeight; box.HeightRequest = heightValue; if (lblSelected.Text.Equals(color.HEXValue)) { box.HeightRequest = heightValue * 2; box.Margin = new Thickness(0, 0, 0, -heightValue); } var tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += (s, e) => { foreach (BoxView newBox in pickColorList.Children) { newBox.HeightRequest = heightValue; newBox.Margin = 0; } BoxView boxview = (BoxView)s; boxview.HeightRequest = heightValue * 2; boxview.Margin = new Thickness(0, 0, 0, -heightValue); btnColor.BackgroundColor = boxview.Color; lblSelected.Text = ToHex(boxview.BackgroundColor.ToSKColor()); string hex = ToHex(boxview.BackgroundColor.ToSKColor()); lblHex.Text = hex; Rgb rgb = colorcd.getRgb(hex); lblRgb.Text = colorcd.getRgbString(rgb); lblHsl.Text = colorcd.getHslString(rgb); lblHsv.Text = colorcd.getHsvString(rgb); lblCmyk.Text = colorcd.getCmykString(rgb); lblLab.Text = colorcd.getLabString(rgb); lblMunsell.Text = colorcd.getMunsellString(rgb); lblPccs.Text = colorcd.getPCCSTone(rgb); lblJis.Text = JisUtil.getJisByMunsell(lblMunsell.Text); }; box.GestureRecognizers.Add(tapGestureRecognizer); pickColorList.Children.Add(box); } }
private void btn_Delete_Click(object sender, EventArgs e) { string strHex = lblSelected.Text; ColorCode colorcd = new ColorCode(); foreach (ImageColorInfo info in qList) { if (info.HEXValue.Equals(strHex)) { qList.Remove(info); break; } } _point = new Xamarin.Forms.Point(0.0, 0.0); lastXMove = lastXMoveBak; lastYMove = lastYMoveBak; if (qList.Count > 0) { string hex = qList[qList.Count - 1].HEXValue; btnColor.BackgroundColor = Xamarin.Forms.Color.FromHex(hex); lblSelected.Text = hex; lblHex.Text = hex; Rgb rgb = colorcd.getRgb(hex); lblRgb.Text = colorcd.getRgbString(rgb); lblHsl.Text = colorcd.getHslString(rgb); lblHsv.Text = colorcd.getHsvString(rgb); lblCmyk.Text = colorcd.getCmykString(rgb); lblLab.Text = colorcd.getLabString(rgb); lblMunsell.Text = colorcd.getMunsellString(rgb); lblPccs.Text = colorcd.getPCCSTone(rgb); lblJis.Text = JisUtil.getJisByMunsell(lblMunsell.Text); } else { btnColor.BackgroundColor = Xamarin.Forms.Color.White; lblSelected.Text = string.Empty; lblHex.Text = string.Empty; lblRgb.Text = string.Empty; lblHsl.Text = string.Empty; lblHsv.Text = string.Empty; lblCmyk.Text = string.Empty; lblLab.Text = string.Empty; lblMunsell.Text = string.Empty; lblPccs.Text = string.Empty; lblJis.Text = string.Empty; } // カンバス更新 canvasView.InvalidateSurface(); }
public void reload() { ColorCode colorcd = new ColorCode(); if (qList.Count > 0) { string hex = qList[qList.Count - 1].HEXValue; btnColor.BackgroundColor = Xamarin.Forms.Color.FromHex(hex); lblSelected.Text = hex; lblHex.Text = hex; Rgb rgb = colorcd.getRgb(hex); lblRgb.Text = colorcd.getRgbString(rgb); lblHsl.Text = colorcd.getHslString(rgb); lblHsv.Text = colorcd.getHsvString(rgb); lblCmyk.Text = colorcd.getCmykString(rgb); lblLab.Text = colorcd.getLabString(rgb); lblMunsell.Text = colorcd.getMunsellString(rgb); lblPccs.Text = colorcd.getPCCSTone(rgb); lblJis.Text = JisUtil.getJisByMunsell(lblMunsell.Text); } else { btnColor.BackgroundColor = Xamarin.Forms.Color.White; lblSelected.Text = string.Empty; lblHex.Text = string.Empty; lblRgb.Text = string.Empty; lblHsl.Text = string.Empty; lblHsv.Text = string.Empty; lblCmyk.Text = string.Empty; lblLab.Text = string.Empty; lblMunsell.Text = string.Empty; lblPccs.Text = string.Empty; lblJis.Text = string.Empty; } // カンバス更新 canvasView.InvalidateSurface(); }