protected void Grow(MethodInvoker afterwards) { Program.AssertOnEventThread(); if (shrunk) { shrunk = false; //First, clear all the anchors. Unanchor(); //Next, grow the window BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(delegate(object o, DoWorkEventArgs e) { int expectedHeight = ClientSize.Height + dx; while (ClientSize.Height < expectedHeight) { Program.Invoke(this, delegate() { ClientSize = new Size(ClientSize.Width, (int)(((2.0 * ClientSize.Height) / 3.0) + (expectedHeight / 3.0) + 1.0)); }); Thread.Sleep(50); } }); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate(object o, RunWorkerCompletedEventArgs e) { Program.Invoke(this, delegate() { MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height + dx); //and put the anchors back Reanchor(); //Finnally, show the progress bar and label ClearAction(); ActionStatusLabel.Show(); ActionProgressBar.Show(); ProgressSeparator.Show(); afterwards(); }); }); worker.RunWorkerAsync(); } else { afterwards(); } }
protected void Shrink() { Program.AssertOnEventThread(); if (!shrunk) { shrunk = true; //First, clear all the anchors. Unanchor(); //Next, hide the progress bar and label ClearAction(); ActionStatusLabel.Hide(); ActionProgressBar.Hide(); ProgressSeparator.Hide(); //Finnally, shrink the window and put the anchors back MinimumSize = new Size(MinimumSize.Width, MinimumSize.Height - dx); ClientSize = new Size(ClientSize.Width, ClientSize.Height - dx); Reanchor(); } }