示例#1
0
        private static void AddVariantTypeGlossInfo(ITsIncStrBldr sb, CoreWritingSystemDefinition wsGloss, IList <IMultiUnicode> multiUnicodeAccessors, CoreWritingSystemDefinition wsUser)
        {
            const string sSeriesSeparator = kDefaultSeriesSeparatorLexEntryTypeReverseAbbr;
            var          fBeginSeparator  = true;

            foreach (var multiUnicodeAccessor in multiUnicodeAccessors)
            {
                int wsActual2;
                var tssVariantTypeInfo = multiUnicodeAccessor.GetAlternativeOrBestTss(wsGloss.Handle, out wsActual2);
                // just concatenate them together separated by comma.
                if (tssVariantTypeInfo == null || tssVariantTypeInfo.Length <= 0)
                {
                    continue;
                }
                if (!fBeginSeparator)
                {
                    sb.AppendTsString(TsStringUtils.MakeString(sSeriesSeparator, wsUser.Handle));
                }
                sb.AppendTsString((tssVariantTypeInfo));
                fBeginSeparator = false;
            }

            // Handle the special case where no reverse abbr was found.
            if (fBeginSeparator && multiUnicodeAccessors.Count > 0)
            {
                sb.AppendTsString(multiUnicodeAccessors.ElementAt(0).NotFoundTss);
            }
        }
示例#2
0
 /// <summary>
 /// Merge two MultiUnicodeAccessor objects.
 /// These cases are handled:
 ///		1. If an alternative exists in both objects, nothing is merged.
 ///		2. If the main object (this) is missing an alternative, and the 'source' has it, then add it to 'this'.
 ///		3. If the main object has an alternative, then do nothing.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="fConcatenateIfBoth"></param>
 /// <param name="sep">separator to use if concatenating</param>
 public void MergeAlternatives(IMultiStringAccessor source, bool fConcatenateIfBoth, string sep)
 {
     if (source == null)
     {
         return;                 // Nothing to do.
     }
     foreach (var lws in m_object.Services.WritingSystemManager.WritingSystems)
     {
         var ws     = lws.Handle;
         var myAlt  = get_String(ws);
         var srcAlt = source.get_String(ws);
         if ((myAlt == null || myAlt.Length == 0) &&
             (srcAlt != null && srcAlt.Length != 0))
         {
             set_String(ws, srcAlt);
         }
         else if (!fConcatenateIfBoth)
         {
             continue;
         }
         else if (myAlt != null && myAlt.Length != 0 &&
                  srcAlt != null && srcAlt.Length != 0 &&
                  !myAlt.Equals(srcAlt))
         {
             ITsIncStrBldr newBldr = TsStringUtils.MakeIncStrBldr();
             newBldr.AppendTsString(get_String(ws));
             newBldr.Append(sep);
             newBldr.AppendTsString(source.get_String(ws));
             set_String(ws, newBldr.GetString());
         }
     }
 }
示例#3
0
        ITsString CreateFeatureLine(IFsClosedValue value)
        {
            ITsIncStrBldr featLine = TsStringUtils.MakeIncStrBldr();

            featLine.AppendTsString(value.ValueRA != null ? value.ValueRA.Abbreviation.BestAnalysisAlternative : m_questions);
            featLine.Append(" ");
            featLine.AppendTsString(value.FeatureRA != null ? value.FeatureRA.Abbreviation.BestAnalysisAlternative : m_questions);
            return(featLine.GetString());
        }
示例#4
0
        private ITsString TitleForWs(int ws)
        {
            ITsString tssTitle = null;

            if (ScriptureServices.ScriptureIsResponsibleFor(this))
            {
                Scripture scripture = Cache.LangProject.TranslatedScriptureOA as Scripture;
                if (scripture != null)
                {
                    tssTitle = scripture.BookChapterVerseBridgeAsTss(this, ws);
                    if (OwningFlid == ScrSectionTags.kflidHeading)
                    {
                        string sFmt = Strings.ksSectionHeading;
                        int    iMin = sFmt.IndexOf("{0}");
                        if (iMin < 0)
                        {
                            tssTitle = m_cache.MakeUserTss(sFmt);
                        }
                        else
                        {
                            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
                            if (iMin > 0)
                            {
                                tisb.AppendTsString(m_cache.MakeUserTss(sFmt.Substring(0, iMin)));
                            }
                            tisb.AppendTsString(tssTitle);
                            if (iMin + 3 < sFmt.Length)
                            {
                                tisb.AppendTsString(m_cache.MakeUserTss(sFmt.Substring(iMin + 3)));
                            }
                            tssTitle = tisb.GetString();
                        }
                    }
                }
            }
            else if (Owner is IText)
            {
                IText text = Owner as IText;
                tssTitle = text.Name.get_String(ws);
            }
            else
            {
                // throw?
            }
            if (tssTitle == null)
            {
                tssTitle = TsStrFactoryClass.Create().EmptyString(Cache.DefaultAnalWs);
            }
            return(tssTitle);
        }
示例#5
0
        public void StringServices_CrawlRunsCanDeleteFromEnd()
        {
            var           wsEn  = Cache.WritingSystemFactory.GetWsFromStr("en");
            var           wsFr  = Cache.WritingSystemFactory.GetWsFromStr("fr");
            var           begin = TsStringUtils.MakeString("beginning", wsEn);
            var           end   = TsStringUtils.MakeString("end", wsFr);
            ITsIncStrBldr tisb  = TsStringUtils.MakeIncStrBldr();

            tisb.AppendTsString(begin);
            tisb.AppendTsString(end);
            ITsString result = null;

            Assert.DoesNotThrow(() => result = StringServices.CrawlRuns(tisb.GetString(), run => run.get_WritingSystemAt(0) == wsFr ? null : run));
            Assert.That(result.Text, Is.StringMatching("beginning"));
        }
		/// <summary>
		/// This method will be overridden in common subtypes (like MoStemMsa)
		/// to use the TsIncStrBldr passed to it instead of creating another builder.
		/// (See LT-13728 for performance issues.)
		/// </summary>
		/// <param name="tisb"></param>
		internal virtual void AddChooserNameInItalics(ITsIncStrBldr tisb)
		{
			ITsStrBldr tsb = ChooserNameTS.GetBldr();
			tsb.SetIntPropValues(0, tsb.Length, (int)FwTextPropType.ktptItalic,
									(int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
			tisb.AppendTsString(tsb.GetString());
		}
示例#7
0
        /// <summary>
        /// Returns a TsString with the entry headword and a sense number if there
        /// are more than one senses.
        /// </summary>
        public ITsString OwnerOutlineNameForWs(ILexSense sense, int wsVern, HomographConfiguration.HeadwordVariant hv)
        {
            var entry = sense.Entry;
            int hn;

            if (!m_homographNumbers.TryGetValue(entry.Hvo, out hn))
            {
                hn = entry.HomographNumber;                 // unknown entry, use its own HN instead of our override
            }
            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.AppendTsString(StringServices.HeadWordForWsAndHn(entry, wsVern, hn, "", hv));
            var hc = sense.Services.GetInstance <HomographConfiguration>();

            if (hc.ShowSenseNumber(hv) && HasMoreThanOneSense(entry))
            {
                // These int props may not be needed, but they're safe.
                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
                                      Cache.DefaultAnalWs);
                tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                     HomographConfiguration.ksSenseReferenceNumberStyle);
                tisb.Append(" ");
                tisb.Append(GetSenseNumber(sense));
            }
            return(tisb.GetString());
        }
        /// <summary>
        /// Crawls all runs in the specified string. The run modifier is called for each run in the
        /// specified string. If the run modifier returns <c>null</c>, the run is removed from
        /// the string. If all runs are removed, this method returns <c>null</c>.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <param name="runModifier">The run modifier.</param>
        /// <returns></returns>
        public static ITsString CrawlRuns(ITsString str, Func <ITsString, ITsString> runModifier)
        {
            ITsIncStrBldr tisb     = TsIncStrBldrClass.Create();
            bool          modified = false;
            bool          empty    = true;

            for (int i = 0; i < str.RunCount; i++)
            {
                int ichMin, ichLim;
                str.GetBoundsOfRun(i, out ichMin, out ichLim);
                ITsString oldRun = str.GetSubstring(ichMin, ichLim);
                ITsString newRun = runModifier(oldRun);
                if (newRun != null)
                {
                    if (modified || newRun != oldRun)
                    {
                        tisb.AppendTsString(newRun);
                        modified = true;
                    }
                    empty = false;
                }
                else
                {
                    modified = true;
                }
            }

            if (empty)
            {
                return(null);
            }

            return(modified ? tisb.GetString() : str);
        }
        public ITsString CreateFeatureLine(ITsString name, ITsString value, bool negated)
        {
            ITsIncStrBldr featLine = TsIncStrBldrClass.Create();

            featLine.AppendTsString(name);
            featLine.Append(": ");
            if (value != null)
            {
                if (negated)
                {
                    featLine.AppendTsString(m_tsf.MakeString("!", m_cache.DefaultUserWs));
                }
                featLine.AppendTsString(value);
            }
            return(featLine.GetString());
        }
示例#10
0
        public void StringServices_CrawlRunsCanSuccessfullyDoNothingWithMultipleRuns()
        {
            var           wsEn       = Cache.WritingSystemFactory.GetWsFromStr("en");
            var           wsFr       = Cache.WritingSystemFactory.GetWsFromStr("fr");
            var           tssFactory = Cache.TsStrFactory;
            var           begin      = tssFactory.MakeString("beginning", wsEn);
            var           end        = tssFactory.MakeString("end", wsEn);
            ITsIncStrBldr tisb       = TsIncStrBldrClass.Create();

            tisb.AppendTsString(begin);
            tisb.AppendTsString(end);
            ITsString result = null;

            Assert.DoesNotThrow(() => result = StringServices.CrawlRuns(tisb.GetString(), run => run.get_WritingSystemAt(0) == wsFr ? null : run));
            Assert.That(result.Text, Is.StringMatching("beginningend"));
        }
示例#11
0
        ///<summary>
        ///</summary>
        ///<param name="sb"></param>
        ///<param name="tssGlossAffix"></param>
        ///<param name="prepend"></param>
        ///<param name="sSeparator"></param>
        ///<param name="wsUser"></param>
        private static void AppendGlossAffix(ITsIncStrBldr sb, ITsString tssGlossAffix, bool prepend, string sSeparator, CoreWritingSystemDefinition wsUser)
        {
            if (prepend)
            {
                sb.AppendTsString(tssGlossAffix);
            }
            string extractedSeparator = ExtractDivider(tssGlossAffix.Text, prepend ? -1 : 0);

            if (String.IsNullOrEmpty(extractedSeparator))
            {
                sb.AppendTsString(TsStringUtils.MakeString(sSeparator, wsUser.Handle));
            }
            if (!prepend)
            {
                sb.AppendTsString(tssGlossAffix);
            }
        }
示例#12
0
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, XCore.Mediator mediator)
        {
            CheckDisposed();

            StringTable strings = mediator.StringTbl;

            m_cache = cache;
            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            Text = String.Format(FdoUiStrings.ksDeleteX, strings.GetString(obj.ClassName, "ClassNames"));

            // Set the s_helpTopic based on the window title and rearrange the buttons if neccesary
            switch (obj.ClassName)
            {
            case "WfiWordform":
                s_helpTopic = "khtpDeleteWordform";
                break;
            }
            if (s_helpTopic != null)
            {
                buttonHelp.Visible = true;
                buttonHelp.Enabled = true;
                this.helpProvider  = new System.Windows.Forms.HelpProvider();
                this.helpProvider.HelpNamespace = FwApp.App.HelpFile;
                this.helpProvider.SetHelpKeyword(this, FwApp.App.GetHelpString(s_helpTopic, 0));
                this.helpProvider.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.Topic);
            }
            else
            {
                m_deleteButton.Location = m_cancelButton.Location;
                m_cancelButton.Location = buttonHelp.Location;
            }

            //Use an FWTextBox so that strings of different writing systems will
            //be displayed with the correct stylesheet settings.
            m_descriptionBox3.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_descriptionBox3.WritingSystemCode    = m_cache.LangProject.DefaultUserWritingSystem;
            m_descriptionBox3.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create();

            tisb3.AppendTsString(obj.Object.DeletionTextTSS);
            m_descriptionBox3.Tss = tisb3.GetString();

            m_descriptionBox4.WritingSystemFactory = m_cache.LanguageWritingSystemFactoryAccessor;
            m_descriptionBox4.WritingSystemCode    = m_cache.LangProject.DefaultUserWritingSystem;
            m_descriptionBox4.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create();

            tisb4.AppendTsString(m_cache.MakeUserTss(" "));             //this is the default for m_descriptionBox4
            m_descriptionBox4.Tss = tisb4.GetString();

            m_deleteButton.Enabled = obj.Object.CanDelete;
            label2.Visible         = m_deleteButton.Enabled;
        }
示例#13
0
        /// <summary>
        /// Static version for avoiding creating actual object.
        /// </summary>
        public static void ShortName1Static(ILexEntry entry, ITsIncStrBldr tsb)
        {
            var ws = entry.Services.WritingSystems.DefaultVernacularWritingSystem;

            // Try vernacular citation
            var tss = entry.CitationForm.get_String(ws.Handle);

            if (tss != null && tss.Length > 0)
            {
                tsb.AppendTsString(tss);
                return;
            }

            // Try lexeme form.
            var form = entry.LexemeFormOA;

            if (form != null)
            {
                tss = form.Form.get_String(ws.Handle);
                if (tss != null && tss.Length > 0)
                {
                    tsb.AppendTsString(tss);
                    return;
                }
            }

            // Try the first alternate form with the wsVern WS.
            // NB: This may not be the actual first alterantge.
            foreach (var alt in entry.AlternateFormsOS)
            {
                tss = alt.Form.get_String(ws.Handle);
                if (tss != null && tss.Length > 0)
                {
                    tsb.AppendTsString(tss);
                    return;
                }
            }

            // Give up.
            tsb.AppendTsString(entry.Cache.TsStrFactory.MakeString(
                                   Strings.ksQuestions,
                                   entry.Cache.DefaultUserWs));
        }
示例#14
0
        ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity)
        {
            int varIndex = GetVarIndex(var);

            if (varIndex == -1)
            {
                return(m_questions);
            }

            ITsIncStrBldr varLine = TsStringUtils.MakeIncStrBldr();

            if (!polarity)
            {
                varLine.AppendTsString(TsStringUtils.MakeString("-", m_cache.DefaultUserWs));
            }
            varLine.AppendTsString(TsStringUtils.MakeString(VariableNames[varIndex], m_cache.DefaultUserWs));
            varLine.Append(" ");
            varLine.AppendTsString(var.FeatureRA == null ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative);
            return(varLine.GetString());
        }
示例#15
0
        ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity)
        {
            int varIndex = GetVarIndex(var);

            if (varIndex == -1)
            {
                return(m_questions);
            }

            ITsIncStrBldr varLine = TsIncStrBldrClass.Create();

            if (!polarity)
            {
                varLine.Append("-");
            }
            varLine.AppendTsString(m_cache.MakeUserTss(VARIABLE_NAMES[varIndex]));
            varLine.Append(" ");
            varLine.AppendTsString(var.FeatureRAHvo == 0 ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative);
            return(varLine.GetString());
        }
示例#16
0
        /// <summary>
        /// This method should have the same logic as the (above) HeadWordForWsAndHn().
        /// </summary>
        /// <param name="tisb"></param>
        /// <param name="entry"></param>
        /// <param name="wsVern"></param>
        /// <param name="nHomograph"></param>
        /// <param name="defaultCf"></param>
        /// <param name="hv"></param>
        internal static void AddHeadWordForWsAndHn(ITsIncStrBldr tisb, ILexEntry entry, int wsVern, int nHomograph, string defaultCf,
                                                   HomographConfiguration.HeadwordVariant hv)
        {
            var citationForm = CitationFormWithAffixTypeStaticForWs(entry, wsVern, defaultCf);

            if (String.IsNullOrEmpty(citationForm))
            {
                tisb.AppendTsString(entry.Cache.TsStrFactory.EmptyString(wsVern));                 // avoids COM Exception!
                return;
            }
            AddHeadwordForWsAndHn(entry, wsVern, nHomograph, hv, tisb, citationForm);
        }
示例#17
0
        public void StringServices_CrawlRunsCanDeleteAllRuns()
        {
            var           wsEn       = Cache.WritingSystemFactory.GetWsFromStr("en");
            var           tssFactory = Cache.TsStrFactory;
            var           begin      = tssFactory.MakeString("beginning", wsEn);
            ITsIncStrBldr tisb       = TsIncStrBldrClass.Create();

            tisb.AppendTsString(begin);
            ITsString result = null;

            Assert.DoesNotThrow(() => result = StringServices.CrawlRuns(tisb.GetString(), run => run.get_WritingSystemAt(0) == wsEn ? null : run));
            Assert.That(result, Is.Null);
        }
示例#18
0
        ITsString CreateFeatureLine(IFsClosedValue value)
        {
            ITsIncStrBldr featLine = TsIncStrBldrClass.Create();

            if (value.ValueRAHvo != 0)
            {
                featLine.AppendTsString(value.ValueRA.Abbreviation.BestAnalysisAlternative);
            }
            else
            {
                featLine.AppendTsString(m_questions);
            }
            featLine.Append(" ");
            if (value.FeatureRAHvo != 0)
            {
                featLine.AppendTsString(value.FeatureRA.Abbreviation.BestAnalysisAlternative);
            }
            else
            {
                featLine.AppendTsString(m_questions);
            }
            return(featLine.GetString());
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strings"></param>
        /// <param name="obj"></param>
        /// <param name="cache"></param>
        /// <param name="mediator"></param>
        /// <param name="tssNote">a second message, in addition to what's in obj.Object.DeletionTextTss</param>
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, XCore.Mediator mediator, ITsString tssNote)
        {
            CheckDisposed();

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            //do not change the order of the following two lines of code
            //because m_descritiptionBox4.Tss is given a default value first.
            SetDlgInfo(obj, cache, mediator);
            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.AppendTsString(tssNote);
            m_descriptionBox4.Tss = tisb.GetString();
        }
示例#20
0
        public ResolveKeyTermRenderingImportConflictDlg(IWin32Window owner, IChkRef occurrence,
                                                        string existingRendering, string importedRendering, IVwStylesheet ss) : this()
        {
            FdoCache     cache  = occurrence.Cache;
            IScripture   scr    = cache.LangProject.TranslatedScriptureOA;
            ScrReference scrRef = (new ScrReference(occurrence.Ref, scr.Versification));

            m_owner                = owner;
            m_lblAnalysis.Text     = occurrence.OwnerOfClass <IChkTerm>().Name.AnalysisDefaultWritingSystem.Text;
            m_lblOriginal.Text     = occurrence.KeyWord.Text;
            m_lblScrReference.Text = scrRef.ToString();
            m_btnExisting.Text     = String.Format(m_btnExisting.Text, existingRendering);
            m_btnImported.Text     = String.Format(m_btnImported.Text, importedRendering);

            // We do this outside the designer-controlled code because it does funny things
            // to FwMultiParaTextBox, owing to the need for a writing system factory, and some
            // properties it should not persist but I can't persuade it not to.
//			IStText text = new NonEditableMultiTss(TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, " "));
            //m_verseTextLabel = new FwMultiParaTextBox(text, ss);
            m_verseTextLabel = new FwLabel();
            m_verseTextLabel.WritingSystemFactory = cache.WritingSystemFactory; // set ASAP.
            m_verseTextLabel.WritingSystemCode    = cache.DefaultVernWs;
            m_verseTextLabel.StyleSheet           = ss;                         // before setting text, otherwise it gets confused about height needed.
            m_verseTextLabel.Location             = new Point(0, 0);
            m_verseTextLabel.Name      = "m_textBox";
            m_verseTextLabel.Dock      = DockStyle.Fill;
            m_verseTextLabel.TabIndex  = 0;
            m_verseTextLabel.TextAlign = ContentAlignment.TopLeft;
            //m_verseTextLabel.BorderStyle = BorderStyle.None;
            //m_textBox.SuppressEnter = true;
            m_pnlActualVerseText.Controls.Add(m_verseTextLabel);
            // ENHANCE: Figure out how to get each part (paragraph) of the verse onm its own line. Using newlines or hard line breaks doesn't work.
            ITsIncStrBldr bldr = TsIncStrBldrClass.Create();

            foreach (TeEditingHelper.VerseTextSubstring verseTextSubstring in TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef))
            {
                bldr.AppendTsString(verseTextSubstring.Tss);
                bldr.Append(StringUtils.kChHardLB.ToString());
            }
            m_verseTextLabel.Tss = bldr.GetString();
            //m_verseTextLabel.Tss = TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, StringUtils.kChHardLB.ToString());
        }
示例#21
0
        ///<summary>
        ///</summary>
        ///<param name="gloss"></param>
        ///<param name="wsGloss"></param>
        ///<param name="variantEntryTypes"></param>
        ///<returns></returns>
        public static ITsString MakeGlossWithReverseAbbrs(IMultiStringAccessor gloss, CoreWritingSystemDefinition wsGloss, IList <ILexEntryType> variantEntryTypes)
        {
            if (variantEntryTypes == null || variantEntryTypes.Count() == 0 || variantEntryTypes.First() == null)
            {
                return(GetTssGloss(gloss, wsGloss));
            }
            var cache  = variantEntryTypes.First().Cache;
            var wsUser = cache.ServiceLocator.WritingSystemManager.UserWritingSystem;
            IList <IMultiUnicode> reverseAbbrs = (from variantType in variantEntryTypes
                                                  select variantType.ReverseAbbr).ToList();
            ITsIncStrBldr sb = TsStringUtils.MakeIncStrBldr();

            AddGloss(sb, gloss, wsGloss);
            const string sBeginSeparator = kDefaultBeginSeparatorLexEntryTypeReverseAbbr;

            if (reverseAbbrs.Count() > 0)
            {
                sb.AppendTsString(TsStringUtils.MakeString(sBeginSeparator, wsUser.Handle));
            }
            AddVariantTypeGlossInfo(sb, wsGloss, reverseAbbrs, wsUser);
            return(sb.Text.Length > 0 ? sb.GetString() : null);
        }
示例#22
0
		/// <summary>
		/// This method should have the same logic as the (above) HeadWordForWsAndHn().
		/// </summary>
		/// <param name="tisb"></param>
		/// <param name="entry"></param>
		/// <param name="wsVern"></param>
		/// <param name="nHomograph"></param>
		/// <param name="defaultCf"></param>
		/// <param name="hv"></param>
		internal static void AddHeadWordForWsAndHn(ITsIncStrBldr tisb, ILexEntry entry, int wsVern, int nHomograph, string defaultCf,
	HomographConfiguration.HeadwordVariant hv)
		{
			var citationForm = CitationFormWithAffixTypeStaticForWs(entry, wsVern, defaultCf);
			if (String.IsNullOrEmpty(citationForm))
			{
				tisb.AppendTsString(entry.Cache.TsStrFactory.EmptyString(wsVern)); // avoids COM Exception!
				return;
			}
			AddHeadwordForWsAndHn(entry, wsVern, nHomograph, hv, tisb, citationForm);
		}
示例#23
0
        public void SetDlgInfo(CmObjectUi obj, FdoCache cache, Mediator mediator, ITsString tssNote)
        {
            CheckDisposed();

            if (obj.Mediator == null)
            {
                obj.Mediator = mediator;
            }
            StringTable strings = mediator.StringTbl;

            m_cache = cache;
            IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);

            Debug.Assert(obj != null);
            Debug.Assert(obj.Object != null);

            Text = String.Format(FdoUiStrings.ksDeleteX, obj.DisplayNameOfClass);

            // Set the s_helpTopic based on the window title and rearrange the buttons if neccesary
            switch (obj.ClassName)
            {
            case "WfiWordform":
                s_helpTopic = "khtpDeleteWordform";
                break;
            }
            if (s_helpTopic != null)
            {
                buttonHelp.Visible = true;
                buttonHelp.Enabled = true;
                this.helpProvider  = new HelpProvider();
                this.helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                this.helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic));
                this.helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
            else
            {
                m_deleteButton.Location = m_cancelButton.Location;
                m_cancelButton.Location = buttonHelp.Location;
            }

            //Use an FWTextBox so that strings of different writing systems will
            //be displayed with the correct stylesheet settings.
            int defUserWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;

            m_descriptionBox3.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_descriptionBox3.WritingSystemCode    = defUserWs;
            m_descriptionBox3.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb3 = TsIncStrBldrClass.Create();

            tisb3.AppendTsString(obj.Object.DeletionTextTSS);
            m_descriptionBox3.Tss = tisb3.GetString();
            // Adjust the dialog size if needed to display the message (FWNX-857).
            int deltaY = GrowTextBox(panel1, m_descriptionBox3);

            panel2.Top += deltaY;

            m_descriptionBox4.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_descriptionBox4.WritingSystemCode    = defUserWs;
            m_descriptionBox4.StyleSheet           = stylesheet;
            ITsIncStrBldr tisb4 = TsIncStrBldrClass.Create();

            tisb4.AppendTsString(tssNote);             //this is the default for m_descriptionBox4
            m_descriptionBox4.Tss = tisb4.GetString();
            GrowTextBox(panel2, m_descriptionBox4);

            m_deleteButton.Enabled = obj.Object.CanDelete;
            label2.Visible         = m_deleteButton.Enabled;
        }
示例#24
0
        /// <summary>
        /// Initialize the dialog before showing it.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="entry"></param>
        /// <param name="titleForEdit">Edit title appropriate to the button's context.</param>
        public void SetDlgInfo(FdoCache cache, IPersistenceProvider persistProvider,
                               Mediator mediator, ILexEntry entry, SandboxGenericMSA sandboxMsa, int hvoOriginalMsa,
                               bool useForEdit, string titleForEdit)
        {
            CheckDisposed();

            Debug.Assert(m_cache == null);
            MsaType msaType = sandboxMsa.MsaType;

            m_cache    = cache;
            m_mediator = mediator;

            if (useForEdit)
            {
                // Change the window title and the OK button text.
                Text        = titleForEdit;
                s_helpTopic = "khtpEditGrammaticalFunction";
                btnOk.Text  = LexText.Controls.LexTextControls.ks_OK;
            }
            helpProvider.HelpNamespace = mediator.HelpTopicProvider.HelpFile;
            helpProvider.SetHelpKeyword(this, mediator.HelpTopicProvider.GetHelpString(s_helpTopic));
            helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);

            // Set font, writing system factory, and code for the edit box.
            float          fntSize   = label1.Font.Size * 2.0F;
            IWritingSystem defVernWs = m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

            m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbCitationForm.WritingSystemCode    = defVernWs.Handle;
            m_fwtbCitationForm.AdjustForStyleSheet(this, null, mediator);
            m_fwtbCitationForm.AdjustStringHeight = false;
            m_fwtbCitationForm.Tss       = entry.HeadWord;
            m_fwtbCitationForm.HasBorder = false;

            m_fwtbSenses.Font = new Font(defVernWs.DefaultFontName, fntSize);
            m_fwtbSenses.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwtbSenses.WritingSystemCode    = defVernWs.Handle;
            m_fwtbSenses.AdjustForStyleSheet(this, null, mediator);
            m_fwtbSenses.AdjustStringHeight = false;

            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_cache.DefaultAnalWs);
            var msaRepository = m_cache.ServiceLocator.GetInstance <IMoMorphSynAnalysisRepository>();

            if (hvoOriginalMsa != 0)
            {
                foreach (var sense in entry.AllSenses)
                {
                    if (sense.MorphoSyntaxAnalysisRA != null)
                    {
                        if (sense.MorphoSyntaxAnalysisRA == msaRepository.GetObject(hvoOriginalMsa))
                        {
                            if (tisb.Text != null)
                            {
                                tisb.Append(", ");                                      // REVIEW: IS LOCALIZATION NEEDED FOR BUILDING THIS LIST?
                            }
                            tisb.AppendTsString(sense.ShortNameTSS);
                        }
                    }
                }
            }
            m_fwtbSenses.Tss       = tisb.GetString();
            m_fwtbSenses.HasBorder = false;

            m_msaGroupBox.Initialize(m_cache, m_mediator, this, sandboxMsa);
            int oldHeight = m_msaGroupBox.Height;
            int newHeight = Math.Max(oldHeight, m_msaGroupBox.PreferredHeight);
            int delta     = newHeight - oldHeight;

            if (delta > 0)
            {
                m_msaGroupBox.AdjustInternalControlsAndGrow();
                Debug.Assert(m_msaGroupBox.Height == m_msaGroupBox.PreferredHeight);
                FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_msaGroupBox);
            }

            if (mediator != null)
            {
                // Reset window location.
                // Get location to the stored values, if any.
                object locWnd = m_mediator.PropertyTable.GetValue("msaCreatorDlgLocation");
                // JohnT: this dialog can't be resized. So it doesn't make sense to
                // remember a size. If we do, we need to override OnLoad (as in SimpleListChooser)
                // to prevent the dialog growing every time at 120 dpi. But such an override
                // makes it too small to show all the controls at the default size.
                // It's better just to use the default size until it's resizeable for some reason.
                //m_mediator.PropertyTable.GetValue("msaCreatorDlgSize");
                object szWnd = this.Size;
                if (locWnd != null && szWnd != null)
                {
                    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
                    ScreenUtils.EnsureVisibleRect(ref rect);
                    DesktopBounds = rect;
                    StartPosition = FormStartPosition.Manual;
                }
            }
        }
示例#25
0
		/// <summary>
		/// Static version for avoiding creating actual object.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="hvo"></param>
		/// <param name="tsb"></param>
		/// <returns></returns>
		public static void ShortName1Static(FdoCache cache, int hvo, ITsIncStrBldr tsb)
		{
			ISilDataAccess sda = cache.MainCacheAccessor;
			int wsVern = cache.DefaultVernWs;

			// try vernacular citation
			ITsString label = sda.get_MultiStringAlt(hvo,
				(int)LexEntry.LexEntryTags.kflidCitationForm, wsVern);
			if (label.Length != 0)
			{
				tsb.AppendTsString(label);
				return;
			}

			// try lexeme form
			int hvoLf = sda.get_ObjectProp(hvo, (int)LexEntry.LexEntryTags.kflidLexemeForm);
			if (hvoLf != 0)
			{
				label = sda.get_MultiStringAlt(hvoLf, (int)MoForm.MoFormTags.kflidForm,
					wsVern);
				if (label.Length != 0)
				{
					tsb.AppendTsString(label);
					return;
				}
			}

			// Try the first alternate form with the wsVern WS.
			for (int i = 0; i < sda.get_VecSize(hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms); i++)
			{
				int hvoAm = sda.get_VecItem(hvo, (int)LexEntry.LexEntryTags.kflidAlternateForms, i);
				label = sda.get_MultiStringAlt(hvoAm, (int)MoForm.MoFormTags.kflidForm,
					wsVern);
				if (label.Length != 0)
				{
					tsb.AppendTsString(label);
					return;
				}
			}

			// give up
			tsb.AppendTsString(cache.MakeUserTss(Strings.ksQuestions));		// was "??", not "???"
		}
示例#26
0
        private static void AddGloss(ITsIncStrBldr sb, IMultiStringAccessor gloss, CoreWritingSystemDefinition wsGloss)
        {
            ITsString tssGloss = GetTssGloss(gloss, wsGloss);

            sb.AppendTsString(tssGloss);
        }
示例#27
0
		/// <summary>
		/// Static version for avoiding creating actual object.
		/// </summary>
		public static void ShortName1Static(ILexEntry entry, ITsIncStrBldr tsb)
		{
			var ws = entry.Services.WritingSystems.DefaultVernacularWritingSystem;

			// Try vernacular citation
			var tss = entry.CitationForm.get_String(ws.Handle);
			if (tss != null && tss.Length > 0)
			{
				tsb.AppendTsString(tss);
				return;
			}

			// Try lexeme form.
			var form = entry.LexemeFormOA;
			if (form != null)
			{
				tss = form.Form.get_String(ws.Handle);
				if (tss != null && tss.Length > 0)
				{
					tsb.AppendTsString(tss);
					return;
				}
			}

			// Try the first alternate form with the wsVern WS.
			// NB: This may not be the actual first alterantge.
			foreach (var alt in entry.AlternateFormsOS)
			{
				tss = alt.Form.get_String(ws.Handle);
				if (tss != null && tss.Length > 0)
				{
					tsb.AppendTsString(tss);
					return;
				}
			}

			// Give up.
			tsb.AppendTsString(entry.Cache.TsStrFactory.MakeString(
				Strings.ksQuestions,
				entry.Cache.DefaultUserWs));
		}
示例#28
0
			/// <summary>
			/// Store this segment's worth of data in the overall builder.
			/// </summary>
			private void StoreClipboardSegment(ITsIncStrBldr tisbClipBoard)
			{
				for (int i = 0; i < m_rgtsbLines.Length; ++i)
				{
					// Trim the final trailing tab on the line since it's not needed.
					int cch = m_rgtsbLines[i].Length;
					if (cch > 0 && m_rgtsbLines[i].Text.LastIndexOf('\t') == cch - 1)
						m_rgtsbLines[i].ReplaceTsString(cch - 1, cch, null);
					tisbClipBoard.AppendTsString(m_rgtsbLines[i].GetString());
					m_rgtsbLines[i].Clear();
					tisbClipBoard.Append(Environment.NewLine);
				}
				tisbClipBoard.Append(Environment.NewLine);
			}