Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-01-2009
Member
 
Join Date: Apr 2007
Posts: 6
Exclamation How to rotate a form in c#, or maybe just the controlls?

Hi,

I have a problem. I have a form in c#, with buttons, controlls, textBoxes and others, which I need to rotate 90 degrees. Is this posible in c#?
Can the form be rotated and with it, it's all content, or maybe just the content to be rotated? Buttons, textboxes, checkboxes, labels, can be rotated?
Or maybe this is posible in WPF?

Any ideas?

Thanks!
Reply With Quote
  #2  
Old 13-01-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: How to rotate a form in c#, or maybe just the controlls?

You can rotate the picture box control by using the following properties.

* Public Property ShowThrough() As Boolean
* Public Property Direction() As DirectionEnum
* Public Property Rotation() As Integer
* Public Property TransparentColor() As Color


ShowThrough will determine whether or not space not used by the image will be transparent and show the control below it. This is accomplished using regions.

Direction as you notice is declared as DirectionEnum. This enumeration was created for the control. It tells the control which way to rotate the image: Clockwise, or Counter_Clockwise.

Rotation
is the angle of rotation of the image. It is in degrees. The range is 0 to 359; however, inputting a number outside of the range will scale it to the appropriate angle that is in the range.

TransparentColor will allow you to set a transparent color for the image. The demo project has an image included with a Lime background. If the TransparentColor property is set to Lime - that color in the image will be painted transparent. Unfortunately, it doesn't show the controls below it through, just the parent's background color.
Reply With Quote
  #3  
Old 13-01-2009
Member
 
Join Date: Feb 2008
Posts: 194
Re: How to rotate a form in c#, or maybe just the controlls?

It seems very simple, just use the Transform property of your Graphics object with a Matrix object having the appropriate Rotate method called on it.
Reply With Quote
  #4  
Old 13-01-2009
Member
 
Join Date: Mar 2008
Posts: 258
Re: How to rotate a form in c#, or maybe just the controlls?

Well, I don't know about drawing the ellipse or streching and rotating, but I made this code recently to relocate an object. It's
not perfect (the object centre jumps to the mouse position), but it works.

Call this on the MouseMove event of your object:

Code:
if (MouseButtons == MouseButtons.Left)
{
mousePoint = /*Your Form/Groupbox Goes
Here*/.PointToClient(new Point(MousePosition.X - /*Your Control Goes
here*/.Size.Width / 2, MousePosition.Y - /*Your Control Goes
here*/.Size.Height / 2));
/*Your Control Goes here*/.Location = mousePoint;
}

You could fix the above mentioned 'jump to mouse' by recording two offset values on MouseDown, and adding them to the declaration of mousePoint, replacing the (yourControl.Size.Width / 2) and (yourControl.Size.Height /2).

On MouseDown ()
{
xOffset = MousePosition.X - /*Your Control Goes
here*/.Location.X;
yOffset = MousePosition.Y - /*Your Control Goes
here*/.Location.Y;
}
Hope this Helps
Reply With Quote
  #5  
Old 13-01-2009
Member
 
Join Date: Apr 2007
Posts: 6
Re: How to rotate a form in c#, or maybe just the controlls?

Here's the scenario. I have a form, a menu, that is displayed on a regular screen (4:3), but I need to display it on a 16:9 screen, not horizontaly, but rotated 90 degrees, like the screen will be.
Screen rotation, from the display driver/application is not an option.
This is my problem.
Reply With Quote
  #6  
Old 13-01-2009
Member
 
Join Date: Mar 2008
Posts: 192
Re: How to rotate a form in c#, or maybe just the controlls?

To adjust your screen in C# you have to measure the angles properly while inserting that into your program, it not complicated but if you are newbie to this you just refer to any C# advance book where you will get How to do that but still after that you itself have to implement that in your program and this is little bit lengthy to explain you that problem here.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to rotate a form in c#, or maybe just the controlls?"
Thread Thread Starter Forum Replies Last Post
Google Chrome is opening in basic HTML form instead of the Standard form Beatrix Technology & Internet 5 25-05-2011 10:21 PM
how to get items in a form to auto-resize with the form using visual basic deansmylie93 Software Development 2 02-05-2011 07:06 AM
Super Meat Boy Keyboard Controlls are unresponsive Mohegan Video Games 4 04-12-2010 07:33 AM
How to Auto Populate fields from sub form to form? mich43 Windows Software 6 09-11-2010 11:29 PM
Problem reloading MDI child form in main form. AFFAN Software Development 3 30-01-2009 09:05 PM


All times are GMT +5.5. The time now is 09:31 AM.