WPF Get Image inside drawing - wpf

I'm using an Image control inside a simple canvas and I allow final user to draw some line (free hand) through Line wpf object.
When user ends his draw I would be able to get the image inside the design (such as a crop image).
Any idea?

Related

How to display a background control in transparent overlapping control?

I'm building a form with two layers of controls. The bottom layer is a set of Panels with defined properties, one of which is a color different from the form background. The top layer is a set of picture boxes I'm using to display a circle. I've set the PictureBox Background to Color.Transparent, and I've offset it from the underlying Panel by one pixel to get the form to draw the underlying Panel. However, the area around the circle in the PictureBox is displaying the Form Background color, not the panel color. I don't want to draw the circle in the Panel, because I want the circles to move between Panels, and actually look like just a circle that's floating across the form independent of the Panel board underneath. Think of the effect as moving a piece on a board game (you see the peg move across the board, possibly on a diagonal not following the normal game path, then stop in a place on the game).
How can I get the PictureBox to have the underlying Form and panels show through, not just the form background color? I'm using C# Visual Studio 2010, and I'm not a terribly experienced programmer, so a code example would be helpful. An image of the form is at:
http://www.imageurlhost.com/images/salgmpcxvcz830c3flt.jpg
Found a way around the problem. I got rid of the Panels for the spaces in the game, and instead drew them as rectangles on the form's background image.

Drawing a XAML map in WPF

I'm working on a module that displays DWG files in WPF. I've managed to use CadLib library but it's working very slowly and I want to make it faster. I found out that if I convert that DWG file to SVG format and then print it to my XPS printer and rename the file to ZIP, I can get .page file which is basically a XAML file that displays the original SVG object in XAML.
I want to display this XAML code on a custom control and be able to pan / zoom it around. I tried to place this XAML code in a Canvas and it did manage to show up there, but now I'm stuck trying to pan / zoom the shape that was drawn there. Also, the mouse events are fired only when you click the actual drawing itself, and not the Canvas, which will be hard for the user to click...
Any help would be highly appreciated :)
You could try creating nested Canvases : One that holds the vectors and is moved on demand, one that is fixed and serves as the viewport. Haven't tried that, but it should be feasible...

How to do Free hand Image Cropping in WPF?

all
I m developing on Medical Image Processing software, I wont crop image on mouse event, means when we drag mouse cursor and move over the image in any shape, the selected portion of image should be cropped. and that will paste in same image. is it Possible in WPF or Silverlight?
Check out the Clip property. You can specify a path in this property that is used to clip the parent object. Set Clip on your Image control to clip the image.
For design time clipping, your best bet is to use Blend (download a trial here if you don't have it) to draw a free hand path. Right click on the path and select Path->Make Clipping Path. In the next dialog, select the image that you want to clip.
EDIT: It sounds like you want to use runtime clipping/cropping, so you will want to generate the clip path using the points gathered from the mouse events. Create a collection of these points and then generate a path from them (linear lines probably... I don't know how you would generate appropriate curves unless you wrote a complex algorithm). Set this path to the Clip property after the fact.
/EDIT
You can add a transparent layer on top of the control and add an InkCanvas.
Then allow the user to draw a stroke (freehand) and turn the stroke into a Geometry by using GetGeometry use the geometry in the Clip property of the control to be clipped.

How to draw onto a PictureBox image when control resizes?

I am using the pictureBox_Paint event to try and draw an overlay onto the image in a PictureBox.
This is working fine until I resize the PictureBox (set to use SizeMode.Zoom), when I do this the overlay graphic is drawn off position by the margin between the image and the edge of the PictureBox. I guess I need to use the ImageRectangle somehow but this is not public.
I would create a custom usercontrol instead, you would have much more control, and would not be difficult to build.

What is the best way in Silerlight to make areas of a large graphic clickable?

In a Silverlight application I have large images which have flow charts on them.
I need to handle the clicks on specific hotspots of the image where the flow chart boxes are.
Since the flow charts will always be different, the information of where the hotspots has to be dynamic, e.g. in a list of coordinates.
I've found article like this one but don't need the detail of e.g. the outline of countries but just simple rectangle and circle areas.
I've also found articles where they talk about overlaying an HTML image map over the silverlight application, but it has to be easier than this.
What is the best way to handle clicks on specific areas of an image in silverlight?
Place the Image and a Canvas in a Grid so that the Canvas overlays the Image.
Add shapes of appropriate sizes and placed as needed to the canvas. All shapes will a transparent fill and no border, hence the user only sees the Image. On the Canvas MouseDown (or Up events) use OriginalSource to determine which shape generated the click. Use the Tag property of each shape to associate it with some object that represents the flowchart element being mapped.
I found an easy way to do this without a canvas:
How to get the coordinates of an image mouse click in the event handler?

Resources