I'm building a C# application using the Model-View-Controller technique.
I've built a form (with no code) that looks like Windows explorer with a menu, tool menu, address combo box, and treeview / listview splitter.
Anyway, in the controller app which contains the code to add and trap events of the items in the form. The menu has some items which are checked menu items that should act like a radio button optioin list. For instance, I'm going to allow the user to view drawing previews in the listview control at a large size, small size or details just like explorer does. When the user selects one of these options the others should be unchecked. In addtition, the toolbar strip that contains a dropdownbutton control should also by synced accordingly.
In order to not have a gazillion event handlers, I'm using a single event handler for the menu items and select case on the tag (set by me in code) to determine which menu item was selcted. The problem is, there is a fair amount of code to sync the checked items.
Here is an example of a two-toggle menu item for local details / web details to sync the menu buttons and the toolbar button:
case "File1":
// menu File Locals details was selected
// toggle this along with File2 menu item
if (mnuItem.Checked)
{
mnuFileWeb.Checked = false;
mnuFileLocal.Checked = true;
// sync the tool strip button too
toolConnect.Text = "Local Details";
toolConnect.Image = Properties.Resources.File1.ToBitmap();
}
else
{
mnuFileWeb.Checked = true;
mnuFileLocal.Checked = false;
toolConnect.Text = "Web Details";
toolConnect.Image = Properties.Resources.File2.ToBitmap();
}
break;
case "File2":
// menu file Web details was selected
if (mnuItem.Checked)
{
mnuFileLocal.Checked = false;
mnuFileWeb.Checked = true;
toolConnect.Text = "Web Details";
toolConnect.Image = Properties.Resources.File2.ToBitmap();
}
else
{
mnuFileLocal.Checked = true;
mnuFileWeb.Checked = false;
toolConnect.Text = "Local Details";
toolConnect.Image = Properties.Resources.File1.ToBitmap();
}
break;
You can imagine this could get complex with more than a couple of options.
How are you guys simulating control arrays for .Net development?