コード例 #1
0
ファイル: FontInfo.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy constructor
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FontInfo(FontInfo copyFrom)
		{
			m_fontName = new InheritableStyleProp<string>(copyFrom.m_fontName);
			m_fontSize = new InheritableStyleProp<int>(copyFrom.m_fontSize);
			m_fontColor = new InheritableStyleProp<Color>(copyFrom.m_fontColor);
			m_backColor = new InheritableStyleProp<Color>(copyFrom.m_backColor);
			m_bold = new InheritableStyleProp<bool>(copyFrom.m_bold);
			m_italic = new InheritableStyleProp<bool>(copyFrom.m_italic);
			m_superSub = new InheritableStyleProp<FwSuperscriptVal>(copyFrom.m_superSub);
			m_underline = new InheritableStyleProp<FwUnderlineType>(copyFrom.m_underline);
			m_underlineColor = new InheritableStyleProp<Color>(copyFrom.m_underlineColor);
			m_offset = new InheritableStyleProp<int>(copyFrom.m_offset);
			m_features = new InheritableStyleProp<string>(copyFrom.m_features);
		}
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Decodes the font info.
        /// </summary>
        /// <param name="blob">The BLOB.</param>
        /// <returns>The font information represented in the BLOB.</returns>
        /// ------------------------------------------------------------------------------------
        private static FontInfo DecodeFontInfo(string blob)
        {
            FontInfo fontInfo = new FontInfo();

            fontInfo.SetAllDefaults();

            if (blob != null)
            {
                for (int i = 0; i < blob.Length;)
                {
                    int iPropLim = blob.IndexOf('\0', i);
                    if (iPropLim < 0)
                    {
                        iPropLim = blob.Length;
                    }

                    FwTextPropType tpt = (FwTextPropType)blob[i++];
                    if (tpt == FwTextPropType.ktptFontFamily)
                    {
                        fontInfo.m_fontName.ExplicitValue = blob.Substring(i, iPropLim - i);
                        i += (iPropLim - i + 1);
                        break;
                    }
                    else if (tpt == FwTextPropType.ktptFontVariations)
                    {
                        fontInfo.m_features.ExplicitValue = blob.Substring(i, iPropLim - i);
                        i += (iPropLim - i + 1);
                        break;
                    }

                    int nVal = (int)blob[i] + (int)(blob[i + 1] << 16);
                    i += 2;

                    switch (tpt)
                    {
                    case FwTextPropType.ktptBold:
                        fontInfo.m_bold.ExplicitValue = nVal == 1;
                        break;

                    case FwTextPropType.ktptItalic:
                        fontInfo.m_italic.ExplicitValue = nVal == 1;
                        break;

                    case FwTextPropType.ktptSuperscript:
                        fontInfo.m_superSub.ExplicitValue = (FwSuperscriptVal)nVal;
                        break;

                    case FwTextPropType.ktptUnderline:
                        fontInfo.m_underline.ExplicitValue = (FwUnderlineType)nVal;
                        break;

                    case FwTextPropType.ktptFontSize:
                        fontInfo.m_fontSize.ExplicitValue = nVal;
                        break;

                    case FwTextPropType.ktptOffset:
                        fontInfo.m_offset.ExplicitValue = nVal;
                        break;

                    case FwTextPropType.ktptBackColor:
                        fontInfo.m_backColor.ExplicitValue = ColorUtil.ConvertBGRtoColor((uint)nVal);
                        break;

                    case FwTextPropType.ktptForeColor:
                        fontInfo.m_fontColor.ExplicitValue = ColorUtil.ConvertBGRtoColor((uint)nVal);
                        break;

                    case FwTextPropType.ktptUnderColor:
                        fontInfo.m_underlineColor.ExplicitValue = ColorUtil.ConvertBGRtoColor((uint)nVal);
                        break;
                    }
                }
            }

            return(fontInfo);
        }
コード例 #3
0
ファイル: FwFontDialog.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the specified font info.
		/// </summary>
		/// <param name="fontInfo">The font info.</param>
		/// <param name="fAllowSubscript"><c>true</c> to allow super/subscripts, <c>false</c>
		/// to disable the controls (used when called from Borders and Bullets tab)</param>
		/// <param name="ws">The default writing system (usually UI ws)</param>
		/// <param name="wsf">The writing system factory</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="fAlwaysDisableFontFeatures"><c>true</c> to disable the Font Features
		/// button even when a Graphite font is selected.</param>
		/// ------------------------------------------------------------------------------------
		void IFontDialog.Initialize(FontInfo fontInfo, bool fAllowSubscript, int ws,
			ILgWritingSystemFactory wsf, FwStyleSheet styleSheet, bool fAlwaysDisableFontFeatures)
		{
			m_DefaultWs = ws;

			m_preview.WritingSystemFactory = wsf;
			m_preview.WritingSystemCode = ws;
			m_preview.StyleSheet = styleSheet;

			m_tbFontName.Text = fontInfo.UIFontName;
			m_tbFontSize.Text = (fontInfo.m_fontSize.Value / 1000).ToString();

			m_FontAttributes.UpdateForStyle(fontInfo);
			m_FontAttributes.AllowSuperSubScript = fAllowSubscript;

			m_FontAttributes.AlwaysDisableFontFeatures = fAlwaysDisableFontFeatures;

			UpdatePreview();
		}
コード例 #4
0
ファイル: FwBulletsTab.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the form based on a style being selected.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void UpdateForStyle(StyleInfo styleInfo)
		{
			CheckDisposed();
			m_dontUpdateInheritance = true;

			bool fDifferentStyle = m_StyleInfo == null ? true : (styleInfo.Name != m_StyleInfo.Name);

			m_StyleInfo = styleInfo;
			m_preview.IsRightToLeft = m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triNotSet ?
				m_DefaultTextDirectionRtoL : m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue;
			m_preview.WritingSystemFactory = m_StyleInfo.Cache.LanguageWritingSystemFactoryAccessor;
			m_preview.WritingSystemCode = m_StyleInfo.Cache.DefaultVernWs;

			VwBulNum bulletType;
			// Note: don't assign m_currentStyleBulletInfo until the end of this method
			// since setting some of the values change m_currentStyleBulletInfo before we have set
			// everything.
			BulletInfo bulletInfo = new BulletInfo(styleInfo.IBullet.Value);
			bulletType = bulletInfo.m_numberScheme;

			// If we have a different style, we have to reload the font info. If it is the same
			// style we were here before so we keep the font info that we already have.
			if (fDifferentStyle)
			{
				if ((int)bulletType >= (int)VwBulNum.kvbnBulletBase)
				{
					// use font from style for bullets
					m_BulletsFontInfo = bulletInfo.FontInfo;
					// create a number font based on the font for bullets
					m_NumberFontInfo = new FontInfo(m_BulletsFontInfo);
					m_NumberFontInfo.m_fontName.ResetToInherited(GetUiFontName(
						styleInfo.FontInfoForWs(-1).m_fontName.Value));
				}
				else
				{
					// use font from style for numbers
					m_NumberFontInfo = bulletInfo.FontInfo;

					if (bulletType == VwBulNum.kvbnNone)
					{
						m_NumberFontInfo.m_fontName.ResetToInherited(GetUiFontName(
							styleInfo.FontInfoForWs(-1).m_fontName.Value));
					}

					// create a bullets font based on the font for numbers
					m_BulletsFontInfo = new FontInfo(m_NumberFontInfo);

					// The font for bullets is hard-coded in the views code, so there is no point
					// in letting the user select any other font for bullets.
					m_BulletsFontInfo.m_fontName.ResetToInherited("Wingdings");
					m_BulletsFontInfo.m_fontName.SetDefaultValue("Wingdings");
				}
			}

			m_nudStartAt.Value = bulletInfo.m_start;
			m_chkStartAt.Checked = (bulletInfo.m_start != 1);

			m_tbTextBefore.Text = bulletInfo.m_textBefore;
			m_tbTextAfter.Text = bulletInfo.m_textAfter;

			m_rbUnspecified.Enabled = styleInfo.Inherits;
			if (styleInfo.IBullet.IsInherited && styleInfo.Inherits)
				m_rbUnspecified.Checked = true;
			else if (bulletType == VwBulNum.kvbnNone)
				m_rbNone.Checked = true;
			else if ((int)bulletType >= (int)VwBulNum.kvbnBulletBase)
				m_rbBullet.Checked = true;
			else // NumberBase
				m_rbNumber.Checked = true;

			m_cboBulletScheme.SelectedIndex = GetBulletIndexForType(bulletType);
			m_cboNumberScheme.SelectedIndex = GetNumberSchemeIndexForType(bulletType);

			m_currentStyleBulletInfo = bulletInfo;
			UpdateBulletSchemeComboBox();

			m_dontUpdateInheritance = false;
		}
コード例 #5
0
ファイル: FwFontDialog.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves the font info.
		/// </summary>
		/// <param name="fontInfo">The font info.</param>
		/// ------------------------------------------------------------------------------------
		void IFontDialog.SaveFontInfo(FontInfo fontInfo)
		{
			// Font name
			string newValue = FontInfo.GetInternalFontName(m_tbFontName.Text);
			fontInfo.IsDirty |= fontInfo.m_fontName.Save(false, newValue);

			// font size
			int fontSize = FontSize;
			fontInfo.IsDirty |= fontInfo.m_fontSize.Save(false, fontSize * 1000);

			// color
			bool fIsInherited;
			Color color = m_FontAttributes.GetFontColor(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_fontColor.Save(fIsInherited, color);

			// background color
			color = m_FontAttributes.GetBackgroundColor(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_backColor.Save(fIsInherited, color);

			// underline style
			FwUnderlineType underlineType = m_FontAttributes.GetUnderlineType(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_underline.Save(fIsInherited, underlineType);

			// underline color
			color = m_FontAttributes.GetUnderlineColor(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_underlineColor.Save(fIsInherited, color);

			// bold, italic, superscript, subscript
			bool fFlag = m_FontAttributes.GetBold(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_bold.Save(fIsInherited, fFlag);

			fFlag = m_FontAttributes.GetItalic(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_italic.Save(fIsInherited, fFlag);

			if (m_FontAttributes.AllowSuperSubScript)
			{
				FwSuperscriptVal superSub = m_FontAttributes.GetSubSuperscript(out fIsInherited);
				fontInfo.IsDirty |= fontInfo.m_superSub.Save(fIsInherited, superSub);

				// position
				int fontPos = m_FontAttributes.GetFontPosition(out fIsInherited);
				fontInfo.IsDirty |= fontInfo.m_offset.Save(fIsInherited, fontPos);
			}

			// features
			string fontFeatures = m_FontAttributes.GetFontFeatures(out fIsInherited);
			fontInfo.IsDirty |= fontInfo.m_features.Save(fIsInherited, fontFeatures);
		}