What's the best way to detect screen width and height on a Windows Store Application? - windows-store

I'm trying to detect the screen (not the Window) Width and Height.
I know that people use Window.Current.Bounds, but that gives me the Window size, not the screen.
I found this article (http://blogs.microsoft.co.il/tomershamam/2012/07/24/get-screen-resolution-in-windows-8-metro-style-application/) from Israel's Blogging Community. But it uses C++, is there any other way?

you can use the SystemInformation.PrimaryMonitorSize you can find it into : System.Windows.Forms
if you work into c#.
See the doc here : http://msdn.microsoft.com/fr-fr/library/system.windows.forms.systeminformation.primarymonitorsize(v=vs.110).aspx

Related

Testing responsive without mobile device

I'm working on making my site more responsive. If I decrease my browser width to its minimal width, is this a good substitute for testing what will happen on mobile devices?
I don't have devices such as the iPad Mini or Galaxy S2/3 but still want to make sure the site will look good on them.
Ctrl + Shift + M on Firefox(Windows)
Cmd + Option + M on Firefox(Mac)
If you want to test your designs locally, in the browser, you can use Web Developer Add-On which will give you an option to view responsive layouts
Also you get ton's of online website out there which will do the job for you like
http://mattkersley.com/responsive/
http://www.studiopress.com/responsive/
http://www.responsivedesigntest.net/
http://screenqueri.es/
If you are using media queries, then yes just resize your browser. You can keep an eye on the window size by using an inspection tool like firebug and checking the body width.
CHECK Responsinator: Help you to test site on different devices and different orientations
http://www.responsinator.com/
I would suggest finding browser plugins that allow you to resize your browser to specific browser dimensions. Then set up the common sizes using it...320px, 480px, 600px, etc, and/or whatever needed for your project.
For Chrome, I use Window Resizer.
I use your described method myself, it is not 100% accurate, some textual sizes could change slightly especially if you are using em or rems. If testing box layout and stuff like that it can be fairly accurate.
Another solution would be to use a service like http://quirktools.com/screenfly is a relatively good solution also.
The best solution that I also use is Browser Stack: http://www.browserstack.com/ It is not free however. Browser Stack also allows you to test different operating systems, different browsers, and a multitude of different mobile devices.
The best way to go is with the devices, but, if some or all the devices are not available then you will have to resort to some other ( good ) tools out there. Here are a few examples :
Testing Tool 1
Testing Tool 2
Keep in mind, these sort of tools will show you pixel perfect output and the user interaction/behaviors maybe different.

What is better: CSS media queries or JQuery mobile?

I'm newbie for developing mobile website. I very confused between two methods because I dont have any experience this it. Whats more better between two methods: css query when we using all of width device in css file or using jquery mobile that use php technique for differented user that use desktop or mobile [user->php?->mobile use jquery mobile/desktop use css standard]?
Many thanks for this answer
I will classify methods by their importance, from most important one to less important:
Client side detection
Using Modernizer javascript library to detect mobile / desktop environment
Server side detection
Using Modernizer Server or WURFL. Little complex then first solution but much more detailed (if you need more data about used device)
CSS media queries
Bad solution to detect desktop /mobile devices. Current mobile devices can have screen resolution equal to desktop platform
JavaScript based browser sniffing
Worst solution possible. Specially if you want to make distinction between smartphones and tablets.
To find more about this solutions, read my other article/answer with examples: https://stackoverflow.com/a/15055352/1848600
I have to post an answer in here since this comes first in search engines and accepted answer is not accurate.
There are two main concerns regarding responsive designs:
Content: Content should be restructured based on the width/height of the view port so the user can view the content without the need of constant zooming in and zooming out. This needs to happen solely based on the resolution of the view port regardless of the device. It could be a mobile device or a small window in desktop. This mainly involved the look and feel of the website and it is absolutely fine to use media queries. Even IMHO it is the best to use media queries to have the separation of concerns between your view and logic. No web designer likes to see random width or height showing up on their html elements during debug without knowing where are they coming from. Media queries will help you to resize the elements and show or hide them; however, in some situations you may need to move elements around; I usually do these using ng-if or ng-switch in angular js in combination with modernizer.
Functionality: If you need to turn on/off features based on the device functionalities, do not depend on the viewport specifications; use the vast libraries available in JS.
On a side note smartphone browsers seem to render at far lower resolution than actual device screen dimensions. Bust out a quick JS to show you your window resolution and run it on your phone.
Example: Chrome runs at 360x640px on my android screen of 1440x2560px.

How do I fix my website so that it works on mobile devices?

I am trying to make my website resize on handheld divices but form some reason its not responding to the stylesheet.
If you take a look here: responsive design link and put www.sofiamillares.com as the site test, the top lines get cut off and everything looks super big.
Can some one please enlighten me on why is it doing that and what would be the easiest way to fix it?
This is happening because your design is not completely fluid.
Only your container div will adjust with the width (a bit)
To fix this quickly, you could
give your divs percentage widths, so they scale with the screen resolution
float your square boxes at the bottom, so they will stack on smaller screens
consider using media queries or some js device detection to target mobile devices and send them a modified css stylesheet.
Get some ideas here: http://mediaqueri.es/
As Jason suggests, creating a mobile specific version of your site is usually the best solution. You can then test the user-agent string for phrases like "android" and "iphone" and re-direct the user to your mobile site. There are libraries available for JavaScript as well as many server-side programming environments (PHP, ASPX, etc) which do all sorts of browser detection for you.
When building a mobile site, you'll of course want to make the page lightweight so it'll load quickly over a mobile data connection, and format it appropriately for a smaller screen in portrait orientation.

How to make the web site design more flexible

I wanna to ask the following question about the design of any web application.
When maximizing ,, minimizing , zooming the browser ,, i note many problems happen to my web application design for example the horizontal menu like the one exists in SO site when minimizing the window the items of the menu in my website go down the other .. and other things make the site sucks and distracts the design .. how to make the design more flexible with the changes in monitor size , the preferences of the browser , maximizing ,and minimizing the browser ,, how to make the site design more flexible about all those issues .
Please any instructions , advice should i take care to reduce these errors.
Use percentage based widths for dimensions of your page and elements rather than pixels
Use em for your font sizes rather than px or pt
Try not to use images for navigation or if you do, make them expandable using the sliding doors method - http://www.alistapart.com/articles/slidingdoors/
Read up on liquid layouts - http://www.maxdesign.com.au/articles/liquid/ http://www.alistapart.com/articles/negativemargins/
A site that makes heavy use of float: and no width: values in its CSS will run into problems when people get crazy with the window sizes.
You can either nail everything in place by specifying width: px; all over your CSS, or you can go liquid and use width: %; for your objects. The former is considerably easier to pull off than the latter.
Try use something like Less Framework( http://lessframework.com/ )
Make sure you resize your browser when you visit the site!

How to design a flash based website when user has different screen size and different resolution?

I am developing a flash based website using mxml. My monitor's resolution is 1280x768 and is widescreen. The problem is while it appears properly in my screen it doesn't appear properly in others. Which is the best approach to solve the problem ?
I have 2 in mind.
Let scrollbars take care of it : If the screen is 14 inch screen with
800x600 resolution it appears zoomed
in. So thats a problem
Get screen resolution and resize using scaleX and scaleY : The graphic
components will get resized but fonts
give problem.
Which is the best approach among these ? If there is a better approach please mention.
Thanks
The BEST approach for this is to create a fluent UI based on percentage and constraints.
This way, the UI will feel the same on all computers not just yours.
I would recommend to also use the flow container that comes as a part of flexLib because that way is the easiest to create a fluent design.
Not long ago I created an application for a forex company that was perfectly fit to all screens larger then 1280X800 (design definition).
It's not that hard to do once you get the hang of it.
Good luck.
You can add an event listener to the stage to this effect:
this.stage.addEventListener(Event.RESIZE, resizeHandler);
private function resizeHandler(e:Event):void {
var newWidth:Number = this.stage.stageWidth;
var newHeight:Number = this.stage.stageHeight;
// etc, roll from here to do your manual positioning logic.
}
Note that this should also work on any DisplayObject - so you can use constraints and percentages on your containers, but then intercept their auto-resizing with a setup like this which will let you fine-tune the appearance of their contents.
Personally I would develop the screen for 800x600 and then dynamically resize the screen for higher resolutions.
You can use vertical scrollbars but horizontal scrolling is a big no-no in my books. It takes away from the whole experience of your site and gets rather irritating.

Resources