Exemplo n.º 1
0
        public virtual bool HighlightOption(int x, int y)
        {
            if (SelectedOption != null && SelectedOption.SubMenu != null && SelectedOption.SubMenu.HighlightOption(x, y))
            {
            }
            else if (x >= MenuBox.Left && x <= MenuBox.Right && y >= MenuBox.Top && y <= MenuBox.Bottom && Options.Count > 0)
            {
                SelectedOption = Options[(y - MenuBox.Top - 1) / OptionHeight];
            }

            else
            {
                SelectedOption = null;
            }

            Map.Invalidate();
            if (SelectedOption != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public void AddOption(MapMenuOption option)
 {
     Options.Add(option);
     CalculateSize();
 }
Exemplo n.º 3
0
        public virtual bool HighlightOption(int x, int y)
        {
            if (SelectedOption != null && SelectedOption.SubMenu != null && SelectedOption.SubMenu.HighlightOption(x, y)) { }
            else if (x >= MenuBox.Left && x <= MenuBox.Right && y >= MenuBox.Top && y <= MenuBox.Bottom && Options.Count > 0)
                SelectedOption = Options[(y - MenuBox.Top - 1) / OptionHeight];

            else
                SelectedOption = null;

            Map.Invalidate();
            if (SelectedOption != null) return true;
            else return false;
        }
Exemplo n.º 4
0
        public void Draw(Graphics g)
        {
            if (MenuBox.Right > Map.Right)
            {
                MenuBox.X -= MenuBox.Width;
            }
            using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(100, Color.Black)))
                g.FillRectangle(shadowBrush, MenuBox.X + 3, MenuBox.Y + 3, MenuBox.Width, MenuBox.Height);
            using (SolidBrush menuBrush = new SolidBrush(MenuColor))
                g.FillRectangle(menuBrush, MenuBox);
            using (Pen shadowPen = new Pen(Color.FromArgb(100, Color.Black)))
            {
                g.DrawLine(shadowPen, MenuBox.Left, MenuBox.Top, MenuBox.Left, MenuBox.Bottom);
                g.DrawLine(shadowPen, MenuBox.Left, MenuBox.Top, MenuBox.Right, MenuBox.Top);
            }


            foreach (MapMenuOption option in Options)
            {
                int optionYPosition = MenuBox.Y + OptionHeight * Options.IndexOf(option);
                if (option == SelectedOption && option.Selectable)
                {
                    using (SolidBrush invertMenu = new SolidBrush(FontColor))
                        g.FillRectangle(invertMenu, MenuBox.X, optionYPosition, MenuBox.Width, OptionHeight);
                    using (Font menuFont = new Font(FontName, FontSize))
                        using (SolidBrush invertFont = new SolidBrush(MenuColor))
                            g.DrawString(option.Text, menuFont, invertFont, MenuBox.X + XBuffer, optionYPosition);
                }
                else
                {
                    if (option.Toggled)
                    {
                        using (SolidBrush toggleBrush = new SolidBrush(ToggleColor))
                            g.FillRectangle(toggleBrush, MenuBox.X, optionYPosition, MenuBox.Width, OptionHeight);
                    }
                    using (Font menuFont = new Font(FontName, FontSize))
                        using (SolidBrush fontBrush = new SolidBrush(FontColor))
                            g.DrawString(option.Text, menuFont, fontBrush, MenuBox.X + XBuffer, optionYPosition);
                }

                if (option.SubMenu != null)
                {
                    using (AdjustableArrowCap subArrow = new AdjustableArrowCap(OptionHeight - 12, 3))
                        using (Pen arrowPen = new Pen(FontColor))
                        {
                            arrowPen.CustomEndCap = subArrow;
                            if (option == SelectedOption)
                            {
                                arrowPen.Color = MenuColor;
                            }
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            g.DrawLine(arrowPen, MenuBox.Right - subArrow.Height - 2, optionYPosition + OptionHeight / 2, MenuBox.Right - 2, optionYPosition + OptionHeight / 2);
                        }
                }
            }

            MapMenuOption autoShowSubMenu = null;

            if (Options.Count(option => option.OptionObject.GetType() == typeof(Battle)) == 1)
            {
                autoShowSubMenu = Options.First(option => option.OptionObject.GetType() == typeof(Battle));
            }
            else if (Options.Count(option => option.OptionObject.GetType() == typeof(List <Battle>)) > 0)
            {
                autoShowSubMenu = Options.First(option => option.OptionObject.GetType() == typeof(List <Battle>));
            }
            else if (Options.Count(option1 => option1.OptionObject.GetType() == typeof(Site)) == 1)
            {
                autoShowSubMenu = Options.First(option1 => option1.OptionObject.GetType() == typeof(Site));
            }
            else if (Options.Count(option1 => option1.OptionObject.GetType() == typeof(War)) == 1)
            {
                autoShowSubMenu = Options.First(option1 => option1.OptionObject.GetType() == typeof(War));
            }
            foreach (MapMenuOption option in Options)
            {
                int optionYPosition = MenuBox.Y + OptionHeight * Options.IndexOf(option);

                if (option.SubMenu != null)
                {
                    if (option == SelectedOption ||
                        (!Open && ((option == autoShowSubMenu) || (Options.Count == 1))))
                    {
                        option.SubMenu.MenuBox.Location = new Point(MenuBox.Right, optionYPosition);
                        if (option.SubMenu.MenuBox.Right > Map.Right)
                        {
                            option.SubMenu.MenuBox.X = MenuBox.X - option.SubMenu.MenuBox.Width;
                        }
                        option.SubMenu.Draw(g);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public void AddOption(MapMenuOption option)
 {
     Options.Add(option);
     CalculateSize();
 }