Category: NETCF

  • Using the Smart Device Framework?

    If you are using the Smart Device Framework in your software then why not take up Neil’s offer of free publicity in an upcoming webcast.


    Chris and Neil will be giving a webcast next Wednesday, and you can submit your Logo or Screenshots of your app to Neil for a quick showcase of all the cool things people are doing with OpenNETCF code. Full details here:-


    http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032254427&Culture=en-US

  • NDoc with Visual Studio 2005 Beta1

    I saw this post by Steve and realised that I hadn’t tried NDoc with Whidbey B1 yet. I was able to get it to work flawlessly, though perhaps my particular configuration is unusual.


    I’m running inside a Virtual PC image, into this I added an absolute bare-bones installation of XP Pro, I’ve applied SP2 RC2 but no other updates – at this moment it doesn’t have the .NET Framework v1,1 installed. Next I installed Whidbey Beta1 with pretty much all the options including the MSDN documentation. I built a very simple C# Pocket PC project, usual hello world stuff, added the configuration option to build xml documentation and built the project.


    I then went off to the NDoc website to download the v1.3 Beta installer. However this checks for .NET v1.1 and won’t install without it. Getting worried that installing v1.1 after v2.0 B1 might cause problems I promptly backed out. My alternative was to share a folder on the host PC and copy across NDoc 1.3 Beta from there. The program loaded flawlessly against the v2.0 Beta1 framework. I then had no problems documenting my .NETCF v2.0 project. So I guess this is the key, if NDoc is running against the v1.1 framework it will choke when faced with a v2.0 assembly, but I don’t intend to check this theory just yet (It’s taken long enough to get this virtual machine set up just the way I want it!


    The solution should be to add a config file for NDoc which includes the following XML to prefer the v2.0 framework:-


    <configuration>
    <startup>
    <supportedRuntime version=”v2.0.40607″ />
    </startup>
    </configuration>

    Save this file as:-
    c:program filesNDoc 1.3binnet1.1NdocGui.exe.config
    You may need to adjust this path depending on where you installed NDoc.


    The next step will to be to test with some more complex projects (like the Smart Device Framework).

  • Write cool .NETCF Code and win prizes

    Chris has announced our Coding Competition on his blog. This is a chance to win some cool prizes including a Smartphone Dev Kit, Visual Studio, Pocket PC, Compact Framework books and more!


    Looking forward to seeing the cool entries we are anticipating!

  • .NET Compact Framework / Visual Studio for Devices Chat starts soon

    This months chat with the Visual Studio for Devices team is due to start in just under half an hour, logon here and bring your tricky questions for the product team members.


    Full details along with other online chats are listed at MSDN.

  • Automatic Capitalisation Of Words In A Text Box

    A question arose recently on the newsgroup of how to automatically capitalise the first letter of a word in a text box, e.g. by activating the shift key on the soft keyboard. Since there is no API for the SIP to do this the workaround is to simulate a mouse click over the position of the Shift key in the soft keyboard.


    An alternative method is to handle the TextChanged event on the TextBox and add some logic to capitalise words as the text is entered. The advantage here is that it is not dependent on a specific SIP being in use:-


    private void textBox1_TextChanged(object sender, System.EventArgs e)


    {


      //start with true as the first character should always be upper case


      bool makeUpper = true;


      //get the current text as a char array


      char[] oldText = textBox1.Text.ToCharArray();


      //create a new char array the same size for the new text


      char[] newText = new char[oldText.Length];



      //for each char


      for(int iChar = 0; iChar < oldText.Length; iChar++)


      {


        if(makeUpper)


        {


          //make the character upper-case and reset the flag


          newText[iChar] = Char.ToUpper(oldText[iChar]);


          makeUpper = false;


        }


        else


        {


          //copy the character as-is


          newText[iChar] = oldText[iChar];


        }


        //if it’s a space the next character should be upper-case


        if(oldText[iChar] == ‘ ‘)


        {


          makeUpper = true;


        }


      }


      //assign the new value


      textBox1.Text = new String(newText);


      //position the cursor at the end of the text


      textBox1.SelectionStart = textBox1.Text.Length;


    }

  • Vibration and Pocket PC devices

    A number of Pocket PC devices support Vibration as an alert method, most (but not all) are Phone Edition devices. The Vibrate class in the OpenNETCF.Notification library is specific to Smartphone devices only.



    However the good news is that the Vibrate functionality is implemented as a notification Led so you can control the vibration using the Led class. One of the peculiarities of the NLed API is that the collection of Leds may contain gaps, for example some devices contain a notification Led at position 0 and a vibration device at position 5. There is no way to programmatically determine the index of the vibration device, you can only determine the overall count of devices. Also the vibration device can only be turned on or off so the Blink setting behaves exactly as On would.


    On the HTC Himalaya the vibration device is implemented at index 1 and the following code can be used to turn on and off the vibration:-


    OpenNETCF.Notification.Led l = new OpenNETCF.Notification.Led();


    //turn on vibration


    l.SetLedStatus(1, OpenNETCF.Notification.Led.LedState.On);



    //turn off vibration


    l.SetLedStatus(1, OpenNETCF.Notification.Led.LedState.Off);

  • Smart Device Programming chat starts soon!

    I intended to post this slightly more in advance but have been travelling around all this week, please excuse me πŸ™‚


    Chat Date: June 10th
    10:00am – 11:00am Pacific Time
    1:00pm – 2:00pm P.M. Eastern time
    17:00 – 18:00 GMT/BST

    Description: You know them from the newsgroups! You love them for their
    immense knowledge! Please join these amazing Microsoft MVPs in this live
    chat regarding the .NET Compact Framework and the Smart Device Programming
    features of VS.NET. The .NET Compact Framework is a subset of the .NET
    Framework designed to allow .NET developer to target smart devices. The
    Smart Device Programming features of VS.NET allow embedded developers to
    target devices running the Compact Framework.

    To join this chat, please visit:
    http://communities2.microsoft.com/home/chatroom.aspx?siteid=34000070

  • Want to know more about OpenNETCF.Security.Cryptography?

    As Sam points out, the OpenNETCF.Security.Cryptography library was donated to the OpenNETCF codebase by fellow MVP Casey Chesnut. So a good source of information about how the library is built is Casey’s original article on the subject.


    The library is designed in such a way that it follows the object model of the System.Security.Cryptography namespace in the full framework. A background on the Cryptographic services in .NET can be found here in the MSDN library.


     

  • Friday Fun: Automating Windows Media Player from .NETCF

    Windows Media Player for Pocket PC (and Smartphone) doesn’t have a true object model like it’s desktop cousin, so the ability to use it from your own code is limited. However there is an undocumented method of sending commands to Windows Media Player via a specific series of Windows Messages. These are actually hidden away in the Registry under the curiously named section “Pendant Bus”.


    Therefore I put together a simple dll which creates an instance of Media Player if one is not already running, and sends messages to it, to allow you to play, pause, move back and forward through the playlist or adjust the volume. The code requires the Smart Device Framework which is used to P/Invoke a couple of Windows methods e.g. SendMessage. A typical method looks like:-

    /// <summary>

    /// Skips to the next track in the playlist.
    /// </summary>
    public void NextTrack()
    {
    Win32Window.SendMessage(hwnd, 32972, IntPtr.Zero, 0);


    }

    There are some limitations in the code I’ve posted here – it doesn’t start the player with a specific file queued up (this would require a very simple overload to the constructor).


    There are currently no events and it is not possible to get information back from the player such as track name, elapsed time etc. I’m still investigating whether such information is output in any way which can be captured. This code should work with all Windows Mobile 2003 devices (inc Smartphone) and possibly earlier Pocket PCs but these have not been tested yet.


    Download the full code project with Pocket PC sample application here.

  • Smart Device Framework v1.1 Release Notes

    I thought it would be a good idea to compile a set of release notes for v1.1! You can view the resulting document here:-


    http://www.opennetcf.org/PermaLink.aspx?guid=a8b2c046-b9fd-4b0b-bd21-f0d03f6bec55


    The document lists the new items in this release. I haven’t compiled the more subtle changes to existing classes (new methods, bug fixes etc). These are available by looking through the ChangeLogs for the individual assemblies via the installed Source Code shipped with the package or via the online SourceBrowse interface.


    Importantly also I’ve documented a number of known issues with this release. For many there is a workaround which is described, for other issues you can be assured they have been logged and will receive attention for the next release. If you encounter an issue which is not listed here please submit it either to the Forums or via our Submissions email address.