private void CreateForm( Rectangle rectLayer, double opacity = .5D, bool progressBar = false, Cursor customCursor = null) { _form = new Form { Size = rectLayer.Size, Location = rectLayer.Location, Opacity = opacity, ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.None, BackColor = Color.Black, StartPosition = FormStartPosition.Manual, UseWaitCursor = customCursor == null }; if (customCursor != null) { _form.Cursor = customCursor; } int wh = Math.Min(rectLayer.Width / 2, rectLayer.Height / 2); _circle = new LoadingCircle { Size = new Size(wh, wh), Location = new Point(rectLayer.Width / 2 - wh / 2, rectLayer.Height / 2 - wh / 2) }; if (progressBar) { _progressBar = new XProgressBar { Size = new Size(_circle.Width, 50), Location = new Point(_circle.Left, _circle.Bottom + 20), Min = 0, Max = 100 }; _circle.Top -= _progressBar.Height + 20; } _form.Controls.AddRange(new Control[] { _circle, _progressBar }); }