I'm making a game, and all of the pictureboxes sizes and locations are based on an 1920x1080 resolution (as that is my screen size). But when the game is played on a different resolution, the game doesn't fullscreen, (using FormBorderStyle = FormBorderStyle.None; and WindowState = FormWindowState.Maximized;), because I have set the maximum form size as 1920x1080. The problem is, that when the game is played on a bigger resolution monitor and the form doesn't fill up the entire screen, the game gets extremely laggy and slow. Is there any way to fix this? Perhaps by adding black bars around the game?
Assuming your game depends on the Screen and the Window being that exact size to work properly, you could move the entire game into a UI Panel, and center that in the window. This would probably require a lot of reworking of your code.
Or you could go the lazy way of opening open a new Window instead of the game from your Program.cs that is entirely black and maximize that, and then open the Game-Window Center-Screen at 1920x1080 without maximizing it as a Dialog from the background window, so it is always in front of the black one.
Related
I have a simple splash screen Windows Form in my application which, in the Visual Studio designer, looks like THIS.
The logo and the progress ring are each inside a PictureBox.
However, when I try to render the application on a windows 10 PC with the text and app scaling set to higher than 100% (for example, a 1080p 15.6-inch laptop), the result kind of looks like THIS (Taken from a PC with 125% resizing).
Do you know of a way to prevent the PictureBoxes from scaling, or perhaps a way to make the form scale up to keep track with the PictureBoxes?
EDIT: Just to be clear, it's the images INSIDE the PictureBoxes that scale up, not the PictureBoxes themselves.
Setting myPictureBox.SizeMode to PictureBoxSizeMode.Zoom solved the issue (Thanks Adds.)
I am making an overlay program with C# that will have an overlay for games. I am currently using a borderless form with a transparent background and a picture box to draw pictures to the screen, but I can't click the window behind the form. I have set the form to be always on top so that I can play games and the UI stays, but every time the mouse goes over the form in the game if I click the focused window switches to my form, preventing game interaction.
I have tried using functions to just draw images to the screen without using forms, but I cannot work out how to do that.
All I want is things like an external menu/crosshair and such, for use in minecraft. As for the menu, I could make my own media controls and such, and the crosshair would be useful because I hate the default crosshair. I could draw shapes to the screen, but if I don't use pictures the crosshair might look tacky.
A possible solution is a per pixel alpha blending window.
Here is a good starting point: Per Pixel Alpha Blend in C#
The example source code should give you the idea.
Hope this helps
I wanted to know whether it's possible to show a 2D Texture in XNA without a window that contains it. Just like drawing a picture/texture (maybe with the SpriteBatch.draw()-method?) simply onto the screen, independent from a seperated window. (What comes to my mind here is the Photoshop-opening window)
Is this possible in XNA? I can't find anything like this for SpriteBatch. Do I have to write totally new code/method?
If you mean splash image, it might be drawn from another application before launch (aka launcher) or you can show border-less window with image while loading application content in background.
Unfortunately XNA does not support border-less window, however there is walk-around using windows forms: https://gamedev.stackexchange.com/questions/37109/is-there-a-simpler-way-to-create-a-borderless-window-with-xna-4-0
If you will be able to create borderless window with XNA, then you need to change window size in constructor to splash image size, and draw same size image while loading content.
I would not recommend displaying splash image as it serves no real purpose, if you want to display some logo while starting the game - simply start game in fullscrean and draw image on black background while loading content, this is the way all modern games does it.
I'm currently developing a game in C# for a University project and have 3 different Windows Forms that make it up.
I was primarily developing the game on my main computer which has a monitor with the resolution of 1920x1080 and all of the elements in each window fit the window as they should. However, when I open it on the laptop I take to university which has a resolution of 1366x768 they don't fit the window and either go out of the visible area of the window or overlap.
I've set the windows to be a certain size and turned off resizing and the maximise button.
This image shows exactly what is happening:
The window shown above is set to 'FormBorderStyle: FixedSingle' and 'Size: 588, 470'.
How can I show a grey transparent overlay in C#?
It should overlay other process which are not owned by the application doing the overlay.
Create a transparent window the size of the whole screen, mark it always-on-top, calculate the regions of your other application windows, and make the non-window regions of the top window grey.
I suppose you could just position your own application windows on top of the transparent grey one, with it being above all the other ones, but getting a tricky z-order scenario like that right, especially in conjunction with other apps that might also be doing z-order tricks, is tough.
Here a little app which do more or less the functionnality you want :
http://www.anappaday.com/downloads/2006/09/day-10-jedi-concentrate.html