public void Add(SubMenu m) { m.NotifySectedTo(y => { if (Level == 0) { CurrentMenu = y; Level++; } else { CurrentChildMenu = y; Level++; } }); Menues.Add(m); }
public void AddMenu(string grandParentName, Action grandParentAction, Action <Action <string, Action, Action <Action <string, Action> > > > addSons) { { MenuItem grandParent = null; addSons((parentName, parentAction, addGrandSon) => { SubMenu tempGrandParent; if (grandParent == null) { if (grandParentAction != null) { tempGrandParent = new AnotherTypeOfSubMenu(grandParentName.Trim()); } else { tempGrandParent = new SubMenu() { Name = grandParentName.Trim() } }; grandParent = tempGrandParent; } else { tempGrandParent = grandParent as SubMenu; } ; MenuItem mb = null; addGrandSon((grandsonName, grandwhat) => { SubMenu yy; if (mb == null) { if (grandParentAction != null) { yy = new AnotherTypeOfSubMenu(parentName.Trim()); } else { yy = new SubMenu() { Name = parentName.Trim() } }; mb = yy; } else { yy = mb as SubMenu; } var mmb = new MenuButton(grandsonName.Trim()); SetActionToMenu(mmb, grandwhat); yy.Add(mmb); }); if (mb == null) { mb = new MenuButton(parentName.Trim()); } SetActionToMenu(mb, parentAction); tempGrandParent.Add(mb); }); if (grandParent == null) { grandParent = new MenuButton(grandParentName.Trim()); } SetActionToMenu(grandParent, grandParentAction); Menu.Add(grandParent); }; }