add zoom and scroll capability with code behind to SCICHART - wpf

Hi I want to add zoom and scroll with code behind to SCICHART
is this possible?
I tried xaml but It did not work. My manager wants it with code behind.

Yes this should be easy, for each modifier in SciChart WPF, you can add it in code behind like this:
var sciChartSurface = new SciChartSurface();
sciChartSurface.XAxis = new NumeriAxis();
sciChartSurface.YAxis = new NumeriAxis();
sciChartSurface.ChartModifiers.Add(new ZoomPanModifier());
sciChartSurface.ChartModifiers.Add(new MouseWheelZoomModifier());
sciChartSurface.ChartModifiers.Add(new ZoomExtentsModifier());
See a full list of the modifiers available in SciChart WPF here

Related

Customize slider

I need to customize the appearance of the slider in order to use it in touchscreen mode. The slider's thumb needs to be 60 - 80 px high.
From all the suggestions around I understand that I will have to modify the slider's control template.
What I was wondering: where can I get the slider's control template? I want the slider to look the same as it does originally, just with a bigger thumb.
In Expression blend you can edit a copy of the original template , it's a good place to start for all control template modifications.
or you can search for the original template on the web :
Slider Tempalte and Style
You don't need Blend to edit a Template.
Right click your slider in VS Designer Edit Template -> Edit a copy..., go ahead and play with it. If you're familiar with XAML it should not take too long for you to get it right.
Just remember that WPF/WP is all about DPI independence. If you fix a Height and Width at a certain value, in some screens the control may look small/large!

how can I draw a rectangle and circle/ellipse in WPF like we do in paint by dragging mouse

I am developing a whiteboard application in WPF.
How can I draw a rectangle and circle/ellipse by dragging the mouse like we do in Paint by dragging the mouse pointer ?
I am using WPF canvas for drawing.
have a look into below link
http://www.codeproject.com/Articles/22776/WPF-DrawTools
To run WPF-DrawTools you have to:
Let the VS to convert the project.
Set appropriate NetFramework version (say, Net 4.5).
Add references to correspondent libraries (e.g., PresentationCore) if VS could not find them itself.

Is there something like Expression Design's skeleton strokes in Silverlight?

Expression design has a feature called Skeleton strokes which allows you to use arbitrary vector/bitmap as a stroke.
http://msdn.microsoft.com/en-us/library/cc294949(v=expression.30).aspx
http://msdn.microsoft.com/en-us/library/cc294775(v=expression.30).aspx
The stroke is treated as a skeleton and the brush is painted following the stroke. Using an ImageBrush in silverlight doesn't seem to have the same effect. Rather it just renders the ImageBrush as if it would render the fill but with the fill portion cut out.
BTW, I'm using Silverlight 5
Silverlight doesn't support this feature. At least not out of the box.

How to print WPF Grid paged?

I'm printing a WPF grid. As long as the data fits on one page, everything works fine. But sometimes the grid contains more data. Therefore I need to split the grid into multiple pages. Can anybody help me?
My code looks like this (visual is the grid).
var printCapabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
var size = new Size(printCapabilities.PageImageableArea.ExtentWidth,
printCapabilities.PageImageableArea.ExtentHeight);
visual.Measure(size);
visual.Arrange(new Rect(new Point(printCapabilities.PageImageableArea.OriginWidth,
printCapabilities.PageImageableArea.OriginHeight), size));
printDialog.PrintVisual(visual, "Print ListView");
Should I try another control? I've tried WPF Toolkit DataGrid, but I couldn't manage to get it printed. I've heard something of a flow document, can this help me?
Best Regards
Oliver Hanappi
It sounds like you want to use PrintDocument instead of PrintVisual. You will probably need to implement your own DocumentPaginator class to split your grid into separate printable documents, though.

Rotating a .NET panel in Windows Forms

We use Windows Forms and custom user controls, and I would like to be able to rotate the panel hosting the userControl in a particular form. I have seen similar functionnalities with WPF, but I can't use it for the moment. Is it possible to achieve the rotation of a panel and its children using possibly built-in .NET methods or GDI+?
I have seen some pretty cool visual effect with menus that are displayed in game development, so I was wondering if it would be possible to create similar effects using Windows Forms.
Rotating a panel and its children in Windows Forms is not something directly supported, and I think it will end up being a buggy headache that could easily suck up lots of time. It's especially painful to think about when you could do this in WPF with zero lines of C# code and only a tiny bit of XAML.
You can use rotations in GDI+ by calling the RotateTransform method on a Graphics object.
However, rotating an entire control is not so simple, and will depend heavily on how the control is implemented.
If it's a composite UserControl that has other controls inside of it, you're out of luck.
If it's a sinlge control that paints itself, try inheriting the control, overriding the OnPaint method, and calling RotateTransform on the Graphics object. However, you will probably have trouble with it. In particular, you will probably need to override all of the mouse events and call the base control's events with rotated coordinates.
You can get halfway there by calling the DrawToBitmap method on your panel, then rotating the bitmap and displaying it e.g. in a PictureBox:
var bitmap = new Bitmap(panel.Width, panel.Height);
panel.DrawToBitmap(bitmap, new Rectangle(Point.Empty, panel.Size));
bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
var pictureBox = new PictureBox();
pictureBox.Location = panel.Location;
pictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox.Image = bitmap;
Controls.Remove(panel);
Controls.Add(pictureBox);
Rotation angles other than 90-degree increments are also possible, if you draw the bitmap into another bitmap using GDI:
var bitmap2 = new Bitmap(bmp.Width + 75, bmp.Height + 100);
var graphics = Graphics.FromImage(bmp2);
graphics.TranslateTransform(bitmap2.Width / 2, bitmap2.Height / 2);
graphics.RotateTransform(-15f);
graphics.TranslateTransform(-bitmap.Width / 2, -bitmap.Height / 2);
graphics.DrawImageUnscaled(bitmap, Point.Empty);
graphics.Dispose();
The problem of course is that you're only displaying an image of your panel, and not the panel itself, so it's no longer possible to interact with the controls inside.
That could probably be done as well, but you would have to mess with window messages, which gets quite a bit more complicated. Depending on your needs you might also be able to get away with handling click and key events on the PictureBox, manipulating the controls in the panel, and then updating the image.

Resources