private void SetBottomMessage()
{
int userWs = m_cache.LangProject.DefaultUserWritingSystem;
int vernWs = m_cache.LangProject.DefaultVernacularWritingSystem;
string sBase;
if (m_obj != null && m_obj.Hvo > 0)
{
sBase = FdoUiStrings.ksMergeXIntoY;
}
else
{
sBase = FdoUiStrings.ksMergeXIntoSelection;
}
ITsStrBldr tsb = TsStrBldrClass.Create();
tsb.ReplaceTsString(0, tsb.Length, m_tsf.MakeString(sBase, userWs));
// Replace every "{0}" with the headword we'll be merging, and make it bold.
ITsString tssFrom = m_tsf.MakeString(m_mainObj.ToString(), m_mainObj.WS);
string sTmp = tsb.Text;
int ich = sTmp.IndexOf("{0}");
int cch = tssFrom.Length;
while (ich >= 0 && cch > 0)
{
tsb.ReplaceTsString(ich, ich + 3, tssFrom);
tsb.SetIntPropValues(ich, ich + cch,
(int)FwTextPropType.ktptBold,
(int)FwTextPropVar.ktpvEnum,
(int)FwTextToggleVal.kttvForceOn);
sTmp = tsb.Text;
ich = sTmp.IndexOf("{0}"); // in case localization needs more than one.
}
if (m_obj != null && m_obj.Hvo > 0)
{
// Replace every "{1}" with the headword we'll be merging into.
ITsString tssTo = m_tsf.MakeString(m_obj.ToString(), m_obj.WS);
ich = sTmp.IndexOf("{1}");
cch = tssTo.Length;
while (ich >= 0 && cch > 0)
{
tsb.ReplaceTsString(ich, ich + 3, tssTo);
tsb.SetIntPropValues(ich, ich + cch,
(int)FwTextPropType.ktptBold,
(int)FwTextPropVar.ktpvEnum,
(int)FwTextToggleVal.kttvForceOn);
sTmp = tsb.Text;
ich = sTmp.IndexOf("{0}");
}
// Replace every "{2}" with a newline character.
ich = sTmp.IndexOf("{2}");
while (ich >= 0)
{
tsb.ReplaceTsString(ich, ich + 3, m_tsf.MakeString("\x2028", userWs));
sTmp = tsb.Text;
ich = sTmp.IndexOf("{2}");
}
}
else
{
// Replace every "{1}" with a newline character.
ich = sTmp.IndexOf("{1}");
while (ich >= 0)
{
tsb.ReplaceTsString(ich, ich + 3, m_tsf.MakeString("\x2028", userWs));
sTmp = tsb.Text;
ich = sTmp.IndexOf("{1}");
}
}
m_fwTextBoxBottomMsg.Tss = tsb.GetString();
int oldHeight = m_fwTextBoxBottomMsg.Height;
int newHeight = m_fwTextBoxBottomMsg.PreferredHeight;
if (newHeight != m_fwTextBoxBottomMsg.Height)
{
int delta = newHeight - oldHeight;
Size = MinimumSize;
SIL.FieldWorks.Common.Widgets.FontHeightAdjuster.GrowDialogAndAdjustControls(this, delta, m_fwTextBoxBottomMsg);
m_fwTextBoxBottomMsg.Height = newHeight;
}
}