/// <summary> /// Заливает градиентом прямоугольник по размеру панели /// </summary> public void GetGradients() { Rectangle rectangle = new Rectangle { Width = TopPanel.Width, Height = TopPanel.Height }; if (rectangle.Width > 0 && rectangle.Height > 0) { LinearGradientBrush linGrBrush = new LinearGradientBrush( rectangle, FirstColor, SecondColor, LinearGradientMode.ForwardDiagonal); FirstColorPanel.BackColor = FirstColor; SecondColorPanel.BackColor = SecondColor; using (var graphics = TopPanel.CreateGraphics()) { graphics.FillRectangle(linGrBrush, 0, 0, TopPanel.Width, TopPanel.Height); }; } }