Skip to content

Commit dc5f62b

Browse files
aror92jasonleenaylor
authored andcommitted
Update No Media message (#758)
Keep "No Media" message when no media filepath is specified. Add the message "Media not found: check Info tab for file name" for the case when a media filepath is specified but the file does not exist. (cherry picked from commit e919f5d)
1 parent f20800d commit dc5f62b

3 files changed

Lines changed: 49 additions & 14 deletions

File tree

Src/LexText/Interlinear/ITextStrings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Src/LexText/Interlinear/ITextStrings.resx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,13 @@
348348
<value>Media </value>
349349
<comment>there is a trailing space</comment>
350350
</data>
351+
<data name="ksMediaNotFound" xml:space="preserve">
352+
<value>Media not found: check Info tab for file name</value>
353+
<comment>Used when a media filepath is specified, but the file doesn't exist. Ensure translation of "Info" matches translation used for the tab label.</comment>
354+
</data>
351355
<data name="ksNoMedia" xml:space="preserve">
352356
<value>No Media</value>
357+
<comment>Used when no there is no media filepath specified.</comment>
353358
</data>
354359
<data name="ksBeginTimeOffset" xml:space="preserve">
355360
<value>Begin</value>

Src/LexText/Interlinear/InterlinVc.cs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,21 +1004,42 @@ private ITsString MakeLabel(string labelText)
10041004
return tssLabel;
10051005
}
10061006

1007-
private void AddNoMediaMessage(IVwEnv vwenv, ITsString tssMediaLabel, bool lineAndSegSameDir, bool lineAndUserSameDir)
1007+
private void AddNoMediaMessage(IVwEnv vwenv, ITsString tssMediaLabel, bool lineAndSegSameDir, bool lineAndUserSameDir, string mediaFile)
10081008
{
10091009
var defUserWs = m_cache.DefaultUserWs;
1010-
1011-
// Build "No Media" message.
1012-
// Use normal label settings, except make it italic instead of bold.
1013-
var tssNoMediaMessage = MakeUiElementString(
1014-
ITextStrings.ksNoMedia, defUserWs,
1015-
propsBldr =>
1016-
{
1017-
propsBldr.SetIntPropValues(
1018-
(int)FwTextPropType.ktptItalic,
1019-
(int)FwTextPropVar.ktpvEnum,
1020-
(int)FwTextToggleVal.kttvForceOn);
1021-
});
1010+
bool isFilePathSpecified = !string.IsNullOrEmpty(mediaFile);
1011+
ITsString tssFilePath = null;
1012+
ITsString tssNoMediaMessage;
1013+
1014+
if (isFilePathSpecified)
1015+
{
1016+
tssFilePath = TsStringUtils.MakeString(mediaFile, defUserWs);
1017+
// We have a media filepath, but file was not found. Build media not found message.
1018+
// Use normal label settings, except make it italic instead of bold.
1019+
tssNoMediaMessage = MakeUiElementString(
1020+
ITextStrings.ksMediaNotFound, defUserWs,
1021+
propsBldr =>
1022+
{
1023+
propsBldr.SetIntPropValues(
1024+
(int)FwTextPropType.ktptItalic,
1025+
(int)FwTextPropVar.ktpvEnum,
1026+
(int)FwTextToggleVal.kttvForceOn);
1027+
});
1028+
}
1029+
else
1030+
{
1031+
// No media filepath was given. Build no media message.
1032+
// Use normal label settings, except make it italic instead of bold.
1033+
tssNoMediaMessage = MakeUiElementString(
1034+
ITextStrings.ksNoMedia, defUserWs,
1035+
propsBldr =>
1036+
{
1037+
propsBldr.SetIntPropValues(
1038+
(int)FwTextPropType.ktptItalic,
1039+
(int)FwTextPropVar.ktpvEnum,
1040+
(int)FwTextToggleVal.kttvForceOn);
1041+
});
1042+
}
10221043

10231044
// If the line WS and segment WS are not the same direction, OR the line WS and user WS
10241045
// are not the same direction, but not both, then we need to insert pieces in reverse
@@ -1099,7 +1120,7 @@ protected virtual void AddMedia(IVwEnv vwenv, int hvoSeg, int lineChoiceIndex)
10991120
vwenv.OpenParagraph();
11001121
bool lineAndSegSameDir = IsWsRtl(wssOptions[0]) == IsWsRtl(wsForSeg);
11011122
bool lineAndUserSameDir = (IsWsRtl(wssOptions[0]) == IsWsRtl(defUserWs));
1102-
AddNoMediaMessage(vwenv, tssMediaLabel, lineAndSegSameDir, lineAndUserSameDir);
1123+
AddNoMediaMessage(vwenv, tssMediaLabel, lineAndSegSameDir, lineAndUserSameDir, mediaFile);
11031124
vwenv.CloseParagraph();
11041125
vwenv.CloseDiv();
11051126
return;

0 commit comments

Comments
 (0)