Beispiel #1
0
 public static void WriteCharacter(this SKCanvas g, string coloredCharacter, SKPaint font, float x, float y)
 {
     //font.Typeface = SKTypeface.FromFamilyName("Courier New",10,20,SKFontStyleSlant.Upright);
     //font.TextSize = 20;
     //g.DrawText("asdf", 20, 20, font);
     font.Color = ColorList.GetColor(coloredCharacter.Substring(1));
     g.DrawText(coloredCharacter[0].ToString(), x, y + font.TextSize, font);
 }
Beispiel #2
0
        private void OnClick(object sender, EventArgs e)
        {
            if (!colorList.IsStatic(index))
            {
                Color color = colorList.GetColor(index);

                if (Frame.UIService.ShowColorDialog(ref color) == Substitutes.DialogResult.OK)
                {
                    colorList.SetColor(index, color);
                    propertyPage.Refresh(colorList);
                }
            }
        }
        public static void PaintBackground(this Graphics g, string backgroundColor, Font font, float x, float y)
        {
            var black  = ColorList.GetColor("BLACK");
            var yellow = ColorList.GetColor("YELLOW");
            var brown  = ColorList.GetColor("BROWN");
            var color  = ColorList.GetColor(backgroundColor);

            if (color.ToArgb() != black.ToArgb())
            {
                if (color.ToArgb() == brown.ToArgb())
                {
                    color = yellow;
                }
                int    stringWidth        = _MeasureDisplayStringWidth(g, " ", font);
                Bitmap backgroundColorbmp = new Bitmap(stringWidth, font.Height);//wrong
                Graphics.FromImage(backgroundColorbmp).Clear(color);
                g.DrawImage(backgroundColorbmp, x, y);
            }
        }
        public static void WriteCharacter(this Graphics g, string coloredCharacter, Font font, float x, float y, string backgroundColor)
        {
            var black  = ColorList.GetColor("BLACK");
            var yellow = ColorList.GetColor("YELLOW");
            var brown  = ColorList.GetColor("BROWN");
            var brush  = new SolidBrush(ColorList.GetColor(coloredCharacter.Substring(1)));
            var color  = ColorList.GetColor(backgroundColor);

            if (color.ToArgb() != black.ToArgb())
            {
                if (color.ToArgb() == brown.ToArgb())
                {
                    color = yellow;
                }
                int    stringWidth        = _MeasureDisplayStringWidth(g, coloredCharacter[0].ToString(), font);
                Bitmap backgroundColorbmp = new Bitmap(stringWidth, font.Height);
                Graphics.FromImage(backgroundColorbmp).Clear(color);
                g.DrawImage(backgroundColorbmp, x, y);
            }
            g.DrawString(coloredCharacter[0].ToString(), font, brush, x, y);
        }
Beispiel #5
0
        public static void WriteCharacter(this SKCanvas g, string coloredCharacter, SKPaint font, float x, float y, string backgroundColor, float OffsetY = 3)
        {
            var black  = ColorList.GetColor("BLACK");
            var yellow = ColorList.GetColor("YELLOW");
            var brown  = ColorList.GetColor("BROWN");
            var color  = ColorList.GetColor(backgroundColor);

            if (color != black)
            {
                if (color == brown)
                {
                    color = yellow;
                }
                var rect     = SKRect.Create(x, y + OffsetY + 5, font.TextSize * 0.9f, font.TextSize * 0.9f);
                var recpaint = new SKPaint
                {
                    Style = SKPaintStyle.Fill,
                    Color = color
                };
                g.DrawRect(rect, recpaint);
            }
            WriteCharacter(g, coloredCharacter, font, x, y + OffsetY);
        }
        public static void WriteCharacter(this Graphics g, string coloredCharacter, Font font, float x, float y)
        {
            var brush = new SolidBrush(ColorList.GetColor(coloredCharacter.Substring(1)));

            g.DrawString(coloredCharacter[0].ToString(), font, brush, x, y);
        }
Beispiel #7
0
        public void IdsShouldMatchColors(int id, string color)
        {
            var sut = new ColorList();

            sut.GetColor(id).Should().Be(color);
        }
Beispiel #8
0
        private bool DrawCurrentTile(SKCanvas g, Model model, Dictionary <string, string> dict, string tile, string tileHighlight, SKBitmap wall, SKBitmap floor, string[] wallAndFloorColors, Dictionary <string, string> overrides, float x, float y, float resize, out SKBitmap drawnTile)
        {
            if (tile[0] == ' ' && (tileHighlight == Enum.GetName(typeof(ColorListEnum), ColorListEnum.LIGHTGREY) || tileHighlight == Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) || tile.StartsWith("@BL"))
            {
                drawnTile = null;
                return(false);
            }

            SKBitmap brandToDraw = null;
            bool     cached      = false;

            if (tile.TryDrawWallOrFloor(tileHighlight, wall, floor, wallAndFloorColors, out drawnTile) ||
                tile.TryDrawMonster(tileHighlight, overrides, _monsterpng, _miscallaneous, floor, out drawnTile, out brandToDraw) ||//first try drawing overrides, that include blue color monsters, and monsters in sight
                tile.TryDrawCachedTile(tileHighlight, _outOfSightCache, new List <char> {
                '!', '?', '=', '"', '$', ')', '[', '_', '}', '/', '(', ':', '|', '%', '÷', '†'
            }, new List <string> {
                "≈RED"
            }, out drawnTile, out cached) ||
                tile.TryDrawMonster(tileHighlight, _monsterdata, _monsterpng, _miscallaneous, floor, out drawnTile, out brandToDraw) ||//draw the rest of the monsters
                tile.TryDrawFeature(tileHighlight, _features, _alldngnpng, _miscallaneous, floor, wall, model.Location, out drawnTile) ||
                tile.TryDrawCloud(_cloudtiles, _alleffects, floor, model.SideData, model.MonsterData, out drawnTile) ||
                tile.TryDrawItem(tileHighlight, _itemdata, _itempng, _miscallaneous, floor, model.Location, out drawnTile))
            {
                var rect = new SKRect(x, y, x + (drawnTile.Width * resize), y + (drawnTile.Height * resize));
                g.DrawBitmap(drawnTile, rect);

                if (brandToDraw != null)
                {
                    g.DrawBitmap(brandToDraw, new SKRect(x, y, x + (brandToDraw.Width * resize), y + (brandToDraw.Height * resize)));
                }
                else if (!tileHighlight.Equals(Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) && (!tile.Substring(1).Equals(Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) || tile[0] == '.'))
                {
                    var backgroundPaint = new SKPaint()
                    {
                        Color = ColorList.GetColor(tileHighlight).WithAlpha(100),
                        Style = SKPaintStyle.StrokeAndFill
                    };

                    g.DrawRect(rect, backgroundPaint);
                }
                if (cached)//darken to match out of sight
                {
                    var backgroundPaint = new SKPaint()
                    {
                        Color = new SKColor(0, 0, 0, 150),
                        Style = SKPaintStyle.StrokeAndFill
                    };

                    g.DrawRect(rect, backgroundPaint);
                }

                return(true);
            }

            if (!dict.ContainsKey(tile))
            {
                dict.Add(tile, "");
            }
            var font = new SKPaint
            {
                Typeface = SKTypeface.FromFamilyName("Courier New"),
                TextSize = 24 * resize,
            };

            g.WriteCharacter(tile, font, x, y, tileHighlight);//unhandled tile, write it as a character instead

            return(false);
        }