Пример #1
0
        private void mnColCustomClick(object sender, EventArgs e)
        {
            TMainMenu.TTBXItem mi = (TMainMenu.TTBXItem)sender;
            int bid  = Utils.ConvertTagToInt(mi.Tag) & 0xffff;
            int user = Utils.ConvertTagToInt(mi.Tag) >> 16;

            mi.Checked = true;
            ((TMainMenu.TTBXCustomItem)mi.OwnerItem).Checked = true;
            // die Zeile deshalb, weil radioitem nur im aktuellen menu funktioniert
            //	if (lastitem != NULL)
            //        lastitem.Checked = false;
            lastitem = mi;
            //	mnColUserDef[user].Caption = xml_config.arBonuses[bid].Names[0];
            vtItems.AllColumns[4 + user].Text = Unit.xml_config.arBonuses[bid].Names[0];
            UserDefId[user] = bid;
            // Speichere den letzten benutzerdefinierten Wert in Registry
            Utils.SetRegistryString("UserDefinedCol" + (user).ToString(), Unit.xml_config.arBonuses[bid].id);
            // Und die Anzeige updaten
            vtItems.Refresh();
        }
Пример #2
0
        //---------------------------------------------------------------------------

        private void btNewClick(object sender, EventArgs e)
        {
            // Hier ist einiges zu tun
            // Erstmal einen Namen besorgen
            TApplication.Instance.CreateForm(out Unit.frmNewName);
            DialogResult ret = Unit.frmNewName.ShowDialog();

            if ((ret == DialogResult.OK) && (Unit.frmNewName.tbName.Text.Length > 0))
            {
                // Neuen Menueintrag erzeugen
                Debug.Assert(CraftMenu != null);
                int idx = Unit.xml_config.arMenuItems.Length;
                Unit.xml_config.arMenuItems.Length++;
                Unit.xml_config.arMenuItems.Array[idx].bPricing = true;
                Unit.xml_config.arMenuItems.Array[idx].Name     = Unit.frmNewName.tbName.Text;
                Unit.xml_config.arMenuItems.Array[idx].Group    = CraftMenu.Name;
                string dataPath;
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    dataPath = Utils.IncludeTrailingPathDelimiter(ApplicationDeployment.CurrentDeployment.DataDirectory);
                }
                else
                {
                    dataPath = Utils.IncludeTrailingPathDelimiter(Path.GetDirectoryName(Application.ExecutablePath));
                }
                Unit.xml_config.arMenuItems.Array[idx].FileName = dataPath + "options\\sc_" + Unit.frmNewName.tbName.Text + ".xml";
                TMainMenu.TTBXItem NewItem = new TMainMenu.TTBXItem();
                Debug.Assert(NewItem != null);
                NewItem.Text       = Unit.frmNewName.tbName.Text;
                NewItem.Tag        = idx;
                NewItem.GroupIndex = Utils.ConvertTagToInt(CraftMenu.Tag);
                NewItem.Click     += Unit.frmMain.mnUserOptionClick;
                CraftMenu.DropDownItems.Add(NewItem);
                cbPriceModel.Add(Unit.frmNewName.tbName.Text, -1, idx);
                cbPriceModel.SelectData(idx);
            }
            Unit.frmNewName.Dispose();
        }
Пример #3
0
        //---------------------------------------------------------------------------
        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);
        }