Wednesday, November 26, 2003

There is no secret that SQL CE currently is not supported on a Smartphone platform. It means that the options for data storage on a Smartphone for .NET Compact Framework developers are generally limited to DataSet XML serialization/deserialization. This option has known deficiencies: you can read/write data in “all or nothing” way only and XML by itself bloats the data, all of which is a big downsize in the memory constrained Smartphone environment. So, what’s the solution? Write your own “a read from the file stream, save in binary form, fast forward-only reading” storage in CF. And this is what I’ve been working on for the last few weeks. The quick test I ran yesterday showed a really good speed/memory benchmarks. DataGrid population with 1000 (5 fields) records takes about 3 secs! Now, I just need to find some time to clean up the code and write up a whitepaper on it…

11/26/2003 1:52:14 PM (GMT Standard Time, UTC+00:00)  #     | 
 Monday, November 24, 2003
I've spent the whole weekend listenning and watching presentations from recent PDC.  I've had a blast when watching MBL311 - Exploring New Features in .NET Compact Framework "Whidbey" Release presented by Seth Demsey a Co.  I can clearly see that they're really listenning to our vows. There's so much cool stuff's been added to the next version of CF that I just can't wait to get my hands on it.  But it's still at least a year away...
11/24/2003 7:17:24 PM (GMT Standard Time, UTC+00:00)  #    Comments [31]  | 
 Sunday, November 23, 2003
I've finally got around to start working on a port of the AtlasCE to SmartPhone. The first thing I realised when trying adapt a UI to the "tapless/mouseless" Smarphone environment is that I have to change the whole way of thinking when creating programs for it. The least to say that the screen is small (176x220), you should always keep in mind that the user must be able to get to the information in the smallest amount of joystick/button pressings. You need to try to be ahead of a user, predict what he'd want to see on the screen and give it to them even before they'd ask for it. Only then your program could make sense when running on a SmartPhone...
11/23/2003 3:47:32 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]  | 
 Wednesday, November 19, 2003

Yeah... it's been a while I posted anything into this blog. I've been doing a lot of different things on CF (one of which is SDF on OpenNETCF.org) which I am going to tell you about later on...

Meanwhile, as an incentive to the loyal and new readers I am posting the function for drawing gradient colors in CF. As you know GradientBrush is not supported in CF and one of my recent projects required filling a background with a gradient colors, so I've put together the following function:

public static void DrawGradientVertical(Graphics g, Color color1, Color color2, Rectangle rect, int percent)
  {
   Pen pen = null;

   //calculate half color
   Color halfColor = Color.FromArgb((color1.R + color2.R) / 2, (color1.G + color2.G) / 2, (color1.B + color2.B) / 2);
   
   int R_color = color1.R;
   int G_color = color1.G;
   int B_color = color1.B;

   int R_step = 0;
   int G_step = 0;
   int B_step = 0;

   int sep1 = rect.Height / 2;
   int sep2 = rect.Height / 2;

   //calculate steps for changing between color1 and halfColor
   if (rect.Height > 0) //avoid 0 division
   {
    sep1 = rect.Height * percent / 100;
    R_step = (halfColor.R - color1.R) / sep1;
    G_step = (halfColor.G - color1.G) / sep1;
    B_step = (halfColor.B - color1.B) / sep1;
   }
   
   //draw the lines
   for(int i=0;i<sep1;i++)
   {
    pen = new Pen(Color.FromArgb(R_color,G_color,B_color));
    g.DrawLine(pen, rect.X, rect.Top + i, rect.Right, rect.Top + i);
    R_color = R_color+R_step;
    G_color = G_color+G_step;
    B_color = B_color+B_step;
   }

   //calculate steps for changing between halfColor and color2
   if (rect.Height > 0) //avoid 0 division
   {
    sep2 = rect.Height - sep1;
    R_step = (color2.R - halfColor.R) / sep2;
    G_step = (color2.G - halfColor.G) / sep2;
    B_step = (color2.B - halfColor.B) / sep2;
   }

   R_color = halfColor.R;
   G_color = halfColor.G;
   B_color = halfColor.B;

   //draw the lines
   for(int i=sep1;i<rect.Height;i++)
   {
    pen = new Pen(Color.FromArgb(R_color,G_color,B_color));
    g.DrawLine(pen, rect.X, rect.Top + i, rect.Right, rect.Top + i);
    R_color = R_color+R_step;
    G_color = G_color+G_step;
    B_color = B_color+B_step;
   }


  }

This function should fill the given rectangle with the gradient colors vertically. You can easily change it to make a filling in the horizontal direction.

 

11/19/2003 4:13:11 PM (GMT Standard Time, UTC+00:00)  #    Comments [32]  | 
 Tuesday, June 10, 2003

I find that the drawing stack in the Compact Framework is really tuned up to run pretty decently. It allows doing a really cool stuff especially in an owner-drawn controls area. Just look at the coming with CF DataGrid control, which is a fully managed (no native controls wrappers) and owner-drawn. That proves that anybody else is able to create such controls or even better. To illustrate this point I’ve written an article Creating Owner-Drawn List Controls in the .NET Compact Framework.” It shows how to develop a custom listbox and menu by creating a base class that raises the DrawItem event for each item in the list…  

 

6/10/2003 9:12:09 PM (GMT Daylight Time, UTC+01:00)  #    Comments [40]  | 
 Wednesday, May 21, 2003

I've been developing with .NET Compact Framework for almost a year now (It was about that time April-May last year when the first public beta was released...). I've been rolling along with the features that'd been added/removed to the CF, adjusting, struggling sometimes, getting into road blocks and finding ways around them as everybody else...

But recently I've started a new project in the "big" .NET and unexpectedly found myself in the different environment - the environment of the absolute freedom, where I am not limited by the memory constrains or horsepower. I can create some GDI objects on the fly, I can use the mighty GDI+ functionality and if I want to go down to the WinAPI's all possible handles are readily available... And asked myself a question: Will there ever be the time when development for CF becomes as unlimited as it is for .NET on a desktop? And obvious answer was: Probably not… unless the hardware changes to be as powerful as the desktops in the small form and power consuming factor.

But meanwhile, Compact Framework is a huge leap in improving developer experience for mobile devices running Windows CE and most certainly will be improving with the next versions…

5/21/2003 7:56:11 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2]  |