Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to resize rectangle?

How to resize rectangle?

Scheduled Pinned Locked Moved C#
csharptutorialvisual-studiowpfgraphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Try
    wrote on last edited by
    #1

    Hi All, I am drawing rectangle on the form. (VC#) I am able to resize the rectangle when rectangle is at zero degrees. For example, if i want to resize top right: rect.Y = mousepoint.Y; rect.Height += OriginalRect.Top - mousepoint.Y; rect.Width += mousepoint.X - OriginalRect.Right; whereas 'rect' is rectangle after resize, 'mousepoint' is mouse pointer while mouse move. But When i rotate rectangle at, say 30 degrees, I have the problem, the above code won't work. I need to change x, y, width and height. How to do it? I just want a clue. I want to make sure that i am using Visual Studio 2005. This app is NOT WPF. Thanks in advance.

    B 1 Reply Last reply
    0
    • T Try

      Hi All, I am drawing rectangle on the form. (VC#) I am able to resize the rectangle when rectangle is at zero degrees. For example, if i want to resize top right: rect.Y = mousepoint.Y; rect.Height += OriginalRect.Top - mousepoint.Y; rect.Width += mousepoint.X - OriginalRect.Right; whereas 'rect' is rectangle after resize, 'mousepoint' is mouse pointer while mouse move. But When i rotate rectangle at, say 30 degrees, I have the problem, the above code won't work. I need to change x, y, width and height. How to do it? I just want a clue. I want to make sure that i am using Visual Studio 2005. This app is NOT WPF. Thanks in advance.

      B Offline
      B Offline
      Bekjong
      wrote on last edited by
      #2

      Use the Rectangle's Inflate method.

      Standards are great! Everybody should have one!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups