I thought I’d share a little snippet on displaying forms in .NET that allow a window/form to dynamically resize, without encountering GUI lockups (due to thread delays), and without having to know the original form dimensions. It’s relatively simple.
First you can define the intended size variables, and also create instances of the Clock class.
public partial class Form1 : Form
{// Define the intended height and width
int INTENDED_WIDTH;
int INTENDED_HEIGHT;// Create two clock instances.
Timer Clock1;
Timer Clock2;
Then comes the constructor for this form. In my case (and the default of C# .NET projects) is the Form1 constructor.
public Form1()
{
InitializeComponent();// Define intended dimensions
INTENDED_HEIGHT = this.Height;
INTENDED_WIDTH = this.Width;// Reset current dimensions
this.Width = 0;
this.Height = 0;// Initialize the clocks
Clock1 = new Timer();
Clock1.Interval = 1;
Clock1.Start();
Clock1.Tick += new EventHandler(IncreaseWidth);Clock2 = new Timer();
Clock2.Interval = 1;
Clock2.Start();
Clock2.Tick += new EventHandler(IncreaseHeight);}
Now it’s just a matter of incrementing the width and height on each tick of the previously defined clocks. This is defined within the event handlers for those clocks.
private void IncreaseWidth(object sender, EventArgs eArgs)
{
if (this.Width != INTENDED_WIDTH)
{
this.Width += 1;
}
else { Clock1.stop(); }
}private void IncreaseHeight(object sender, EventArgs eArgs)
{
if (this.Height != INTENDED_HEIGHT)
{
this.Height += 1;
}
else { Clock2.stop(); }
}
That concludes my first informative C# / .NET post.


If everything is working correctly, you should now be able to view your repository in a web browser. Go ahead and browse to https://youmachinename:8443/svn/ (or https://127.0.0.1:8443/svn/, if you prefer) and you should see all the available repositories listed.
