Irregular Polygon - wpf

Take a look at the attached pic, I need to mimic the grey irregular polygon header at the top of the form. If it wasn't for the angled portion on the right-hand side, it would be straightforward. What is the best method to create it? Can this be created in XAML? Should I use an image? Any pointers are greatly appreciated.

This can easily be done via the standard drawing capabilities in XAML. See Shapes and Basic Drawing for details on making custom shapes.

Related

Complex Shape Generation Issue

How can I achieve XAML design for following image? I have main issue with curve that have applied to white fill area. I want to achieve that curve in WPF. I want to generate shape that contains "Group" text.

How to render a VisualElement to a Vector Based Image?

I am working on a Chart Control,
I need to implement the Chart Snapshot feature for capturing a vector based image in high quality of Curves and Texts, in any requested size.
Can anyone suggest me any solution or a pointer to resolve this problem.
Any kind of help in deeply appreciated.
If you have to save your image in a vector format you can using tracing. Potrace is an open source bitmap-to-vector tracer library (but considers that bitmap tracing is imperfect). Also considers that wpf is linked closely with XAML, a vector graphics markup languages, so you may want convert raster graphics to XAML (though Charles Petzold you can't embed a bitmap in a XAML file)
If you need to draw a vector image you can use the Shape element that provides a base class for shape elements, such as Ellipse, Polygon, and Rectangle; and add the shape as Panel child. If you are dealing with thousands of shape I suggest to use the DrawingVisual class, a visual object that can be used to render vector graphics on the screen, and its RenderOpen method.
To zoom you have to work with transformations, in particular ScaleTrasnform and apply the transformation to your panel or to your shapes.
Hope this help.
You can take a look at XamlToy but I have not already try it.
http://xamltoys.codeplex.com/

Rectangular shaped Gradient Fill

I'm currently looking to achieve a gradient effect a bit like the rectangle in http://pjnicholson.com/Fireworks/fillgradients.htm
If I compromise a little I can get close to this using RadialGradientBrush... but is there any (not too painful) way to achieve the rectangular effect?
Use an ImageBrush instead and use this image (or a similar image generated using some image editor) for the background of your rectangle.
One solution a colleague and I came with was to derive a new Panel that used a WriteableBitmap as the source for its background.
The panel will give you the dimensions you need to make your WriteableBitmap. Using whatever algorithm you want you can fill it appropriately. In our case, we needed a radial or cone gradient, but the same concept applies.
Additionally, you can create several properties on your new control to specify the colors for the gradient. We adapted a LinearGradientBrush for our needs, but if you're working on just two colors, simple properties may suffice.
I don't have the code handy but will try to find it and post an update later. But the above should get you going.

How to build the following visual

I am not a real designer and I would like to know if anyone have an idea how can I build the following visual :
The idea is to get 2 rings where inside I will draw secific number of pie represented as "Interactive shape or button". Base on the number of shape, they should cover the whole circle.
In addition to that, I need to be able to interact with each pie shape, and inside and oustide edge of those shape should be a perfect arc based on the circle diameter.
As I am not a perfect designer, how can I represent this visual ?
I was thinking of using a custom panel but then how to draw each panel shape in order that they gets perfect inside and ouside arc and offer interactivity with each of them ?
Thanks for your help
I would appreciate samples as well
Theres actually a Silverlight tutorial on making something exactly like this.
If you didnt want to use that, you could always do it in javascript. Here's an example using Rapheal js
I would recommend looking into WPF Geometry and how you can create custom controls (such as the Circular Gauge Custom Control over on CodeProject) using said Geometry.
I've never created a control quite like what your suggesting, but I would image you would define some form of area that can contain children and style it so that it forms the circular shape you want. Then, adding interactive regions should be as simple as adding controls to standard containers.
Here's a link to a "generic radial panel that can be used to host any items" which subclasses Panel.

How to draw a Bezier curve programmatically in WPF?

I need to write a simple WPF program to draw a Bezier curve, but I have to draw it programmatically since I need to allow user to modify the shape interactively.
Any code sample to do this task is highly appreciated!
Thanks,
Mike
Have a look at the Path Markup Syntax to get a feel for the raw drawing primitives available to you in WPF.
You could use either cubic or quadratic Bezier curves (each has a smoothed version too) depending on how you want to define the control points.
As for rendering the control points on screen and allowing the user to drag them about you might like to look into adorners and possibly the Thumb class.

Resources