开发者

Add RubberBand on Silverlight Image Control

开发者 https://www.devze.com 2023-01-05 01:49 出处:网络
I want to have a rubberband on a silverlight image control, in order to select zones on an image and copy it.

I want to have a rubberband on a silverlight image control, in order to select zones on an image and copy it.

Thanks for your help.

(No specific version of SL required)

Guys??? Where are the experts? any ideas? remarks, anything....????开发者_开发百科


The trick to add a rubber band is to create a dynamic rectangle on your image control when a mouse click occurs such as:

private void cMain_MouseLeftButtonDown( object sender, MouseButtonEventArgs e )
{
    OriginatingPostionOnCanvas = e.GetPosition( cMain );

    RubberBandBox = new Rectangle() { Width = 1, 
                                        Height = 1, 
                                        Fill = new SolidColorBrush( Colors.Red ), 
                                        Opacity = .1 };

    RubberBandBox.SetValue( Canvas.LeftProperty, OriginatingPostionOnCanvas.X);
    RubberBandBox.SetValue( Canvas.TopProperty,  OriginatingPostionOnCanvas.Y );

    cMain.Children.Add( RubberBandBox );
}

Then one handles the mouse movements and resizes the rectangle as appropriate. I provide more detail about a process with a canvas on my blog entitled Silverlight (How To): Manipulation of Dynamic Selection Rubber Band in C#

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号