示例#1
0
        internal Typography(FontConfiguration fontFamily)
        {
            // FONT SIZES
            TryAddIntResource(Constants.FontSize.H1, 96);
            TryAddIntResource(Constants.FontSize.H2, 60);
            TryAddIntResource(Constants.FontSize.H3, 48);
            TryAddIntResource(Constants.FontSize.H4, 34);
            TryAddIntResource(Constants.FontSize.H5, 24);
            TryAddIntResource(Constants.FontSize.H6, 20);
            TryAddIntResource(Constants.FontSize.SUBTITLE1, 16);
            TryAddIntResource(Constants.FontSize.SUBTITLE2, 14);
            TryAddIntResource(Constants.FontSize.BODY1, 16);
            TryAddIntResource(Constants.FontSize.BODY2, 14);
            TryAddIntResource(Constants.FontSize.BUTTON, 14);
            TryAddIntResource(Constants.FontSize.CAPTION, 12);
            TryAddIntResource(Constants.FontSize.OVERLINE, 10);

            // LETTER SPACING
            TryAddIntResource(Constants.LetterSpacing.H1, 1.5);
            TryAddIntResource(Constants.LetterSpacing.H2, 0.5);
            TryAddIntResource(Constants.LetterSpacing.H3, 0);
            TryAddIntResource(Constants.LetterSpacing.H4, 0.25);
            TryAddIntResource(Constants.LetterSpacing.H5, 0);
            TryAddIntResource(Constants.LetterSpacing.H6, 0.15);
            TryAddIntResource(Constants.LetterSpacing.SUBTITLE1, 0.15);
            TryAddIntResource(Constants.LetterSpacing.SUBTITLE2, 0.1);
            TryAddIntResource(Constants.LetterSpacing.BODY1, 0.5);
            TryAddIntResource(Constants.LetterSpacing.BODY2, 0.25);
            TryAddIntResource(Constants.LetterSpacing.BUTTON, 1.25);
            TryAddIntResource(Constants.LetterSpacing.CAPTION, 0.4);
            TryAddIntResource(Constants.LetterSpacing.OVERLINE, 1.5);
            TryAddIntResource(Constants.LetterSpacing.NONE, 0);

            if (fontFamily == null)
            {
                return;
            }

            // FONT FAMILY
            TryAddStringResource(Constants.FontFamily.H1, fontFamily.H1);
            TryAddStringResource(Constants.FontFamily.H2, fontFamily.H2);
            TryAddStringResource(Constants.FontFamily.H3, fontFamily.H3);
            TryAddStringResource(Constants.FontFamily.H4, fontFamily.H4);
            TryAddStringResource(Constants.FontFamily.H5, fontFamily.H5);
            TryAddStringResource(Constants.FontFamily.H6, fontFamily.H6);
            TryAddStringResource(Constants.FontFamily.SUBTITLE1, fontFamily.Subtitle1);
            TryAddStringResource(Constants.FontFamily.SUBTITLE2, fontFamily.Subtitle2);
            TryAddStringResource(Constants.FontFamily.BODY1, fontFamily.Body1);
            TryAddStringResource(Constants.FontFamily.BODY2, fontFamily.Body2);
            TryAddStringResource(Constants.FontFamily.BUTTON, fontFamily.Button);
            TryAddStringResource(Constants.FontFamily.CAPTION, fontFamily.Caption);
            TryAddStringResource(Constants.FontFamily.OVERLINE, fontFamily.Overline);

            // OTHERS
            Add(Constants.FONTATTRIBUTE_BOLD, FontAttributes.Bold);
        }
        private void InitializeView(String configurationPath, NoticeboardMessage message)
        {
            lm.Comol.Core.BaseModules.Editor.EditorConfiguration config = ServiceEditor.GetConfiguration(configurationPath);
            if (!(config == null || (config.DefaultEditor == null && !config.Settings.Any())))
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();

                EditorType loadType = (mSettings != null) ?
                                      mSettings.EditorType
                                    :
                                      ((config.Settings.Any() && config.Settings.Where(s => s.EditorType == EditorType.telerik).Any())
                                    ? EditorType.telerik : ((config.DefaultEditor != null) ? config.DefaultEditor.EditorType : EditorType.none));
                EditorSettings rSettings = (config.Settings.Any() ? config.Settings.Where(s => s.EditorType == loadType).FirstOrDefault() : null);

                EditorSettings settings   = (rSettings != null) ? rSettings : config.DefaultEditor;
                String         fontfamily = (mSettings != null) ? mSettings.FontNames : (settings != null) ? settings.FontNames : config.FontNames;
                if (String.IsNullOrEmpty(fontfamily))
                {
                    fontfamily = config.FontNames;
                }

                String  fontSizes       = (mSettings != null) ? mSettings.FontSizes : (settings != null) ? settings.FontSizes : config.FontSizes;
                String  realFontSizes   = (mSettings != null) ? mSettings.RealFontSizes : (settings != null) ? settings.RealFontSizes : config.RealFontSizes;
                Boolean useRealFontSize = (!String.IsNullOrEmpty(realFontSizes)) ? View.UseRealFontSize : (mSettings != null) ? mSettings.UseRealFontSize : (settings != null) ? settings.UseRealFontSize : config.UseRealFontSize;


                FontConfiguration   defaultFont      = (mSettings != null && mSettings.DefaultFont != null) ? mSettings.DefaultFont : (settings != null && settings.DefaultFont != null) ? settings.DefaultFont : config.DefaultFont;
                FontConfiguration   defaultRealFont  = (mSettings != null && mSettings.DefaultRealFont != null) ? mSettings.DefaultRealFont : (settings != null && settings.DefaultRealFont != null) ? settings.DefaultRealFont : config.DefaultRealFont;
                List <FontSettings> fontSizeSettings = config.FontSizeSettings;
                List <String>       fitems           = fontfamily.Split(',').Where(s => !String.IsNullOrEmpty(s)).ToList();


                String dFont = "";
                if (!useRealFontSize && defaultFont != null && fitems.Select(s => s.ToLower()).Contains(defaultFont.Family.ToLower()))
                {
                    dFont = defaultFont.Family;
                }
                else if (useRealFontSize && defaultRealFont != null && fitems.Select(s => s.ToLower()).Contains(defaultRealFont.Family.ToLower()))
                {
                    dFont = defaultRealFont.Family;
                }
                if (message.StyleSettings != null && !String.IsNullOrEmpty(message.StyleSettings.FontFamily) && fitems.Select(s => s.ToLower()).Contains(message.StyleSettings.FontFamily.ToLower()))
                {
                    dFont = message.StyleSettings.FontFamily;
                }
                View.LoadFontFamily(fitems, dFont);


                List <String> sizeItems = fontSizeSettings.Select(s => s.Value).ToList();

                //fontfamily.Split(',').Where(s=> !String.IsNullOrEmpty(s)).ToList();

                //LoadFontSize
            }
            View.isInitialized = true;
        }
示例#3
0
        private FontConfiguration ExtractFontConfiguration()
        {
            var ff = (FontFamily)cmbFontFamily.SelectedValue;

            var font = new Font(ff, 10, FontStyle.Regular);

            var characters = ExtractChars();
            var height     = numCharHeight.Value;

            var fc = new FontConfiguration(font, characters)
            {
                CharSize    = new Size((int)txtCharWidth.Value, (int)txtCharHeight.Value),
                ItemsPerRow = (int)height,
                BackColor   = lblBackgroundColor.BackColor,
                ForeColor   = lblForegroundColor.BackColor
            };

            return(fc);
        }