Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
quacka  
#1 Posted : Thursday, August 3, 2006 5:02:32 PM(UTC)
quacka

Rank: Member

Groups: Member
Joined: 1/17/2005(UTC)
Posts: 32

I am trying to move the rubberband location to no avail. any idea how I can move it programmatically with a button?

This is what I thought it would be:
Code:
RectangleRubberband1.Rectangle.Offset(0, 5) = 5 pixels up
RectangleRubberband1.Rectangle.Offset(0, -5) =  5 pixels down
RectangleRubberband1.Rectangle.Offset(5, 0) = 5 pixels right
RectangleRubberband1.Rectangle.Offset(-5, 0) = 5 pixels left

this don't seem to work how ever.

I am also trying to zoom in and out. using
Code:
RectangleRubberband1.Rectangle = New Rectangle(RectangleRubberband1.Rectangle.X, RectangleRubberband1.Rectangle.Y, RectangleRubberband1.Rectangle.Width * 1.02, RectangleRubberband1.Rectangle.Height * 1.02)


I tried using
Code:
RectangleRubberband1.Rectangle.Inflate(5,5)

but this doesn't work for me.

What I want to know is that since I keep my rubberband to a certain ratio using:
Code:
RectangleRubberband1.Ratio = PrintRatio
RectangleRubberband1.ResizeMode = WinControls.ResizeMode.Proportional

When I click zoom out too much the proportion don't get affect any more. Anyway to stop this?

Thanks

Edited by user Wednesday, December 19, 2007 3:18:25 PM(UTC)  | Reason: Not specified

Alex Kon  
#2 Posted : Thursday, August 3, 2006 8:28:27 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Administration
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hi,

System.Drawing.Rectangle is a structure, so it is a value-type, not reference-type. By using the code like that:
Code:
RectangleRubberband1.Rectangle.Offset(0, 5)
you change the value of the returned rectangle, but this doesn't affect the RectangleRubberband1 object (setter of the RectangleRubberband.Rectangle property was not called at all). To get the effect you need, you should write something like that:
Code:
Dim rect As System.Drawing.Rectangle = RectangleRubberband1.Rectangle
rect.Offset(10, 10)
RectangleRubberband1.Rectangle = rect

Edited by user Wednesday, December 19, 2007 3:18:05 PM(UTC)  | Reason: Not specified

quacka  
#3 Posted : Friday, August 4, 2006 11:01:23 AM(UTC)
quacka

Rank: Member

Groups: Member
Joined: 1/17/2005(UTC)
Posts: 32

Thanks for that I got the offset and the inflate to work.

What I want to know is how do I make it so when I inflate and move it the rectangle don't go outside the area on bitmapviewer like when I use the mouse to move and resize it?
Alex Kon  
#4 Posted : Saturday, August 5, 2006 1:06:50 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Administration
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

You should just check rectangle size and location before every assignment to the RectangleRubberband.Rectangle property - the new rectangle value should be inside BitmapViewer.Bitmap dimensions. E.g. if X coordinate of the new rectangle value is less than zero, it should be replaced with zero value, and so on.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.