Hi Noah,
Thank you for contacting us.
We do not have such a control in our suite so far. We do have a feature request for image editor control which seems to be related. If you find it useful, feel free to vote for it here:
http://www.telerik.com/support/pits.aspx#/details/Issue=15947.
However, you can easily implement a custom control which can support the
Rubber Band Selection. I have made a small example of such control. Here is the code for it:
[Browsable(
true
)]
public
class
RubberBandSelectionControl : RadControl
{
private
RubberBandSelectionElement rubberBandSelectionElement;
protected
override
void
CreateChildItems(RadElement parent)
{
this
.rubberBandSelectionElement =
new
RubberBandSelectionElement();
parent.Children.Add(
this
.rubberBandSelectionElement);
}
protected
override
Size DefaultSize
{
get
{
return
new
Size(200, 300);
}
}
}
public
class
RubberBandSelectionElement : LightVisualElement
{
private
bool
isMouseDown;
private
Point startingPoint;
private
Point currentPoint;
protected
override
void
OnMouseDown(MouseEventArgs e)
{
base
.OnMouseDown(e);
if
(e.Button == MouseButtons.Left)
{
this
.isMouseDown =
true
;
this
.startingPoint = Control.MousePosition;
}
}
protected
override
void
OnMouseUp(MouseEventArgs e)
{
base
.OnMouseUp(e);
this
.isMouseDown =
false
;
this
.currentPoint = Point.Empty;
}
protected
override
void
OnMouseMove(MouseEventArgs e)
{
base
.OnMouseMove(e);
if
(
this
.isMouseDown)
{
if
(
this
.currentPoint != Point.Empty)
{
this
.DrawRectangle(
this
.startingPoint,
this
.currentPoint);
}
this
.currentPoint = Control.MousePosition;
this
.DrawRectangle(
this
.startingPoint,
this
.currentPoint);
}
}
private
void
DrawRectangle(Point startingPoint, Point endingPoint)
{
Rectangle rect =
new
Rectangle();
if
(startingPoint.X < endingPoint.X)
{
rect.X = startingPoint.X;
rect.Width = endingPoint.X - startingPoint.X;
}
else
{
rect.X = endingPoint.X;
rect.Width = startingPoint.X - endingPoint.X;
}
if
(startingPoint.Y < endingPoint.Y)
{
rect.Y = startingPoint.Y;
rect.Height = endingPoint.Y - startingPoint.Y;
}
else
{
rect.Y = endingPoint.Y;
rect.Height = startingPoint.Y - endingPoint.Y;
}
ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed);
}
}
You can drag it on a form, setup its BackgroudImage property and start making rectangles.
I hope this helps.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application.
Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>