Get Owners Name - c#

I'm porting an iPhone game to Windows Phone 7, and I'm wondering how I would go about getting the phone's name? Like, on the iPhone it would be the name you had set it to in iTunes, and that's also readable in the API with (obj-c..) [[UIDevice currentDevice] name]..
Anyone know the equivalent WP7 .NET methods/properties? I can't find them on MSDN.

You can get the manufacturer specified name of the device via:
Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString();
Note that "There is no standard format for this string. This value may be empty."
More at: http://msdn.microsoft.com/en-us/library/ff941122(VS.92).aspx

My guess is you are going to be working in the Microsoft.Phone.Info namespace, but they have not released members of the DeviceExtendedProperties or UserExtendedProperties classes yet.
MSDN Namespace Info

If you are using XNA, use the static SignedInGamers property of the Gamer class.
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.gamerservices.gamer.signedingamers.aspx
Edit: I thought you meant owner's name, like their gamertag or name, instead of what they named the device.

Use DeviceStatus.DeviceName of Microsoft.Phone.Info directive
Refer: http://dotnetspeaks.com/DisplayArticle.aspx?ID=151

Related

Get Application Icon Id - Monodroid

I need to get the int id of my application icon. Is there any way I can do this?
I'm aware that there's GetApplicationIcon in PackageManager, but this returns a drawable. How can I get the Id of the drawable?
Drawable drawable = ApplicationContext.PackageManager.GetApplicationIcon(applicationInfo);
I was thinking of looping through all the resources in Android, but I'm not sure how, and I think it would be expensive. Any efficient way I can get the icon id?
EDIT: I understand that I can just easily get the resource id from R.drawable.myicon, but I was hoping to get the Id with the use of PackageManager or ApplicationContext.Resources.
EDIT #2: I got it. See my answer below.
R.drawable.ic_launcher (or other name you gave it) should represent the id you need.
Okay, I got it.
Intent intent = context.PackageManager.GetLaunchIntentForPackage(context.PackageName);
ResolveInfo resolveInfo = context.PackageManager.ResolveActivity(intent, PackageInfoFlags.MatchDefaultOnly);
int appIcon = resolveInfo.IconResource;
Well, since it's your application, you can just look in your manifest. Your icon appears in the <application> tag, in the android:icon attribute. Just look at that file and see what it says.
You don't need to program that, just do it yourself one time.

How to set the start position for a video using AxShockwaveFlash (revised)

Revised question with added detail...
I'm trying to use AxShockwaveFlash to play a youtube video and start it at a specific location. This is within a C# winforms app. I have the basics. I can successfully start and stop the video. I cannot, however, figure out how to set the position and start at a specific time within the video. What property or method needs to be called to do this?
Here's what I have so far:
AxShockwaveFlashObjects.AxShockwaveFlash mFlashPlayer;
...
mFlashPlayer.Movie = #"http://www.youtube.com/v/9O9HfafzBPE?version=3&hl=ru_RU";
mFlashPlayer.Play();
I've tried setting various properties and calling various methods, but I'm just guessing. For example, I tried calling
mFlashPlayer.GotoFrame(200);
and it did nothing. Seems so simple, I'm starting to wonder if I'm encountering a bug. ?
I also tried using the standard form when using a web browser, which is to encode it directly in the url. For example, the following did not work either:
mFlashPlayer.Movie = #"http ...blah... #t=77s";
mFlashPlayer.Play();
Thanks in advance for any suggestions.
ANSWER
Apparently, I'm not authorized to post an answer, so I'm editing the question and adding it here...
Got it! The magic trick is to set the 'start' parameter in the url that you provide to the Movie property or the LoadMovie() method.
Embedded AS3 player:
http://www.youtube.com/v/VIDEO_ID?version=3&start=NUMBER_SECONDS
Chromeless AS3 player:
http://www.youtube.com/apiplayer?video_id=VIDEO_ID&version=3&start=NUMBER_SECONDS
Replace VIDEO_ID and NUMBER_SECONDS with the desired values.
Example:
mFlashPlayer.Movie = #"http://www.youtube.com/v/1ZKz2KW87Y4?version=3&start=100";
I found the required info here:
https://developers.google.com/youtube/player_parameters
That was one of the more frustrating hunts for info that I've been on in a while. Hope this post saves other folks the headaches.

Determine COM-Port number by given PnpDeviceID: Is the DeviceID of a COM-Port device always "COMx"?

I need to determine the COM-Port of a Plug-And-Play-Device. I have the PnPDeviceID. It's a bluetooth usb dongle.
So, I retrieve information about the device using WMI like in the first example at this website. The result of the WMI-query contains a property "DeviceID" which is a string. The value in my case is "COM3".
I get the same value, when I do (instead of using WMI)
string[] names = System.IO.Ports.SerialPort.GetPortNames();
Now I am wondering, if the DeviceId of COM-Devices always has the format "COMx"? I actually need a property called "Port" with an integer as value.
There is another approach, to go over the registry, but I don't know, if this is suggested.
See comment of Hans Passant. They are commonly named COMx. And u should let the user pick.
More important to me: Mostly it is not necessary to get the com port number as integer, since the Com-port name (string) is used as identifier widely, e.g. with System.io... They take the string "COM3" or the driver specific name.

Plotting geocoordinates in a Windows 8/Bing maps app

I'm making a C#/XAML Windows 8 app using Bing Maps. I'm copying a bunch of Windows Phone 7 code over, and I'm having a problem simply plotting geocoords. Here's the WP7 code:
GeoCoordinate mapCenter = new GeoCoordinate(37.784, -122.408);
map1.Center = mapCenter;
However, when I try to instantiate mapCenter in Win 8, (and I do use lowercase Geocoordinate instead of GeoCoordinate) I get an error saying that "Windows.Devices.Geolocation.Geocoordinate does not contain a constructor that takes 2 arguments".
I'm sorta stumped, as I planned on using Geocoordinates quite a bit, and I'm not really sure how to figure out what exactly the Geocoordinate constructor takes.
thanks,
Amanda
Edited to fix code indentation
The Windows.Devices.Geolocation.Geocoordinate class cannot be directly instantiated. Also, keep in mind, that the namespace you are using is used specifically for retrieving location data from the device.
First, you'll need to get an instance of Geoposition via Geolocator.GetGeopositionAsync.
You can then get the Geocoordinate instance from Geoposition.Coordinate.
If you're looking to simply center the map on a given latitude and longitude (and you're using the Bing Maps for Windows Store Apps SDK), it looks like you should be using the Location class instead (as Map.Center is of type Location).
Your code and you error output are saying two different things. I had the same problem make sure you are using the capital C in GeoCoordianate in you code. teh lower case C in geocoordinate is for getting the phones location.
The Center property of the Map control requires a value of type GeoCoordinate from the System.Device.Location namespace. If you are using location services from the Windows.Devices.Geolocation namespace, you have to convert a Windows.Devices.Geolocation.Geocoordinate value to a System.Device.Location.GeoCoordinate value for use with the Map control.
You can get an extension method to do this conversion, along with other useful extensions to the Maps API, by downloading the Windows Phone Toolkit. If you want to write your own code, here is an example of a method that you can use to convert a Geocoordinate to a >GeoCoordinate:
from http://msdn.microsoft.com/en-US/library/windowsphone/develop/jj207045(v=vs.105).aspx#BKMK_converting

Determining current paper type for default printer

I'm trying to determine the current paper type selection on the default printer using C#.
I've determined the default printer using WMI and enumerating through the Properties collection, I can see there's a CurrentPaperType string property, but on both printers in the office, its set to an empty string.
MSDN's documentation starts rambling on about printers implementing this standard blah blah, but very little in the way of practical advice :-
Type of paper the printer is using. Must be expressed in the form specified by the ISO/IEC 10175 Document Printing Application (DPA), which is summarized in Appendix C of RFC 1759 (Printer MIB). This property is inherited from CIM_Printer.
I can retrieve a list of all paper types the chosen printer supports, but it doesn't tell me which one it is currently set to.
I'm creating a dynamic report in memory and then spitting it out to the printer in one hit, so I need to know the paper size in order to correctly set margins, column widths etc.
Anyone had any success retrieving this information?
Don't use WMI unless you really need to. Use the built in .Net classes like Foxfire said. You can get a printer using the following:
System.Drawing.Printing.PrinterSettings printer = new System.Drawing.Printing.PrinterSettings();
printer.PrinterName = "YourPrinterName";
You can then access all the properties you require through:
printer.DefaultPageSettings;
Is there any particular reason why you use WMI instead of the .Net printer classes in System.Drawing.Printing?
You could easily get your Info through the PaperSources property of the PrinterSettings class which contains all PaperKinds that are currently available in the printer (could be more than one because several printers have multiple trays)

Categories