コード例 #1
0
 private GMenuItem FormatMenu(GMenuItem mi)
 {
     mi.FillAlpha     = 1f;
     mi.DefaultColor  = GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f);
     mi.OverColor     = GumpPaint.Blend(Color.SteelBlue, SystemColors.Control, 0.5f);
     mi.ExpandedColor = GumpPaint.Blend(Color.SteelBlue, SystemColors.Control, 0.5f);
     mi.SetHue(Hues.Load(1));
     return(mi);
 }
コード例 #2
0
 public void Remove(GMenuItem child)
 {
     if (child == this || !this.Contains(child))
     {
         return;
     }
     this.m_Children.Remove((Gump)child);
     child.Visible = false;
     this.Layout();
 }
コード例 #3
0
        private GMenuItem GetMenuFrom(ParamNode n, Action a, ActionHandler ah)
        {
            GMenuItem mi = n.Param == null ? new GMenuItem(n.Name) : (GMenuItem) new GParamMenu(n, ah, a);

            if (n.Nodes != null)
            {
                for (int index = 0; index < n.Nodes.Length; ++index)
                {
                    mi.Add(this.GetMenuFrom(n.Nodes[index], a, ah));
                }
            }
            return(this.FormatMenu(mi));
        }
コード例 #4
0
        private GMenuItem GetMenuFrom(ActionNode n)
        {
            GMenuItem mi1 = new GMenuItem(n.Name);

            for (int index = 0; index < n.Nodes.Count; ++index)
            {
                mi1.Add(this.GetMenuFrom((ActionNode)n.Nodes[index]));
            }
            for (int index1 = 0; index1 < n.Handlers.Count; ++index1)
            {
                ActionHandler actionHandler = (ActionHandler)n.Handlers[index1];
                GMenuItem     mi2           = (GMenuItem) new GNewActionMenu(this, this.m_Macro, actionHandler);
                for (int index2 = 0; actionHandler.Params != null && index2 < actionHandler.Params.Length; ++index2)
                {
                    mi2.Add(this.GetMenuFrom(actionHandler.Params[index2], (Action)null, actionHandler));
                }
                mi1.Add(this.FormatMenu(mi2));
            }
            return(this.FormatMenu(mi1));
        }
コード例 #5
0
        public void Layout()
        {
            int num1 = 0;

            Gump[] array = this.m_Children.ToArray();
            for (int index = 0; index < array.Length; ++index)
            {
                if (array[index] is GMenuItem)
                {
                    ++num1;
                }
            }
            int num2;
            int num3;

            if (this.m_DropDown)
            {
                num2 = 0;
                num3 = this.Height - 1;
            }
            else
            {
                Gump desktop = Gumps.Desktop;
                num2 = 124;
                num3 = 0;
                if (desktop != null)
                {
                    Point screen = this.PointToScreen(new Point(0, 0));
                    int   y      = desktop.PointToClient(screen).Y;
                    int   num4   = (desktop.Height - y - 1) / 23;
                    if (num4 < 1)
                    {
                        num4 = 1;
                    }
                    if (num4 < num1)
                    {
                        num3 = this.Height - (num1 - num4 + 1) * 23 - 1;
                    }
                    if (y + num3 < 0)
                    {
                        num3 = -y;
                    }
                }
            }
            for (int index = 0; index < array.Length; ++index)
            {
                GMenuItem gmenuItem = array[index] as GMenuItem;
                if (gmenuItem != null)
                {
                    if (gmenuItem.X != num2)
                    {
                        gmenuItem.X = num2;
                    }
                    if (gmenuItem.Y != num3)
                    {
                        gmenuItem.Y = num3;
                    }
                    num3 += 23;
                }
            }
        }
コード例 #6
0
 public bool Contains(GMenuItem child)
 {
     return(this.m_Children.IndexOf((Gump)child) >= 0);
 }
コード例 #7
0
        protected internal override void Render(int rx, int ry)
        {
            GMenuItem gmenuItem1 = Gumps.LastOver as GMenuItem;
            int       num1;
            bool      flag1;

            if (gmenuItem1 == null)
            {
                num1  = this.m_DefaultColor.ToArgb() & 16777215;
                flag1 = true;
            }
            else
            {
                GMenuItem gmenuItem2 = gmenuItem1;
                while (gmenuItem2 != null && gmenuItem2 != this)
                {
                    gmenuItem2 = gmenuItem2.Parent as GMenuItem;
                }
                flag1 = gmenuItem2 != this;
                num1  = !flag1 ? (gmenuItem1 != this ? this.m_ExpandedColor.ToArgb() & 16777215 : this.m_OverColor.ToArgb() & 16777215) : this.m_DefaultColor.ToArgb() & 16777215;
            }
            this.FillColor = num1;
            if (flag1)
            {
                if (this.Width != 120)
                {
                    this.Width = 120;
                }
                Gump[] array = this.m_Children.ToArray();
                for (int index = 0; index < array.Length; ++index)
                {
                    if (array[index] is GMenuItem)
                    {
                        array[index].Visible = false;
                    }
                }
            }
            else
            {
                bool   flag2 = false;
                Gump[] array = this.m_Children.ToArray();
                for (int index = 0; index < array.Length; ++index)
                {
                    if (array[index] is GMenuItem)
                    {
                        array[index].Visible = true;
                        flag2 = true;
                    }
                }
                int num2 = !flag2 || this.m_DropDown ? 120 : 125;
                if (this.Width != num2)
                {
                    this.Width = num2;
                }
                if (flag2 && this.m_MakeTopmost)
                {
                    this.BringToTop();
                }
                this.Layout();
            }
            base.Render(rx, ry);
        }
コード例 #8
0
        public GMacroEditorPanel(Macro m)
            : base(0, 0, 259, 230)
        {
            this.m_Macro   = m;
            this.m_CanDrag = false;
            this.m_NonRestrictivePicking = true;
            this.ShouldHitTest           = false;
            this.m_Ctrl          = new GSystemButton(10, 10, 40, 20, GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f), SystemColors.ControlText, "Ctrl", (IFont)Engine.GetUniFont(2));
            this.m_Alt           = new GSystemButton(49, 10, 40, 20, GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f), SystemColors.ControlText, "Alt", (IFont)Engine.GetUniFont(2));
            this.m_Shift         = new GSystemButton(88, 10, 42, 20, GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f), SystemColors.ControlText, "Shift", (IFont)Engine.GetUniFont(2));
            this.m_Ctrl.OnClick  = new OnClick(this.Ctrl_OnClick);
            this.m_Alt.OnClick   = new OnClick(this.Alt_OnClick);
            this.m_Shift.OnClick = new OnClick(this.Shift_OnClick);
            this.m_Ctrl.Tooltip  = (ITooltip) new Tooltip("Toggles the control key modifier", true);
            this.m_Alt.Tooltip   = (ITooltip) new Tooltip("Toggles the alt key modifier", true);
            this.m_Shift.Tooltip = (ITooltip) new Tooltip("Toggles the shift key modifier", true);
            this.m_Children.Add((Gump)this.m_Ctrl);
            this.m_Children.Add((Gump)this.m_Alt);
            this.m_Children.Add((Gump)this.m_Shift);
            this.UpdateModifiers();
            this.m_Children.Add((Gump) new GAlphaBackground(129, 10, 74, 20)
            {
                FillAlpha = 1f,
                FillColor = GumpColors.Window
            });
            GMacroKeyEntry gmacroKeyEntry = new GMacroKeyEntry(GMacroEditorPanel.GetKeyName(m.Key), 129, 10, 74, 20);

            gmacroKeyEntry.Tooltip = (ITooltip) new Tooltip("Press any key here to change the macro", true);
            this.m_Children.Add((Gump)gmacroKeyEntry);
            GSystemButton gsystemButton = new GSystemButton(10, 10, 40, 20, GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f), SystemColors.ControlText, "Delete", (IFont)Engine.GetUniFont(2));

            gsystemButton.SetBackColor(GumpPaint.Blend(Color.SteelBlue, SystemColors.Control, 0.25f));
            gsystemButton.InactiveColor = GumpPaint.Blend(Color.WhiteSmoke, SystemColors.Control, 0.5f);
            gsystemButton.Tooltip       = (ITooltip) new Tooltip("Deletes the entire macro", true);
            gsystemButton.OnClick       = new OnClick(this.Delete_OnClick);
            gsystemButton.X             = this.Width - 10 - gsystemButton.Width;
            this.m_Children.Add((Gump)gsystemButton);
            this.FillAlpha = 0.15f;
            for (int index = 0; index < m.Actions.Count; ++index)
            {
                try
                {
                    Action action = m.Actions[index];
                    if (action.Handler != null)
                    {
                        ActionHandler handler   = action.Handler;
                        GMainMenu     gmainMenu = new GMainMenu(10, 35 + index * 23);
                        GMenuItem     mi        = (GMenuItem) new GActionMenu(this, m, action);
                        gmainMenu.Add(this.FormatMenu(mi));
                        if (handler.Params == null)
                        {
                            GAlphaBackground galphaBackground = new GAlphaBackground(129, 35 + index * 23, 120, 24);
                            galphaBackground.FillAlpha = 1f;
                            galphaBackground.FillColor = GumpColors.Window;
                            this.m_Children.Add((Gump)galphaBackground);
                            IHue     windowText = GumpHues.WindowText;
                            GTextBox gtextBox   = (GTextBox) new GMacroParamEntry(action, action.Param, galphaBackground.X + 4, galphaBackground.Y, galphaBackground.Width - 4, galphaBackground.Height);
                            gtextBox.MaxChars = 239;
                            this.m_Children.Add((Gump)gtextBox);
                        }
                        else if (handler.Params.Length != 0)
                        {
                            GMenuItem menuFrom = this.GetMenuFrom(new ParamNode(GMacroEditorPanel.Find(action.Param, handler.Params) ?? action.Param, handler.Params), action, handler);
                            menuFrom.DropDown = index == m.Actions.Count - 1;
                            gmainMenu.Add(menuFrom);
                        }
                        gmainMenu.LeftToRight = true;
                        this.m_Children.Add((Gump)gmainMenu);
                    }
                }
                catch
                {
                }
            }
            GMainMenu gmainMenu1 = new GMainMenu(10, 35 + m.Actions.Count * 23);
            GMenuItem menuFrom1  = this.GetMenuFrom(ActionHandler.Root);

            menuFrom1.Tooltip  = (ITooltip) new Tooltip("To create a new instruction pick one from the menu below", false, 200);
            menuFrom1.Text     = "New...";
            menuFrom1.DropDown = true;
            gmainMenu1.Add(this.FormatMenu(menuFrom1));
            gmainMenu1.LeftToRight = true;
            this.m_Children.Add((Gump)gmainMenu1);
        }