Search code examples
c#windows-7taskbar

JumpList in C# application (recent files)


At the moment I am developing an application and want to add a Windows (7) JumpList. I followed several tutorials and studied documentation, but I can't figure out how to get the job done. In short: I want a recent list of last choosen files. So after closing the app, the user can easily open a recent file with my application. I already implemented some file association mechanism.

Is it possible to share some code/ tutorial how I can solve above problem?

Thank you in advance!

*I already tried the next few projects/ tutorials:

*The code of Coding 4 Fun works, but I don't know how to develop a recent file list.


Solution

  • You can check out this article. Instead of showing result in WPF you need to show it in jumplist.

    Why dont you try storing the recently opened file names in a database or an xml file and read it to set the jumplist.

    For eg.

    private void ReportUsage()
    
       {
    
           XmlDocument myXml = new XmlDocument();
    
           myXml.Load(historyXml);
    
           string list = historyXml;
    
           jumpList.ClearAllUserTasks();
    
           foreach (XmlElement el in myXml.DocumentElement.ChildNodes)
    
           {
    
               string s = el.GetAttribute("url");
    
               JumpListLink jll = new JumpListLink(Assembly.GetEntryAssembly().Location, s);
    
               jll.IconReference = new IconReference(Path.Combine("C:\\Program Files\\ACS Digital Media\\TOC WPF Browser\\Icon1.ico"), 0);
    
               jll.Arguments = el.GetAttribute("url");
    
               jumpList.AddUserTasks(jll);
    
           }
    
           jumpList.Refresh();
    
       }
    



    Or a beginners solution will be retain all the file paths into a Queue of given maximum capacity and adding them at run-time into a menuItem. Sorry I didnt have time to write the whole code.