How to find out, if your app is running in an emulator, or on a real device?

In July’s beta, Microsoft has moved this property from System.Environment to Microsoft.Devices.Environment namespace.

//enum DeviceType contains: Device, Emulator
this.IsEmulator = (Microsoft.Devices.Environment.DeviceType == DeviceType.Emulator);
Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg
Fulltext Search On XML Files using XDocument
Given the following XML-Document:
<Customers>
<Customer>
 <Name>Jerry</Name>
 <Age>26</26>
 <Addresses>
<Address>
<Street>Main Street</Street>
<Address>
<Addresses>
<Customers>
1) How would you implement a fulltext search to return a List of Customer-Names?
public void StartRead(string searchTerm)
{
XDocument xDocument = XDocument.Parse(GetFile());
//get all retval-nodes (allthough it’s just 1)
var customers = from cmd in xDocument.Descendants(“Customer”)
select cmd;
//loop through retval-nodes (still only 1)
foreach (XElement cust in customers)
{
if (RecursiveParser(cust, searchTerm))
{
this.textBox1.Text += cust.Element(“Name”).Value + @” ### “;
}
else
{
this.textBox1.Text += @”empty ### “;
}
}
}
public bool RecursiveParser(XElement element, string searchTerm)
{
if (element.IsEmpty) return false;
if (element.HasElements)
{
foreach (XElement xElement in element.Elements())
{
if (xElement.Value.ToLower().Contains(searchTerm))
return true;
if (RecursiveParser(xElement, searchTerm))
return true;
}
}
return false;
}
2. How would you implement a fulltext search for addresses only?
Just replace “Customer” by “Address”:
//get all retval-nodes (allthough it’s just 1)
var customers = from cmd in xDocument.Descendants(“Address”)
select cmd;

Given the following XML-Document (it’s the output of a serialized List<Customer>):

<ArrayOfCustomer>
<Customer>
<Name>Jerry</Name>
<Age>26</Age>
<Addresses>
<Address>
<Street>Main Street</Street>
</Address>
</Addresses>
</Customer>
</ArrayOfCustomer>

1) How would you implement a fulltext search to return a List of Customer-Names?

(weiterlesen…)

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

MS announced, that there will be no database available for 3rd party applications, like on windows mobile 6.5. Instead of using SqlServerCE the user shall use cloud computing or xml files to store data.

So I searched for alternatives, and found a very pretty proof of concept. This guy is using a modified version of csharp-SQLLite to manage a database in Isolated Storage. I tried it a few minutes ago, and although it has some performance issues yet, it’s working also with the beta release of Windows Phone 7 Development Tools.

Here’s the link: Mobile Development .
Thanks, Dan, you made my day!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg
The developer Tool for Windows Phone reached beta-status. And Microsoft included into the 380 mb Setup Expression Blend 4 for Windows Phone.
So far the good news.
The bad news: several things have changed from CTP.April to beta – most of all: consolidation and Namespaces. MS advices to totally rebuild your projects, and just copy the content of xaml and xaml.cs files except the template-code.
It took some time, but I got my application running again.
See a detailed list of changes on this page:

The developer Tool for Windows Phone reached beta-status! And Microsoft included Expression Blend 4 for Windows Phone into the 380 mb Setup. Get it here: MS Setup, but make sure to uninstall any CTP version before!

So far the good news.

Bad news are: several things have changed from CTP.April to beta – most of all: consolidation and Namespaces. MS advices to totally rebuild your projects, and just copy the content of xaml and xaml.cs files except the template-code.

It took some time, but I got my application running again.

See a detailed list of changes on this page: MS What’s new in beta version.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

We are currently working with Wix (Windows Installer XML) and  today we wanted to roll out a new software package with a prerequisite for Silverlight 3.0.

I must say it’s pretty hard to find something on the web, on how to check installation or version of Silverlight (for Wix or other deployment projects).

But Alex and I found the solution.

If Silverlight is installed you will find the following Registry Entry:

[HKEY_CLASSES_ROOT\AgControl.AgControl\CurVer]

@=”AgControl.AgControl.x.x”

The “AgControl.AgControl.x.x” part contains the current installed version (Silverlight 3.0 = AgControl.AgControl.3.0)

As a little extra here the “Condition” check for Wix:

<Property Id="SILVERLIGHTVERSION">
  <RegistrySearch Id="SilverLightSearch" Type="raw" Root="HKCR" Key="AgControl.AgControl\CurVer"/>
</Property> 

<Condition Message="Please install Silverlight 3.0 or higher, available at: http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40818.0">
  <![CDATA[Installed OR SILVERLIGHTVERSION >= "AgControl.AgControl.3.0"]]>
</Condition>
Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

Since I do some Compact Framework programming on the side. I ran into the problem on how to do full screen applications on WM. Due to our background as “third level developers” we got a pretty good framework for C# Compact Framework programming and there I found the good old HHTaskBar “Hack”.

public static class TaskBar
{
    private static IntPtr taskbar; 

    [DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)]
    private static extern IntPtr FindWindowCE(string lpClassName, string lpWindowName); 

    [DllImport("coredll.dll")]
    private static extern IntPtr ShowWindow(IntPtr hWnd, int visible); 

    [DllImport("coredll.dll")]
    private static extern bool EnableWindow(IntPtr hwnd, bool enabled); 

    /// <summary>
    /// hides windows taskbar
    /// </summary>
    public static void HideTaskbar()
    {
        taskbar = FindWindowCE("HHTaskBar", null);
        ShowWindow(taskbar, 0);
        EnableWindow(taskbar, false);
    } 

    /// <summary>
    /// shows windows taskbar
    /// </summary>
    public static void ShowTaskbar()
    {
        ShowWindow(taskbar, 1);
        EnableWindow(taskbar, true);
    } 

}

This is fine,… but if the app crashes or you forget to implement the  ”ShowTasbar” function your TaskBar is gone (till the next cold reset). So I searched and found the following “lightweight” way to “hide” the TaskBar.

public static void FullSize(Form frm)
{
    frm.WindowState = FormWindowState.Maximized;
    frm.Size = Screen.PrimaryScreen.WorkingArea.Size;
    frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
}

Only tested for WM 5.0, 6.0 and 6.5!

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg

For some applications this is a very useful technique to assure, the user runs the latest version.
For some applications, you may experience difficulty with settings files. Settings files in that way, that users store local data in there, and that these changes are not going to be lost on the next app-update.

There are 3 known circumstances, where your settings files will not get updated:
1) downgrade your deployment version (e.g previous version was 2.5, new version is 2.3)
2) change your deployment provider url
3) changes in public key token/certificates

So if you can make sure, that none of the 3 reasons will ever appear, let click-once setup handle your settings files.
Otherwise, you might consider moving the files to a location outside the click-once environment (e.g. the localappdata folder).
Get an idea of how to do this in this article.

Share and Enjoy:
  • Technorati
  • Digg
  • Facebook
  • del.icio.us
  • Live
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • TwitThis
  • Blogosphere News
  • Blogplay
  • LinkedIn
  • MisterWong
  • MisterWong.DE
  • MSN Reporter
  • MyShare
  • RSS
  • StumbleUpon
  • Suggest to Techmeme via Twitter
  • Tumblr
  • Twitter
  • Webnews.de
  • Yahoo! Bookmarks
  • Yigg