예제 #1
0
        protected override void OnInitialized()
        {
            ITypographyOptions themeClass = Theme != null?TypographyService.ThemeForName(Theme) : new DefaultTypographyOptions();

            if (themeClass == null)
            {
                themeClass = new DefaultTypographyOptions();
            }
            if (BaseFontSize != "16px")
            {
                themeClass.BaseFontSize = BaseFontSize;
            }
            if (BaseLineHeight != "1.45")
            {
                themeClass.BaseLineHeight = BaseLineHeight;
            }
            if (ScaleRatio.HasValue)
            {
                themeClass.ScaleRatio = ScaleRatio;
            }
            if (HeaderColor != "inherit")
            {
                themeClass.HeaderColor = HeaderColor;
            }
            if (BodyColor != "hsla(0,0%,0%,0.8)")
            {
                themeClass.BodyColor = BodyColor;
            }
            if (HeaderWeight != "bold")
            {
                themeClass.HeaderWeight = HeaderWeight;
            }
            if (BodyWeight != "normal")
            {
                themeClass.BodyWeight = BodyWeight;
            }
            if (BoldWeight != "bold")
            {
                themeClass.BoldWeight = BoldWeight;
            }
            if (BlockMarginBottom != "1")
            {
                themeClass.BlockMarginBottom = BlockMarginBottom;
            }
            if (IncludeNormalize.HasValue)
            {
                themeClass.IncludeNormalize = IncludeNormalize;
            }
            if (HeaderFontFamily != "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif")
            {
                List <string> headerFontFamily = HeaderFontFamily.Split(',').ToList();
                themeClass.HeaderFontFamily = headerFontFamily;
            }
            if (BodyFontFamily != "georgia,serif")
            {
                List <string> bodyFontFamily = BodyFontFamily.Split(',').ToList();
                themeClass.BodyFontFamily = bodyFontFamily;
            }
            if (Plugins != null)
            {
                //For now, plugins are in the Plugins namespace, but in the future they could be external
                themeClass.Plugins = new List <IPlugin>();
                string[] plugins = Plugins.Split(',');
                foreach (string pluginname in plugins)
                {
                    IPlugin plugin = PluginForName(pluginname);
                    if (plugin != null)
                    {
                        themeClass.Plugins.Add(plugin);
                    }
                }
            }


            //Load all styles of the listed fonts
            if (!string.IsNullOrWhiteSpace(GoogleFonts))
            {
                if (themeClass.GoogleFonts == null)
                {
                    themeClass.GoogleFonts = new List <GoogleFont>();
                }

                string[] fonts = GoogleFonts.Split(',');
                foreach (string fontname in fonts)
                {
                    Font font = GetFont(fontname.Trim());
                    if (font == null)
                    {
                        continue;
                    }

                    List <string> styles = font.Weights.Select(w =>
                    {
                        w = w.Replace("regular", "400");
                        if (w == "italic")
                        {
                            w = "400i";
                        }
                        w = w.Replace("italic", "i");
                        return(w);
                    }).ToList();
                    GoogleFont gf = new GoogleFont
                    {
                        Name   = font.Family,
                        Styles = styles
                    };
                    themeClass.GoogleFonts.Add(gf);
                }
            }
            TypographyService.ApplyTypography(themeClass);
        }
예제 #2
0
        /// ************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        private void FillMinColumnsSize()
        {
            string gleisText = Common.MultiplatformTramStations.Contains(StationName.ToUpperInvariant()) ? Common.HeaderTitles["PlatformT"] :
                               (Common.MultiplatformSbahnStations.Contains(StationName.ToUpperInvariant()) ? Common.HeaderTitles["PlatformS"] : "");
            string textToMeasure;

            MinWidth = new double[Common.HeaderTitles.Count - 1];
            foreach (string column in Common.HeaderTitles.Keys)
            {
                if (string.Compare(column, "PlatformT") == 0)
                {
                    continue;
                }
                if (string.Compare(column, "PlatformS") == 0)
                {
                    textToMeasure = gleisText;
                }
                else
                {
                    textToMeasure = Common.HeaderTitles[column];
                }
                MinColumnsSize.Add(Common.HeaderTitles[column], Common.MeasureText(textToMeasure, HeaderFontFamily.ToString(), HeaderFontSize));
            }
            MinWidth[0] = MinColumnsSize["Linie"];
            MinWidth[1] = MinColumnsSize["Ziel"];
            MinWidth[2] = MinColumnsSize["Gleis"];
            MinWidth[3] = MinColumnsSize["Abfahrt"];
            MinWidth[4] = MinColumnsSize["Zeit"];
        }