Rank: Member
Groups: Guest
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.
|
|
|
|
Rank: Advanced Member
Groups: Guest
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 |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 5/11/2007(UTC) Posts: 2
|
That worked great. Thanks for your help.
|
|
|
|
Rank: Newbie
Groups: Guest
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.
|
|
|
|
Rank: Advanced Member
Groups: Guest
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.
|
|
|
|
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.