Hoot With a Ribbon, MDI, and Inheritance

I just released a new beta version of Hoot. While it is fully functioning, it does involve significant changes in the way Hoot works. With version 1.9.0, Hoot employs an MDI (Multiple document interface). Previously, Hoot opened new windows for different types of searches. These windows filled the taskbar and were scattered across the desktop. With MDI all windows are contained in the program's main menu.

Another significant difference is the use of inherited forms. While users should not care, it does mean the code is smaller and (theoretically) faster. For me, it means changes can be made to the interface easier.

Finally, the new Hoot includes a ribbon, like you might have seen in Microsoft Office applications beginning in 2007. While this ribbon is not from Microsoft, it is a very good look-alike. All of this may sound boring, but for a developer it is a little fascinating, figuring out how things work, as well as how to work around limitations.

Multiple Document Interface

With the MDI I could avoid creating new form for each call and instead open them as child windows. Other than setting the appropriate flags on the parent form, the only thing I had to do different is open the forms appropriately for the MDI. One standard way to open such forms is with code like what I've used. This also cascades the new form over the last active child.

Inheritance

When I mentioned Inherited forms on one discussion board one of the responses started with "ouch, ouch, ouch". Well, it's not so bad. With inheritance in C# you can't normally pass parameters to an inherited form, so I found a workaround. While inherited forms apparently can't take parameters in their constructors, at least not directly, you can access the controls of the inherited form and force a parameter.

1. Add a label named lblTrigger (public or protected)2. Add an event to the label for the TextChanged event

You're not limited to one label, either. You can add parameters to use with a different label. That's what I've done using lblParameters included in one of the code segments below. Set the parameters, then "pull" the trigger.

In one case "SavedSearch" is the text I set for the trigger.

case "SavedSearch": OpenFromRecent(); break;

That then calls this method which simulates a button click on the form.

Ribbon

The ribbon I am using in this project is the one mentioned in the Code Project article at https://www.codeproject.com/articles/364272/easily-add-a-ribbon-into-a-winforms-application-cs. It's a third-party ribbon for C#, not WPF or other Microsoft. While it looks and performs well, there is a limited documentation for it. The intellisense and integration with Windows is good, and many items are similar. One of my biggest challenges was determining how to use the Recent Items list.

Recent items

One thing that was not so easy to understand was the use of the Recent Items list in the Orb menu. Determining how to create recent items dynamically, however, was one of the biggest accomplishments recently. My last blog entry touched on recent items and using the C# .Designer file to figure out how to create them. Actual implementation was a little more difficult. With my implementation I created a new class with properties of the recent item that I would use.

The Recent Item

The text is the filename. The tag indicates the type of item since the items are not identified by file extension. ItemID will be updated when saved to the database. The database fields are similar to the class fields.

One of the things I learned about Recent Items is that there is no obvious way to enable user-deletion of items. I notice Word doesn't have that either, nor does Windows, so I decided not to worry about it.

If you use this in a program you may notice that the items are added to Windows list of Recent Items, but it's not because of this method. It's simply because they were files that "you" opened. Anyway, this is my contribution to the C# Ribbon knowledge base.