   [.net] C# - WinForm expand top and right
  HiThis is not strictly a games related question but I was hoping you would be kind enough to point me in the right direction with a problem that has been annoying me for a while now.I have a C# (.NET 2.0) Win forms application that starts out anchored to the taskbar (either just above, just below or to one side depending on where it is docked. Typically with the taskar being docked to the bottom of the screen my application starts just above the clock on the right hand side of the tray. This application is not a full screen application, its more of an MSN Messenger sized app)What I want the application to do is to be able to be resized upwards or to the right when an expandable panel is clicked. I already have these panels in place but as you can imagine if I just resize the main applications form with something like...this.Size = new Size(this.Width + 20, this.Height + 20);the application expands downwards and to the left, rather than upwards and to the right.If I capture the forms resize event and calculate how much the app has grown or shrunk and automatically move the forms location I can get the app to stay on screen but as you can imagine this gives a very juddery performance as the app is resizing down for instance while its location is being moved up.Does anyone know of a method of smoothly resizing an application upwards (I can smoothly resize downwards currently) and to the right (I'm trying to make the application smoothly animate the resize rather then just be resized)?Thanks in advance for any help.P.S. If you need me to clarify anything let me know.Crude diagramsE.g.| - Rest of desktop* - My app- - TaskbarStarting pos||||||||||**||**----Current behaviour (If I set the app to have a larger size)||||||||||**||**--**What I want to happen||||||**||**||**----   
  WindowWidth += desiredExpansionSize.X;WindowPos.X -= desiredExpansionSize.X/2;WindowHeight += desiredExpansionSize.Y;WindowPos.Y -= desiredExpansionSize.Y/2;Conceptually, does that not work?   ;  If you want to "animate" this action... you could do something like this:(I threw this together in a matter of a couple of minutes, and could use some work, but I think you'll get the idea)private void MoveFormUp(){Screen curScreen = Screen.FromControl(this);int y = curScreen.WorkingArea.Height - this.Height;while(this.Location.Y > y){this.Location = new Point(this.Location.X, this.Location.Y - 2);}}You'll need to obviously add some error checking, and you can play with the value that you decrement by to speed up or slow down the animation.Your best bet is to have the form resize, and then animate to the new location, rather than have both happen (or be animated) at the same time.   ;Quote:Original post by return0WindowWidth += desiredExpansionSize.X;WindowPos.X -= desiredExpansionSize.X/2;WindowHeight += desiredExpansionSize.Y;WindowPos.Y -= desiredExpansionSize.Y/2;Conceptually, does that not work?I have tried something similar to this and that's what produces the judder affect as the app moves up as the same time as expanding down.jhunt1 - I'll give that a time and report back. Thanks for the suggestion.   ;Quote:Original post by jhunt1...private void MoveFormUp(){Screen curScreen = Screen.FromControl(this);int y = curScreen.WorkingArea.Height - this.Height;while(this.Location.Y > y){this.Location = new Point(this.Location.X, this.Location.Y - 2);}}You'll need to obviously add some error checking, and you can play with the value that you decrement by to speed up or slow down the animation.Your best bet is to have the form resize, and then animate to the new location, rather than have both happen (or be animated) at the same time.HiAfter having fiddled around with your code sample this morning, I think your right in saying that it would be easier to animate the resize then animate the movement of the app into a new position (if a new position is needed) rather then trying to do both actions at the same time.Many thanks for everybody’s help and apologies for taking so long to reply.