using DevExpress.XtraBars; using DevExpress.XtraEditors; using DevExpress.XtraGrid; using DevExpress.XtraGrid.Columns; using DevExpress.XtraReports.Design; using DevExpress.XtraTab; using Lskj.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace Lskj.Control.Model { public static class ReplaceTranslation { /// /// 翻译文本 /// /// public static void TranslationFixedButton(System.Windows.Forms.Control Control) { if (!string.IsNullOrWhiteSpace(ERPInfo.Instance.LanguageName)) { foreach (System.Windows.Forms.Control ctrol in Control.Controls) { if (ctrol is SimpleButton) { SimpleButton simpleButton = ctrol as SimpleButton; simpleButton.Text = Business.Impl.LanguageTranslation.GetTranslatedText(ctrol.Text); } if (ctrol is DropDownButton) { DropDownButton dropDownButton = ctrol as DropDownButton; //翻译按钮文本 dropDownButton.Text = Business.Impl.LanguageTranslation.GetTranslatedText(ctrol.Text); //翻译按钮下拉框文本 if (dropDownButton.DropDownControl is PopupMenu) { PopupMenu popup = dropDownButton.DropDownControl as PopupMenu; foreach (BarButtonItemLink item in popup.ItemLinks) { item.Item.Caption = Business.Impl.LanguageTranslation.GetTranslatedText(item.Caption); } } } if (ctrol is BaseUserControl) { //替换固定的控件,如审核双击模块。动态生成的已经替换了。 //直接改控件基类,如果接着循环去改自定义控件中的文本控件,会有文本被输入框挡住的问题 BaseUserControl baseUserControl = ctrol as BaseUserControl; baseUserControl.LabelText = Business.Impl.LanguageTranslation.GetTranslatedText(baseUserControl.LabelText); continue; } if (ctrol is Label) { Label label = ctrol as Label; label.Text = Business.Impl.LanguageTranslation.GetTranslatedText(label.Text); } if (ctrol is LabelControl) { LabelControl label = ctrol as LabelControl; label.Text = Business.Impl.LanguageTranslation.GetTranslatedText(label.Text); } //if (ctrol is XtraTabPage) //{ //有的地方会重新加载页签标题(页签标题+"-条数"),这里改的话会被覆盖,所以页签在页签类里修改名字 // XtraTabPage xtraTabPage = ctrol as XtraTabPage; // xtraTabPage.Text = Business.Impl.LanguageTranslation.GetTranslatedText(xtraTabPage.Text); //} if (ctrol.Controls.Count > 0) { TranslationFixedButton(ctrol); } } } } } }