1- // Copyright (c) 2003-2017 SIL International
1+ // Copyright (c) 2003-2023 SIL International
22// This software is licensed under the LGPL, version 2.1 or later
33// (http://www.gnu.org/licenses/lgpl-2.1.html)
44
1313
1414namespace XCore
1515{
16-
1716 /// <summary>
1817 /// Summary description for IContextHelper.
1918 /// </summary>
2019 public interface IContextHelper
2120 {
22- Control ParentControl
23- {
24- set ;
25- }
26-
2721 string GetToolTip ( string id ) ;
28-
2922 }
3023
3124 /// summary>
@@ -149,18 +142,6 @@ protected virtual void Dispose(bool disposing)
149142
150143 #endregion IDisposable & Co. implementation
151144
152- abstract protected void SetHelps ( Control target , string caption , string text ) ;
153-
154- abstract public Control ParentControl
155- {
156- set ;
157- }
158-
159- protected abstract bool ShowAlways
160- {
161- set ;
162- }
163-
164145 #region IxCoreColleague
165146 /// <summary/>
166147 public void Init ( Mediator mediator , PropertyTable propertyTable , XmlNode configurationParameters )
@@ -172,7 +153,6 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configu
172153 m_propertyTable . SetProperty ( "ContextHelper" , this , false ) ;
173154 m_propertyTable . SetPropertyPersistence ( "ContextHelper" , false ) ;
174155
175- ParentControl = m_propertyTable . GetValue < Control > ( "window" ) ;
176156 m_document = new XmlDocument ( ) ;
177157
178158 //we use the directory of the file which held are parameters as the starting point
@@ -182,9 +162,6 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configu
182162 var configParamatersBasePath = FileUtils . StripFilePrefix ( configurationParameters . BaseURI ) ;
183163 path = Path . Combine ( Path . GetDirectoryName ( configParamatersBasePath ) , path ) ;
184164 m_document . Load ( path ) ;
185- //m_items = m_document.SelectNodes("strings/item");
186-
187- ShowAlways = m_propertyTable . GetBoolProperty ( "ShowBalloonHelp" , true ) ;
188165 }
189166
190167 public IxCoreColleague [ ] GetMessageTargets ( )
@@ -215,7 +192,7 @@ public string GetToolTip(string id)
215192 return text ;
216193 }
217194
218- protected bool GetHelpText ( string id , ref string caption , out string text )
195+ private bool GetHelpText ( string id , ref string caption , out string text )
219196 {
220197 text = "" ;
221198 if ( id == null )
@@ -300,71 +277,5 @@ protected bool GetHelpText (string id, ref string caption, out string text)
300277 }
301278 return false ; //there was no real match
302279 }
303-
304- //this will just give each sub controlled the same helped message. If you want to have
305- //different messages for individual controls, you need register them separately.
306- protected void AddControls ( Control parent , string helpid , string caption , string text )
307- {
308- foreach ( Control child in parent . Controls )
309- {
310- SetHelps ( child , caption , text ) ;
311- AddControls ( child , helpid , caption , text ) ;
312- }
313-
314- }
315- /// <summary>
316- /// register a control with the context of system
317- /// </summary>
318- /// <param name="argument"></param>
319- /// <returns>always returns true</returns>
320- //arguments:
321- // 0) the target control
322- // 1) the id to use when looking up the help text
323- // 2) (optional) a string to concatenate to the Id for a more specific help message, if it exists.
324- public bool OnRegisterHelpTargetWithId ( object argument )
325- {
326- CheckDisposed ( ) ;
327- object [ ] arguments = ( object [ ] ) argument ;
328- System . Diagnostics . Debug . Assert ( arguments . Length == 3 || arguments . Length == 4 , "OnRegisterHelpTargetWithId Expects three or four arguments" ) ;
329-
330- Control target = ( Control ) arguments [ 0 ] ;
331- string caption = ( string ) arguments [ 1 ] ;
332- string helpid = ( string ) arguments [ 2 ] ;
333- //this can be used for some elements of the control, to give them their own help message.
334- string helpSubId = "" ;
335- if ( arguments . Length == 4 )
336- helpSubId = ( string ) arguments [ 3 ] ;
337-
338- string text ;
339- //first tried to see if there is an item for the fully qualified if
340- if ( ! GetHelpText ( helpid + helpSubId , ref caption , out text ) )
341- {
342- GetHelpText ( helpid , ref caption , out text ) ; //just use the id without the qualifier
343- }
344- else helpid = helpid + helpSubId ; //this is what will be fed to any sub controls
345-
346- SetHelps ( target , caption , text ) ;
347-
348- AddControls ( target , helpid , caption , text ) ;
349- return true ; //we handled this.
350- }
351-
352- /// summary>
353- /// Receives the broadcast message "PropertyChanged"
354- /// /summary>
355- public void OnPropertyChanged ( string name )
356- {
357- CheckDisposed ( ) ;
358-
359- // Debug.WriteLine("record clerk ("+this.m_vectorName + ") saw OnPropertyChanged " + name);
360- switch ( name )
361- {
362- case "ShowBalloonHelp" :
363- ShowAlways = m_propertyTable . GetBoolProperty ( name , true ) ;
364- break ;
365- default :
366- break ;
367- }
368- }
369280 }
370281}
0 commit comments