コード例 #1
0
        protected string GetInitialsStyle()
        {
            string style     = "";
            var    dimension = CoinSize != -1 ? CoinSize : sizeToPixels[Size];

            style += $"width:{dimension}px;height:{dimension}px;";

            style += $"background-color:{PersonaColorUtils.GetPersonaColorHexCode(PersonaColorUtils.GetInitialsColorFromName(Text))};";

            style += $"line-height:{(dimension == 48 ? 46 : dimension)}px;";

            if (dimension < 32)
            {
                style += $"font-size:var(--fontSize-XSmall);";
            }
            else if (dimension >= 32 && dimension < 40)
            {
                style += $"font-size:var(--fontSize-Medium);";
            }
            else if (dimension >= 40 && dimension < 56)
            {
                style += $"font-size:var(--fontSize-MediumPlus);";
            }
            else if (dimension >= 56 && dimension < 72)
            {
                style += $"font-size:var(--fontSize-XLarge);";
            }
            else if (dimension >= 72 && dimension < 100)
            {
                style += $"font-size:var(--fontSize-XxLarge);";
            }
            else if (dimension >= 100)
            {
                style += $"font-size:var(--fontSize-SuperLarge);";
            }


            return(style);
        }
コード例 #2
0
        private void SetStyle()
        {
            var    dimension = CoinSize != -1 ? CoinSize : PersonaSize.SizeToPixels(Size);
            string fontSize  = Theme.FontStyle.FontSize.Large;

            if (dimension < 32)
            {
                fontSize = Theme.FontStyle.FontSize.XSmall;
            }
            else if (dimension >= 32 && dimension < 40)
            {
                fontSize = Theme.FontStyle.FontSize.Medium;
            }
            else if (dimension >= 40 && dimension < 56)
            {
                fontSize = Theme.FontStyle.FontSize.MediumPlus;
            }
            else if (dimension >= 56 && dimension < 72)
            {
                fontSize = Theme.FontStyle.FontSize.XLarge;
            }
            else if (dimension >= 72 && dimension < 100)
            {
                fontSize = Theme.FontStyle.FontSize.XxLarge;
            }
            else if (dimension >= 100)
            {
                fontSize = Theme.FontStyle.FontSize.SuperLarge;
            }

            InitialsRule.Properties = new CssString
            {
                Css = $"height:{dimension}px;" +
                      $"background-color:{PersonaColorUtils.GetPersonaColorHexCode(PersonaColorUtils.GetInitialsColorFromName(Text))};" +
                      $"line-height:{(dimension == 48 ? 46 : dimension)}px;" +
                      $"font-size:{fontSize};"
            };


            ImageAreaRule.Properties = new CssString
            {
                Css = (dimension <= 10 ?
                       $"overflow:visible;" +
                       $"background:transparent;" +
                       $"height:0;" +
                       $"width:0;"
                    :
                       $"width:{dimension}px;" +
                       $"height:{dimension}px;"
                       )
            };

            ImageRule.Properties = new CssString
            {
                Css = (dimension <= 10 ?
                       $"overflow:visible;" +
                       $"background:transparent;" +
                       $"height:0;" +
                       $"width:0;"
                    :
                       $"width:{dimension}px;" +
                       $"height:{dimension}px;"
                       )
            };
        }