How To: Convert String to InputStream
Here is a method that does convertion:
public InputStream stringToInputStream(String text) throws UnsupportedEncodingException {
return new ByteArrayInputStream(text.getBytes("UTF-8"));
}
Here is a method that does convertion:
public InputStream stringToInputStream(String text) throws UnsupportedEncodingException {
return new ByteArrayInputStream(text.getBytes("UTF-8"));
}
Sometimes message from exception that occurred inside .Net CF classes doesn’t look handly at all:
An error message cannot be displayed because an optional resource assembly containing it cannot be found.
The thing is that error messages are actually in the resource assembly which is not installed on the device. So to fix the problem you just need to install this assembly:
As new articles and opinions pop up after official presentation of Windows Phone 7 I’m getting more and more excited about new OS.
But here’s a question: Will they multitask? Um, that depends on your definition of multitasking! When we asked Joe Belfiore, the guy running Windows Phone, he alluded to live tiles and feeds as some ofthe ways that third-parties will be able to “bring value to the user, even when their apps aren’t running.” Which sounds to us like a big ol’ “shnope,” but we’ll see more next month at Microsoft’s developer event MIX.
And another post from WMPoweuser:
On Mobile World Congress that take place in Barcelona Microsoft presented new generation of Windows Mobile. Here are some of reviews that reveal WM 7:
Yesterday I was surfing the web looking for information regarding Windows Mobile 7. Although not much details are available by this time I created a brief summary of rumors, leaks and announcements.
Official Announce and Preview
Mobile World Congress in Feb 2010 at Barcelona.
MIX in Mar 2010 at Las Vegas.
Editions
Business edition (expected in Q4 2010) is designed to give OEMs more control over customization.
Media edition (expected in Q1 2011) will be targeting the main consumer of cell phone devices, this version will come loaded with full support for Silverlight, Xbox Live, Mediaroom, Zune Music and Social media sites interfaces.
First Expected Phones
From LG in Sept 2010.
From HTC in Oct 2010.
Updates in Features
As reported Windows Mobile 7 will be the first release in WM history that totally breaks backward compatibility, so existing legacy code will have to be rewritten. However this is not official information and I expect to have this clarified during official preview at conferences in Feb and Mar.
New features and functionality updates include:
References:
Windows Mobile 7
Microsoft Zune Phone: Loaded With Windows Mobile 7 Ready To Kill iPhone
Windows Mobile 7 early build hands-on review, not compatible with old apps
Windows Mobile 7 Mockup
Windows Mobile 7 Exclusive Screenshots and Analysis!
Everything you need to know about Windows Mobile 7
Microsoft confirms Silverlight for Windows Mobile 7
A secret/hidden Windows Mobile 7 leak!
Windows Mobile 7: What we expect and what we are hearing
Windows Mobile 7: Fifteen New Details
Below is a snapshot that shows how to change screen orientation from normal to 90 degree rotated or from 90 degree back to normal depending on current screen state:
if (SystemSettings.ScreenOrientation == ScreenOrientation.Angle0) {
SystemSettings.ScreenOrientation = ScreenOrientation.Angle90;
}
else {
SystemSettings.ScreenOrientation = ScreenOrientation.Angle0;
}
To make this code compile don’t forget to import Microsoft.WindowsCE.Forms namespace.
New home screen available in Windows Mobile 6.5 should be refreshed differently for Professional and Standard editions of OS. It can be done using the same API methods as for earlier versions of Windows Mobile.
For Professional edition it can be done like this:
[DllImport("coredll.dll")]
private static extern IntPtr PostMessage(int hWnd, int msg, uint wParam, uint lParam);
private const int HWND_BROADCAST = 0xFFFF;
private const int WM_WININICHANGE = 0x001A;
public static void Refresh() {
PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
For Standard edition the trick is to provide correct GUID to API. This GUID can be found in SlidingPanel.home.xml file located in “\Application Data\Home” folder. Here is the code:
[DllImport("aygshell.dll")]
public extern static uint SHOnPluginDataChange(ref Guid clsid);
public static void Refresh() {
Guid guid = new Guid("{E9267CAB-02EE-4f37-8216-6BF6A8FF5A71}");
SHOnPluginDataChange(ref guid);
}
Here is a code for loading embedded image named MyImage.png stored directly in project directory:
Assembly assembly = Assembly.GetExecutingAssembly();
string iconFileName = string.Format("{0}.MyImage.png", assembly.GetName().Name);
using (Stream io = assembly.GetManifestResourceStream(iconFileName)) {
return new Bitmap(io);
}
Name of resource to load contains three elements divided by dots:
Path to resource should be created using names of folders. For example, if resource is in “Resources/Images” folder than path will be “Resources.Images”.
Normally saving XmlDocument leads to xml declaration at the beginning of file. In case it is desirable to omit it, XmlWriterSettings comes to help:
XmlDocument doc = new XmlDocument();
// Do with document whatever is needed...
// Save xml document without xml declaration.
XmlWriterSettings writerSettings = new XmlWriterSettings();
writerSettings.OmitXmlDeclaration = true;
using (XmlWriter writer = XmlWriter.Create(@"\omit.xml", writerSettings)) {
doc.Save(writer);
}
Making read-only file writable with full .Net Framework is a piece of cake: there is FileInfo.IsReadOnly. Just set it to false and it’s done.
With Compact Framework we need to use FileInfo.Attributes and a solid knowledge of bitwise operations:
FileInfo info = new FileInfo(pathToReadonlyFile); info.Attributes &= ~FileAttributes.ReadOnly;