🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Recent Files Feature for WinForms editor

Started by
4 comments, last by Steven Ford 6 years, 2 months ago

Hi,

I've written a level designer in C# / WinForms. As part of this, I'd like to add the ability to report the set of recently used files so that when a user right clicks on the task bar, they get a list of the recently used files / possibly a set of tasks (such as create new level). This'd match the behaviour of apps like Visual Studio and the browsers etc.

Looking on google, I can see there's a UWP API (Windows.Storage.AccessCache) which would appear to be what I want, but I don't see what the WinForms equivalent would be. 

Does anyone know what the equivalent would be / where to look?

Thanks

Steve

PS This is independent of the adding the entries to the ribbon's home area

image.png

image.png

Advertisement

Hi, although not answering all of your question, I found one of my WinForms apps I’ve written automatically shows ‘Recent’ files used on it if I right click on it in the task bar.  I believe this is the case because I’ve associated a file type (used by my app) to my application.  I did this association in the installer for my application but can be done from c# as well.

 

Currently I have my application pinned to the task bar and when I right click on it, it shows recent files used.  Selecting one of these files starts my application and passes the filename as argument 2 when calling main. I.e.

 


static void Main()
{
	string[] args = System.Environment.GetCommandLineArgs();
	if (args.Length > 1)
	{
		if (args[1].ToLower().EndsWith(".abc") )
		{
			// Load in recent abc file

 

I don’t know how to add tasks to a right click, sorry.

Hi @desiado, thanks. 

That confirms that it's definitely something that the framework will provide for me automatically if I can find out the magic keyword to use to let it know that I've done the load internally to the app.

Cheers

Steve

Yes, the ‘Recent’ files list was done automatically for me, I didn’t implement anything to do it specifically and almost surprised to see it there when I did notice.  This is either automatic in .net or windows somewhere.
For loading/saving a project file in my WinForms application I simply use the XmlDocument Save and Load methods.  My project files have their own extension but are ultimately in xml format. I.e. I do.
 

System.Xml.XmlDocument myDocument = new XmlDocument();
myDocument.Load(filename)
....
myDocument.Save(filename)

And apart from having the file extension associated to my app I don’t do anything else and Windows detects that I've loaded/saved the files and shows them in the ‘Recent’ files list in the taskbar

I did find this about adding ‘jump-lists’ to WindowForms app which may help for adding additional tasks.
 
 
For windows forms you need to get hold of the WindowsAPICodePack assembly and use Microsoft.WindowsAPICodePack.Taskbar;
For WPF and UWP you don’t need this as they have their own way to do it.
Sorry not able to investigate further or try things out at this moment.

Thanks @desiado. You've given me the key hint of jumplist though, I didn't know what the feature is called, at least now I know what I'm meant to be searching for. I'll do some more research over the weekend and let you know how I get on. 

Thanks again

Steve

This topic is closed to new replies.

Advertisement