How to get the screen resolution of android devices in c# - c#

I'm creating a optimized web page for mobile devices with C#. Is there a way to offer a page for larger screens and one for smaller screens on android devices? With Apple i can differentiate between iPad and iPhone, but how can I do this with the galaxy tab or a regular android phone?
I don't want to use any javascript in this case.

First of all i would suggest you you JavaScript for that as you could write you own code code to detect the screen width and height and style the page accordingly, but then again it is your choice.
There are however 2 possibilities (if you really don't want JS):
#media queries to where you can state different css styles (media-dependent style sheets) that work for different screen heights, widths, resolution and even more if it is a handheld device, print, etc
read http://www.w3.org/TR/css3-mediaqueries/ for general idea or Bingoogle "media queries and you will find a lot of info"
second solution is http://mdbf.codeplex.com/ which apparently is going to be removed on 29 Oct. you put the downloaded file in the "App_browsers" of your ASP.NET application and you serve back to the client the tailored page to his request. You can intercept the client's browser's feature during "Pade_Load" using "Request.Browser.[feature]" where feature can be ScreenPixelsWidth/height and build your page accordingly. This is really ugly since the document is man-made and man-updated, so if a new browser/screen size shows up, someone has to put it there manually so either you have to do it yourself (or somebody else) or it is not up to date.

I don't think that there is a way to do this without using java script. Think about how you would determine the screen resolution of a normal browser. There is not much difference to that with the android browser. It is a OS that runs on very much different devices that can not possible all be known to your application. To totally optimize your page you have to ask the client for its screen resolution.

Related

Embedding a Website in an App

Is there a way to embed a website (that I have no control what-so-ever over) in an app for Windows Phone?
I basically just want an extremely simple app that's just the Google+ website embeded in an app for Windows Phone. I realize I can just pin the website, but it's just not the same as having a nice pretty icon on the start screen, even if it's just a mobile site in a shell.
I know a small amount of C#, so that's the language I'd prefer.
EDIT: I just found this: How to launch IE7 from a Windows Phone App?
So now my question is, how do I use this so it happens on load?
To answer your question, you can execute the code that you reference in the above link, in the constructor of your MainPage.xaml. The question is, though, why? As you stated, you know you can pin a site, but you want an icon. Are you aware that you can make the icon appear as any part of the web page you are pinning? The tile will look like the page you're on, and the view you are at when you pin. If you want it zoomed out, then zoom out, then pin. Want an image on the page to be your icon? Zoom in on that image, and pin. You have a good deal of flexibility with this, depending on the page, of course.

using webcam & taking high res (2Mpix) pictures in a web application

I need a web based application where the user needs to fill in 3 fields and taking a high resolution image (2mpix) with a webcam. Once these are ready I need to post them to the server so they are saved in a database.
1) What is the best way/tools available?
2) I saw thisjquery webcam plugin - is it possible to capture photos through your webcam up to 1920×1080?
Thanks
The quality of the pictures you take with ANY camera depends on the sophistication of the camera.
Cameras have maximum resolutions and settings to configure them to a lower one as needed.
If the webcam on the machine has a resolution as high as the one you need, you'll probably be able to do this.
And its worth mentioning that the jquery webcam plugin requires flash to be available on the machine.
Since you've tagged this question with the ".net" and "c#" tags i guess i should mention that you can access the webcam via a silverlight app as well.

C# mute/unmute specific window/s?

I would like to know if it is possible to mute only a specific window. For example I have got Firefox open and two more windows. I want to mute everything related to Firefox but not the whole sound of my computer.
Is this possible? If so, how can it be done?
look, basically, there isn't any relation between the window handle and the sound which something in its code is playing.. the audio card can't tell who wants it to play.
theoretically, there is an option to do what you want on web browsers, but it's not easy, and not 100%. it goes like this:
most of the audio that is playing from browsers are from known objects like wmp/quick time/vlc/flash/etc..
when the user will choose to mute all audio from firefox, your application will search those known objects in the firefox tabs, and mute/unmute them using their api.
in order to do that, you will need to write an extension to firefox, so you could have an access to the tabs memory from your application.
btw, what os?
and check this out: http://www.indev.no/?p=projects#flashmute (flashmute) i believe it does what is said - only for flash.
On Vista/Windows 7:
I expect there to be some API which can change the volume on a per process basis which the audiomanager uses. Should be relatively straight forward to use.
On XP
I don't think there is any built in functionality for what you want to do. I recommend just not offering that feature on XP. But if you really want to, there are some hackish solutions:
Usermode API hooking. Intercept the calls to audioapis with your own functions. These change the volume or manipulate the audiosignal so you get what you want. You need to do this differently for any of the several available audio-apis. I guess DirectSound and DirectShow are particularly annoying. And this requires injection of a dll into any process you want to manipulate. And this dll better not require the .net runtime. Search for IAT(import address table) or EAT(export address table) hooking.
Kernel mode audio hooking. Write a driver which intercepts the audio in the kernel and changes it on a per process basis. No clue how to do that.
But as you can see both solutions aren't good.

Tips for designing web pages for mobile browser?

I'm making my debut in designing a web app specifically targeted at mobile browsers. While I've written web pages before in C#/ASP.NET, I've never done anything specifically for the limited screen real estate and other idiosyncrasies of mobile browsers. So I'm looking for some pointers here:
What design considerations should I be taking account of (aside from the obviously smaller screen)?
What useful features are there in C# that can be put to good effect for the mobile client?
How do you make sure to give a relatively uniform user experience for all different mobile browsers?
Any other tips you have?
Thanks!
Probably obvious but make sure you define a bespoke handheld stylesheet.
<link rel="stylesheet" href="http://domain.tld/mobile.css" type="text/css" media="handheld" />
Whilst modern smartphones (e.g. iPhone) can handle normal sites the constant zooming in and out is better avoided for a dedicated mobile app. However, it's worth designing two versions in case the user wants to access the app using a laptop / desktop too.
What design considerations should I be
taking account of (aside from the
obviously smaller screen)?
How about the user interaction, for example there are few devices that allow for "hovering", so don't depend on psuedo-classes that cannot be emulated on a mobile device, but don't completely ignore them, so mobile devices may use them.
Think about orientation of the design, if the device supports landscape and horizontal viewing.
Some devices like the iPhone cannot be operated to a mm accuracy using a stylus, so don't make inputs dangerously small.
If using effects to tart up the UI, most mobile devices don't display effect (such as those provided by jQuery) very well...
Finally test, test, test! Test on as many real mobile devices you can, and when you're done consider using emulators (such as ones for BlackBerrys or the iPhone), whilst this won't provide you with the feel of using the device, it should show any rendering problems.
Making a good mobile device experience is mostly about the UI, and not the back end application.
Use a mobile device style sheet (media="handheld" attribute on the link-element)
Have as few HTTP-requests as possible:
Compress all scripts and stylesheets into one single file (one for .js, one for .css, that is)
As few images as possible
Keep in mind the differences between touch devices and non-touch devices (size of buttons, for example)
Be careful with the amount of content you fit into one page.
Compress, minifying, optimize for a couple of reasons. Bandwidth isn't great, a page that loads in a couple of seconds on the desktop could take 30+ seconds on a mobile device. Caching is really poor on mobiles. An example being the iPhone will not cache components of a website over 25k. So get your images, scripts, stylesheets as small as possible.
You should check out WURFL which basically is a huge xml file that helps you identify the device. You grab the user agent and check it against the file with their API to get all the capabilities and features for that device. I´ve used it in numerous projects with great success.
Don't redirect to the mobile version of the site, losing the intended target. If I want to view an article on a site, don't take me to the mobile home page. You may take me to the mobile view of the article, but hijacking my target entirely is unacceptable.
A certain cr***ed.com does this always which is incredibly infuriating....

How to get the best font clarity to display on an HDTV with c#?

This is for an arrivals/departures flight display. The display is difficult to read because of blurry fonts. The current state is an asp.net page displayed using internet explorer on a HDTV.
From the software side, what can I do to produce good looking fonts? I've noticed that powerpoint presentations have nicely rendered fonts even on smaller resolutions. Refactoring as a windows application is an option.
Note: I know there is an issue with the hardware that needs to be worked out but I want to make sure I'm displaying the best fonts possible. The current hardware setup is a vga output to hardware to convert to component video and a long cable run to a hdtv.
Use ClearType.
If it's an LCD connected with DVI or VGA, set it to the native resolution.
If powerpoint looks good, then I can assume your display is set up reasonably well. Make sure Always use ClearType for HTML is checked in IE under Tools/Internet Options/Advanced.
Note you need to restart the browser for this to take effect.
Edit: To know when you've got it right, load the PowerPoint that looks good, and use the exact same font face in your web app. Then compare them side by side so you know when they look exactly the same.
The current hardware setup is a vga output to hardware to convert to component video and a long cable run to a hdtv.
One more thing: as a rule, component video comes in several predefined resolutions, namely: 720x576 (576p), 1280x720 (720p) and 1920x1080 (1080p).
It seems that your VGA -> YPrPb hardware rescales the picture.
Set your VGA resolution to one of mentioned above.
Are you sure it has to do with the actual software? Have you checked connection to the HDTV, resolution used, any upscaling used by the HDTV to get the incoming digital signal to the potentially larger number of display pixels?
It's not on the software side, but probably the biggest factor in font readability is whether or not the display is showing the picture with 1:1 pixel mapping between the display and the source, and that no overscan is going on and causing unnecessary interpolation.

Categories

Resources