Results 1 to 6 of 6

Thread: How to rotate a form in c#, or maybe just the controlls?

  1. #1
    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!

  2. #2
    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.

  3. #3
    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.

  4. #4
    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

  5. #5
    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.

  6. #6
    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.

Similar Threads

  1. Replies: 5
    Last Post: 25-05-2011, 10:21 PM
  2. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  3. Super Meat Boy Keyboard Controlls are unresponsive
    By Mohegan in forum Video Games
    Replies: 4
    Last Post: 04-12-2010, 07:33 AM
  4. How to Auto Populate fields from sub form to form?
    By mich43 in forum Windows Software
    Replies: 6
    Last Post: 09-11-2010, 11:29 PM
  5. Problem reloading MDI child form in main form.
    By AFFAN in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,049,583.65215 seconds with 16 queries