Mercurial > repos > IBBoard.Windows.Forms
comparison Windows/Forms/I18N/ControlTranslator.cs @ 15:7c459ebc4210
* Code clean-up and documentation
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 18 Apr 2010 15:04:21 +0000 |
parents | 774fd3daefe1 |
children | 5f35edc84791 |
comparison
equal
deleted
inserted
replaced
14:774fd3daefe1 | 15:7c459ebc4210 |
---|---|
9 using System.ComponentModel; | 9 using System.ComponentModel; |
10 using IBBoard.Lang; | 10 using IBBoard.Lang; |
11 | 11 |
12 namespace IBBoard.Windows.Forms.I18N | 12 namespace IBBoard.Windows.Forms.I18N |
13 { | 13 { |
14 /// <summary> | |
15 /// A custom cascading translator. It take any widget type (controls or components) and translates them | |
16 /// if they implement <see>ITranslatable</see> and optionally cascades the process to translate all children. | |
17 /// | |
18 /// Note: Translations <strong>will not</strong> cascade into MdiClient controls | |
19 /// </summary> | |
14 public class ControlTranslator | 20 public class ControlTranslator |
15 { | 21 { |
16 /// <summary> | 22 /// <summary> |
17 /// Recursively translates a collection of controls, such as those from a form's <code>Controls</code> collection | 23 /// Recursively translates a collection of controls, such as those from a form's <code>Controls</code> collection |
18 /// </summary> | 24 /// </summary> |
19 /// <param name="controls"></param> | 25 /// <param name="controls"></param> |
20 public static void TranslateControls(Control.ControlCollection controls) | 26 public static void TranslateControls(Control.ControlCollection controls) |
21 { | 27 { |
22 foreach (Control ctrl in controls) | 28 foreach (Control ctrl in controls) |
23 { | 29 { |
24 ControlTranslator.TranslateControl(ctrl); | 30 if (!(ctrl is MdiClient)) |
31 { | |
32 //Client windows must translate themselves | |
33 ControlTranslator.TranslateControl(ctrl); | |
34 } | |
25 } | 35 } |
26 } | 36 } |
27 | 37 |
28 /// <summary> | 38 /// <summary> |
29 /// Recursively translates a collection of components, such as those from a form's <code>components.Components</code> collection | 39 /// Recursively translates a collection of components, such as those from a form's <code>components.Components</code> collection |
76 TranslateComponent(item, true, replacements); | 86 TranslateComponent(item, true, replacements); |
77 } | 87 } |
78 } | 88 } |
79 else | 89 else |
80 { | 90 { |
81 foreach (Control subctr in ctrl.Controls) | 91 TranslateControls(ctrl.Controls); |
82 { | |
83 TranslateControl(subctr, true, replacements); | |
84 } | |
85 } | 92 } |
86 } | 93 } |
87 | 94 |
88 public static void TranslateComponent(Component comp, params object[] replacements) | 95 public static void TranslateComponent(Component comp, params object[] replacements) |
89 { | 96 { |