Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I'm new to WPF. Well I need to draw an ellipse over an image based on its X,Y values(on image mouse move). Somehow I have managed to draw ellipse using DrawGeometry() over the image. Now I have to animate that ellipse(like blinking or LED kind of). I'm not able to do that. I have created animated ellipse(storyboard) using Blend but I don't know how to use that on this scenario. Please some body help me. I don't have much time to wait. Because in few days I have to deliver this project.

Here I have attached the code below. Please let me know if any changes has to be done on this code. For time being I'm using Timer for animation but this is not a good approach.

Thanks.

C#
BitmapImage bmImage = new BitmapImage(new Uri(currentImagePath));
                DrawingVisual drawingVisual = new DrawingVisual();
                DrawingContext drawingContext = drawingVisual.RenderOpen();
                drawingContext.DrawImage(img.Source, new Rect(0, 0, bmImage.Width, bmImage.Height));
                SolidColorBrush myBrush = new SolidColorBrush(Colors.Red);
                Pen pen = new Pen(myBrush, 5.0);
                EllipseGeometry el = new EllipseGeometry(new Point(x, y + 5), 38, 38);
                drawingContext.DrawGeometry(null, pen, el);
               RenderTargetBitmap renderBmap = new RenderTargetBitmap(bmImage.PixelWidth, bmImage.PixelHeight, 96, 96, PixelFormats.Pbgra32);
                renderBmap.Render(drawingVisual);
                img.Source = renderBmap;
Posted
Updated 20-Nov-10 5:51am
v2
Comments
Tarun.K.S 20-Nov-10 13:21pm    
How about using Style.Triggers?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900