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

Notification

Icon
Error

Options
Go to last post Go to first unread
jimox  
#1 Posted : Friday, May 11, 2007 2:32:26 AM(UTC)
jimox

Rank: Member

Groups: Member
Joined: 5/11/2007(UTC)
Posts: 2

Is there a way to set the minimum size of a RectangleRubberband. Any code samples would be appreciated. Thanks in advance for any help.
Alex Kon  
#2 Posted : Saturday, May 12, 2007 1:29:02 PM(UTC)
Alex Kon

Rank: Advanced Member

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

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

Yes, of course. Here is small code snippet which illustrates the way:
Code:
private int _minWidth = 200;
private int _minHeight = 200;
private int _lastGoodX;
private int _lastGoodY;

private void InitializeRubberband(object sender, EventArgs e)
{
	_bitmapViewer.Bitmap.Load(@"E:\Pictures\TestSamples\FromWebDepartment\Aviation\0708793.jpg");
	_bitmapViewer.Rubberband = _rubberband;
	_rubberband.Rectangle = new System.Drawing.Rectangle(40, 40, _minWidth, _minHeight);

	_rubberband.RectangleChanged += new Aurigma.GraphicsMill.WinControls.RectangleEventHandler(RectangleChangedHandler);
	_rubberband.RectangleChanging += new Aurigma.GraphicsMill.WinControls.RectangleEventHandler(RectangleChangingHandler);
}

void RectangleChangingHandler(object sender, Aurigma.GraphicsMill.WinControls.RectangleEventArgs e)
{			
	if (e.ChangeMode != Aurigma.GraphicsMill.WinControls.RectangleChangeMode.Resizing)
		return;

	System.Drawing.Rectangle newRect = e.Rectangle;

	if (newRect.Width < _minWidth)
	{
		newRect.X = _lastGoodX;
		newRect.Width = _minWidth;
	}

	if (e.Rectangle.Height < _minHeight)
	{
		newRect.Y = _lastGoodY;
		newRect.Height = _minHeight;
	}

	e.Rectangle = newRect;
}

void RectangleChangedHandler(object sender, Aurigma.GraphicsMill.WinControls.RectangleEventArgs e)
{
	_lastGoodX = e.Rectangle.X;
	_lastGoodY = e.Rectangle.Y;
}

Edited by user Tuesday, December 18, 2007 3:45:26 AM(UTC)  | Reason: Not specified

jimox  
#3 Posted : Monday, May 14, 2007 12:45:31 AM(UTC)
jimox

Rank: Member

Groups: Member
Joined: 5/11/2007(UTC)
Posts: 2

That worked great. Thanks for your help.
PowerWare  
#4 Posted : Tuesday, April 8, 2008 5:21:52 AM(UTC)
PowerWare

Rank: Newbie

Groups: Member
Joined: 4/8/2008(UTC)
Posts: 4

While this would work great on a WinForm, is there a way to set a minimum crop size when using the WebControl version of the RubberBand?

I know that the same event exists, but I definately don't want to incur a postback, just to enforce a minimum size.
Sergey Peshekhonov  
#5 Posted : Friday, April 11, 2008 1:50:03 PM(UTC)
Sergey Peshekhonov

Rank: Advanced Member

Groups: Member
Joined: 6/5/2007(UTC)
Posts: 57

Hello, PowerWare.

Here is a small JavaScript snippet for AjaxControls. (if you are using obsolete WebControls the implementation will be similar).

If you will have some problems with the sample please feel free to contact us.

Code:
Sys.Application.add_load(function() {
			
	var _minWidth = 200;
	var _minHeight = 200;
	var _lastGoodX = 40;
	var _lastGoodY = 40;
	
	var rr = $find("RectangleRubberband1");
	rr.set_rectangle(new GraphicsMill.Rectangle(40, 40, _minWidth, _minHeight))
		
	function on_changing() {
	
		var r = rr.get_rectangle();
		if (r.width < _minWidth) {
			r.width = _minWidth;
			r.x = _lastGoodX;
		}
		if (r.height < _minHeight) {
			r.height = _minHeight;
			r.y = _lastGoodY;
		}
		rr.set_rectangle(r);
		
		_lastGoodX = rr.get_rectangle().x;
		_lastGoodY = rr.get_rectangle().y;
	}
		
	rr.add_rectangleChanging(on_changing);
});
Sincerely yours,
Sergey Peshekhonov.

Aurigma Technical Support Team.
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.