Tuesday, January 03, 2006

You probably know how difficult it was to create a screen snapshot in CF v1. It required usage of many API calls and custom marshaling of a few structures. Just take a look at these resources:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/scibf.asp?frame=true

http://vault.netcf.tv/VaultService/VaultWeb/Blame.aspx?repid=2&path=%24%2fSDF%2fv1.4%2fOpenNETCF.Drawing%2fGDIPlus.cs&version=5&includedversions=20

The world has become a much better place since release of the CF v2 - availability of the native handles and ability to save image from Bitmap - have reduced the required code to just a few lines and one API call:

private void Snapshot(string filename, Graphics gx, Rectangle rect)

{

     Bitmap bmp = new Bitmap(rect.Width, rect.Height);

     // Create compatible graphics

     Graphics gxComp = Graphics.FromImage(bmp);

     // Blit the image data

     BitBlt(gxComp.GetHdc(), 0, 0, rect.Width, rect.Height, gx.GetHdc(), rect.Left, rect.Top, SRCCOPY);

     bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp);

     // Cleanup

     bmp.Dispose();

     gxComp.Dispose();

}

 

// P/Invoke declaration

[DllImport("coredll.dll")]

public static extern int BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);

 

const int SRCCOPY = 0x00CC0020;

All you need to use it is just place the Snapshot method on your form and call it like that:

//Create a snapshot of a current view of the TextBox

Snapshot(@"\Temp\save.bmp", this.CreateGraphics(), textBox1.Bounds);

 

1/3/2006 1:44:08 PM (GMT Standard Time, UTC+00:00)  #     | 
 Wednesday, December 21, 2005
 Friday, December 09, 2005

I've got the following info from Microsoft guys that could be helpful for anybody:

The following downloads for SQL Server 2005 Mobile Edition (SQL Server Mobile) available at http://download.microsoft.com is described below. For more information please refer to the SQL Server Mobile website at http://www.microsoft.com/sql/editions/sqlmobile.

a.    Microsoft SQL Server 2005 Mobile Edition Server Tools - The package installs the SQL Server Mobile Replications Components on the machine running the IIS server. The components are required for connecting the SQL Server Mobile database on a mobile device to SQL Server 2000 SP3a database and later versions. Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=6ed0fb7e-7c05-4f59-879a-8fb619e36612&displaylang=en

b.    Microsoft SQL Server 2000 Service Pack 4 Replication Components – The package installs the SQL Server 2000 SP4 replication components on the machine running the IIS server. The components are required for connecting the SQL Mobile database on a mobile device to a SQL Server 2000 SP4 database. Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=a0241f9c-79b1-4011-81e3-2601aa701e02&displaylang=en

c.     Microsoft SQL Server 2000 Service Pack 3a Replication Components – The package installs the SQL Server 2000 SP3a SQL Server 2000 SP3a replication components on the machine running the IIS server. The components are required for connecting the SQL Mobile database on a mobile device to a SQL Server 2000 SP3a database.  Link to download: http://www.microsoft.com/downloads/details.aspx?familyid=a9e0cea0-6f8d-4625-af71-fc8d671f64b6&displaylang=en

d.     Microsoft SQL Server 2005 Mobile Edition Device SDK – The SDK contains the product installers files for installing SQL Server Mobile on the mobile devices, and it also contains the DLL’s and Header files required for developing SQL Mobile applications on the Desktop. Link to download: http://www.microsoft.com/downloads/details.aspx?FamilyId=5BD8ABAA-5813-4DB3-B23A-24551DE2ECC1&displaylang=en

e.     IBuySpy Delivery 2005 Developer Toolkit Sample Application– The Toolkit is a sample e-commerce storefront to demonstrate how simple it is to create scalable applications for the Microsoft® .NET® platform by using SQL Server Mobile . Link to download: http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=7A5F64B0-4E64-4A72-A2C9-994A0C55CECD .

Apart from these the following are also available – 

EULA for SQL Server Mobile Device SDK: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/EULA.rtf

ReadMe file for SQL Server Mobile Device SDK: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/SSMREADME.htm

Help File for the SQL Server Mobile: http://download.microsoft.com/download/2/4/8/2482E95D-00FD-4374-BD15-57A8C4C34444/ssm3chm.chm

 

12/9/2005 2:38:47 PM (GMT Standard Time, UTC+00:00)  #     | 
 Friday, October 14, 2005

Watch this demo that shows Avalon err... WPF application executed on the Windows Mobile 5.0 device:

http://channel9.msdn.com/Showpost.aspx?postid=126729

10/14/2005 6:13:35 PM (GMT Daylight Time, UTC+01:00)  #    Comments [31]  | 
 Monday, October 10, 2005

RSS team at Microsoft has posted a link to download the PDC slides from “Windows Vista: Building RSS-enabled applications.”  presentation. In the slides they show the diagram of the RSS objects model and a few code samples of its usage in the managed code. First of all the object structure is presented as a set of interfaces (IFeed, IFeedItem etc..) which is explained by the fact that RSS platform in the Vista are built on COM and the RCW in  .NET exposes COM objects as interfaces. Second of all, because of its COM nature the code in .NET becomes not particularly a .NET friendly forcing a developer to use Class when instantiating an interface instance:

IFeeds feedMgr = new FeedsClass();

foreach (IFeed feed in feedMgr.Subscriptions.Feeds)
{                         
 Console.WriteLine(feed.Name);
 
   foreach (IFeedItem item in feed.Items)
      Console.WriteLine("\t" + item.Title);
 
 Console.WriteLine ();
}

I am not sure why the RSS team has decided use COM for that (probably to make RSS platform accessible from VC++), but it's better than nothing, right?

RSS
10/10/2005 7:08:48 PM (GMT Daylight Time, UTC+01:00)  #    Comments [30]  | 
 Monday, September 26, 2005

I am getting ready for MVP Summit in Seattle (from Wednesday September 28th until Saturday Oct 1th). I am staying in W hotel. Any MVP who wants to meet me, you will find me in the company with the usual suspects :)

On Friday, I received my copy of Framework Design Guidelines : Conventions, Idioms, and Patterns for Reusable .NET Libraries book and I am really enjoying every bit of it. I like Brad's and Krys's “Do, Consider, Avoid, and Do not“ style, but the most interesing I find the inline comments from Paul Vick, Chris Anderson, Brent Rector and others, who reveal many fascinating details on how the whole designing process works at Microsoft and making the text more alive and interactive.

 

9/26/2005 2:23:48 PM (GMT Daylight Time, UTC+01:00)  #    Comments [40]  | 
 Wednesday, September 21, 2005
9/21/2005 9:50:02 PM (GMT Daylight Time, UTC+01:00)  #     | 
 Thursday, September 08, 2005

How many times you wished to be able to use data binding with the ListView control. Well.. there are a few implementations of the bindable ListView available on the web, including the one on the MSDN. But in my opinion the best implementation was done by Ian Griffins a few years ago. In fact I've re-used this code for the ListBoxEx that's a part of SDF. So, here's the ported to .NetCF version of the BindableListView control. It doesn't have the desing-time version, but you should be able to use it in the following way:

private BindableListView bindList;

 

public Form1()

{

      //

      // Required for Windows Form Designer support

      //

      InitializeComponent();

 

      bindList = new BindableListView();

      bindList.View = View.Details;

      bindList.Size = new Size(240, 100);

      bindList.Location = new Point(0, 0);

      this.Controls.Add(bindList);

 

      bindList.DataSource = CreateData();

}

 

private ArrayList CreateData()

{

      ArrayList list = new ArrayList();

 

      Person person = new Person();

      person.Id = 4123;

      person.Name = "Alex Yakhnin";

      list.Add(person);

 

      person = new Person();

      person.Id = 5327;

      person.Name = "Chris Tacke";

      list.Add(person);

 

      //…

      return list;

}

Where the Person class is:

public class Person

{

      private int id;

      private string name;

 

      public Person()

      {

 

      }

 

      public int Id

      {

            get

            {

                  return id; 

            }

            set

            {

                  id = value;

            }

      }

 

      public string Name

      {

            get

            {

                  return name;     

            }

            set

            {

                  name = value;

            }

      }

 

}

Download the BindableListView and a test client here:

BindableListViewClient.zip (11.62 KB)
9/8/2005 3:58:26 PM (GMT Daylight Time, UTC+01:00)  #     |