Forums

Welcome Guest Search | Active Topics | Members

Minimum size for RectangleRubberband Options
jimox
Posted: Friday, May 11, 2007 10:32:26 AM
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.
Alex Kon
Posted: Saturday, May 12, 2007 9:29:02 PM
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.
jimox
Posted: Monday, May 14, 2007 8:45:31 AM
Rank: Member
Groups: Member

Joined: 5/11/2007
Posts: 2
Points: 0
That worked great. Thanks for your help.
PowerWare
Posted: Tuesday, April 08, 2008 1:21:52 PM
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.
Sergey Peshekhonov
Posted: Friday, April 11, 2008 9:50:03 PM
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.
Users browsing this topic
Guest


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.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.