public void RGBACheck(ExtractFromString extractFromString) { if (extractFromString.colorType.Length == 3 || extractFromString.backColorType.Length == 3) { regex = new Regex(@"^rgb\((25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9]),?(25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9]),?(25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9])\)$"); if (!extractFromString.color.Equals(regex.Match(extractFromString.color).ToString()) || !extractFromString.backColor.Equals(regex.Match(extractFromString.backColor).ToString())) { flag = false; MessageBox.Show("Цвет указан неверно", "Неверный формат", MessageBoxButtons.OK); } } else if (extractFromString.colorType.Length == 4 || extractFromString.backColorType.Length == 4) { regex = new Regex(@"^rgba\((25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9]), ?(25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9]), ?(25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?|[0-9]), ?(1|0|0\.[0-9]+)\)$"); if (!extractFromString.color.Equals(regex.Match(extractFromString.color).ToString()) || !extractFromString.backColor.Equals(regex.Match(extractFromString.backColor).ToString())) { flag = false; MessageBox.Show("Цвет указан неверно", "Неверный формат", MessageBoxButtons.OK); } } else { flag = true; } }
public FigureDraw(ExtractFromString extractFromString) { this.extractFromString = extractFromString; }