Beispiel #1
0
		public void UserDefinedCharacterStyle_ExplicitFontName()
		{
			// Create a style with an unspecified font name.
			IStStyle charStyle = new StStyle();
			Cache.LangProject.StylesOC.Add(charStyle);
			charStyle.Context = ContextValues.Text;
			charStyle.Function = FunctionValues.Prose;
			charStyle.Structure = StructureValues.Body;
			charStyle.Type = StyleType.kstCharacter;
			StyleInfo basedOn = new StyleInfo(charStyle);

			// Create a user-defined character style inherited from the previously-created character
			// style, but this style has a font name specified.
			StyleInfo charStyleInfo = new StyleInfo("New Char Style", basedOn,
				StyleType.kstCharacter, Cache);
			FontInfo charFontInfo = charStyleInfo.FontInfoForWs(Cache.DefaultVernWs);
			m_fontTab.UpdateForStyle(charStyleInfo);

			// Select a font name for the style (which will call the event handler
			// m_cboFontNames_SelectedIndexChanged).
			FwInheritablePropComboBox cboFontNames =
				ReflectionHelper.GetField(m_fontTab, "m_cboFontNames") as FwInheritablePropComboBox;
			Assert.IsNotNull(cboFontNames);
			cboFontNames.AdjustedSelectedIndex = 2;
			// Make sure we successfully set the font for this user-defined character style.
			Assert.IsTrue(charStyleInfo.FontInfoForWs(-1).m_fontName.IsExplicit);
			Assert.AreEqual("<default pub font>", charStyleInfo.FontInfoForWs(-1).m_fontName.Value,
				"The font should have been set to the default publication font.");

			cboFontNames.AdjustedSelectedIndex = 3;
			// Make sure we successfully set the font for this user-defined character style.
			Assert.IsTrue(charStyleInfo.FontInfoForWs(-1).m_fontName.IsExplicit);
			Assert.AreEqual("<default sans serif>", charStyleInfo.FontInfoForWs(-1).m_fontName.Value,
				"The font should have been set to the default heading font (i.e., sans-serif).");
		}
Beispiel #2
0
		public void SaveToDB_NewInfo()
		{
			var styleFactory = Cache.ServiceLocator.GetInstance<IStStyleFactory>();
			var realStyle = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(realStyle);
			realStyle.Context = ContextValues.Intro;
			realStyle.Function = FunctionValues.Table;
			realStyle.Structure = StructureValues.Heading;
			StyleInfo basedOn = new StyleInfo(realStyle);

			StyleInfo testInfo = new StyleInfo("New Style", basedOn,
				StyleType.kstParagraph, Cache);

			// simulate a save to the DB for the test style.
			var style = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(style);
			testInfo.SaveToDB(style, false, false);

			Assert.AreEqual(ContextValues.Intro, testInfo.Context);
			Assert.AreEqual(StructureValues.Heading, testInfo.Structure);
			Assert.AreEqual(FunctionValues.Table, testInfo.Function);
			Assert.AreEqual(ContextValues.Intro, style.Context);
			Assert.AreEqual(StructureValues.Heading, style.Structure);
			Assert.AreEqual(FunctionValues.Table, style.Function);
		}
Beispiel #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="StyleInfo"/> class. Creates a new
		/// style of a given type.
		/// </summary>
		/// <param name="name">new style name</param>
		/// <param name="basedOnStyle">style to be based on</param>
		/// <param name="styleType"></param>
		/// <param name="cache">FDO cache</param>
		/// ------------------------------------------------------------------------------------
		public StyleInfo(string name, StyleInfo basedOnStyle, StyleType styleType,
			FdoCache cache) : base(cache)
		{
			Name = name;
			m_styleType = styleType;
				m_basedOnStyle = basedOnStyle;
			if (basedOnStyle != null)
				m_basedOnStyleName = basedOnStyle.Name;
			else if (styleType == StyleType.kstParagraph)
			{
				throw new ArgumentNullException("basedOnStyle",
					"New paragraph styles are required to be based on an existing style.");
			}
			m_nextStyleName = name;
		}
Beispiel #4
0
		public void SaveToDB_CopyOfStyleBasedOnNormal()
		{
			StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.ServiceLocator.WritingSystemManager);
			var styleFactory = Cache.ServiceLocator.GetInstance<IStStyleFactory>();
			var normalStyle = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(normalStyle);
			normalStyle.Name = "Normal";
			normalStyle.Context = ContextValues.Internal;
			normalStyle.Function = FunctionValues.Prose;
			normalStyle.Structure = StructureValues.Undefined;
			StyleInfo normal = new StyleInfo(normalStyle);
			styleTable.Add("Normal", normal);

			var realStyle = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(realStyle);
			realStyle.Name = "Paragraph";
			realStyle.Context = ContextValues.Text;
			realStyle.Function = FunctionValues.Prose;
			realStyle.Structure = StructureValues.Body;
			realStyle.BasedOnRA = normalStyle;
			StyleInfo styleToCopyFrom = new StyleInfo(realStyle);
			styleTable.Add("Paragraph", styleToCopyFrom);

			StyleInfo testInfo = new StyleInfo(styleToCopyFrom, "Copy of Paragraph");
			styleTable.Add("Copy of Paragraph", testInfo);
			styleTable.ConnectStyles();

			// simulate a save to the DB for the test style.
			var style = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(style);
			testInfo.SaveToDB(style, false, false);

			Assert.AreEqual(ContextValues.Text, testInfo.Context);
			Assert.AreEqual(StructureValues.Body, testInfo.Structure);
			Assert.AreEqual(FunctionValues.Prose, testInfo.Function);
			Assert.AreEqual(ContextValues.Text, style.Context);
			Assert.AreEqual(StructureValues.Body, style.Structure);
			Assert.AreEqual(FunctionValues.Prose, style.Function);
		}
Beispiel #5
0
		public void SaveToDB_NewInfo()
		{
			IStStyle realStyle = new StStyle();
			Cache.LangProject.StylesOC.Add(realStyle);
			realStyle.Context = ContextValues.Intro;
			realStyle.Function = FunctionValues.Table;
			realStyle.Structure = StructureValues.Heading;
			StyleInfo basedOn = new StyleInfo(realStyle);

			StyleInfo testInfo = new StyleInfo("New Style", basedOn,
				StyleType.kstParagraph, Cache);

			// simulate a save to the DB for the test style.
			IStStyle style = new StStyle();
			Cache.LangProject.StylesOC.Add(style);
			testInfo.SaveToDB(style, false);

			Assert.AreEqual(ContextValues.Intro, testInfo.Context);
			Assert.AreEqual(StructureValues.Heading, testInfo.Structure);
			Assert.AreEqual(FunctionValues.Table, testInfo.Function);
			Assert.AreEqual(ContextValues.Intro, style.Context);
			Assert.AreEqual(StructureValues.Heading, style.Structure);
			Assert.AreEqual(FunctionValues.Table, style.Function);
		}
Beispiel #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves the font information to the styleInfo
        /// </summary>
        /// <param name="styleInfo">The style info.</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToInfo(StyleInfo styleInfo)
        {
            CheckDisposed();

            FontInfo fontInfo = styleInfo.FontInfoForWs(m_currentWs);
            // Font name
            bool   newInherit = IsInherited(m_cboFontNames);
            string newValue   = string.Empty;

            switch (m_cboFontNames.AdjustedSelectedIndex)
            {
            case 1: newValue = StStyle.DefaultFont; break;

            case 2: newValue = StStyle.DefaultPubFont; break;

            case 3: newValue = StStyle.DefaultHeadingFont; break;

            default: newValue = m_cboFontNames.Text; break;
            }
            if (fontInfo.m_fontName.Save(newInherit, newValue))
            {
                styleInfo.Dirty = true;
            }

            // font size
            newInherit = IsInherited(m_cboFontSize);
            int fontSize = (m_cboFontSize.Text == string.Empty || newInherit) ? 0 : Int32.Parse(m_cboFontSize.Text);

            if (fontInfo.m_fontSize.Save(newInherit, fontSize * 1000))
            {
                styleInfo.Dirty = true;
            }

            // color
            Color color = m_FontAttributes.GetFontColor(out newInherit);

            if (fontInfo.m_fontColor.Save(newInherit, color))
            {
                styleInfo.Dirty = true;
            }

            // background color
            color = m_FontAttributes.GetBackgroundColor(out newInherit);
            if (fontInfo.m_backColor.Save(newInherit, color))
            {
                styleInfo.Dirty = true;
            }

            // underline style
            FwUnderlineType underlineType = m_FontAttributes.GetUnderlineType(out newInherit);

            if (fontInfo.m_underline.Save(newInherit, underlineType))
            {
                styleInfo.Dirty = true;
            }

            // underline color
            color = m_FontAttributes.GetUnderlineColor(out newInherit);
            if (fontInfo.m_underlineColor.Save(newInherit, color))
            {
                styleInfo.Dirty = true;
            }

            // bold, italic, superscript, subscript
            bool fFlag = m_FontAttributes.GetBold(out newInherit);

            if (fontInfo.m_bold.Save(newInherit, fFlag))
            {
                styleInfo.Dirty = true;
            }

            fFlag = m_FontAttributes.GetItalic(out newInherit);
            if (fontInfo.m_italic.Save(newInherit, fFlag))
            {
                styleInfo.Dirty = true;
            }

            FwSuperscriptVal superSub = m_FontAttributes.GetSubSuperscript(out newInherit);

            if (fontInfo.m_superSub.Save(newInherit, superSub))
            {
                styleInfo.Dirty = true;
            }

            // position
            int fontPos = m_FontAttributes.GetFontPosition(out newInherit);

            if (fontInfo.m_offset.Save(newInherit, fontPos))
            {
                styleInfo.Dirty = true;
            }

            // features
            string fontFeatures = m_FontAttributes.GetFontFeatures(out newInherit);

            if (fontInfo.m_features.Save(newInherit, fontFeatures))
            {
                styleInfo.Dirty = true;
            }
        }
Beispiel #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the following styles combo box.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		private void UpdateFollowingStylesCbo(StyleInfo styleInfo)
		{
			// Handle the Following Paragraph Style combo box
			if (styleInfo.IsCharacterStyle)
			{
				m_cboFollowingStyle.Items.Clear();
				m_cboFollowingStyle.Enabled = false;
			}
			else
			{
				FillFollowingStyles(styleInfo);
				if (styleInfo.NextStyle == null)
					m_cboFollowingStyle.SelectedIndex = -1;
				else
					m_cboFollowingStyle.SelectedItem = styleInfo.NextStyle.Name;
			}
		}
Beispiel #8
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;
		}
Beispiel #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Changes the name of the style
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		private void ChangeStyleName(StyleInfo styleInfo)
		{
			string newName = m_txtStyleName.Text;
			string oldName = styleInfo.Name;
			// fix any styles that refer to this one
			foreach (StyleInfo updateStyle in m_styleTable.Values)
			{
				if (updateStyle.BasedOnStyle != null && updateStyle.BasedOnStyle.Name == oldName)
					updateStyle.SaveBasedOn(newName);
				if (updateStyle.NextStyle != null && updateStyle.NextStyle.Name == oldName)
					updateStyle.SaveFollowing(newName);
			}

			// save the new name and update the entry in the style table
			styleInfo.SaveName(newName);
			m_styleTable.Remove(oldName);
			m_styleTable.Add(newName, styleInfo);

			// Change the displayed entry
			m_styleListHelper.Rename(oldName, newName);

			// Save an entry to rename the style if it is a real style
			if (styleInfo.RealStyle != null)
				SaveRenamedStyle(oldName, newName);
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves the paragraph information to the styleInfo
        /// </summary>
        /// <param name="styleInfo">The style info.</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToInfo(StyleInfo styleInfo)
        {
            CheckDisposed();

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

            // direction
            bool newInherit = IsInherited(m_cboDirection);

            if (styleInfo.IRightToLeftStyle.Save(newInherit, (TriStateBool)m_cboDirection.SelectedIndex))
            {
                styleInfo.Dirty = true;
            }

            // alignment
            newInherit = m_cboAlignment.IsInherited;
            FwTextAlign newAlignment = FwTextAlign.ktalLeading;

            switch (m_cboAlignment.AdjustedSelectedIndex)
            {
            case 1: newAlignment = FwTextAlign.ktalLeading; break;

            case 2: newAlignment = FwTextAlign.ktalLeft; break;

            case 3: newAlignment = FwTextAlign.ktalCenter; break;

            case 4: newAlignment = FwTextAlign.ktalRight; break;

            case 5: newAlignment = FwTextAlign.ktalTrailing; break;

            case 6: newAlignment = FwTextAlign.ktalJustify; break;
            }
            if (styleInfo.IAlignment.Save(newInherit, newAlignment))
            {
                styleInfo.Dirty = true;
            }

            // background color - only save it if the control is visible
            if (m_cboBackground.Visible)
            {
                newInherit = IsInherited(m_cboBackground);
                FontInfo fontInfo = styleInfo.FontInfoForWs(-1);                 // get default FontInfo
                if (fontInfo.m_backColor.Save(newInherit, m_cboBackground.ColorValue))
                {
                    styleInfo.Dirty = true;
                }
            }

            // left indent
            newInherit = IsInherited(m_nudLeftIndentation);
            if (styleInfo.ILeadingIndent.Save(newInherit, m_nudLeftIndentation.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // right indent
            newInherit = IsInherited(m_nudRightIndentation);
            if (styleInfo.ITrailingIndent.Save(newInherit, m_nudRightIndentation.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // special indent
            newInherit = m_cboSpecialIndentation.IsInherited;
            int newValue = 0;

            switch (m_cboSpecialIndentation.AdjustedSelectedIndex)
            {
            case 2: newValue = m_nudIndentBy.MeasureValue; break;

            case 3: newValue = -m_nudIndentBy.MeasureValue; break;
            }
            if (styleInfo.IFirstLineIndent.Save(newInherit, newValue))
            {
                styleInfo.Dirty = true;
            }

            // spacing before
            newInherit = IsInherited(m_nudBefore);
            if (styleInfo.ISpaceBefore.Save(newInherit, m_nudBefore.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // spacing after
            newInherit = IsInherited(m_nudAfter);
            if (styleInfo.ISpaceAfter.Save(newInherit, m_nudAfter.MeasureValue))
            {
                styleInfo.Dirty = true;
            }

            // line spacing
            int index = m_cboLineSpacing.AdjustedSelectedIndex;

            newInherit = m_cboLineSpacing.IsInherited;
            LineHeightInfo newLineHeight = new LineHeightInfo();

            newLineHeight.m_relative = (index <= 3);
            switch (index)
            {
            case 1:                      // single spacing
                newLineHeight.m_lineHeight = 10000; break;

            case 2:                     // 1.5 spacing
                newLineHeight.m_lineHeight = 15000; break;

            case 3:                     // double spacing
                newLineHeight.m_lineHeight = 20000; break;

            case kAtLeastIndex:                     // at least
                newLineHeight.m_lineHeight = m_nudSpacingAt.MeasureValue; break;

            case kExactlyIndex:                     // exactly
                newLineHeight.m_lineHeight = -m_nudSpacingAt.MeasureValue; break;
            }
            if (styleInfo.ILineSpacing.Save(newInherit, newLineHeight))
            {
                styleInfo.Dirty = true;
            }
        }
Beispiel #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwStylesDlg"/> class.
		/// </summary>
		/// <param name="rootSite">The root site.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="defaultRightToLeft">Indicates whether current context (typically the
		/// default direction of the view from which this dialog is invoked) is right to left.</param>
		/// <param name="showBiDiLabels">Indicates whether to show labels that are meaningful
		/// for both left-to-right and right-to-left. If <c>defaultRightToLeft</c> is set to
		/// <c>true</c> the passed-in value for this parameter will be ignored and the display
		/// will automatically be BiDi enabled. If this value is false, then simple "Left" and
		/// "Right" labels will be used in the display, rather than "Leading" and "Trailing".</param>
		/// <param name="normalStyleName">Name of the normal style.</param>
		/// <param name="customUserLevel">The custom user level.</param>
		/// <param name="userMeasurementType">User's prefered measurement units.</param>
		/// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
		/// <param name="charStyleName">Name of the currently selected character style.</param>
		/// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
		/// <param name="app">The application.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		protected void Init(IVwRootSite rootSite, FdoCache cache, FwStyleSheet styleSheet,
			bool defaultRightToLeft, bool showBiDiLabels, string normalStyleName,
			int customUserLevel, MsrSysType userMeasurementType, string paraStyleName,
			string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider)
		{
			CheckDisposed();

			m_rootSite = rootSite;
			m_cache = cache;
			m_customUserLevel = customUserLevel;
			m_hvoRootObject = hvoRootObject;
			m_app = app;
			showBiDiLabels |= defaultRightToLeft;
			m_fShowBidiLabels = showBiDiLabels;
			m_userMeasurementType = userMeasurementType;
			m_helpTopicProvider = helpTopicProvider;

			// Cache is null in tests
			if (cache == null)
				return;

			m_cboTypes.SelectedIndex = 1; // All Styles

			// Load the style information
			m_styleTable = new StyleInfoTable(normalStyleName,
				cache.LanguageWritingSystemFactoryAccessor);
			m_styleSheet = styleSheet;
			FillStyleTable(m_styleSheet);
			m_normalStyleInfo = (StyleInfo)m_styleTable[normalStyleName];
			Debug.Assert(m_normalStyleInfo != null);
			m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
			m_styleListHelper.AddStyles(m_styleTable, null);
			m_styleListHelper.ShowInternalStyles = true;
			m_styleListHelper.StyleChosen += new StyleChosenHandler(m_styleListHelper_StyleChosen);
			m_styleListHelper.Refresh();

			// Mark the current styles
			m_styleListHelper.MarkCurrentStyle(paraStyleName);
			m_styleListHelper.MarkCurrentStyle(charStyleName);

			// General tab
			m_generalTab.StyleListHelper = m_styleListHelper;
			m_generalTab.StyleTable = m_styleTable;
			m_generalTab.ShowBiDiLabels = showBiDiLabels;
			m_generalTab.UserMeasurementType = m_userMeasurementType;
			m_generalTab.RenamedStyles = m_renamedStyles;

			// Load the font information
			m_fontTab.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			m_fontTab.FillFontInfo(cache);

			// Disable the background color on the paragraph tab.
			m_paragraphTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_paragraphTab.ShowBiDiLabels = showBiDiLabels;
			m_paragraphTab.MeasureType = userMeasurementType;

			m_bulletsTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_bulletsTab.StyleSheet = m_styleSheet;

			m_borderTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_borderTab.ShowBiDiLabels = showBiDiLabels;

			// Select the current paragraph style in the list (or fall back to Normal)
			if (!string.IsNullOrEmpty(paraStyleName))
				m_styleListHelper.SelectedStyleName = paraStyleName;
			else
				m_styleListHelper.SelectedStyleName = normalStyleName;
			m_styleListHelper_StyleChosen(null, m_styleListHelper.SelectedStyle);

			// Default is not to show the style type selection combo.
			if (!DesignMode)
				AllowSelectStyleTypes = false;
		}
Beispiel #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the properties of a StyleInfo to the factory default settings
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected abstract void SetPropsToFactorySettings(StyleInfo styleInfo);
Beispiel #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the information on the font tab using the current writing system.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void UpdateForStyle(StyleInfo styleInfo)
		{
			CheckDisposed();

			UpdateForStyle(styleInfo, m_currentWs);
		}
		protected override void SetPropsToFactorySettings(StyleInfo obj)
		{
			throw new NotImplementedException();
		}
Beispiel #15
0
		public void SaveToDB_NewInfoAndBasedOnNewInfo()
		{
			IStStyle realStyle = new StStyle();
			Cache.LangProject.StylesOC.Add(realStyle);
			realStyle.Context = ContextValues.Intro;
			realStyle.Function = FunctionValues.Table;
			realStyle.Structure = StructureValues.Heading;
			StyleInfo basedOn = new StyleInfo(realStyle);

			StyleInfo testInfo1 = new StyleInfo("New Style 1", basedOn,
				StyleType.kstParagraph, Cache);
			StyleInfo testInfo2 = new StyleInfo("New Style 2", testInfo1,
				StyleType.kstParagraph, Cache);

			// simulate a save to the DB for the test styles. Save the second one first for
			// a better test.
			IStStyle style2 = new StStyle();
			Cache.LangProject.StylesOC.Add(style2);
			testInfo2.SaveToDB(style2, false);
			IStStyle style = new StStyle();
			Cache.LangProject.StylesOC.Add(style);
			testInfo1.SaveToDB(style, false);

			Assert.AreEqual(ContextValues.Intro, testInfo1.Context);
			Assert.AreEqual(StructureValues.Heading, testInfo1.Structure);
			Assert.AreEqual(FunctionValues.Table, testInfo1.Function);
			Assert.AreEqual(ContextValues.Intro, style.Context);
			Assert.AreEqual(StructureValues.Heading, style.Structure);
			Assert.AreEqual(FunctionValues.Table, style.Function);

			Assert.AreEqual(ContextValues.Intro, testInfo2.Context);
			Assert.AreEqual(StructureValues.Heading, testInfo2.Structure);
			Assert.AreEqual(FunctionValues.Table, testInfo2.Function);
			Assert.AreEqual(ContextValues.Intro, style2.Context);
			Assert.AreEqual(StructureValues.Heading, style2.Structure);
			Assert.AreEqual(FunctionValues.Table, style2.Function);
		}
Beispiel #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves bullet info into a StyleInfo
		/// </summary>
		/// <param name="styleInfo">styleInfo to save into</param>
		/// ------------------------------------------------------------------------------------
		public void SaveToInfo(StyleInfo styleInfo)
		{
			CheckDisposed();

			// Save the bullet information
			styleInfo.IBullet.IsInherited = false;
			BulletInfo bulInfo = new BulletInfo();
			UpdateBulletInfo(ref bulInfo);

			// Replace the value
			if (styleInfo.IBullet.Save(m_rbUnspecified.Checked, bulInfo))
				styleInfo.Dirty = true;
		}
Beispiel #17
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();
			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;
		}
Beispiel #18
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;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the properties of a StyleInfo to the factory default settings
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void SetPropsToFactorySettings(StyleInfo styleInfo)
		{
			TeStylesXmlAccessor acc = new TeStylesXmlAccessor(styleInfo.Cache.LanguageProject.TranslatedScriptureOA);
			acc.ResetProps(styleInfo);
		}
Beispiel #20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the information on the font tab.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// <param name="ws">The writing system for the overrides. -1 for the default settings
		/// </param>
		/// ------------------------------------------------------------------------------------
		public void UpdateForStyle(StyleInfo styleInfo, int ws)
		{
			CheckDisposed();

			if (styleInfo == null)
				return;

			m_dontUpdateInheritance = true;
			m_currentStyleInfo = styleInfo;
			m_currentWs = ws;
			if (ws == -1)
			{
				m_fIgnoreWsSelectedIndexChange = true;
				m_lstWritingSystems.SelectedIndices.Clear();
				m_lstWritingSystems.SelectedIndices.Add(0);
				m_fIgnoreWsSelectedIndexChange = false;
			}

			// If the first item is selected, it is the "default", so the font list should
			// only include the magic font names, not the real ones.
			FillFontNames(ws > -1);

			m_FontAttributes.ShowingInheritedProperties = ShowingInheritedProperties;

			// Initialize controls based on whether or not this style inherits from another style.
			InitControlBehavior(ShowingInheritedProperties);

			FontInfo fontInfo = styleInfo.FontInfoForWs(ws);
			m_FontAttributes.UpdateForStyle(fontInfo);

			// update the font size combobox
			if (!m_cboFontSize.SetInheritableProp(fontInfo.m_fontSize))
				m_cboFontSize.Text = (fontInfo.m_fontSize.Value / 1000).ToString();

			// update the font names
			if (!m_cboFontNames.SetInheritableProp(fontInfo.m_fontName))
			{
				string fontName = fontInfo.m_fontName.Value;
				if (string.IsNullOrEmpty(fontName))
				{
					Debug.Fail("How did this happen? Tim & Tom don't think it can.");
					m_cboFontNames.AdjustedSelectedIndex = 0;
				}
				else if (fontName == StyleServices.DefaultFont)
					m_cboFontNames.AdjustedSelectedIndex = 1;
				else
					m_cboFontNames.Text = fontName;
			}

			// Update the descriptions for the writing system overrides
			UpdateWritingSystemDescriptions();

			m_dontUpdateInheritance = false;
		}
Beispiel #21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the properties of a StyleInfo to the factory default settings
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void SetPropsToFactorySettings(StyleInfo styleInfo)
		{
			TeStylesXmlAccessor.SetPropsToFactorySettings(styleInfo);
		}
Beispiel #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves the font information to the styleInfo
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void SaveToInfo(StyleInfo styleInfo)
		{
			CheckDisposed();

			FontInfo fontInfo = styleInfo.FontInfoForWs(m_currentWs);
			// Font name
			bool newInherit = IsInherited(m_cboFontNames);
			string newValue;
			switch (m_cboFontNames.AdjustedSelectedIndex)
			{
				case 1: newValue = StyleServices.DefaultFont; break;
				default: newValue = m_cboFontNames.Text; break;
			}
			if (fontInfo.m_fontName.Save(newInherit, newValue))
				styleInfo.Dirty = true;

			// font size
			newInherit = IsInherited(m_cboFontSize);
			int fontSize = (m_cboFontSize.Text == string.Empty || newInherit) ? 0 : Int32.Parse(m_cboFontSize.Text);
			if (fontInfo.m_fontSize.Save(newInherit, fontSize * 1000))
				styleInfo.Dirty = true;

			// color
			Color color = m_FontAttributes.GetFontColor(out newInherit);
			if (fontInfo.m_fontColor.Save(newInherit, color))
				styleInfo.Dirty = true;

			// background color
			color = m_FontAttributes.GetBackgroundColor(out newInherit);
			if (fontInfo.m_backColor.Save(newInherit, color))
				styleInfo.Dirty = true;

			// underline style
			FwUnderlineType underlineType = m_FontAttributes.GetUnderlineType(out newInherit);
			if (fontInfo.m_underline.Save(newInherit, underlineType))
				styleInfo.Dirty = true;

			// underline color
			color = m_FontAttributes.GetUnderlineColor(out newInherit);
			if (fontInfo.m_underlineColor.Save(newInherit, color))
				styleInfo.Dirty = true;

			// bold, italic, superscript, subscript
			bool fFlag = m_FontAttributes.GetBold(out newInherit);
			if (fontInfo.m_bold.Save(newInherit, fFlag))
				styleInfo.Dirty = true;

			fFlag = m_FontAttributes.GetItalic(out newInherit);
			if (fontInfo.m_italic.Save(newInherit, fFlag))
				styleInfo.Dirty = true;

			FwSuperscriptVal superSub = m_FontAttributes.GetSubSuperscript(out newInherit);
			if (fontInfo.m_superSub.Save(newInherit, superSub))
				styleInfo.Dirty = true;

			// position
			int fontPos = m_FontAttributes.GetFontPosition(out newInherit);
			if (fontInfo.m_offset.Save(newInherit, fontPos))
				styleInfo.Dirty = true;

			// features
			string fontFeatures = m_FontAttributes.GetFontFeatures(out newInherit);
			if (fontInfo.m_features.Save(newInherit, fontFeatures))
				styleInfo.Dirty = true;
		}
Beispiel #23
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();
            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;
        }
Beispiel #24
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;
        }
        /// ------------------------------------------------------------------------------------
        /// <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
            // Don't allow controls to undo their inherited state while filling in
            m_dontUpdateInheritance = true;
            m_currentStyleInfo      = styleInfo;

            // Initialize controls based on whether or not this style inherits from another style.
            InitControlBehavior(styleInfo.Inherits);

            // LTR or RTL
            m_cboDirection.SetInheritableProp(styleInfo.IRightToLeftStyle);
            m_cboDirection.AdjustedSelectedIndex = (int)styleInfo.IRightToLeftStyle.Value;
            ChangeDirectionLabels(styleInfo.IRightToLeftStyle.Value == TriStateBool.triNotSet ||
                                  m_fShowBiDiLabels ? m_fShowBiDiLabels :
                                  styleInfo.IRightToLeftStyle.Value == TriStateBool.triTrue);

            // Paragraph Alignment
            m_cboAlignment.SetInheritableProp(styleInfo.IAlignment);
            switch (styleInfo.IAlignment.Value)
            {
            case FwTextAlign.ktalLeading: m_cboAlignment.AdjustedSelectedIndex = 1; break;

            case FwTextAlign.ktalLeft: m_cboAlignment.AdjustedSelectedIndex = 2; break;

            case FwTextAlign.ktalCenter: m_cboAlignment.AdjustedSelectedIndex = 3; break;

            case FwTextAlign.ktalRight: m_cboAlignment.AdjustedSelectedIndex = 4; break;

            case FwTextAlign.ktalTrailing: m_cboAlignment.AdjustedSelectedIndex = 5; break;

            case FwTextAlign.ktalJustify: m_cboAlignment.AdjustedSelectedIndex = 6; break;
            }

            // Special indent
            m_cboSpecialIndentation.SetInheritableProp(styleInfo.IFirstLineIndent);
            if (styleInfo.IFirstLineIndent.Value == 0)
            {
                m_cboSpecialIndentation.AdjustedSelectedIndex = 1;                      // none
            }
            else if (styleInfo.IFirstLineIndent.Value > 0)
            {
                m_cboSpecialIndentation.AdjustedSelectedIndex = 2;                      // first line
            }
            else
            {
                m_cboSpecialIndentation.AdjustedSelectedIndex = 3;                      // hanging
            }
            m_nudIndentBy.ForeColor    = GetCtrlForeColorForProp(styleInfo.IFirstLineIndent);
            m_nudIndentBy.MeasureValue = Math.Abs(styleInfo.IFirstLineIndent.Value);

            // update the up/down measure controls
            m_nudLeftIndentation.ForeColor     = GetCtrlForeColorForProp(styleInfo.ILeadingIndent);
            m_nudLeftIndentation.MeasureValue  = styleInfo.ILeadingIndent.Value;
            m_nudRightIndentation.ForeColor    = GetCtrlForeColorForProp(styleInfo.ITrailingIndent);
            m_nudRightIndentation.MeasureValue = styleInfo.ITrailingIndent.Value;
            m_nudBefore.ForeColor    = GetCtrlForeColorForProp(styleInfo.ISpaceBefore);
            m_nudBefore.MeasureValue = styleInfo.ISpaceBefore.Value;
            m_nudAfter.ForeColor     = GetCtrlForeColorForProp(styleInfo.ISpaceAfter);
            m_nudAfter.MeasureValue  = styleInfo.ISpaceAfter.Value;

            LineHeightInfo info = styleInfo.ILineSpacing.Value;
            m_cboLineSpacing.SetInheritableProp(styleInfo.ILineSpacing);
            m_nudSpacingAt.ForeColor = GetCtrlForeColorForProp(styleInfo.ILineSpacing);
            if (!info.m_relative)
            {
                if (info.m_lineHeight < 0)
                {
                    // Exact line spacing
                    m_cboLineSpacing.AdjustedSelectedIndex = kExactlyIndex;
                    m_nudSpacingAt.MeasureMin = 1000;
                }
                else
                {
                    // at least line spacing
                    m_cboLineSpacing.AdjustedSelectedIndex = kAtLeastIndex;
                    m_nudSpacingAt.MeasureMin = 0;
                }

                m_nudSpacingAt.MeasureValue = Math.Abs(info.m_lineHeight);
            }
            else
            {
                switch (info.m_lineHeight)
                {
                case 10000:                             // single spacing
                    m_cboLineSpacing.AdjustedSelectedIndex = 1;
                    break;

                case 15000:                             // 1.5 line spacing
                    m_cboLineSpacing.AdjustedSelectedIndex = 2;
                    break;

                case 20000:                             // double spacing
                    m_cboLineSpacing.AdjustedSelectedIndex = 3;
                    break;
                }
            }

            FontInfo fontInfo = styleInfo.FontInfoForWs(-1);             // get default fontInfo
            m_cboBackground.ForeColor  = GetCtrlForeColorForProp(fontInfo.m_backColor);
            m_cboBackground.ColorValue = fontInfo.m_backColor.Value;

            m_dontUpdateInheritance = false;
        }
Beispiel #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves any changes in the dialog for the style
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		private void UpdateChanges(StyleInfo styleInfo)
		{
			if (styleInfo == null)
				return;

			// save the changes from the other tabs
			m_generalTab.SaveToInfo(styleInfo);
			m_fontTab.SaveToInfo(styleInfo);
			if (styleInfo.IsParagraphStyle)
			{
				m_paragraphTab.SaveToInfo(styleInfo);
				m_bulletsTab.SaveToInfo(styleInfo);
				m_borderTab.SaveToInfo(styleInfo);
			}

			// do this last
			m_styleTable.ConnectStyles();
		}
Beispiel #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves the information on the tab to the specified style info.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void SaveToInfo(StyleInfo styleInfo)
		{
			// save the changes from the general tab
			// NOTE: The name has to be set last as ChangeStyleName can update the basedOn
			// and Following styles for styleInfo to its correct values.
			styleInfo.SaveBasedOn(m_cboBasedOn.Text);
			styleInfo.SaveFollowing(m_cboFollowingStyle.Text);
			if (m_txtStyleName.Text != styleInfo.Name)
				ChangeStyleName(styleInfo);
			styleInfo.SaveDescription(m_txtStyleUsage.Text);
		}
Beispiel #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the controls on each of the tab pages being displayed to reflect the
		/// properties of the specified style.
		/// </summary>
		/// <param name="styleInfo">The style info (for the currently selected style).</param>
		/// ------------------------------------------------------------------------------------
		private void UpdateTabsForStyle(StyleInfo styleInfo)
		{
			m_fontTab.UpdateForStyle(styleInfo, -1);

			// Only update the rest of the tabs if the style is a paragraph style
			if (styleInfo.IsParagraphStyle)
			{
				m_paragraphTab.UpdateForStyle(styleInfo);
				m_bulletsTab.UpdateForStyle(styleInfo);
				m_borderTab.UpdateForStyle(styleInfo);
			}
		}
Beispiel #29
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();

            m_dontUpdateInheritance  = true;
            m_fIgnoreCascadingEvents = true;
            m_currentStyleInfo       = styleInfo;

            m_cboColor.ForeColor   = GetCtrlForeColorForProp(styleInfo.IBorderColor);
            m_cboColor.IsInherited = styleInfo.Inherits;

            m_cboColor.ColorValue = styleInfo.BorderColor;

            bool fWidthInherited = styleInfo.BorderThickness.IsInherited && styleInfo.Inherits;

            m_chkTop.ThreeState    = fWidthInherited;
            m_chkRight.ThreeState  = fWidthInherited;
            m_chkBottom.ThreeState = fWidthInherited;
            m_chkLeft.ThreeState   = fWidthInherited;
            if (fWidthInherited)
            {
                m_chkBottom.CheckState = CheckState.Indeterminate;
                m_chkTop.CheckState    = CheckState.Indeterminate;
                m_chkLeft.CheckState   = CheckState.Indeterminate;
                m_chkRight.CheckState  = CheckState.Indeterminate;
            }
            else
            {
                m_chkTop.CheckState    = (styleInfo.BorderTop == 0) ? CheckState.Unchecked : CheckState.Checked;
                m_chkBottom.CheckState = (styleInfo.BorderBottom == 0) ? CheckState.Unchecked : CheckState.Checked;
                m_chkLeft.CheckState   = (styleInfo.BorderLeading == 0) ? CheckState.Unchecked : CheckState.Checked;
                m_chkRight.CheckState  = (styleInfo.BorderTrailing == 0) ? CheckState.Unchecked : CheckState.Checked;
            }

            m_cboWidth.SetInheritableProp(styleInfo.BorderThickness);
            m_cboWidth.ShowingInheritedProperties = styleInfo.Inherits;
            int maxWidth = styleInfo.BorderWidth;

            if (maxWidth == 0)
            {
                // 1/2 pt is the default value to display, even though 0 is the default value
                maxWidth = 500;
            }
            // select the border width in the combobox
            m_cboWidth.AdjustedSelectedIndex = Array.IndexOf <int>(s_borderSizes, maxWidth);

            // Change the left and right check boxes if the check boxes need to change
            // places (because the paragraph direction is different)
            if ((m_chkRight.Left < m_chkLeft.Left) != DefaultTextDirectionRtoL)
            {
                System.Drawing.ContentAlignment saveChkAlign = m_chkLeft.CheckAlign;
                m_chkLeft.CheckAlign  = m_chkRight.CheckAlign;
                m_chkRight.CheckAlign = saveChkAlign;

                AdjustCheckboxPositionsToPreserveGap();
            }

            // Change the labels to show leading/trailing or left/right depending on the
            // paragraph direction.
            ChangeDirectionLabels(styleInfo.IRightToLeftStyle.Value == TriStateBool.triNotSet ?
                                  m_fShowBiDiLabels : styleInfo.IRightToLeftStyle.Value == TriStateBool.triTrue);

            m_dontUpdateInheritance  = false;
            m_fIgnoreCascadingEvents = false;
            m_pnlBorderPreview.Refresh();
        }
Beispiel #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Reset the properties of a StyleInfo to the factory default settings
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		protected void ResetProps(StyleInfo styleInfo)
		{
			styleInfo.ResetAllPropertiesToFactoryValues(() =>
				{
					XmlNode styleNode = LoadDoc().SelectSingleNode("markup/tag[@id='" + styleInfo.Name.Replace(" ", "_") + "']");
					SetFontProperties(styleInfo.Name, styleNode,
						(tpt, iVar, iVal) => styleInfo.SetExplicitFontIntProp(tpt, iVal),
						(tpt, sVal) =>
						{
							if (tpt == (int)FwTextPropType.ktptWsStyle)
								styleInfo.ProcessWsSpecificOverrides(sVal);
							else
								throw new InvalidEnumArgumentException("tpt", tpt, typeof(FwTextPropType));
						},
						OverwriteOptions.All);
					if (styleInfo.IsParagraphStyle)
					{
						SetParagraphProperties(styleInfo.Name, styleNode, (tpt, iVar, iVal) =>
							{
								if (!styleInfo.SetExplicitParaIntProp(tpt, iVar, iVal))
									throw new InvalidEnumArgumentException("tpt", tpt, typeof(FwTextPropType));
							},
							OverwriteOptions.All);
					}
				});
		}
Beispiel #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a new style to our internal table of styles (i.e., not yet to the DB) in
		/// response to the user clicking one of the style type submenu items.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void StyleTypeMenuItem_Click(object sender, EventArgs e)
		{
			bool fParaStyle = (sender == paragraphStyleToolStripMenuItem);

			// generate a name for the new style
			string styleName = fParaStyle ?
				FwCoreDlgs.kstidNewParagraphStyle : FwCoreDlgs.kstidNewCharacterStyle;
			int styleNum = 2;
			string styleFormatString = fParaStyle ?
				FwCoreDlgs.kstidNewParagraphStyleWithNumber :
				FwCoreDlgs.kstidNewCharacterStyleWithNumber;
			while (m_styleTable.ContainsKey(styleName))
				styleName = string.Format(styleFormatString, styleNum++);

			// create a new styleinfo
			StyleInfo style = new StyleInfo(styleName,
				fParaStyle ? m_normalStyleInfo : null,
				fParaStyle ? StyleType.kstParagraph : StyleType.kstCharacter,
				m_cache);

			// add the styleinfo to the style list and the list control
			m_styleTable.Add(style.Name, style);
			m_styleTable.ConnectStyles();
			m_styleListHelper.Add(style);

			// select the name field
			m_tabControl.SelectedTab = m_tbGeneral;
			m_tbGeneral.Focus();
		}
Beispiel #32
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the information on the font tab using the current writing system.
        /// </summary>
        /// <param name="styleInfo">The style info.</param>
        /// ------------------------------------------------------------------------------------
        public void UpdateForStyle(StyleInfo styleInfo)
        {
            CheckDisposed();

            UpdateForStyle(styleInfo, m_currentWs);
        }
Beispiel #33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwStylesDlg"/> class. This version
		/// can be used by C# clients. There is no need for the client to call Init if this
		/// constructor is used.
		/// </summary>
		/// <param name="rootSite">The root site.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="defaultRightToLeft">Indicates whether current context (typically the
		/// default direction of the view from which this dialog is invoked) is right to left.</param>
		/// <param name="showBiDiLabels">Indicates whether to show labels that are meaningful
		/// for both left-to-right and right-to-left. If <c>defaultRightToLeft</c> is set to
		/// <c>true</c> the passed-in value for this parameter will be ignored and the display
		/// will automatically be BiDi enabled. If this value is false, then simple "Left" and
		/// "Right" labels will be used in the display, rather than "Leading" and "Trailing".</param>
		/// <param name="normalStyleName">Name of the normal style.</param>
		/// <param name="customUserLevel">The custom user level.</param>
		/// <param name="userMeasurementType">User's prefered measurement units.</param>
		/// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
		/// <param name="charStyleName">Name of the currently selected character style.</param>
		/// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
		/// <param name="app">The application.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public FwStylesDlg(IVwRootSite rootSite, FdoCache cache, FwStyleSheet styleSheet,
			bool defaultRightToLeft, bool showBiDiLabels, string normalStyleName,
			int customUserLevel, MsrSysType userMeasurementType, string paraStyleName,
			string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider)
			: this()
		{
			m_rootSite = rootSite;
			m_cache = cache;
			m_customUserLevel = customUserLevel;
			m_hvoRootObject = hvoRootObject;
			m_app = app;
			showBiDiLabels |= defaultRightToLeft;
			m_userMeasurementType = userMeasurementType;
			m_helpTopicProvider = helpTopicProvider;

			// Cache is null in tests
			if (cache == null)
				return;

			m_cboTypes.SelectedIndex = 1; // All Styles

			// Load the style information
			m_styleTable = new StyleInfoTable(normalStyleName,
				cache.ServiceLocator.WritingSystemManager);
			m_styleSheet = styleSheet;
			FillStyleTable(m_styleSheet);
			m_normalStyleInfo = (StyleInfo)m_styleTable[normalStyleName];
			Debug.Assert(m_normalStyleInfo != null);
			m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
			m_styleListHelper.AddStyles(m_styleTable, null);
			m_styleListHelper.ShowInternalStyles = true;
			m_styleListHelper.StyleChosen += new StyleChosenHandler(m_styleListHelper_StyleChosen);
			m_styleListHelper.Refresh();

			// Mark the current styles
			m_styleListHelper.MarkCurrentStyle(paraStyleName);
			m_styleListHelper.MarkCurrentStyle(charStyleName);

			// General tab
			m_generalTab.Application = m_app;
			m_generalTab.StyleListHelper = m_styleListHelper;
			m_generalTab.StyleTable = m_styleTable;
			m_generalTab.ShowBiDiLabels = showBiDiLabels;
			m_generalTab.UserMeasurementType = m_userMeasurementType;
			m_generalTab.RenamedStyles = m_renamedStyles;

			// Load the font information
			m_fontTab.WritingSystemFactory = cache.WritingSystemFactory;
			m_fontTab.FillFontInfo(cache);

			// Disable the background color on the paragraph tab.
			m_paragraphTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_paragraphTab.ShowBiDiLabels = showBiDiLabels;
			m_paragraphTab.MeasureType = userMeasurementType;

			m_bulletsTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_bulletsTab.StyleSheet = m_styleSheet;

			m_borderTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_borderTab.ShowBiDiLabels = showBiDiLabels;

			// Select the current paragraph style in the list (or fall back to Normal)
			CurrentStyle = (!string.IsNullOrEmpty(paraStyleName)) ? paraStyleName : normalStyleName;
		}
Beispiel #34
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the information on the font tab.
        /// </summary>
        /// <param name="styleInfo">The style info.</param>
        /// <param name="ws">The writing system for the overrides. -1 for the default settings
        /// </param>
        /// ------------------------------------------------------------------------------------
        public void UpdateForStyle(StyleInfo styleInfo, int ws)
        {
            CheckDisposed();

            m_dontUpdateInheritance = true;
            m_currentStyleInfo      = styleInfo;
            m_currentWs             = ws;
            if (ws == -1)
            {
                m_fIgnoreWsSelectedIndexChange = true;
                m_lstWritingSystems.SelectedIndices.Clear();
                m_lstWritingSystems.SelectedIndices.Add(0);
                m_fIgnoreWsSelectedIndexChange = false;
            }

            // If the first item is selected, it is the "default", so the font list should
            // only include the magic font names, not the real ones.
            FillFontNames(ws > -1);

            m_FontAttributes.ShowingInheritedProperties = ShowingInheritedProperties;

            // Initialize controls based on whether or not this style inherits from another style.
            InitControlBehavior(ShowingInheritedProperties);

            FontInfo fontInfo = styleInfo.FontInfoForWs(ws);

            m_FontAttributes.UpdateForStyle(fontInfo);

            // update the font size combobox
            if (!m_cboFontSize.SetInheritableProp(fontInfo.m_fontSize))
            {
                m_cboFontSize.Text = (fontInfo.m_fontSize.Value / 1000).ToString();
            }

            // update the font names
            if (!m_cboFontNames.SetInheritableProp(fontInfo.m_fontName))
            {
                string fontName = fontInfo.m_fontName.Value;
                if (fontName == null || fontName == string.Empty)
                {
                    Debug.Fail("How did this happen? Tim & Tom don't think it can.");
                    m_cboFontNames.AdjustedSelectedIndex = 0;
                }
                else if (fontName == StStyle.DefaultFont)
                {
                    m_cboFontNames.AdjustedSelectedIndex = 1;
                }
                else if (fontName == StStyle.DefaultPubFont)
                {
                    m_cboFontNames.AdjustedSelectedIndex = 2;
                }
                else if (fontName == StStyle.DefaultHeadingFont)
                {
                    m_cboFontNames.AdjustedSelectedIndex = 3;
                }
                else
                {
                    m_cboFontNames.Text = fontName;
                }
            }

            // Update the descriptions for the writing system overrides
            UpdateWritingSystemDescriptions();

            m_dontUpdateInheritance = false;
        }
Beispiel #35
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handles the Click event of the m_btnCopy control.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void m_btnCopy_Click(object sender, EventArgs e)
		{
			// before copying a new style, save any edits to the current style
			if (m_styleListHelper.SelectedStyle != null)
				UpdateChanges((StyleInfo)m_styleListHelper.SelectedStyle.StyleInfo);
			else
				return;

			// Get the selected style
			StyleListItem copiedStyle = m_styleListHelper.SelectedStyle;
			if (copiedStyle.StyleInfo == null)
				return;

			// Generate a name for the copied style.
			int styleNum = 2;
			string styleFormatString = FwCoreDlgs.kstidCopyStyleNameFormat;
			string styleFormatNumberString = FwCoreDlgs.kstidCopyStyleNameFormatNumber;
			string newStyleName = string.Format(styleFormatString, copiedStyle.Name);
			while (m_styleTable.ContainsKey(newStyleName))
				newStyleName = string.Format(styleFormatNumberString, styleNum++, copiedStyle.Name);

			// create a new styleinfo
			StyleInfo newStyle = new StyleInfo(copiedStyle.StyleInfo, newStyleName);

			// add the styleinfo to the style list and the list control
			m_styleTable.Add(newStyleName, newStyle);
			m_styleTable.ConnectStyles();
			m_styleListHelper.Add(newStyle);

			// select the name field
			m_tabControl.SelectedTab = m_tbGeneral;
			m_tbGeneral.Focus();
		}
Beispiel #36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the information on the tab with the information in the specified style info.
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		public void UpdateForStyle(StyleInfo styleInfo)
		{
			if (styleInfo == null)
			{
				FillForDefaultParagraphCharacters();
				this.Enabled = false;
				return;
			}
			this.Enabled = true;

			m_txtStyleName.Enabled = !styleInfo.IsBuiltIn;
			m_txtStyleUsage.ReadOnly = styleInfo.IsBuiltIn;
			m_cboBasedOn.Enabled = !styleInfo.IsBuiltIn;
			m_cboFollowingStyle.Enabled = !styleInfo.IsBuiltIn;
			m_txtShortcut.Enabled = false;
			m_txtStyleName.Text = styleInfo.Name;
			m_lblStyleType.Text = (styleInfo.IsCharacterStyle) ?
				FwCoreDlgControls.kstidCharacterStyleText : FwCoreDlgControls.kstidParagraphStyleText;
			m_txtStyleUsage.Text = styleInfo.Usage;
			m_lblStyleDescription.Text = styleInfo.ToString(m_fShowBiDiLabels, m_userMeasurementType);

			// Handle the Based On style combo
			FillBasedOnStyles(styleInfo);
			if (styleInfo.BasedOnStyle != null)
				m_cboBasedOn.SelectedItem = styleInfo.BasedOnStyle.Name;
			else
			{
				if (styleInfo.IsCharacterStyle)
					m_cboBasedOn.SelectedIndex = 0;	// "default paragraph characters"
				else
					m_cboBasedOn.SelectedIndex = -1;
			}

			UpdateFollowingStylesCbo(styleInfo);
		}