Exemple #1
0
        /// <summary>
        /// X軸として描画
        /// </summary>
        /// <param name="context"></param>
        void drawAxisX(IDrawContext context)
        {
            //軸線
            var startPos = new PointF(context.PlotArea.Left, context.PlotArea.Bottom);
            var endPos   = new PointF(context.PlotArea.Right, context.PlotArea.Bottom);

            context.DrawLine(startPos, endPos, 1, Parameter.Color);

            //キャプション
            context.DrawString(startPos.X, startPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMin), StringAlignment.Middle, StringAlignment.Near);
            context.DrawString(endPos.X, endPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMax), StringAlignment.Middle, StringAlignment.Near);

            //途中の線とキャプション
            if (TickEnumerator != null)
            {
                foreach (var tickInfo in TickEnumerator(this))
                {
                    var c = tickInfo.Item2 ? Parameter.WideGridColor : Parameter.NarrowGridColor;
                    var e = tickInfo.Item2 ? Parameter.DrawWideGrid : Parameter.DrawNarrowGrid;
                    var w = tickInfo.Item2 ? Parameter.DrawWideTickCaption : Parameter.DrawNarrowTickCaption;
                    var x = LogicalValueToPhysicalValue(tickInfo.Item1, context.PlotArea.Location);
                    if (e)
                    {
                        context.DrawLine(new PointF(x, context.PlotArea.Top), new PointF(x, context.PlotArea.Bottom), 1, c);
                    }
                    if (w)
                    {
                        context.DrawString(x, context.PlotArea.Bottom, Parameter.Font.Height, c, Translator(tickInfo.Item1), StringAlignment.Middle, StringAlignment.Near);
                    }
                }
            }
        }
Exemple #2
0
        public virtual void DrawInfo(IDrawContext context)
        {
            Vector2 position = new Vector2(Bounds.Right + 2, Bounds.Top);

            context.DrawString(GlobalContent.Default.InfoFont, ClickState.ToString(), position, Color.Yellow);
            position += new Vector2(0, 20 + 4);
            context.DrawString(GlobalContent.Default.InfoFont, IsEnabled ? "Enabled": "Not enabled", position, Color.Yellow);
        }
        public override void DrawContent(IDrawContext context)
        {
            const int padding         = 2;
            const int distanceToImage = 10;
            const int lineHeight      = 20;

            context.Draw(image, new Vector2(Bounds.Left, Bounds.Top), Color.White);
            int left = Bounds.Left + image.Width + distanceToImage;
            int top  = Bounds.Top + padding;

            context.DrawString(descriptionFont, WeaponSettings.Name, new Vector2(left, top), Color.Black);
            top += lineHeight;
            context.DrawString(descriptionFont, $"{WeaponSettings.Price:#,##0}e", new Vector2(left, top), Color.Black);
            base.DrawContent(context);
        }
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null) builder = new StringBuilder();

            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var bounds = new Rect(textBlock.RenderSize);
            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;
            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, textBlock.FontStretch,
                        textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                        Color.White, textBlock.Padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y) break;
            }
        }
        void DrawHeader(IDrawContext context)
        {
            const int   HeaderHeight   = 60;
            const float BetweenColumns = 80;
            const float BetweenRows    = 20;
            const float Top            = 10;
            const float Left           = 10;
            var         view           = View;
            var         topLeftView    = new Vector2(view.Left, view.Top);

            context.FillRectangle(new Rectangle(view.Left, view.Top, view.Width, HeaderHeight), new Color(Color.Black, 0.2f));
            context.DrawString(GlobalContent.Default.HudFont, "Health", topLeftView + new Vector2(Left, Top), Color.Yellow);
            context.DrawString(GlobalContent.Default.HudFont, Health.ToString("#,##0"), topLeftView + new Vector2(Left, Top + BetweenRows), Color.Yellow);
            context.DrawString(GlobalContent.Default.HudFont, "Amount", topLeftView + new Vector2(Left + BetweenColumns, Top), Color.Yellow);
            context.DrawString(GlobalContent.Default.HudFont, Amount.ToString("#,##0"), topLeftView + new Vector2(Left + BetweenColumns, Top + BetweenRows), Color.Yellow);
        }
Exemple #6
0
        /// <summary>
        /// Y軸として描画
        /// </summary>
        /// <param name="context"></param>
        void drawAxisY(IDrawContext context)
        {
            //軸線
            var startPos = new PointF();
            var endPos   = new PointF();
            var hAlign   = StringAlignment.Far;

            startPos.Y = context.PlotArea.Top;
            endPos.Y   = context.PlotArea.Bottom;
            if (Type == AxisType.YLeft)
            {
                startPos.X = endPos.X = context.PlotArea.Left;
                hAlign     = StringAlignment.Far;
            }
            else
            {
                startPos.X = endPos.X = context.PlotArea.Right;
                hAlign     = StringAlignment.Near;
            }
            context.DrawLine(startPos, endPos, 1, Parameter.Color);

            //キャプション
            context.DrawString(startPos.X, startPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMax), hAlign, StringAlignment.Middle);
            context.DrawString(endPos.X, endPos.Y, Parameter.Font.Height, Parameter.Color, Translator(LogicalMin), hAlign, StringAlignment.Middle);

            //途中の線とキャプション
            if ((TickEnumerator != null))
            {
                foreach (var tickInfo in TickEnumerator(this))
                {
                    var c = tickInfo.Item2 ? Parameter.WideGridColor : Parameter.NarrowGridColor;
                    var e = tickInfo.Item2 ? Parameter.DrawWideGrid : Parameter.DrawNarrowGrid;
                    var w = tickInfo.Item2 ? Parameter.DrawWideTickCaption : Parameter.DrawNarrowTickCaption;
                    var y = LogicalValueToPhysicalValue(tickInfo.Item1, context.PlotArea.Location);
                    if (e)
                    {
                        context.DrawLine(new PointF(context.PlotArea.Left, y), new PointF(context.PlotArea.Right, y), 1, c);
                    }
                    if (w)
                    {
                        context.DrawString(startPos.X, y, Parameter.Font.Height, c, Translator(tickInfo.Item1), hAlign, StringAlignment.Middle);
                    }
                }
            }
        }
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            // 文字色を白として描画します。
            drawContext.DrawString(
                new Rect(textBlock.RenderSize), font, textBlock.Text, textBlock.FontStretch,
                textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                Color.White, textBlock.Padding);
        }
Exemple #8
0
 public override void Draw(IDrawContext context)
 {
     context.Draw(texture, Center, sourceRectangle: null, MouseHoverColorTransition.Current, 0, Origin, Vector2.One, SpriteEffects.None, 0);
     if (Globals.ShowMouseCoordinates)
     {
         context.DrawString(GlobalContent.Default.CoordinatesFont, $"{Bounds.Left}:{Bounds.Top}-{Bounds.Right}:{Bounds.Bottom}",
                            new Vector2(Bounds.Left, Bounds.Top - 20), Color.Yellow);
     }
     Weapon?.Draw(context);
     base.Draw(context);
 }
Exemple #9
0
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;

            if (font == null)
            {
                return;
            }

            // 文字色を白として描画します。
            drawContext.DrawString(
                new Rect(textBlock.RenderSize), font, textBlock.Text, textBlock.FontStretch,
                textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                Color.White, textBlock.Padding);
        }
Exemple #10
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (stringBuilder.Length == 0) return;

            var font = Font ?? Screen.Font;
            if (font == null) return;

            // TODO: 面倒なのでキャレットをそのまま文字連結していますが、本当はダメ。
            drawContext.DrawString(
                new Rect(RenderSize), font, stringBuilder.ToString() + "|", FontStretch,
                HorizontalAlignment.Left, VerticalAlignment.Top,
                ForegroundColor, Padding);
        }
Exemple #11
0
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null)
            {
                builder = new StringBuilder();
            }

            var font = textBlock.Font ?? textBlock.Screen.Font;

            if (font == null)
            {
                return;
            }

            var bounds = new Rect(textBlock.RenderSize);

            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;

            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, textBlock.FontStretch,
                                           textBlock.TextHorizontalAlignment, textBlock.TextVerticalAlignment,
                                           Color.White, textBlock.Padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y)
                {
                    break;
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// 描画処理の実施
        /// </summary>
        /// <param name="context"></param>
        public void Draw(IDrawContext context)
        {
            //位置決め
            var x = AxisX.LogicalValueToPhysicalValue(LogicalX, context.PlotArea.Location);
            var y = AxisY.LogicalValueToPhysicalValue(LogicalY, context.PlotArea.Location);

            //ラベル
            context.DrawString(x, y, 16, Color, Message, HolizontalAlign, VerticalAlign);
            //水平線
            if (DrawHolizontalLine)
            {
                context.DrawLine(new PointF(context.PlotArea.Left, y), new PointF(context.PlotArea.Right, y), 1, Color);
            }
            //垂直線
            if (DrawVerticalLine)
            {
                context.DrawLine(new PointF(x, context.PlotArea.Top), new PointF(x, context.PlotArea.Bottom), 1, Color);
            }
        }
        public override void Draw(IDrawContext drawContext, DrawingLayer drawingLayer)
        {
            var finalText = this.Parameters != null ? string.Format(this.Text, this.Parameters) : this.Text;
            var finalZoomFactor = drawingLayer.CameraMode == CameraMode.Fix ? 1.0f : drawContext.Camera.ZoomFactor;
            var finalVector = drawingLayer.CameraMode == CameraMode.Fix
                ? this.Position
                : this.Position
                    .Scale(drawContext.Camera.ZoomFactor)
                    .Translate(drawContext.Camera.GetSceneTranslationVector(drawingLayer.ParallaxScrollingVector));

            var param = new DrawStringParams
            {
                Text = finalText,
                Vector = finalVector,
                ZoomFactor = finalZoomFactor,
                DrawingFont = this.DrawingFont,
                Color = this.Color
            };

            drawContext.DrawString(param);
        }
Exemple #14
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (stringBuilder.Length == 0)
            {
                return;
            }

            var font = Font ?? Screen.Font;

            if (font == null)
            {
                return;
            }

            // TODO: 面倒なのでキャレットをそのまま文字連結していますが、本当はダメ。
            drawContext.DrawString(
                new Rect(RenderSize), font, stringBuilder.ToString() + "|", FontStretch,
                HorizontalAlignment.Left, VerticalAlignment.Top,
                ForegroundColor, Padding);
        }
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;

            if (font == null)
            {
                return;
            }

            var text         = textBlock.Text;
            var stretch      = textBlock.FontStretch;
            var padding      = textBlock.Padding;
            var fColor       = textBlock.ForegroundColor;
            var bColor       = textBlock.BackgroundColor;
            var bounds       = new Rect(textBlock.RenderSize);
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign       = textBlock.TextHorizontalAlignment;
            var vAlign       = textBlock.TextVerticalAlignment;

            // 影を描画します。
            var shadowOffset = textBlock.ShadowOffset;

            if (shadowOffset.X != 0 || shadowOffset.Y != 0)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                                       shadowOffset);
            }

            // 文字枠を描画します。
            if (0 < outlineWidth)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                                       new Vector2(-outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                                       new Vector2(-outlineWidth, outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                                       new Vector2(outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                                       new Vector2(outlineWidth, outlineWidth));
            }

            // 文字を描画します。
            drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, fColor, padding);
        }
        void DrawText(TextBlock textBlock, IDrawContext drawContext)
        {
            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var text = textBlock.Text;
            var stretch = textBlock.FontStretch;
            var padding = textBlock.Padding;
            var fColor = textBlock.ForegroundColor;
            var bColor = textBlock.BackgroundColor;
            var bounds = new Rect(textBlock.RenderSize);
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign = textBlock.TextHorizontalAlignment;
            var vAlign = textBlock.TextVerticalAlignment;

            // 影を描画します。
            var shadowOffset = textBlock.ShadowOffset;
            if (shadowOffset.X != 0 || shadowOffset.Y != 0)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    shadowOffset);
            }

            // 文字枠を描画します。
            if (0 < outlineWidth)
            {
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(-outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(-outlineWidth, outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(outlineWidth, -outlineWidth));
                drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, bColor, padding,
                    new Vector2(outlineWidth, outlineWidth));
            }

            // 文字を描画します。
            drawContext.DrawString(bounds, font, text, stretch, hAlign, vAlign, fColor, padding);
        }
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null)
            {
                builder = new StringBuilder();
            }

            var font = textBlock.Font ?? textBlock.Screen.Font;

            if (font == null)
            {
                return;
            }

            var stretch      = textBlock.FontStretch;
            var padding      = textBlock.Padding;
            var fColor       = textBlock.ForegroundColor;
            var bColor       = textBlock.BackgroundColor;
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign       = textBlock.TextHorizontalAlignment;
            var vAlign       = textBlock.TextVerticalAlignment;
            var shadowOffset = textBlock.ShadowOffset;

            var bounds = new Rect(textBlock.RenderSize);

            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;

            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 影を描画します。
                    if (shadowOffset.X != 0 || shadowOffset.Y != 0)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                                               shadowOffset);
                    }

                    // 文字枠を描画します。
                    if (0 < outlineWidth)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                                               new Vector2(-outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                                               new Vector2(-outlineWidth, outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                                               new Vector2(outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                                               new Vector2(outlineWidth, outlineWidth));
                    }

                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, fColor, padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y)
                {
                    break;
                }
            }
        }
 private void DrawLine(IDrawContext drawContext, Vector position, string text)
 {
     drawContext.DrawString(new DrawStringParams
     {
         Text = text,
         Vector = position,
         DrawingFont = this.font,
         Color = Color.White,
         ZoomFactor = 1.0f
     });
 }
        void DrawWrappedText(TextBlock textBlock, IDrawContext drawContext)
        {
            if (builder == null) builder = new StringBuilder();

            var font = textBlock.Font ?? textBlock.Screen.Font;
            if (font == null) return;

            var stretch = textBlock.FontStretch;
            var padding = textBlock.Padding;
            var fColor = textBlock.ForegroundColor;
            var bColor = textBlock.BackgroundColor;
            var outlineWidth = textBlock.TextOutlineWidth;
            var hAlign = textBlock.TextHorizontalAlignment;
            var vAlign = textBlock.TextVerticalAlignment;
            var shadowOffset = textBlock.ShadowOffset;

            var bounds = new Rect(textBlock.RenderSize);
            bounds.Height = textBlock.WrappedText.MaxMeasuredHeight;

            var wrappedText = textBlock.WrappedText;
            for (int i = 0; i < wrappedText.LineCount; i++)
            {
                // 行の文字列を取得します。
                wrappedText.GetLineText(i, builder);

                // 空行は文字列描画をスキップします。
                if (builder.Length != 0)
                {
                    // 影を描画します。
                    if (shadowOffset.X != 0 || shadowOffset.Y != 0)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            shadowOffset);
                    }

                    // 文字枠を描画します。
                    if (0 < outlineWidth)
                    {
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(-outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(-outlineWidth, outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(outlineWidth, -outlineWidth));
                        drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, bColor, padding,
                            new Vector2(outlineWidth, outlineWidth));
                    }

                    // 文字を描画します。
                    drawContext.DrawString(bounds, font, builder, stretch, hAlign, vAlign, fColor, padding);
                }

                // 描画領域を次の行の位置へ進めます。
                bounds.Y += textBlock.WrappedText.MaxMeasuredHeight;
                // 描画対象の領域を完全に越える行は描画しません。
                if (textBlock.RenderSize.Height <= bounds.Y) break;
            }
        }