Skip to content

Commit 69cda45

Browse files
committed
Merge branch 'release/9.3.7' into 'main'
# Conflicts: # .github/workflows/patch-installer-cd.yml # Src/Common/Controls/DetailControls/DetailControls.csproj # Src/LexText/Interlinear/ITextDll.csproj # Src/LexText/Interlinear/ITextDllTests/InterlinLineChoicesTests.cs # Src/LexText/Interlinear/ITextStrings.Designer.cs # Src/LexText/Interlinear/ITextStrings.resx
2 parents 2947f58 + 1d4f181 commit 69cda45

6 files changed

Lines changed: 200 additions & 19 deletions

File tree

DistFiles/Language Explorer/Configuration/Parts/Cellar.fwlayout

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<part ref="AbbreviationAllWs"/>
6565
<part ref="SourceAllWs"/>
6666
<part ref="IsTranslated"/>
67+
<part ref="Media"/>
6768
<part ref="Genres"/>
6869
<part ref="CommentAllWs"/>
6970
<part label="Date Created" ref="DateCreated"/>

DistFiles/Language Explorer/Configuration/Parts/CellarParts.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@
183183
<part id="Text-Detail-IsTranslated" type="Detail">
184184
<slice label="Text is a translation" field="IsTranslated" editor="Checkbox" menu="mnuDataTree-Help"/>
185185
</part>
186+
<part id="Text-Detail-Media" type="Detail">
187+
<slice label="Media" field="MediaFiles" editor="custom" assemblyPath="DetailControls.dll" class="SIL.FieldWorks.Common.Framework.DetailControls.MediaInfoSlice" />
188+
</part>
186189
<part id="Text-Detail-CommentAllWs" type="Detail">
187190
<slice label="Comment" editor="multistring" ws="analysis vernacular" field="Description" menu="mnuDataTree-Help"/>
188191
</part>
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
// Copyright (c) 2026 SIL International
2+
// This software is licensed under the LGPL, version 2.1 or later
3+
// (http://www.gnu.org/licenses/lgpl-2.1.html)
4+
5+
using System;
6+
using System.Windows.Forms;
7+
using SIL.LCModel.Core.Text;
8+
using SIL.LCModel;
9+
using SIL.FieldWorks.Common.RootSites;
10+
using SIL.LCModel.Core.KernelInterfaces;
11+
using SIL.LCModel.Utils;
12+
using XCore;
13+
using SIL.FieldWorks.Common.ViewsInterfaces;
14+
15+
namespace SIL.FieldWorks.Common.Framework.DetailControls
16+
{
17+
/// <summary>
18+
/// A slice that displays the media file URIs as static text.
19+
/// </summary>
20+
public class MediaInfoSlice : ViewSlice
21+
{
22+
public MediaInfoSlice()
23+
{
24+
InitializeComponent();
25+
}
26+
27+
private void InitializeComponent()
28+
{
29+
this.Name = "MediaInfoSlice";
30+
this.Size = new System.Drawing.Size(208, 32);
31+
}
32+
33+
protected override void Dispose(bool disposing)
34+
{
35+
if (IsDisposed)
36+
return;
37+
base.Dispose(disposing);
38+
}
39+
40+
public ILcmOwningCollection<ICmMediaURI> MediaURIs
41+
{
42+
get
43+
{
44+
CheckDisposed();
45+
return (m_obj as IText)?.MediaFilesOA?.MediaURIsOC;
46+
}
47+
}
48+
49+
/// <summary>
50+
/// Create the embedded RootSite-based view.
51+
/// </summary>
52+
public override void FinishInit()
53+
{
54+
CheckDisposed();
55+
Control = new MediaInfoView(m_obj.Hvo);
56+
}
57+
58+
public override void Install(DataTree parent)
59+
{
60+
CheckDisposed();
61+
base.Install(parent);
62+
63+
var view = Control as MediaInfoView;
64+
if (view != null)
65+
{
66+
LcmCache cache = null;
67+
if (m_propertyTable != null)
68+
cache = m_propertyTable.GetValue<LcmCache>("cache");
69+
view.Init(cache, m_propertyTable, MediaURIs);
70+
}
71+
}
72+
73+
/// <summary>
74+
/// RootSite is the embedded control (MediaInfoView derives from RootSiteControl).
75+
/// </summary>
76+
public override RootSite RootSite
77+
{
78+
get
79+
{
80+
CheckDisposed();
81+
return base.Control as RootSite;
82+
}
83+
}
84+
}
85+
86+
/// <summary>
87+
/// RootSite control that displays static strings (media file paths).
88+
/// </summary>
89+
public class MediaInfoView : RootSiteControl
90+
{
91+
public const int kfragRoot = 1;
92+
private int m_ownerHvo;
93+
private MediaInfoVc m_vc;
94+
private ILcmOwningCollection<ICmMediaURI> m_mediaURIs;
95+
96+
public MediaInfoView(int ownerHvo)
97+
{
98+
m_ownerHvo = ownerHvo;
99+
BackColor = System.Drawing.SystemColors.Window;
100+
Dock = DockStyle.Fill;
101+
}
102+
103+
public void Init(LcmCache cache, PropertyTable propertyTable, ILcmOwningCollection<ICmMediaURI> mediaURIs)
104+
{
105+
CheckDisposed();
106+
m_cache = cache;
107+
m_propertyTable = propertyTable;
108+
m_mediaURIs = mediaURIs;
109+
110+
MakeRoot();
111+
}
112+
113+
public override void MakeRoot()
114+
{
115+
CheckDisposed();
116+
117+
if (DesignMode)
118+
return;
119+
120+
if (m_rootb == null)
121+
{
122+
base.MakeRoot();
123+
124+
// Ensure root box has a data access appropriate for view constructors that may query it.
125+
m_rootb.DataAccess = m_cache.DomainDataByFlid;
126+
}
127+
128+
m_vc = new MediaInfoVc(m_cache, m_mediaURIs);
129+
130+
// We need to pass in a valid Hvo, so we are using the ownerHvo. This call is
131+
// needed so the VC's Display() will be called.
132+
m_rootb.SetRootObject(m_ownerHvo, m_vc, kfragRoot, m_rootb.Stylesheet);
133+
m_rootb.Reconstruct();
134+
}
135+
136+
protected override void Dispose(bool disposing)
137+
{
138+
if (IsDisposed)
139+
return;
140+
141+
base.Dispose(disposing);
142+
}
143+
}
144+
145+
/// <summary>
146+
/// View constructor that displays the URI strings.
147+
/// </summary>
148+
public class MediaInfoVc : FwBaseVc
149+
{
150+
private ILcmOwningCollection<ICmMediaURI> m_mediaURIs;
151+
152+
public MediaInfoVc(LcmCache cache, ILcmOwningCollection<ICmMediaURI> mediaURIs)
153+
{
154+
m_cache = cache;
155+
m_mediaURIs = mediaURIs;
156+
}
157+
158+
public override void Display(IVwEnv vwenv, int hvo, int frag)
159+
{
160+
switch (frag)
161+
{
162+
case MediaInfoView.kfragRoot:
163+
if (m_mediaURIs == null)
164+
return;
165+
166+
// Make non-editable.
167+
vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
168+
(int)FwTextPropVar.ktpvDefault,
169+
(int)TptEditable.ktptNotEditable);
170+
171+
// Add the URI strings.
172+
int userWs = m_cache.WritingSystemFactory.UserWs;
173+
foreach (var medUri in m_mediaURIs)
174+
{
175+
// If the URI is valid a nice path will be displayed. If not valid then the URI
176+
// string will be displayed, which may still be helpful for the user.
177+
string uriString = medUri.MediaURI;
178+
try
179+
{
180+
Uri uri = new Uri(uriString);
181+
uriString = uri.LocalPath;
182+
}
183+
catch { }
184+
185+
ITsString tss = TsStringUtils.MakeString(uriString, userWs);
186+
vwenv.OpenParagraph();
187+
vwenv.AddString(tss);
188+
vwenv.CloseParagraph();
189+
}
190+
break;
191+
default:
192+
throw new ArgumentException("Unknown frag in MediaInfoVc", nameof(frag));
193+
}
194+
}
195+
}
196+
}

Src/LexText/Interlinear/ITextStrings.Designer.cs

Lines changed: 0 additions & 9 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: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,6 @@
344344
<data name="ksMedia" xml:space="preserve">
345345
<value>Media</value>
346346
</data>
347-
<data name="ksMedia_" xml:space="preserve">
348-
<value>Media </value>
349-
<comment>there is a trailing space</comment>
350-
</data>
351347
<data name="ksMediaNotFound" xml:space="preserve">
352348
<value>Media not found: check Info tab for file name</value>
353349
<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>

Src/LexText/Interlinear/InterlinVc.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,12 +1441,6 @@ protected virtual void AddFreeformComment(IVwEnv vwenv, int hvoSeg, int lineChoi
14411441
if (exporter != null)
14421442
exporter.FreeAnnotationType = "note";
14431443
break;
1444-
case InterlinLineChoices.kflidMedia:
1445-
label = ITextStrings.ksMedia_;
1446-
flid = SegmentTags.kflidMediaURI;
1447-
if (exporter != null)
1448-
exporter.FreeAnnotationType = "media";
1449-
break;
14501444
default:
14511445
throw new Exception("Unexpected FF annotation type");
14521446
}

0 commit comments

Comments
 (0)