Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Building OpenPOS: Part 8 – Windows 7 Love

, 20 May 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
OpenPOS is almost ready and I am very excited!!! The first OFFICIAL version should be released by the end of the month, I am just busy finishing off some last touches… With that said, I do want to give an update on the current status of the project and also give Windows 7 some love!

OpenPOS is almost ready and I am very excited!!!

The first OFFICIAL version should be released by the end of the month, I am just busy finishing off some last touches… With that said, I do want to give an update on the current status of the project and also give Windows 7 some love! I truly love Windows 7 and have been writing about using some of its features in the past… now it's time to put my money where my mouth is and use some of these.

In Part 3, I wrote about the navigation “framework” used in this project… I updated this “framework” to automatically add NavigationPoints to the JumpList. Let's re-cap:

To register a NavigationPoint

_navigationService.RegisterNavigationPoint(
    new NavigationPoint() 
    { 
        Name = "Sales",
        Category = "Main",
        ShowInJumpList = true,
        Icon = "\\Images\\mycomputer.png"
    });

This will add a NavigationPoint to the Navigation pane:

If the ShowInJumpList is set to True, the NavigationPoint will also be added to the JumpList:

Let’s look at some of the implementation details… To make JumpList work, you need to ensure that only one instance of your application is running and that if a new instance is launched, it somehow sends the arguments passed into it all the way back to the original version already running (using some form of IPC). In my original series on the Anatomy of the Windows 7 taskbar, I used my Inter-process Mediator to facilitate this “process”. My Inter-process Mediator has some flaws though. :(

This being said, I decided to try out the SingleInstance implementation used in the FishBowl application:

“Fishbowl brings Facebook to your desktop.”

For their approach to work, I first needed to create a custom Main() method (I used approach 3 explained in this document).

public static class OpenPOS_Main
{
    [STAThread]
    public static void Main()
    {
        if (SingleInstance.InitializeAsFirstInstance("OpenPOS"))
        {
            var application = new App();

            application.InitializeComponent();
            application.Run();

            // Allow single instance code to perform cleanup operations
            SingleInstance.Cleanup();
        }
    }
}

And wrap the normal Main() stuff in a SingleInstance.InitializeAsFirstInstance. This will ensure that the application will only really be started once. Once a second instance is created, an event will fire… We can handle this event then in our ShellViewModel:

SingleInstance.SingleInstanceActivated += 
    new EventHandler<SingleInstanceEventArgs>(SingleInstance_SingleInstanceActivated);

In the SingleInstance_SingleInstanceActivated event handler, we can navigate to the new passed in “View”.

Ok, this is great but where do we create the JumpList? In WPF 4, the JumpList is built in, so we do not need the Windows® API Code Pack for Microsoft® .NET Framework any more… Now we can just do the following:

var jl = JumpList.GetJumpList(Application.Current);

Which should return the current application’s JumpList… and add or remove any JumpTask. Here is the CreateJumpList method in my NavigationService:

public void CreateJumpList()
{
    var jl = JumpList.GetJumpList(Application.Current);
    jl.JumpItems.Clear();
    for (int i = _navigationPoints.Count-1; i >= 0; i--)
    {
        var point = _navigationPoints[i];
        if (point.ShowInJumpList)
        {
            jl.JumpItems.Add(new JumpTask
                                    {
                                        Title = point.Name,
                                        CustomCategory = point.Category,
                                        IconResourceIndex = 0,
                                        IconResourcePath =
                                            Path.Combine(System.Environment.
					CurrentDirectory, "OpenPOS.exe"),
                                        Arguments = point.CreateArg(),
                                        ApplicationPath =
                                            Path.Combine(System.Environment.
					CurrentDirectory, "OpenPOS.exe")
                                    });
        }
    }
    jl.Apply();
}

We just loop through all the NavigationPoints and for each one that has the ShowInJumpList set to true will be added…

What is the Current State of OpenPOS?

I have been hard at work finishing off some of the “normal” business requirements of a point of sale system. Here is a somewhat incomplete list of stuff I have done:

  • Implemented the Sales module
  • Implemented Ticket/Payment (Multi payment)
  • Users/Navigation plumming
  • Implemented Stock control (Stock can be added or removed)
  • Implemented reporting (Using Open-Source WPF Reporting Engine)
  • Cashup
  • Implemented basic Customer support
  • And much, much more…

Want to learn more?

The source is available on Codeplex.

License

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

Share

About the Author

rudigrobler

South Africa South Africa
No Biography provided

Comments and Discussions

 
GeneralOpenPOS progress PinmemberGeirFAndersen30-Jun-10 0:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150331.1 | Last Updated 20 May 2010
Article Copyright 2010 by rudigrobler
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid