A control for Picture Viewing - winforms

I need a control for a WinForms application to implement PICTURE VIEWING. The control has to:
- understand multiple image formats;
- to perform Zoom;
- to perform Scrolling when the image is too large to fit to the control area;
- to perform Rotate of the picture (90 degrees to the left and to the right)
The standard Forms.PictureBox, I see, cannot do Scrolling, Zoom and Rotate.
What else can I use?

For rotate you can use:
pb.Image.RotateFlip(....)
For stretching or fit you can use:
pb.SizeMode
Implementing other functions is not so difficult...

Related

How to easily change the layout of the screen from Portrait to Landscape and vice versa in WPF

Let's suppose we have the designed the layout of some WPF application to be used on standard Full HD screen 1920x1080. Then we need to rotate the screen and install it in a box that is mounted on kiosk PC but in Portrait orientation.
I need to find a way on how to rotate the screen easily or at least in some more elegant way.
I tried to use use RenderTransform and RotateTransform applied to the contents of the window but this rotates the image and of course not the layout.
The controls remain of the same width and height.
Is there a way to do it automatically or should I take each control and change it properties one by one ?
The problem is present for TextBlocks and TextBoxes. They are intended to be used horizontally. You can rotate it but the layout is calculated based to it's horizontal width.
BTW. Rotation of the entire window is not allowed. It throws an exception.
It looks like that I have found the solution myself. If we choose the Layout transform instead of RenderTransform then the visual system does the arrangement and measurement of the layout automatically before the rendering.
The WPF framework does the job in this order
LayoutTransform
Measure
Arrange
RenderTransform
Render
This is best described here LAYOUTTRANSFORM VS. RENDERTRANSFORM - WHAT'S THE DIFFERENCE?

two questions about rectangle and canvas in silverlight 4

I have a rectangle on canvas. I can already moving this object using with mouse, but I can't find how can I resize it in runtime using mouse too?
And second question, how can I programatically check positions of each objects (e.g rectangles) on the canvas?
Most people use a Thumb. This is an msdn article that shows you how to use a thumb to resize a canvas. The same principles can be applied to your rectangle.
Re-sizing a rectangle using the mouse can be pretty involved. Basically you can listen for mouse-down, mouse-up, and mouse-move events which would allow you to adjust the width and height of it programmatically.
To move a rectangle within the canvas, try the following concept:
double x = Canvas.GetLeft(this.myRectangle);
x += 100;
Canvas.SetLeft(this.myRectangle, x);

How to display texts and shapes with same width height at any zoom in Silverlight deep zoom applications?

In my Silverlight application I display texts (textblock on canvas) as well as rectangles and lines (again shapes drawn on the canvas) over deep zoom images. I handle zoom in / out, pan and tilts. What is not realy cool in my opinion, is the way my vector objects look at different zoom factors. Of cause they become bigger or smaller.
Would you have any suggestions how to keep some of the objects dimentions look the same at any zoom? let's say, a line with StrokeThickness will always be of 10 screen pixels. or text block width, height 100 screen pix by 300 screen pix.
Thanks,
Val
It depends on how/where your objects are defined that you want to remain at 1:1 scale.
The 2 options I can think of are:
Render those objects in a canvas above the deep zoom (this means you need to work out the positions again yourself).
Apply reciprocal scaling to those objects (which means you work out what scale the item is going to display at and apply a 1/x scaling factor to them. That way the deep zoom shrinks an object that is scaled up to compensate and the 2 cancel out).
Hope this helps.

Scaling two Windows Forms controls while keeping the same ratio

I have 2 controls in a resize-able panel (1 datagridview and 1 textbox) with some space betwen and I need them both to scale in all directions with the panel. Problem is, since they're vertically stacked they run into each other when the panel scales vertically. I think I need some way to scale vertically while keeping the same ratio of the total panel size (ie, if the panel is scaled 2x, each control is scaled 2x) instead of anchoring them to all sides. Using C# if that matters, but I'm hoping for a non-programmatic solution.
A TableLayoutPanel was designed to provide this kind of scaling support. You'll need three rows with the middle one Absolute and the top and bottom Percent. Dock fill the controls in the rows, the rest is automatic.

Converting equations of motion to pixels for display on Silverlight canvas

Can anyone point me in the direction of some information to understand this. I have a Canvas that displays an ellipse. I can move the ellipse around using the keyboard but I want to simulate a "jump", so I thought I'd use Newtons equations of motion to move the ellipse up and then down when the user presses the up arrow. All these equations are defined in metres where as the TranslateTransform on the UserControl is in pixels.
Can I get the resolution in SL to convert from metres to pixels?
Not really, no. Silverlight doesn't understand pixels.
There are 96 units in an inch (no matter the dpi of the display). That suggests there are 3779.5 silverlight units in a metre. I'd think about applying a ScaleTransform to any area you're displaying so you can give Silverlight metres and get the right visuals out if that matters to you.

Resources