XNA/C# Game Settings (Menu?) - c#

It's my first time trying to make anything really interesting in C# and I was trying to make a simple form or game screen where the user could define a custom resolution/screen ratio etc. or to automatically detect the max screen size/ratio and output? its my first game, so I was wondering if it was possible or if there would be any major issues with such, rather than just setting it to 1366x768 (the resolution of all of my computers).
Thanks in advance for any assistance.

You could enumerate through the default GraphicAdapter's DisplayModeCollection property to find the DisplayMode with the max width/height/aspect ratio.
Something like:
GraphicsAdapter defaultAdapter = GraphicsAdapter.DefaultAdapter;
DisplayMode maxMode = defaultAdapter.DisplayModeCollection[0];
foreach (DisplayMode enumeratedDisplay in defaultAdapter.DisplayModeCollection)
{
//Test enumeratedDisplay against maxMode, setting maxMode to enumeratedDisplay if enumeratedDisplay is better
}
Maybe there's a better way, but that's certainly one way you could find the max.
Or, you could take the same DisplayModeCollection and populate a comboBox of sorts or a list, letting the user choose for themselves.
My apologies if the above code doesn't work in that exact form. I can't test it where I am currently

Just set the PreferredBackBuffer to 1366x768 and if the graphics device can handle that resolution you'll get it. otherwise you'll get something scaled down. the xbox will automatically scale if nescessary to support the television being used as well.

Related

Implementing a 2D interactive area in WPF using C#

We are developing an application in C# and WPF, that requires the user to select one or more items in a 2D area using the mouse in order to edit their corresponding properties in text fields below it. I am new to C# and WPF and currently trying to figure out the best way to implement this.
The figure below shows a scetch of what I have in mind. Each circle represents an item of the same type whose properties/values can differ between instances. The user should be able to select a single or multiple items using either Mouse-Click, Mouse-Click+Ctrl, or Mouse-Drag (by selecting an area). Furthermore it would ideal if similarly columns and/or rows could selected by selecting one or more of their numbers/letters.
Furthermore the color of the items should change border-color to signal their selection-status (selected vs. unselected) and fill-color to signal their contained values and make groups of identical items easily identifiable.
The number of shown items (cirlces) needs to scale to at least 400. In the future perhaps 2000 or more, so performance could become an issue. By then the area would likely also have to be zoomable. However at the moment ease of implentation has highest priority.
I am currently reading up on WPF and it seems, that the unified grid along with templating to fill it might be an option. However, I am unsure if the performance will be sufficient(?).
I am hopeful, that someone has already implemented something similar and perhaps could recommend a direction for further investigation. Thanks in advance and best regards.

Redraw Image every ~5ms

I have a Picturebox with...content approximately 2000x1080 pixel (yes, this makes sense for me)
Now I need to get the old content, replace it 1 pixel down and fill the empty line on the top with new data.
BUT I have to do this in a very short time ~5ms maybe a little bit more.
I get the trigger and the new data to do so.
So now the question is:
What is the fastest and cleanest way to do this?
Maybe I need to buffer the new data and write them in a more "human" time!?
You didn't mention what kind of app it is... I'm more of a web developer, but in jquery, the trick to this is to load all images with zero visibility, and then use logic to determine which to display; I would think that even if this isn't web based, you could use a similar approach... just line them all up on the screen, set the left most to be visible, and then every 5ms, make the next visible... if you were constantly adding images, just make sure you're loading them earlier, maybe during the 5ms between switches?

maintain button's position in c#, no matter the resolution of the screen

i designed a game in c# and finished it... but i tried it on my friend's laptop with different screen size and resolution, all my design was in a total mess!!
if there is a way to keep everything (panels, picturebox,buttons,labels,...) in their positions despite the size and resolution of screen!?!?
really need help, my project's deadline is on Monday :(
Use anchors on your controls:
I assume this is a windows form application? If so, you can use docking to maintain positions. Also, the positions should stay the same anyway unless the form is not a fixed size.
So use docking or a fixed sized form.
Also, please make sure to specify what type of GUI framework you're using next time. My answer is incredibly wrong if you're using something other than windows forms.
Aside from docking, another option would be to place all of your objects within a panel, and then center it horizontally and vertically on your resize event. e.g.
panel1.Left = this.Width/2 + panel1.Width/2;
panel1.Top = this.Height/2 + panel1.Height/2;
This will ensure that your applications static contents are always centered, regardless of resolution.

wpf custom control: audiowaveform rectangle with selection slider

I'm working on a c# wpf app in which I want to do something with audio. the irrklang audio library provides me with a pcm decoded 16 bit byte array.
I want to create a timeline control which shows the waveform along the timeline with an overlaying rectangle which the user can drag and click/drag the left and right side to increase or decrease the selection.
It is used to the trim the audio track. I would like the selected min and max to be databindable, the minimum and maximum value of the total track to be bindable.
To clarify here is an image mockup:
I'm not asking for a complete control but tips and suggestions on how to tackle this are more than welcome. Perhaps solutions like this already exist but so far I haven't been able to find it.
I think I need to tackle: the control (zooming, panning and changing the selection) and drawing the waveform in the control
Thanks in advance,
I think you should check out this codeplex project
http://wpfsvl.codeplex.com/
Refer to Audio WaveForm Drawing Using WPF.
Something based upon WaveFileTrimmerControl.xaml would be useful, it uses related controls PolygonWaveFormControl.xaml & RangeSelectionControl.xaml (links are to the XAML but refer to the CS also). In any case it'd be a good starting point for building a control that exactly meets what you want.
You could override the render method and use primitives which will give possibly better performance; but like anything related to performance I'd try the above approach first which is almost certainly good enough.

Dynamically setting screen resolution in Asp.Net(C#) .net framework 1.0

I have designed a page with all asp.net controls which is well alligned in 1024*1024 resolution but in other resolution it gets misalligned..please help
if we cant change the resolution then please tell me what i have to do..
Are you seriously asking to modify the client's screen resolution from ASP.NET? No, you can't do this.
Explore your layout options. Look at relative CSS formatting (width: 80%; vs. width: 800px). At worst, discover the client's resolution and adjust.
From http://particletree.com/features/dynamic-resolution-dependent-layouts/
function getBrowserWidth(){
if (window.innerWidth){
return window.innerWidth;}
else if (document.documentElement && document.documentElement.clientWidth != 0){
return document.documentElement.clientWidth; }
else if (document.body){return document.body.clientWidth;}
return 0;
}
...
var browserWidth = getBrowserWidth();
if (browserWidth < 750){
// thin layout
}
else
{
// fat layout
}
You can't change the resolution and I am glad it is like that. I get annoyed when a page resizes the browser. If a page changed my screen resolution it would probably be the safest way to get me to never, ever again visit that site. In short: I think you are attacking the problem from the wrong angle.
What you need to do is to change your design. You cannot change the world to fit your needs, you will need to adopt your app to the world. So the solution is simple:
Run your app on a resolution where it looks bad
Find out exactly why it looks bad
Fix it (typically this will involve using %-based sizing instead of absolute units)
It's usually really not that hard to get a page flexible enough to work on screens ranging from, say 800x600 and upwards. If it looks a bit strange on a high-resolution monitor (such as 1920x1200) it is usually not a problem; when I use a resolution like that, I typically do not have the web browser maximized.
Google for how to design web sites for different resolutions. You should find plenty of information.
It sounds like your CSS is too inflexible. If you're trying to change the client's screen resolution, it's not gonna work.
the best way to perform this task is make multiple css for different screen resolutions and then use one according to that if you like the idea then i can give you the code sample for this i have implemented the same way and now silverlight gives more nice solution. you can look it in my blog. Hope it helps you.

Categories