예제 #1
0
파일: Menu.cs 프로젝트: CjShu/PortAIOCommon
        /// <summary>
        ///     The drawing event.
        /// </summary>
        /// <param name="args">
        ///     The event args.
        /// </param>
        internal void OnDraw(EventArgs args)
        {
            if (!this.Visible)
            {
                return;
            }

            var childs = this.Children.ToArray();
            var items  = this.Items.ToArray();

            Drawing.Direct3DDevice.SetRenderState(RenderState.AlphaBlendEnable, true);

            MenuDrawHelper.DrawBox(
                this.Position,
                this.Width,
                this.Height,
                (childs.Length > 0 && childs[0].Visible || items.Length > 0 && items[0].Visible)
                    ? MenuSettings.ActiveBackgroundColor
                    : MenuSettings.BackgroundColor,
                1,
                System.Drawing.Color.Black);

            var style = this.Style;

            var font = MenuDrawHelper.GetFont(style);

            font.DrawText(
                null,
                (this.DisplayName),
                new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.VerticalCenter,
                this.Color);

            font.DrawText(
                null,
                ">",
                new Rectangle((int)this.Position.X - 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.Right | FontDrawFlags.VerticalCenter,
                this.Color);

            //Draw the menu submenus
            foreach (var child in childs.ToArray().Where(child => child.Visible))
            {
                child.OnDraw(args);
            }

            //Draw the items
            for (var i = items.Length - 1; i >= 0; i--)
            {
                var item = items[i];
                if (item.Visible)
                {
                    item.OnDraw();
                }
            }
        }
예제 #2
0
        /// <summary>
        ///     The drawing event.
        /// </summary>
        /// <param name="args">
        ///     The event args.
        /// </param>
        internal void OnDraw(EventArgs args)
        {
            if (!this.Visible)
            {
                return;
            }

            Drawing.Direct3DDevice.SetRenderState(RenderState.AlphaBlendEnable, true);
            MenuDrawHelper.DrawBox(
                this.Position,
                this.Width,
                this.Height,
                (this.Children.Count > 0 && this.Children[0].Visible || this.Items.Count > 0 && this.Items[0].Visible)
                    ? MenuSettings.ActiveBackgroundColor
                    : MenuSettings.BackgroundColor,
                1,
                System.Drawing.Color.Black);

            MenuDrawHelper.Font.DrawText(
                null,
                MultiLanguage._(this.DisplayName),
                new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.VerticalCenter,
                this.Color);
            MenuDrawHelper.Font.DrawText(
                null,
                ">",
                new Rectangle((int)this.Position.X - 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.Right | FontDrawFlags.VerticalCenter,
                this.Color);

            //Draw the menu submenus
            foreach (var child in this.Children.Where(child => child.Visible))
            {
                child.OnDraw(args);
            }

            //Draw the items
            for (var i = this.Items.Count - 1; i >= 0; i--)
            {
                var item = this.Items[i];
                if (item.Visible)
                {
                    item.OnDraw();
                }
            }
        }
예제 #3
0
        private static void Drawing_OnDraw(EventArgs args)
        {
            if (Info.Item("水印").GetValue <bool>() && DrawWaterMark)
            {
                MenuDrawHelper.DrawBox(
                    new Vector2(0, Drawing.Height * 48f / 100),
                    Drawing.Width,
                    Drawing.Height * 5 / 100,
                    Color.Black,
                    1,
                    Color.Goldenrod);

                WaterMarkFont.DrawText(null, "FrozenGJ脚本  致力于做到最好!",
                                       Drawing.Width * 40 / 100,
                                       Drawing.Height * 49 / 100,
                                       new ColorBGRA(Color.Goldenrod.R, Color.Goldenrod.G, Color.Goldenrod.B, Color.Goldenrod.A));
            }
        }
예제 #4
0
        /// <summary>
        ///     The drawing event.
        /// </summary>
        /// <param name="args">
        ///     The event args.
        /// </param>
        internal void OnDraw(EventArgs args)
        {
            if (!this.Visible)
            {
                return;
            }

            Drawing.Direct3DDevice.SetRenderState(RenderState.AlphaBlendEnable, true);
            MenuDrawHelper.DrawBox(
                this.Position,
                this.Width,
                this.Height,
                (this.Children.Count > 0 && this.Children[0].Visible || this.Items.Count > 0 && this.Items[0].Visible)
                    ? MenuSettings.ActiveBackgroundColor
                    : MenuSettings.BackgroundColor,
                1,
                System.Drawing.Color.Black);

            var style = this.Style;

            style &= ~FontStyle.Strikeout;
            style &= ~FontStyle.Underline;

            var font = MenuDrawHelper.GetFont(style);

            font.DrawText(
                null,
                MultiLanguage._(this.DisplayName),
                new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.VerticalCenter,
                this.Color);
            font.DrawText(
                null,
                ">",
                new Rectangle((int)this.Position.X - 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.Right | FontDrawFlags.VerticalCenter,
                this.Color);

            var textWidth = font.MeasureText(null, MultiLanguage._(this.DisplayName));

            if ((this.Style & FontStyle.Strikeout) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    1f,
                    System.Drawing.Color.FromArgb(this.Color.A, this.Color.R, this.Color.G, this.Color.B));
            }

            if ((this.Style & FontStyle.Underline) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    1f,
                    System.Drawing.Color.FromArgb(this.Color.A, this.Color.R, this.Color.G, this.Color.B));
            }

            //Draw the menu submenus
            foreach (var child in this.Children.Where(child => child.Visible))
            {
                child.OnDraw(args);
            }

            //Draw the items
            for (var i = this.Items.Count - 1; i >= 0; i--)
            {
                var item = this.Items[i];
                if (item.Visible)
                {
                    item.OnDraw();
                }
            }
        }
예제 #5
0
        /// <summary>
        ///     On draw event.
        /// </summary>
        internal void OnDraw()
        {
            var s = MultiLanguage._(this.DisplayName);

            MenuDrawHelper.DrawBox(
                this.Position,
                this.Width,
                this.Height,
                MenuSettings.BackgroundColor,
                1,
                System.Drawing.Color.Black);

            if (this.DrawingTooltip)
            {
                MenuDrawHelper.DrawToolTipText(
                    new Vector2(this.Position.X + this.Width, this.Position.Y),
                    this,
                    this.TooltipColor);
            }

            var style = this.FontStyle;

            style &= ~FontStyle.Strikeout;
            style &= ~FontStyle.Underline;

            var font = MenuDrawHelper.GetFont(style);

            switch (this.ValueType)
            {
            case MenuValueType.Boolean:
                MenuDrawHelper.DrawOnOff(
                    this.GetValue <bool>(),
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);
                break;

            case MenuValueType.Slider:
                MenuDrawHelper.DrawSlider(this.Position, this);
                break;

            case MenuValueType.KeyBind:
                var val = this.GetValue <KeyBind>();

                if (this.Interacting)
                {
                    s = MultiLanguage._("Press new key(s)");
                }

                if (val.Key != 0)
                {
                    var x = !string.IsNullOrEmpty(this.Tooltip)
                                    ? (int)this.Position.X + this.Width - this.Height
                            - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width - 35
                                    : (int)this.Position.X + this.Width - this.Height
                            - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width - 10;

                    font.DrawText(
                        null,
                        "[" + Utils.KeyToText(val.Key) + "]",
                        new Rectangle(x, (int)this.Position.Y, this.Width, this.Height),
                        FontDrawFlags.VerticalCenter,
                        new ColorBGRA(1, 169, 234, 255));
                }

                if (val.SecondaryKey != 0)
                {
                    var x_secondary = !string.IsNullOrEmpty(this.Tooltip)
                                              ? (int)this.Position.X + this.Width - this.Height
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width / 4
                                      - font.MeasureText("[" + Utils.KeyToText(val.SecondaryKey) + "]").Width
                                      - 35
                                              : (int)this.Position.X + this.Width - this.Height
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width
                                      - font.MeasureText("[" + Utils.KeyToText(val.Key) + "]").Width / 4
                                      - font.MeasureText("[" + Utils.KeyToText(val.SecondaryKey) + "]").Width
                                      - 10;

                    font.DrawText(
                        null,
                        "[" + Utils.KeyToText(val.SecondaryKey) + "]",
                        new Rectangle(x_secondary, (int)this.Position.Y, this.Width, this.Height),
                        FontDrawFlags.VerticalCenter,
                        new ColorBGRA(1, 169, 234, 255));
                }

                MenuDrawHelper.DrawOnOff(
                    val.Active,
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);

                break;

            case MenuValueType.Integer:
                var intVal = this.GetValue <int>();
                MenuDrawHelper.Font.DrawText(
                    null,
                    intVal.ToString(),
                    new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                    FontDrawFlags.VerticalCenter | FontDrawFlags.Right,
                    new ColorBGRA(255, 255, 255, 255));
                break;

            case MenuValueType.Color:
                var colorVal = this.GetValue <System.Drawing.Color>();
                MenuDrawHelper.DrawBox(
                    this.Position + new Vector2(this.Width - this.Height, 0),
                    this.Height,
                    this.Height,
                    colorVal,
                    1,
                    System.Drawing.Color.Black);
                break;

            case MenuValueType.Circle:
                var circleVal = this.GetValue <Circle>();
                MenuDrawHelper.DrawBox(
                    this.Position + new Vector2(this.Width - this.Height * 2, 0),
                    this.Height,
                    this.Height,
                    circleVal.Color,
                    1,
                    System.Drawing.Color.Black);
                MenuDrawHelper.DrawOnOff(
                    circleVal.Active,
                    new Vector2(this.Position.X + this.Width - this.Height, this.Position.Y),
                    this);
                break;

            case MenuValueType.StringList:
                var slVal = this.GetValue <StringList>();

                var t = slVal.SList[slVal.SelectedIndex];

                MenuDrawHelper.DrawArrow(
                    "<<",
                    this.Position + new Vector2(this.Width - this.Height * 2, 0),
                    this,
                    System.Drawing.Color.Black);
                MenuDrawHelper.DrawArrow(
                    ">>",
                    this.Position + new Vector2(this.Width - this.Height, 0),
                    this,
                    System.Drawing.Color.Black);

                MenuDrawHelper.Font.DrawText(
                    null,
                    MultiLanguage._(t),
                    new Rectangle(
                        (int)this.Position.X - 5 - 2 * this.Height,
                        (int)this.Position.Y,
                        this.Width,
                        this.Height),
                    FontDrawFlags.VerticalCenter | FontDrawFlags.Right,
                    new ColorBGRA(255, 255, 255, 255));
                break;
            }

            if (!string.IsNullOrEmpty(this.Tooltip))
            {
                MenuDrawHelper.DrawToolTipButton(new Vector2(this.Position.X + this.Width, this.Position.Y), this);
            }

            font.DrawText(
                null,
                s,
                new Rectangle((int)this.Position.X + 5, (int)this.Position.Y, this.Width, this.Height),
                FontDrawFlags.VerticalCenter,
                this.FontColor);

            var textWidth = font.MeasureText(null, MultiLanguage._(this.DisplayName));

            if ((this.FontStyle & FontStyle.Strikeout) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 2f),
                    1f,
                    System.Drawing.Color.FromArgb(
                        this.FontColor.A,
                        this.FontColor.R,
                        this.FontColor.G,
                        this.FontColor.B));
            }

            if ((this.FontStyle & FontStyle.Underline) != 0)
            {
                Drawing.DrawLine(
                    this.Position.X + 5,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    this.Position.X + 5 + textWidth.Width,
                    this.Position.Y + (MenuSettings.MenuItemHeight / 1.5f),
                    1f,
                    System.Drawing.Color.FromArgb(
                        this.FontColor.A,
                        this.FontColor.R,
                        this.FontColor.G,
                        this.FontColor.B));
            }
        }