|
|
Rank: Member Groups: Member
Joined: 5/11/2007 Posts: 2 Points: 0
|
Is there a way to set the minimum size of a RectangleRubberband. Any code samples would be appreciated. Thanks in advance for any help.
|
|
Rank: Advanced Member Groups: Administration
, Member
Joined: 1/31/2005 Posts: 385 Points: 400
|
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;
}
Best wishes, Alex.
|
|
Rank: Member Groups: Member
Joined: 5/11/2007 Posts: 2 Points: 0
|
That worked great. Thanks for your help.
|
|
Rank: Newbie Groups: Member
Joined: 4/8/2008 Posts: 4 Points: 12
|
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.
|
|
Rank: Advanced Member Groups: Member
Joined: 6/6/2007 Posts: 53 Points: 33
|
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.
|
|
|
Guest |