WPF C# Application does not show loading gif - c#

I want to add a gif into the program that will be shown during init of the actual app, as a splashscreen for WPF only takes static imgs(png etc).
I need to take a different route, i was hoping anyone could point me in the correct way.
Im figuring that i need to create a new thread for a form(so the gif doesn't freeze) and then displaying it somehow.
Help or example code would be appreciated, cheers guys

You should do various steps:
Install this library, that allow you put gifs in Image
elements.
In the Window where you put your gif, set properties
AllowsTransparency="True", Background="Transparent" and WindowStyle="None", and inside this window put your Image with the gif.
In the loaded event of the window, perform your code that initialize your app in a Task. In this way, your app will not freeze.
After initialization, show your main window y hide the window that
contains your gif.
You also must set in the App.xaml, your property ShutdownMode="OnLastWindowClose".
I leave a project with this approach (check MainWindow and App.xaml)

Related

Take a screenshot behind window in C# WinForm

I'm working on an app in c# windows forms, I have a form called Form1 with a button, and after click this button the idea is to take a screenshoot of everything behind it except the Form1 itself (without minimizing Form1).
Any idea or suggestion?
Thank you!
If you want a solution without hiding, moving, minimizing etc., you need the following approach:
EnumWindows() to iterate all windows. This will give you the windows top to bottom.
Don't forget to exclude your own window
Exclude windows that are invisible. Check out GetWindowLongPtr with GWL_STYLE and compare against WS_VISIBLE
GetWindowRect() to get their size
PrintWindow() to get a bitmap of the window, no matter whether it's in the background
Create a bitmap with the size of the VirtualScreen
Paint the windows in reverse order (bottom to top) using DrawImage()
I found that this is quite fast (514 ms on a 2560x1440 screen with 20 visible windows to draw).
Limitations:
since it sends a WM_PRINT message to the application, you can not capture applications that are "not responding"
For me, Firefox does not render well. It's missing page contents.
For me, control panel content appears black, although it's there when getting a screenshot of the whole screen.
you can use hard code. Actually light shot and other tools working such as. When you click to screenshot button you may close the form window after the event and reopen it. it is the basic way of solution...
Please check this way: How can i capture the screen without the Form?

How to create a window within a UWP app to enter in detail/properties information

So I'm sure there's an easy way to do this but I don't know the exact terminology for what I'm wanting.
Essentially in my C# xaml uwp app I have a couple objects that need to have details added to them, kind of like file properties. I have a button that I would like to open up another window (still part of the app), just to enter in the properties. I just don't know the terminology to look up what this window would be called or find documentation for it. So the exact same as when you're in a file browser and you open the properties of a file; it opens in a little extra window that you can drag around.
I don't want to be able to use the main window while the properties window is open, and of course they need to be able to transfer data between one another.
In my previous apps I've simply made a grid that appears over everything else in the middle of the app and shaded the outer area. A workaround as I didn't know how to do this.
Can anyone help me out?
Maybe you can use Dialog refer to https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/dialogs-and-flyouts/dialogs.
Dialog controls are modal UI overlays that provide contextual app information. They block interactions with the app window until being explicitly dismissed. They often request some kind of action from the user.

WPF SplashScreen using external image

I need to make my SplashScreen show image from hard drive (since i will use several images, which may be changed outside of project). But WPF SplashScreen accepts only resource files, present in this or another assembly.
So, how can i solve it? Maybe, there is some way to create temporary resource file during runtime?
The best way to accomplish this goal is to not use the splash screen feature at all.
Create a new XAML window and size it to the size you want your splash screen to be. You can then use to reference the image you'd like to. This can also be done from code-behind now when loading.
When you're ready, have your main window launch the splash screen as the first thing it does. Let it load everything you need, and then show the main window and close the splash screen window.
This way you have full control over your "splash screen" because it's just another window that you're loading.
The one downside of this is that it might have a very small (.5 second or so) delay because WPF has to load before the window can show. An actual splashscreen is not WPF so it will show immediately. This has never been an issue for me.
I don't think this can be done as you want, however, it could be possible to create a separate assembly, which can be changed out whenever you want, which would contain the resource, using:
SpashScreen(Assembly, string);

C# launch form when images fully loaded

I'm making C# application design with images, but when I launch it, I see loading images (~1sec), so how to make simple loader, when images (background, logo, etc..) fully loads, to show my app? I know it's possible but I don't know how to. Thanks so much!
This sounds like standard behaviour. The controls get painted one by one in z-order and if one is slow the rest may appear to flicker.
You could try double buffering the whole form as shown here:
How to fix the flickering in User controls
Alternatively you could suspend the layout while everything is drawn and resume it afterwards:
How do I suspend painting for a control and its children?

WPF applacation window screen shot displayed on button

i have create a few WPF applications in visual studio, and now i would like to create a final application to run all of the created apps in the final application. i would like to know how i can create a layout that displays the apps that are running inside the final app as buttons that can be clicked and cause the app to expand and allow the user to work on that app and then when finished return back to the final app and see the other apps to choose from. I imagine it would look like a Google chrome blank page that allows you see your familiar webpages and click on them to load them up. Any help or advice on what i should focus on to implement this would be much appreciated.
Thank you for taking the time to read over this.
Consider using a VisualBrush this takes other WPF UI (your "apps") and uses their UI as a brush for another UI element.
Raj Kumar has a simple article called Visual Brush in WPF for details.
The bit you probably want is at the bottom where he shows you rendering a controls content in another control. The magic being binding the controls visual to the element name whos UI it should render.

Categories