public ToolBarSettingsGump(ToolbarEntry entry)
            : base()
        {
            m_Entry = entry;

            Closable = false;
            Disposable = true;
            Dragable = true;
            Resizable = false;

            AddPage(0);

            AddBackground(0, 0, 475, 525, 3600);
            AddBackground(162, 30, 150, 40, 9270);
            AddHtml(0,40,475,20,Colorize(Center("Toolbar Settings"), "ffffff"),false, false);

            AddBackground(235, 95, 225, 200, 9270);
            AddLabel(250, 75, 1152, "Login Options:");
            AddCheck(255, 115, 210, 211, entry.BooleanOptions[0], 0); AddLabel(285, 115, 1152, "Load Toolbar");
            AddCheck(255, 145, 210, 211, entry.BooleanOptions[2], 2); AddLabel(285, 145, 1152, "Page Command");
            AddCheck(255, 175, 210, 211, entry.BooleanOptions[3], 3); AddLabel(285, 175, 1152, "Who Command");
            AddCheck(255, 205, 210, 211, entry.BooleanOptions[1], 1); AddLabel(285, 205, 1152, "SpeedBoost Command");
            AddCheck(255, 235, 210, 211, entry.BooleanOptions[4], 4); AddLabel(285, 235, 1152, "No preset commands");

            AddBackground(235, 320, 225, 200, 9270);
            AddLabel(245, 300, 1152, "Options:");
            AddLabel(250, 335, 1152, "Command Collumns:");AddLabel(413, 335, 1152, entry.ButtonWidth.ToString());
            AddButton(390, 340, 9706, 9707, 300, GumpButtonType.Reply, 0);
            AddButton(425, 340, 9702, 9703, 301, GumpButtonType.Reply, 0);
            AddLabel(250, 360, 1152, "Command Rows:");AddLabel(411, 360, 1152, entry.ButtonHeight.ToString());
            AddButton(390, 365, 9706, 9707, 400, GumpButtonType.Reply, 0);
            AddButton(425, 365, 9702, 9703, 401, GumpButtonType.Reply, 0);
            AddCheck(250, 385, 210, 211, entry.BooleanOptions[6], 6); AddLabel(280, 385, 1152, "Locked Location");
            AddLabel(250, 410, 1152, "X-Loc:"); AddTextEntry(300, 410, 170, 18, 1152, 1000, entry.X_Loc.ToString());
            AddLabel(250, 435, 1152, "Y-Loc:"); AddTextEntry(300, 435, 170, 18, 1152, 1001, entry.Y_Loc.ToString());

            AddBackground(10, 95, 225, 200, 9270);
            AddLabel(25, 75, 1152, "Custom Commands:");

            AddButton(171, 484, 247, 248, 1, GumpButtonType.Reply, 0);
            AddButton(17, 485, 242, 241, 0, GumpButtonType.Reply, 0);

            for (int page = 1; page < 6; page++)
            {
                AddPage(page);

                for (int i = 0; i < 6; i++)
                {
                    int loc = i + (page - 1) * 6;
                    AddLabel(25, 115 + 25 * i, 1152, (loc + 1).ToString());

                    AddTextEntry(45, 115 + 25 * i, 170, 18, 1152, loc, loc < entry.CustomCommands.Count ? entry.CustomCommands[loc] : "");
                    AddImageTiled(45, 133 + 25 * i, 170, 2, 2700);
                }

                if (page < 5)
                {
                    AddLabel(170, 295, 1152, "Next");
                    AddButton(205, 300, 9762, 9763, 0, GumpButtonType.Page, page + 1);
                }
                if (page > 1)
                {
                    AddLabel(45, 295, 1152, "Previous");
                    AddButton(20, 300, 9766, 9767, 0, GumpButtonType.Page, page - 1);
                }
            }
        }
        public ToolbarGump(ToolbarEntry entry, Mobile m)
            : base(entry.X_Loc, entry.Y_Loc)
        {
            PlayerMobile pm = (PlayerMobile)m;
            if(pm == null)
                return;

            m_Entry = entry;

            Closable = false;
            Disposable = true;
            Dragable = !entry.BooleanOptions[6];
            Resizable = false;

            if (entry.BooleanOptions[(int)Booleans.NoPresetCommands])
                m_MaxLevel = 0;
            else
                switch (pm.AccessLevel)
                {
                    case AccessLevel.Administrator:
                    case AccessLevel.Developer:
                    case AccessLevel.Owner:
                        m_MaxLevel = SunnyToolbar.BaseCommands.Length; break;

                    case AccessLevel.Seer:
                    case AccessLevel.GameMaster:
                        m_MaxLevel = 8; break;

                    case AccessLevel.Counselor:
                        m_MaxLevel = 4; break;
                }

            AddPage(0);
            int button = 0;
            int xpos = 10;
            int ypos = 15;
            int height = entry.ButtonHeight * 40 + 20;
            int width = entry.ButtonWidth * 110 + 25;
            bool locs = entry.BooleanOptions[(int)Booleans.ShowLocations];
            int locsextra = 460;
            int pages = (int)Math.Ceiling((double)(m_MaxLevel + entry.CustomCommands.Count) / (entry.ButtonHeight * entry.ButtonWidth));

            AddBackground(0, locsextra, width, height, 3600);
            AddBackground(width, 33 + locsextra, 45, 45, 3600);
            AddBackground(width, locsextra, 45, 45, 3600);
            AddBackground(width + 45, 33 + locsextra, 45, 45, 3600);
            AddBackground(width + 45, locsextra, 45, 45, 3600);
            AddButton(width + 57, 16 + locsextra,  2118, 2117, 1000, GumpButtonType.Reply, 0);
            AddButton(width + 56, 51 + locsextra, locs ? 2223 : 2224, locs ? 2223 : 2224, 2000, GumpButtonType.Reply, 0);

            if (locs)
            {
                AddBackground(width+ 90, 0, 165, 460, 3600);
                for (int i = 0; i < 10; i++)
                    GenerateButton(width + 100, 15 + i *40, entry.Locations[i].Name, i + 100, false);

                GenerateButton(width + 100, 415, "Edit Locs", 3000, false);
            }

            for (int page = 1; page < pages +1; page++)
            {
                AddPage(page);
                if (page < pages )
                    AddButton(width + 12, 16 + locsextra, 55, 55, 0, GumpButtonType.Page, page + 1);
                if (page != 1)
                    AddButton(width + 12, 49 + locsextra, 56, 56, 0, GumpButtonType.Page, page - 1);

                for (int i = 0; i < entry.ButtonHeight; i++)
                {
                    xpos = 10;
                    for (int j = 0; j < entry.ButtonWidth; j++)
                    {
                        int custombutt = button - m_MaxLevel;

                        if (button < m_MaxLevel)
                            GenerateButton(xpos, ypos + locsextra, SunnyToolbar.BaseCommands[button], button + 1, true);

                        else if (custombutt < entry.CustomCommands.Count)
                            GenerateButton(xpos, ypos + locsextra, entry.CustomCommands[custombutt], button + 1, true);

                        button++;
                        xpos += 110;
                    }
                    ypos += 40;
                }
                ypos = 15;
            }
        }
        public ToolBarLocsGump(ToolbarEntry entry)
            : base()
        {
            m_Entry = entry;

            Closable = false;
            Disposable = true;
            Dragable = true;
            Resizable = false;

            AddPage(0);
            AddBackground(0, 0, 241, 460, 3600);
            for (int i = 0; i < 10; i++)
            {
                AddBackground(10, 15 + i * 40, 140, 40, 9270);
                AddButton(150, 23 + i * 40, 4014, 4015, i, GumpButtonType.Reply, 0);
                AddButton(185, 23 + i * 40, 4029, 4030, i + 10, GumpButtonType.Reply, 0);
                AddTextEntry(20, 24 + i * 40, 118, 20, 1152, i, m_Entry.Locations[i].Name);
            }
            AddButton(84, 419, 247, 248, 100, GumpButtonType.Reply, 0);
        }
        private static void Toolbar_OnCommand(CommandEventArgs e)
        {
            Mobile m = e.Mobile;
            ToolbarEntry entry = null;

            if (!EntryCollection.TryGetValue(m, out entry))
                entry = new ToolbarEntry(m);

            m.CloseGump(typeof(ToolbarGump));
            m.SendGump(new ToolbarGump(entry, m));
        }