Drydo's Blog

Teenager of the Internet

This blog hosted by:
http://blogs.vbcity.com
  Home :: Syndication  :: Login   Community Forums   :: vbCity.com   :: DevCity.NET  

Well, it's been a fun couple of days messing with the Micro Framework and overall I'm impressed. Sure - the .NET Micro Framework doesn't have the XML namespace, but it is a *Micro* framework people.

Anyhoo, I've managed to code up some simple applications such as an image viewer that could move between image, which I then improved so it moved between images and used an alpha transition between each one. And I've also been messing the SerialPort class to just send some simple commands to our RS232 relay board - the plan is to get an RS232 IR transmitter so we can communicate with Kevin our RoboSapien2 so fingers crossed.

From all that playing around, here are a couple of titbits...

  • Debugging live from the actual board. Sussed out that this wasn't a limitation but rather that Visual Studio SP1 had 'lost' the configuration manager from the Project Properties and Dropdown combo from the Build menu bar. Anyhoo, to get it back simply goto 'Tools', 'Options', navigate to 'Projects and Solutions' and ensure that 'Show advanced build configurations' is checked! Then it was a matter of setting the configuration manager to 'Build' and 'Deploy'!
  • For some reason the Tahoe board completely crapped out on me big time. Basically, my application would start up but then overwrite on the display with 'ABORT data' and output the some various debug data / registers (that could be navigated using the 'Up' and 'Down' buttons). Not a problem you would think? Well, it seems that the 'ABORT data' left the board is a non-interruptible state and therefore I could no longer deploy again to the device.

    OK - I panicked. I tried everything to get the board back up and running and the only way I got it (after an hour messing with the board, swapping out and installing the USB drivers) was to reset the actual board at the moment when the deploy actually took place. Whether this actually solved the problem remains to be seen - I couldn't tell through the blurred tears.

  • Finally, a little bit of code on resizing an image and displaying it (in this case to the dimensions of the screen). My first natural instinct was to ensure that the bitmap object had an appropriate routine (there called 'Bitmap.StretchImage') - however, it came with the 'Remark' that the method was for backward compatibility, etc. So, here's my attempt at demonstrating the old technique (StretchImage) and one new technique. Enjoy...

    (Note: and remember to remove the 'System.Drawing' namespace from your assembly when adding images as resources!)

    Utilising an Image Brush and Rectangle

    /// <summary> Constructor for the window</summary>
    public
    MainViewWindow()
    {
    // panel control to fill the window client area
    Panel
    panel = new Panel();
    panel.HorizontalAlignment = HorizontalAlignment.Stretch;
    panel.VerticalAlignment = VerticalAlignment.Stretch;
    // Generate a bitmap and obtain from the resource
    Bitmap
    bOriginal = Resources.GetBitmap(Resources.BitmapResources.MyResourceImage);
    Bitmap
    bResized = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
    // Resize the image
    bResized.StretchImage(0, 0, bOriginal, bResized.Width, bResized.Height, 255);
    // Generate an image control and set with the resized image
    Image
    img = new Image(bResized);
    // Add the image to the main panel
    panel.Children.Add(img);
    // The window has exactly one child
    this
    .Child = panel;
    }

    Utilising an Image Brush and Rectangle

    /// <summary> Constructor for the window</summary>
    public
    MainViewWindow()
    {
    // panel control to fill the window client area
    Panel
    panel = new Panel();
    panel.HorizontalAlignment = HorizontalAlignment.Stretch;
    panel.VerticalAlignment = VerticalAlignment.Stretch;
    // Create an image brush with the bitmap from resource
    ImageBrush
    imgBrush = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.MyResourceImage));
    // Ensure it will fill the parent

    imgBrush.Stretch = Stretch.Fill;
    // Generate a rectangle

    Microsoft.SPOT.Presentation.Shapes.Rectangle rect = new Microsoft.SPOT.Presentation.Shapes.Rectangle();
    // Configure (e.g. lose the stroke border)

    rect.Stroke = new Pen( Color.White , 0);
    rect.Fill = imgBrush;
    // Add the image to the main panel
    panel.Children.Add(rect);
    // The window has exactly one child
    this
    .Child = panel;
    }

Note: the above code is just test / development code - no picking through my clumsy C# :p

Have fun - M

posted on Thursday, May 24, 2007 10:48 AM

Feedback

# re: .NET Micro Framework - Further thoughts... 5/24/2007 11:27 AM Clinton
So how is it to use .NET Frameworks? I'm planning to transfer from Delphi, but I'm afraid it can take much time

# re: .NET Micro Framework - Further thoughts... 5/24/2007 1:10 PM Drydo
The .NET framework or just the Micro Framework? To be fair, both are great platforms to develop on (with the MF being a tiny subset of the main framework) and promote quick, easy, effecient and reusable code.

I'm a mod over at VBCity that has loads of article on .NET (C# and VB flavoured) that introduce the concept of .NET (albeit from a VB6 background in some cases) and might help you :-)

Post Feedback

Title:
Name:
Url:
Comments: 
Protected by Clearscreen.SharpHIPEnter the code you see: