void pnListColor_Paint(object sender, PaintEventArgs e) { if (currentDrawing == DRAWING.NONE) { } else if (currentDrawing == DRAWING.LIST_VW_COLORS) { #region pnListColor.AutoScroll = true; pnListColor.CreateGraphics().SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Graphics g = e.Graphics; int x = 0, y = 0; int widthEachColor = 30; List <Color> colorVisualWord = ColorHelper.GenerateColorVisualWord_Rgb(); for (int i = 0; i < colorVisualWord.Count; i++) { DrawDot(g, new Dot_RGB(new Point(x + widthEachColor / 2, y + widthEachColor / 2), widthEachColor / 2, colorVisualWord[i])); x += widthEachColor + 10; // go to new row if (x + widthEachColor + 10 > pnListColor.Width - widthEachColor / 2) { x = 0; y += widthEachColor + 20; } } #endregion } else if (currentDrawing == DRAWING.LIST_VW_COLORS_RGB_SORTED) { #region // Input: rgb color // Output: draw input color, draw visualize color in distance order des, distance below the color Color inputColor = Color.FromArgb(int.Parse(txtR.Text.Trim()), int.Parse(txtG.Text.Trim()), int.Parse(txtB.Text.Trim())); List <Color> listVWColorRgb = ColorHelper.GenerateColorVisualWord_Rgb(); List <double> listDistance = new List <double>(); foreach (Color colorVWRgb in listVWColorRgb) { listDistance.Add(DistanceHelper.CalDistance_RGBEuclid(Color.FromArgb((int)inputColor.R, (int)inputColor.G, (int)inputColor.B), colorVWRgb)); } List <int> listIndexSortAsc = SortingHelper.SortAsc(listDistance); DrawDot(pnVisualizse.CreateGraphics(), new Dot_RGB(new Point(50, 50), 20, Color.FromArgb(int.Parse(txtR.Text.Trim()), int.Parse(txtG.Text.Trim()), int.Parse(txtB.Text.Trim())))); int x = 0, y = 0; int widthEachColor = 30; List <Color> colorVisualWord = ColorHelper.GenerateColorVisualWord_Rgb(); foreach (int index in listIndexSortAsc) { //Console.WriteLine(listDistance[index]); Graphics g = e.Graphics; //g.Clear(Color.Green); DrawDot(g, new Dot_RGB(new Point(x + widthEachColor / 2, y + widthEachColor / 2), widthEachColor / 2, colorVisualWord[index])); g.DrawString(Math.Round(listDistance[index], 1).ToString(), new Font("Arial", 8), new SolidBrush(Color.Black), x, y + widthEachColor); x += widthEachColor + 10; // go to new row if (x + widthEachColor + 10 > pnListColor.Width - widthEachColor / 2) { x = 0; y += widthEachColor + 20; } } #endregion } else if (currentDrawing == DRAWING.LIST_VW_COLORS_LAB_SORTED) { #region // Input: rgb color // Output: draw input color, draw visualize color in distance order des, distance below the color Lab inputColor = ColorHelper.RgbToLab(new Rgb { R = double.Parse(txtR.Text.Trim()), G = double.Parse(txtG.Text.Trim()), B = double.Parse(txtB.Text.Trim()) }); List <Lab> listVWColorLab = ColorHelper.GenerateColorVisualWord_Lab(); List <double> listDistance = new List <double>(); if (currentDeltaE == DELTA_E.CIE76) { calDistanceHander = DistanceHelper.CalDistance_CIE76; } else if (currentDeltaE == DELTA_E.CMCIC) { calDistanceHander = DistanceHelper.CalDistance_CMCIC; } else if (currentDeltaE == DELTA_E.CIE94) { calDistanceHander = DistanceHelper.CalDistance_CIE94; } else if (currentDeltaE == DELTA_E.CIE2000) { calDistanceHander = DistanceHelper.CalDistance_CIE2000; } foreach (Lab colorVWLab in listVWColorLab) { listDistance.Add(calDistanceHander(inputColor, colorVWLab)); } List <int> listIndexSortAsc = SortingHelper.SortAsc(listDistance); DrawDot(pnVisualizse.CreateGraphics(), new Dot_RGB(new Point(50, 50), 20, Color.FromArgb(int.Parse(txtR.Text.Trim()), int.Parse(txtG.Text.Trim()), int.Parse(txtB.Text.Trim())))); int x = 0, y = 0; int widthEachColor = 30; List <Color> colorVisualWord = ColorHelper.GenerateColorVisualWord_Rgb(); foreach (int index in listIndexSortAsc) { //Console.WriteLine(listDistance[index]); Graphics g = e.Graphics; //g.Clear(Color.Green); DrawDot(g, new Dot_RGB(new Point(x + widthEachColor / 2, y + widthEachColor / 2), widthEachColor / 2, colorVisualWord[index])); g.DrawString(Math.Round(listDistance[index], 1).ToString(), new Font("Arial", 8), new SolidBrush(Color.Black), x, y + widthEachColor); x += widthEachColor + 10; // go to new row if (x + widthEachColor + 10 > pnListColor.Width - widthEachColor / 2) { x = 0; y += widthEachColor + 20; } } #endregion } }