Click here to Skip to main content
11,411,840 members (66,117 online)
Click here to Skip to main content
Technical Blog

Mobile Development: writing today screen plugins the easy way

, 24 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
today Plugins with compact framework The following today or home screen plugins for Windows Mobile are based on a work of CrisText at codeplex. The codeplex sources provide a framework to create home screen plugins very easily. You just start a Form or UserControl and add the attribute “[Today

today Plugins with compact framework

The following today or home screen plugins for Windows Mobile are based on a work of CrisText at codeplex.

The codeplex sources provide a framework to create home screen plugins very easily.

You just start a Form or UserControl and add the attribute “[TodayScreenItem("a unique name")]” before the class. Further on, the framework looks for such plugins dynamically and you can add or remove plugins by just adding or removing DLLs.

I did two plugins, one shows the Intermec device ID and the other enables you to have buttons on the home screen to directly launch applications.

Show some information

The first plugin is very simple. An user control that just shows some static text (see the lower info on the screen shot):

today_date_only today_with_apps_and_deviceID

Simple code:

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using ChrisTec.WindowsMobile.TodayScreen;

namespace todayDeviceID
{
    [TodayScreenItem("todayScreenDeviceID")]
    public partial class todayDeviceID : UserControl
    {
        private Label label1;
        private PictureBox pictureBox1;
    
        public todayDeviceID()
        {
            InitializeComponent();
            int w = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            int h = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            int factor = w / this.Width;
            this.Width = w;
            this.Height = this.Height * factor;
            
            this.pictureBox1.Height = this.Height - (pictureBox1.Top*2);
            pictureBox1.Width = pictureBox1.Height;    //make a square box

            label1.Width = this.Width - pictureBox1.Width;
            label1.Height = this.Height;

            label1.Text = ITC_DeviceID.getDeviceID();
        }
		...

The above simply has a label and a picturebox on a user control.

To get the above working on your device you must install the ChrisTec.WindowsMobile.TodayScreen cab file or at least the files:

  • ManagedTodayScreenItem.dll
  • ManagedTodayScreenItemHost.exe

And you must register the today plugin framework:

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Microsoft\Today\Items\Managed Items]
"DLL"="%CE1%\\Managed Today Screen Framework\\ManagedTodayScreenItem.dll"
"Enabled"=dword:00000001
"Options"=dword:00000000
"Selectability"=dword:00000002
"Type"=dword:00000004

All files should be placed inside “\Program Files\Managed Today Screen Framework\”.

Debug and deployment

You should setup your plugins to be deployed to the above directory. So you can easily update and test your plugins. Unfortunately you can not replace any existing plugin as long as Managed Items are enabled in Home screen settings. So I added a project and application that works similar to the plugin framework loader. You may use testPlugin to test and debug your plugin:

testPlugin

Then test your plugin by Start-Settings-Home:Items and enabling “Managed Items”:

settings_home_1 settings_home_2

If everything is correct, you will see your plugin on the home screen.

The other plugin I wrote is a program launcher. I started another Control Library SmartDevice project. Just add the attribute to let the framework know that this is another plugin:

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime;

using ChrisTec.WindowsMobile.TodayScreen;

namespace todayApp1
{
    [TodayScreenItem("todayScreenApps1")]
    public partial class todayApp1 : UserControl
    {
        theApps apps = new theApps();
        myApps.myApp[] allApps;

        public todayApp1()
        {
            InitializeComponent();
            allApps = apps.myAppList.ToArray();
			...

The above uses a class to determine the application buttons to create. This theApps class uses a xml file to let you define launcher buttons:

<?xml version="1.0" encoding="UTF-8"?>
<myApps>
   <myApp>
     <title>The File Explorer</title>
     <iconFile>\Program Files\managed today screen framework\fexplore.gif</iconFile>
     <exeFile>\Windows\fexplore.exe</exeFile>
     <args>\My Documents</args>
   </myApp>
   <myApp>
     <title>Internet Explorer</title>
     <iconFile>\Program Files\managed today screen framework\iexplore.gif</iconFile>
     <exeFile>\Windows\iexplore.exe</exeFile>
     <args>www.google.de</args>
   </myApp>
</myApps>

You can see that you can define the exe to start, arguments for the exe, a title and a symbol.

The todayApp user control adds buttons dynamically and will show a scroll bar if more than 4 apps are defined.

Now start your own home screen plugin the easy way.

Source code at: https://github.com/hjgode/todayPlugins

<!-- Social Bookmarks BEGIN --> <!-- Social Bookmarks END -->

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

hjgode

Germany Germany
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.5 | Last Updated 24 Apr 2014
Article Copyright 2014 by hjgode
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid