private void mnColCustomCheckedChanged(object sender, EventArgs e) { TMainMenu.TTBXSubmenuItem pmi = (TMainMenu.TTBXSubmenuItem)sender; if (!pmi.Checked) { foreach (TMainMenu.TTBXItem mi in pmi.DropDownItems) { mi.Checked = false; } } }
//--------------------------------------------------------------------------- public TfrmManageDB() { InitializeComponent(); ((Bitmap)bnCancel.Image).MakeTransparent(); ((Bitmap)bnOk.Image).MakeTransparent(); //Hint: Can't be moved to designer code, because it would be a great hack into the designer to //reference non-constant static objects, that are only constructed at runtime. cbRealm.ImageList = Unit.frmMain.ImageList1; ZQuery.Connection = Unit.frmMain.ZConnection; iClass = -1; iBasePos = -1; iPosition = -1; iType = -1; iMinLevel = -1; iMinUtility = -1; iMaxLevel = 100; iMaxUtility = 1000; iOnlineDB = -1; sName = ""; bSaveDB = false; bSearchMode = false; SearchedItem = null; sExtensions = ""; int i; int j; for (i = 0; i < Unit.xml_config.nExtensions; i++) { if (Utils.GetRegistryInteger(Unit.xml_config.arExtensions[i].Name, 1, "\\Extensions") == 0) { if (sExtensions != "") { sExtensions = sExtensions + ","; } sExtensions = sExtensions + "'" + Unit.xml_config.arExtensions[i].id + "'"; } } // SuspendLayout does not work recursive, so to get better performance, we need to call it on every child // control which has its own childs but not on the leaves of this tree. TBXPopupMenu1.SuspendLayout(); for (i = 0; i < USER_COLS; i++) { mnColCustom[i] = (TMainMenu.TTBXSubmenuItem) this.FindComponent("miUser" + (i + 1).ToString()); mnColCustom[i].DropDown.SuspendLayout(); } // Benutzerdefinirtes Menü aufbauen // Lade die letzten benutzerdefinierten Werte for (i = 0; i < USER_COLS; i++) { UserDefId[i] = Unit.xml_config.GetBonusId(Utils.GetRegistryString("UserDefinedCol" + (i).ToString(), "")); if (UserDefId[i] < 0) { UserDefId[i] = i; // i, damit jeder einen anderen Defaultwert hat } } // Erstelle das Menü für die benutzerdefinierte Zeile for (i = 1; i < Unit.xml_config.nGroups; i++) { // Erst die Gruppen erzeugen for (j = 0; j < USER_COLS; j++) { TMainMenu.TTBXSubmenuItem mnItem = new TMainMenu.TTBXSubmenuItem(); mnItem.Text = Unit.xml_config.arGroups[i].Name; mnItem.Tag = i; mnItem.GroupIndex = 1; // mnItem.CheckOnClick = true; mnItem.CheckedChanged += new EventHandler(mnColCustomCheckedChanged); mnItem.DropDown.SuspendLayout(); mnColCustom[j].DropDownItems.Add(mnItem); } } for (i = 0; i < Unit.xml_config.nBonuses; i++) { // Und nun die Boni dort eintragen if ((Unit.xml_config.arBonuses[i].iRealm & Unit.player.Realm) != 0) { // Boni nur hinzufügen, wenn im Spielerrealm möglich for (j = 0; j < USER_COLS; j++) { if (Unit.xml_config.arBonuses[i].idGroup < 0) { string msg; msg = "Fehlerhafte Gruppenzuordnung für den Bonus: " + Unit.xml_config.arBonuses[i].Names[0]; MessageBox.Show(msg, "XML-Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } TMainMenu.TTBXSubmenuItem parent = (TMainMenu.TTBXSubmenuItem)mnColCustom[j].DropDownItems[Unit.xml_config.arBonuses[i].idGroup - 1]; TMainMenu.TTBXItem mnItem = new TMainMenu.TTBXItem(); mnItem.Text = Unit.xml_config.arBonuses[i].Names[0]; mnItem.Tag = (j << 16) | i; mnItem.GroupIndex = 2; mnItem.CheckOnClick = true; mnItem.Click += mnColCustomClick; parent.DropDownItems.Add(mnItem); if (UserDefId[j] == i) { mnItem.Checked = true; parent.Checked = true; vtItems.AllColumns[4 + j].Text = Unit.xml_config.arBonuses[i].Names[0]; } } } } for (i = 0; i < USER_COLS; i++) { foreach (TMainMenu.TTBXSubmenuItem mnItem in mnColCustom[i].DropDownItems) { mnItem.DropDown.ResumeLayout(false); } mnColCustom[i].DropDown.ResumeLayout(false); } TBXPopupMenu1.ResumeLayout(false); }