public void DecodeBackwardCompatible_EverythingSet()
		{
			// Setup what we expect
			FontInfo expectedFontInfo = m_infoTable["TestStyle"].FontInfoForWs(-1);
			expectedFontInfo.m_fontName = new InheritableStyleProp<string>("Algerian");
			expectedFontInfo.m_fontSize = new InheritableStyleProp<int>(8000);
			expectedFontInfo.m_fontColor = new InheritableStyleProp<Color>(Color.Red);
			expectedFontInfo.m_backColor = new InheritableStyleProp<Color>(Color.White);
			expectedFontInfo.m_underline = new InheritableStyleProp<FwUnderlineType>(FwUnderlineType.kuntNone);
			expectedFontInfo.m_underlineColor = new InheritableStyleProp<Color>(Color.Black);
			expectedFontInfo.m_bold = new InheritableStyleProp<bool>(false);
			expectedFontInfo.m_italic = new InheritableStyleProp<bool>(false);
			expectedFontInfo.m_superSub = new InheritableStyleProp<FwSuperscriptVal>(FwSuperscriptVal.kssvOff);
			expectedFontInfo.m_offset = new InheritableStyleProp<int>(0);

			// Here's the BLOB.
			// we got these values by looking at the memory when debugging Data Notebook.
			byte[] byteBlob = new byte[] {0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
				0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
				0x00, 0x00, 0x06, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00,
				0x00, 0x08, 0x00, 0xff, 0x00, 0x00, 0x00, 0x09, 0x00, 0xff, 0xff, 0xff, 0x00,
				0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x00, 0x6c, 0x00, 0x67,
				0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x00, 0x00 };
			string blob = new string(Encoding.Unicode.GetChars(byteBlob));

			BulletInfo bulletInfo = new BulletInfo();
			bulletInfo.EncodedFontInfo = blob;

			Assert.AreEqual(expectedFontInfo, bulletInfo.FontInfo);
		}
Exemple #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:BulletInfo"/> class.
		/// </summary>
		/// <param name="other">The other bullet info to copy from.</param>
		/// ------------------------------------------------------------------------------------
		public BulletInfo(BulletInfo other)
		{
			m_numberScheme = other.m_numberScheme;
			m_start = other.m_start;
			m_textBefore = other.m_textBefore;
			m_textAfter = other.m_textAfter;
			m_fontInfo = new FontInfo(other.FontInfo);
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:BulletInfo"/> class.
 /// </summary>
 /// <param name="other">The other bullet info to copy from.</param>
 /// ------------------------------------------------------------------------------------
 public BulletInfo(BulletInfo other)
 {
     m_numberScheme = other.m_numberScheme;
     m_start        = other.m_start;
     m_textBefore   = other.m_textBefore;
     m_textAfter    = other.m_textAfter;
     m_fontInfo     = new FontInfo(other.FontInfo);
 }
Exemple #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="FwBulletsTab"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public FwBulletsTab()
		{
			InitializeComponent();
			m_currentStyleBulletInfo = new BulletInfo();
			UpdateGroupBoxes();
			m_cboBulletScheme.SelectedIndex = m_kDefaultBulletIndex;
			m_cboNumberScheme.SelectedIndex = m_kDefaultNumberIndex;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Compares the contents to another instance of a BulletInfo
 /// </summary>
 /// <param name="other">item to compare to</param>
 /// <returns>true if the contents are equal</returns>
 /// ------------------------------------------------------------------------------------
 public bool CompareEquals(BulletInfo other)
 {
     return
         ((m_numberScheme == other.m_numberScheme) &&
          (m_start == other.m_start) &&
          (m_textAfter == other.m_textAfter) &&
          (m_textBefore == other.m_textBefore) &&
          (m_fontInfo == other.m_fontInfo));
 }
Exemple #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares the contents to another instance of a BulletInfo
		/// </summary>
		/// <param name="other">item to compare to</param>
		/// <returns>true if the contents are equal</returns>
		/// ------------------------------------------------------------------------------------
		public bool CompareEquals(BulletInfo other)
		{
			return
				(m_numberScheme == other.m_numberScheme) &&
				(m_start == other.m_start) &&
				(m_textAfter == other.m_textAfter) &&
				(m_textBefore == other.m_textBefore) &&
				(m_fontInfo == other.m_fontInfo);
		}
		public void RoundTripEncodingAndDecodingOfFontInfo()
		{
			// Setup what we expect
			FontInfo expectedFontInfo = m_infoTable["TestStyle"].FontInfoForWs(-1);
			expectedFontInfo.m_fontName = new InheritableStyleProp<string>("Algerian");
			expectedFontInfo.m_fontSize = new InheritableStyleProp<int>(8000);
			expectedFontInfo.m_fontColor = new InheritableStyleProp<Color>(Color.Red);
			expectedFontInfo.m_backColor = new InheritableStyleProp<Color>(Color.White);
			expectedFontInfo.m_underline = new InheritableStyleProp<FwUnderlineType>(FwUnderlineType.kuntNone);
			expectedFontInfo.m_underlineColor = new InheritableStyleProp<Color>(Color.Black);
			expectedFontInfo.m_bold = new InheritableStyleProp<bool>(false);
			expectedFontInfo.m_italic = new InheritableStyleProp<bool>(false);
			expectedFontInfo.m_superSub = new InheritableStyleProp<FwSuperscriptVal>(FwSuperscriptVal.kssvOff);
			expectedFontInfo.m_offset = new InheritableStyleProp<int>(0);

			BulletInfo bulletInfo1 = new BulletInfo();
			bulletInfo1.FontInfo = expectedFontInfo;

			BulletInfo bulletInfo2 = new BulletInfo();
			bulletInfo2.EncodedFontInfo = bulletInfo1.EncodedFontInfo;

			Assert.AreEqual(expectedFontInfo, bulletInfo2.FontInfo);
		}
Exemple #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the bullet info.
		/// </summary>
		/// <param name="bulInfo">The bullet info.</param>
		/// ------------------------------------------------------------------------------------
		private void UpdateBulletInfo(ref BulletInfo bulInfo)
		{
			if (m_rbNone.Checked)
				bulInfo.m_numberScheme = VwBulNum.kvbnNone;
			else if (m_rbBullet.Checked)
			{
				bulInfo.m_numberScheme = (VwBulNum)((int)VwBulNum.kvbnBulletBase +
					m_cboBulletScheme.SelectedIndex);
				bulInfo.FontInfo = m_BulletsFontInfo;
			}
			else if (m_rbNumber.Checked)
			{
				switch (m_cboNumberScheme.SelectedIndex)
				{
					case 0: bulInfo.m_numberScheme = VwBulNum.kvbnArabic; break;
					case 1: bulInfo.m_numberScheme = VwBulNum.kvbnRomanUpper; break;
					case 2: bulInfo.m_numberScheme = VwBulNum.kvbnRomanLower; break;
					case 3: bulInfo.m_numberScheme = VwBulNum.kvbnLetterUpper; break;
					case 4: bulInfo.m_numberScheme = VwBulNum.kvbnLetterLower; break;
					case 5: bulInfo.m_numberScheme = VwBulNum.kvbnArabic01; break;
				}
				bulInfo.m_start = m_nudStartAt.Value;
				bulInfo.m_textBefore = m_tbTextBefore.Text;
				bulInfo.m_textAfter = m_tbTextAfter.Text;
				bulInfo.FontInfo = m_NumberFontInfo;
			}
		}
Exemple #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves bullet info into a StyleInfo
		/// </summary>
		/// <param name="styleInfo">styleInfo to save into</param>
		/// ------------------------------------------------------------------------------------
		public void SaveToInfo(StyleInfo styleInfo)
		{
			CheckDisposed();

			if (styleInfo.IsCharacterStyle)
			{
				Debug.Assert(false, "Somehow, the Bullets tab has been asked to write its data to a character-based style [" + styleInfo.Name + "].");
				return;
			}

			// Save the bullet information
			BulletInfo bulInfo = new BulletInfo();
			UpdateBulletInfo(ref bulInfo);

			// Replace the value
			if (styleInfo.IBullet.Save(m_rbUnspecified.Checked, bulInfo))
				styleInfo.Dirty = true;
		}
Exemple #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the form based on a style being selected.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void UpdateForStyle(StyleInfo styleInfo)
		{
			CheckDisposed();
#if __MonoCS__
			// On Mono, the sequence of events when changing styles can cause this to be
			// called even when switching to a character style.  See FWNX-870.
			if (!styleInfo.IsParagraphStyle)
				return;
#endif
			m_dontUpdateInheritance = true;

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

			// Don't use a 0 size bullet. Fixes FWNX-575.
			if (styleInfo != null && styleInfo.IBullet != null)
				if (styleInfo.IBullet.Value.FontInfo.FontSize.Value == 0)
					styleInfo.IBullet.Value.FontInfo.m_fontSize =
						new InheritableStyleProp<int>(FontInfo.kDefaultFontSize);

			m_StyleInfo = styleInfo;
			m_preview.IsRightToLeft = m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triNotSet ?
				m_DefaultTextDirectionRtoL : m_StyleInfo.DirectionIsRightToLeft == TriStateBool.triTrue;
			m_preview.WritingSystemFactory = m_StyleInfo.Cache.WritingSystemFactory;
			m_preview.WritingSystemCode = m_StyleInfo.Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle;

			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(styleInfo.FontInfoForWs(-1).UIFontName());
				}
				else
				{
					// use font from style for numbers
					m_NumberFontInfo = bulletInfo.FontInfo;

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

					// 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("Quivira");
					m_BulletsFontInfo.m_fontName.SetDefaultValue("Quivira");
				}
			}

			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;
		}