public static ProgressIndicator CreateProgressIndicator( Control parent, Action <Task <ProgressIndicator> > SubCreator) { ProgressIndicator i = new ProgressIndicator(); i.SubCreator = SubCreator; i.parent = parent; i.panelMain = new FlowLayoutPanel(); i.pbProgress = new ProgressBar(); i.lblStatus = new Label(); i.gbSubTask = new GroupBox(); i.subTaskPanel = new Panel(); i.mainProgressPanel = new Panel(); i.panelMain.SuspendLayout(); i.gbSubTask.SuspendLayout(); i.mainProgressPanel.SuspendLayout(); // // panelMain // i.panelMain.Controls.Add(i.mainProgressPanel); i.panelMain.Controls.Add(i.gbSubTask); i.panelMain.FlowDirection = FlowDirection.TopDown; i.panelMain.Location = new Point(12, 233); i.panelMain.Name = "panelMain"; i.panelMain.Size = new Size(412, 257); i.panelMain.TabIndex = 0; i.panelMain.WrapContents = false; i.panelMain.Dock = DockStyle.Fill; i.parent.SizeChanged += (sender, args) => Parent_SizeChanged(i, args); // // pbProgress // i.pbProgress.Dock = DockStyle.Top; i.pbProgress.Location = new Point(0, 0); i.pbProgress.Margin = new Padding(0); i.pbProgress.Name = "pbProgress"; i.pbProgress.Size = new Size(403, 23); i.pbProgress.Padding = new Padding(3, 3, 3, 3); i.pbProgress.TabIndex = 0; // // lblStatus // i.lblStatus.AutoSize = true; i.lblStatus.Location = new Point(3, 26); i.lblStatus.Margin = new Padding(3); i.lblStatus.Name = "lblStatus"; i.lblStatus.Size = new Size(37, 13); i.lblStatus.TabIndex = 1; i.lblStatus.Text = ""; // // gbSubTask // i.gbSubTask.Controls.Add(i.subTaskPanel); i.gbSubTask.Location = new Point(3, 55); i.gbSubTask.Name = "gbSubTask"; i.gbSubTask.Size = new Size(406, 202); i.gbSubTask.TabIndex = 2; i.gbSubTask.TabStop = false; i.gbSubTask.Text = "Sub Task"; // // subTaskPanel // i.subTaskPanel.Dock = DockStyle.Fill; i.subTaskPanel.Location = new Point(3, 16); i.subTaskPanel.Name = "subTaskPanel"; i.subTaskPanel.Size = new Size(400, 183); i.subTaskPanel.TabIndex = 0; // // mainProgressPanel // i.mainProgressPanel.Controls.Add(i.pbProgress); i.mainProgressPanel.Controls.Add(i.lblStatus); i.mainProgressPanel.Dock = DockStyle.Top; i.mainProgressPanel.Location = new Point(3, 3); i.mainProgressPanel.Name = "mainProgressPanel"; i.mainProgressPanel.Size = new Size(406, 46); i.mainProgressPanel.TabIndex = 2; i.mainProgressPanel.Margin = new Padding(3, 3, 3, 3); // // temp // i.panelMain.Parent = parent; i.panelMain.ResumeLayout(false); i.gbSubTask.ResumeLayout(false); i.mainProgressPanel.ResumeLayout(false); i.mainProgressPanel.PerformLayout(); Parent_SizeChanged(i, EventArgs.Empty); OnCreate?.Invoke(i); return(i); }
public static void RunTask(Action <IProgressIndicator> task, Control parent, Action onWait) { ProgressIndicator pi = CreateProgressIndicator(parent, SetThreadTask); RunTask(task, parent, onWait, pi); }