A quick look at the final code of the tutorials project (My Project). This code is from Program.cs, includes the start-up parameters of that project.
ManagedUI (Managed User Interface) is a .NET framework library written in C#, and can be considered as a getting-started library for creating a very advanced C# desktop applications. The idea is that ManagedUI can be like an engine for .NET windows desktop applications.
I decided to write this library a few years ago, when attempting to create new version for one of my projects AHD Subtitles Maker. The point is that I needed to rebuild my project because the old version didn't allow for further updates and specially for add-ons support. I started the project rebuild then the idea of MUI came to my head. At that point I stopped working on ASM and started on ManagedUI, so that ASM next version will be built using MUI.
Let's say you need to make a simple windows forms application that does simple tasks. You do it simply by creating a Windows Forms Application in Visual Studio, add then some controls, menu strip, etc. You handle some events (menu item click, button click, etc.) then your program is done and ready for use. But when your program becomes more complicated and huge with many controls and tasks, then your application requires a more advanced build and design, like:
- Editable and dynamic menu items and toolbars. Can give end-user options to edit main menu, toolbars, theme and shortcuts (hotkeys)
- Editable and dynamic tabs (control windows in the main window). Also you can give the end-user option to edit the tabs layout easily.
- Dynamic built-in settings engine. Allows end-user to manage your application configuration easily, easy to create setting pages as well.
- Add-ons support, the project uses MEF (see here), use services instead of just add-reference style.
- Uses commands and command combinations instead of just calling methods and creating instances.
- Multilingual interface support built in. You can make your project multilingual or simply single language.
- An engine that can be used more than once to create more applications.
- Easy to deal with and coding.
And that's the basic idea of MUI (Managed User Interface). You just worry about your services, commands, menu items and controls and the enviroment will order them all, allowing you (and end-users, where you can configure what end-user can do) to edit and configure the enviroment.
With the binaries file, I included a Tutorials file that explain step by step how to create a project, to get the code that used in tutorials please download the file TutorialProjectCode_MyProject.zip.
Here we will talk about how's MUI work and how to get started with it.
How does it work?
The main idea of MUI is:
- We have services that get detected by the main core MUI.cs
- When a service is detected, the Initialize() method of it is called. (MEF import thus services can be anywhere)
- ManagedUI has a main service for GUI called GUIService. This service is responsible for managing the main window, main menu, toolbars and controls.
- Also, there is another main service called CommandsManager. This service is responsible for managing the commands of the application.
Commands are detected as well (MEF import thus commands can be anywhere), but to use command: developer needs to use the CommandsManager service to execute them, end-user can execute commands using menu items and/or commands combinations.
As a developer, you only need to:
- Create services. Services are not required but it would be better to use them. The best use for service is a core that holds the important information for your program. In the Tutorials that included in the binaries file, We use one service that hold all information. When info is changed, an event is raised so all components can act depending on that change.
- Create commands. Commands are the basic elements of MUI. Simply, a command is something can be executed (for example, you can make a command that opens a file and other saves that file). A full example of commands can be found at the tutorials that comes in the binaries file.
- Create menu items. Menu items can be used both in main menu and toolbars. A menu item can be a way to execute a command, or simplly to hold commands. A full example of menu items also can be found at the tutorials that comes in the binaries file.
- Create controls. Controls can be TabControl or SettingsControl. Tab controls are displayed for the user in the main window while the settings controls are used in settings only.
Once these elements are created, your application will be ready for use. Also, MUI has a built-in engine that implement the localizing of Windows Forms so your project can be multilingual (see Localizing Windows Forms).
Installation of MUI is very easy:
- If you want to use binaries, just create a Windows Forms Application then add reference for ManagedUI in your project. Start using ManagedUI by using ManagedUI namespace.
- If you want to use the source code (which is better since you can debug and change the build configuration of your project) just add ManagedUI project into your solution then add reference for it in the main project.
Simply create a new Windows Forms Application project
Right-click on solution then Add existing project.
Now it is the time to add some references for MUI and MEF (right-click on references then Add reference)
Done! We can now start coding.
Using the code
Coding with MUI is very simple. For a quick start, just open the Program.cs file of new created Windows Forms Application, the code will be something like:
static class Program
static void Main()
Just change the code to be like this:
static class Program
static void Main()
MUIParameters parameters = new MUIParameters();
parameters.ProjectTitle = "My Project";
parameters.ProjectCopyright = "Copyright (C) <Year> <Author name>";
parameters.ProjectCopyrightMessage = "A short copyright message for the application. i.e. This program is protected by the law ....etc";
parameters.ProjectVersion = "1.0.0";
parameters.ProjectIcon = null;
parameters.ShowSplash = true;
parameters.UseColorForSplashBackground = true;
parameters.SplashBackgroundColor = System.Drawing.Color.White;
parameters.SplashBackgroundImage = null;
parameters.SplashSize = new System.Drawing.Size(650, 260);
GUIConfiguration.MainWindowDefaultSize = new System.Drawing.Size(1000, 700);
GUIConfiguration.UserCanChangeLanguage = true;
GUIConfiguration.UserCanEditMenu = false;
GUIConfiguration.UserCanEditShortcuts = false;
GUIConfiguration.UserCanEditTheme = true;
GUIConfiguration.UserCanEditToolbars = false;
GUIConfiguration.UserCanHideTabs = true;
GUIConfiguration.UserCanHideToolbars = true;
GUIConfiguration.EnableExitCMI = true;
GUIConfiguration.EnableHelpCMI = true;
GUIConfiguration.EnableShowSettingsCMI = false;
GUIConfiguration.EnableMenuItemsSettingsControl = false;
GUIConfiguration.EnableShortcutsHotkeysSettingsControl = false;
GUIConfiguration.EnableThemeSettingsControl = false;
Done! Hit F5 and the program will start!
Follow the tutorials, and finally the application will be like:
With MUI, we deal with attributes and resources. Examples:
A code of a service:
[ServiceInfo("MainService", "main.service", "The core service of the application.")]
class MainService : IService
This service is good to go.
A code of a command:
class NewCommand : ICommand
public override void Execute(object parameters, out object responses)
responses = new object;
responses = false;
Command now is ready and can be located and executed. To execute this command, we can create a menu item that can do this:
[MIRResourcesInfo("CMI_Name_New", "CMI_Tooltip_New", "page_white_text")]
class CMI_New : CMI
And yes, this menu item now ready to use, and executes the command 'new' we've created before. The attribute
MIRResourcesInfo is used to get the menu item properties values from resources, thus the application is multilingual, we just create some string keys in the resources file!
And yes, no more code is need for a menu item!
class TCDisks : ITabControl
private void InitializeComponent()
private MainService service;
public override void Initialize()
We just design our control, handle events, and change information in a service. Once that info is changed, events will be raised and other controls and components react! This is the main idea of MUI :)
I'm still working on a big document file that include all the references of each type of MUI. With the Demo Project that come with the source code and the tutorials, I think you can get started with the basics.
Publishing the project, the final touchs
When you are finished with menu items and need to edit the main menu, to create the default main menu just go to View>Edit Menu
And of course, the menu items you create will be listed when you want to add one of them. There are several types, each one have it's use.
- Root items can be added as roots (File, edit ...etc)
- Parent can be anywhere (but not as root), can have tooltip and icon, cannot be executed. Used for holding items (i.e. Add item in Add>Something).
- Commandable (CMI) can be anywhere as well (but not as root), can have tooltip and icon, and can be executed (executes a command you specify in the attr of that menu item). These items can hold other items as well and can be executed at the same time. (New, Open, Save ...etc)
- Spliter is used only for splitting between items. Cannot be coded or created. Only used in map (can be added by an editor only)
- Dynamic can be anywhere, can only habe a tooltip. This one is used to have children items that dynamically changed (Recent OpendFiles, Recent Opened Projects ...)
- Textbox is a text box item. Can be anywhere and have special events and handlers.
- Combbox as same as textbox, can be anywhere and have special events and handlers.
Depending on your use, you create the items. When you done, you place them in toolbar and/or main menu. The same goes with toolbars, theme, shortcuts ....
But what about end-user? You may mot want your main menu editable, or toolbars, theme, tabs layout, etc.
Okay, let's talk how MUI handle this :)
- When MUI is started, it checks the GUIConfiguration (we add in Program.cs, remember?). To see what's allowed and what's not for end-user.
- MUI will look for menu, toolbar, theme, shortcuts and controls files for default menu, toolbar, theme, shortcuts and controls settings in the documents (MUI creates a folder titled as same as your project title in the documents)
- If these files are not found, it looks for them in the bin dir (binaries dir when your app exe file is located and ManagedUI.dll) to load the default ones.
- If nothing is found, not in documents nor in bin dir, MUI will create the default layouts (default menu you see when you start a blank project, no control is there ...etc)
Thus, to make default layouts for your app (Menu, Toolbars, etc.)
- Design your application normally, when you are done with everything, place the controls as you like, edit the main menu as you like ....etc
- Close the app, MUI will save the settings files in the documents. Open the folder using explorer !!
- Copy the content of that folder into your project binaries folder
Now the settings you edited in the final steps will be used as default settings since when your app will run in new pc, the documents folder will not be existed; the files will not be located in the documents, thus MUI will use these files.
And if you don't allow (for example) end-user to edit the main menu using GUIConfiguration at the startup code (in Program.cs) then he/she will be stuck with the default main menu.
Same for other stuff, the toolbars, shortcuts, etc.
There is a project ManagedUIUtilities (comes in the full source code of ManagedUI), placing that utility in a MUI bin dir (like this in the picture above), it will allows to edit the settings without the need to copy and paste from documents to your project each time.
Points of Interest
For me, I will use this library for bulding new major versions for my programs. I decided to publish this library so that it may a good use for other developers whom which to get started with creating desktop applications but don't have the time for the enviroment coding (how's controls layout handled, menu items ...etc), MUI can provide something to start with. Even if you don't want to use MUI, you may get interested with how MUI works.
Coding with attributes is the best way I think about with coding. For example, I want to descripe the name and the id of something, I just put an attribute instead of creating properties, fields.. etc.
Please note that MUI is one way of creating desktop application that uses MEF, commands module, etc. There are more and maybe better ways to acomplish this.
I know that MUI lacks proper documentation, so please feel free to contact me at my email: ahdsoftwares[at]hotmail.com if you have questions, ideas, or bugs.
Also, you can get the latest updates for bin files and source code on the original hosting website: https://sourceforge.net/projects/managedui/
First created ASM v6 at 2013. ASM engine was so dynamic that gave me the idea of ManagedUI but was buggy.
Recreated ASM v6 again at 2014. The engine was better and all bugs are gone, too much to be done for a huge project such as ASM ...
In 2015 I noticed that ASM v6 engine can be used for more project, thus I decided to start with a project like an engine can be used to create projects, I canceled ASM v6 and started planning MUI.
In July 2016 started with MUI coding, finished it in November. I had to do some tests of it and done it with a base code of ASM v6. All tests went create and the project become almost; bugs free.
I decided to publish MUI and still working on ASM v6.