/// <summary> /// Change the value of the new color and replace the image if auto mode is on. /// </summary> private void UpdateNewColor() { if (m_trackbarsAutoUpdating) { return; } // Generate the color depending of the color mode. Color c = m_rgbMode ? Color.FromArgb(tbRed.Value, tbGreen.Value, tbBlue.Value) : Colorer.FromAhsb(255, tbHue.Value, tbSaturation.Value / 100f, tbBrightness.Value / 100f); cdNewColor.Color = c; pnlNewColor.BackColor = c; if (cbAutoMode.Checked) { if (m_rgbMode) { ReplaceImage(ReplaceMode.RGB); } else { ReplaceImage(ReplaceMode.HSB); } } }
/// <summary> /// It replaces the image of the picture box. /// </summary> /// <param name="replaceMode">The way the image must be changed.</param> private void ReplaceImage(ReplaceMode replaceMode) { Color notToChangeC = cbSpriteMode.Checked ? pnlSpriteMode.BackColor : Color.Empty; if (replaceMode == ReplaceMode.HSB) { pbImage.Image = Colorer.ReplaceColor((Image)m_currentSettings[0], pnlOldColor.BackColor, tbTolerance.Value, tbHue.Value, tbSaturation.Value / 100f, tbBrightness.Value / 100f, new List <Color>() { notToChangeC }); } else if (replaceMode == ReplaceMode.RGB) { pbImage.Image = Colorer.ReplaceColor((Image)m_currentSettings[0], pnlOldColor.BackColor, pnlNewColor.BackColor, tbTolerance.Value, new List <Color>() { notToChangeC }, cbAutoMode.Checked); } else { pbImage.Image = m_baseImage; } // Change the old panel color so the good color is always edited. if (!cbAutoMode.Checked) { cdOldColor.Color = pnlNewColor.BackColor; pnlOldColor.BackColor = cdOldColor.Color; } }