Mercurial > repos > IBBoard.Windows.Forms
view Windows/Forms/I18N/ControlTranslator.cs @ 4:1acdb0aff4a7
Re #8 - LGPL license all libraries
* Add LGPL header to all IBBoard.Windows.Forms files
* Add license files
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 17 Feb 2009 15:10:30 +0000 |
parents | b829a3320688 |
children | 97cab866aba9 |
line wrap: on
line source
// This file (ColorableStatusBar.cs) is a part of the IBBoard.Windows.Forms library and is copyright 2009 IBBoard. // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.ComponentModel; using IBBoard.Lang; namespace IBBoard.Windows.Forms.I18N { public class ControlTranslator { public static void TranslateControl(Control ctrl, params object[] replacements) { TranslateControl(ctrl, true, replacements); } public static void TranslateControl(Control ctrl, bool cascadeTranslate, params object[] replacements) { if (ctrl is ITranslatable) { Translation.Translate((ITranslatable)ctrl, replacements); } if (cascadeTranslate) { CascadeControlTranslation(ctrl, replacements); } } private static void CascadeControlTranslation(Control ctrl, params object[] replacements) { if (ctrl is ToolBar) { foreach (ToolBarButton bttn in ((ToolBar)ctrl).Buttons) { TranslateComponent(bttn, true, replacements); } } else { foreach (Control subctr in ctrl.Controls) { TranslateControl(subctr, true, replacements); } } } public static void TranslateComponent(Component comp, params object[] replacements) { TranslateComponent(comp, true, replacements); } public static void TranslateComponent(Component comp, bool cascadeTranslate, params object[] replacements) { if (comp is ITranslatable) { Translation.Translate((ITranslatable)comp, replacements); } else if (comp is FileDialog) { //HACK: We can't override SWF dialogs in .Net 1.1, so put in a special condition check for them FileDialog dialog = (FileDialog)comp; if (dialog.Title.StartsWith("Translatable:")) { dialog.Title = Translation.GetTranslation(dialog.Title.Substring(13), replacements); } } if (cascadeTranslate) { CascadeComponentTranslations(comp, cascadeTranslate, replacements); } } private static void CascadeComponentTranslations(Component comp, params object[] replacements) { if (comp is Menu) { foreach (MenuItem mi in ((Menu)comp).MenuItems) { TranslateComponent(mi, true, replacements); } } } } }