stretch only certain part in the image when resize - c#

I'm starting to build a GUI app in C# (.NET 4.0), and find it a little hard to design the graphics.
I want to have one image background to all panels, and resize it automatically so it fit the panel dimensions.
If the image would just stretched normally, then it won't look good since the background image is built in a way of header, frame, center.
So what I want is actually to define the left, top, right, bottom anchors of the rectangle in the image that I want to be stretched.
I thought about overriding PictureBox::OnPaint and continue from there, but it feels too manual for something that suppose to be pretty simple in GUI developments.
So what is the best approach for resizing only the relevant part of the background image?

Related

Darkened User Resizable Area C# WPF .NET-Core

I'm trying to make a simple WPF application where you will be able to crop a video quickly and simply. I want it to look like and operate like how this website does it: https://clideo.com/crop-video
It darkens the video outside of the boundaries and has the rule of thirds guidelines. It can also be freely resized to any aspect ratio. Having the "grab" squares on the corners and sides would be nice but i am not too fussed about that :)
I've had a search already and came across this: http://csharphelper.com/blog/2014/12/let-user-move-resize-rectangle-wpf-c/
It operates great but if you look at the code it doesn't work very nicely and will be messy to implement the dark background I think, it is also from 2014 and there is probably a better way to do this in WPF nowadays. The only way I can think of doing the dark background is to have 4 dark rectangles on the top, right, bottom and left, resizing when you resize the crop area. There is most likely a better way to do this, hence why I am here.
In summary, I'm very new to WPF, not sure where to start, looking for some pointers :)

C# proper image alpha layer when form is invisible

I'm looking for a way to have images on invisible form that allow alpha transparency and allow to place and use buttons/labels etc.
I've tried this Transparent background on winforms?, layered window and many more, nothing fully successful. I've ended up with such failures http://imgur.com/a/t6nmF
Transparency key only makes one color transparent, which doesn't work on images that have smooth color gradients on the edges.
First of all, are you certain that your image has a transparent background?
Layered window is exactly what you should use to achieve the desired effect. Since you don't give much details, I don't know what's wrong with your implementation. Try to use the PerPixelAlphaForm from the following article: Per Pixel Alpha Blend in C#. When used correctly, it will work (even though the article is really old).

Drawing a lot of lines and other shapes in WinRT App

In my WinRT app I need to draw about 3000 objects on a canvas, where I can translate and zoom the view. Unfortunatley, after adding about 1500 lines to my canvas my Windows 8 App always crashes. What could be the best practice to achieve this?
One solution could be rendering everything on an image (how do I do this?). But then I loose comfort of easy access and editing of every element.
Also my scale and translate is very slow. But since I also need a big overview, it makes no sense to put only the objects of the visible area in the canvas, since on minimum zoom it's still everything and zoomed it's still very laggy cause of add and remove operations.
There are a couple of different things you should employ to have a smooth UX:
Use a Quadtree, whenever you add a shape to your canvas you also put it on your Quadtree. This will be helpful when you will zoom on a portion of the image: you will know what objects are in this portion of the image; you will render them again (against using a cached/pixellated version).
To overcome the potentially lengthy drawing process you could do the following:
display the portion of the cached image overview at the right scale
use a progress indicator to let know the user that the program is working render this portion
when the faint rendering is done, blit it on the screen
A concrete example: Google Maps does that.

c# how to perform a screen clipping similar to OneNote Windows + S shortcut key

I'd like to implement a similar screen clipping functionality to that of OneNote. Basically it can draw a translucent overlay on top of the whole screen, and also freeze the screen so users can clip a portion of it.
I've done some research around and it seems that the easiest way is to create a translucent TopMost form with the size of the whole screen and then perform clipping on this form. This approach, however, is slow. I see some other suggestions about doing a Direct3D hook for drawing overlay, but this is probably too complicated and I'm not sure how stable it is with respect to different Direct3D version. Any ideas how OneNote does it?
I think instead of creating the transparent layer on top of the screen, just grab a screenshot of the whole screen and make it full screen. So users are drawing on a static image not a translucent layer. Since it is a screenshot already, it is already frozen. I think this is how they do it anyway, I doubt an application can simply freeze a screen, they take a photo of it and cover your screen with it, so its as if its frozen.

Developing a drawing utility in C#

I am trying to create a simple drawing utility as .net desktop application(i.e Windows Form using C#). What i am planing to develop is:
There should be a canvas area (This is the area where the actual drawing is performed).
The canvas should be zoomable (Zoom in and zoom out)
The canvas areas should have grid lines (the ideal size of grid is 100X100pixel, but it can be changed with zooming)
There is a single character written inside each cell (here by the term "cell" i am refering to the box that is formed by the intersection of grid lines)
Now until this step all the thing are automatic (i.e user don't have to do anything until now all is done by my application)
User is only allowed to draw rectangles in canvas area(my application will also need to keep the track of those rectangles in such a way that user is allowed to resize those rectangles later)
Since i am beginner to C# so i need only guidance. Till now i just look at System.Drawing library (only look at it don't go deep :P) but not sure should it cater all my requirements or not (but i guess it will cater my req) and if it will then from where do i start with and what resource do i need to study in order to create this application.

Categories