private static void InitLanguage( Form formMain, frmDebug formDebug ) { InterfaceLanguage engl = null; foreach( InterfaceLanguage lang in InterfaceLanguage.Languages ) { if( lang.Id == "engl" ) { engl = lang; break; } } if( engl == null ) return; List<Control> controls = new List<Control>(); formMain.GetAllControls( ref controls ); List<string> tags = new List<string>(); foreach( Control control in controls ) { if( control.Tag != null && control.Tag.ToString().StartsWith( "lang" ) ) { string tag = control.Tag.ToString().Substring( 4 ); if( !tags.Contains( tag ) ) tags.Add( tag ); } } List<string> unusedTags = tags; TreeNode loaded = new TreeNode( "Loaded" ); foreach( InterfaceLanguage lang in InterfaceLanguage.Languages ) { TreeNode langNode = new TreeNode( lang.Id + " (" + lang.Name + ")" ); TreeNode fields = langNode.Nodes.Add( "Fields" ); TreeNode missing = new TreeNode( "Missing" ); FieldInfo[] fieldInfos = lang.GetType().GetFields(); int fieldsCount = 0, missingCount = 0; foreach( FieldInfo field in fieldInfos ) { if( field.FieldType != typeof( string ) ) continue; if( lang.Id == "engl" ) tags.Remove( field.Name ); if( field.IsInitOnly ) // readonly continue; fieldsCount++; string englValue = (string)engl.GetType().GetField( field.Name ).GetValue( engl ); string value = (string)field.GetValue( lang ); fields.Nodes.Add( field.Name + " = " + value ); if( lang.Id != "engl" && value == englValue ) { missingCount++; missing.Nodes.Add( field.Name ); } } if( missing.Nodes.Count > 0 ) { missing.Text += " (" + missingCount + "/" + fieldsCount + ")"; langNode.Nodes.Add( missing ); } loaded.Nodes.Add( langNode ); } if( tags.Count > 0 ) { TreeNode notImplemented = formDebug.treeLang.Nodes.Add( "Not implemented (" + tags.Count + ")" ); foreach( string tag in tags ) { notImplemented.Nodes.Add( tag ); } } if( loaded.Nodes.Count > 0 ) { loaded.Text += " (" + loaded.Nodes.Count + ")"; formDebug.treeLang.Nodes.Add( loaded ); } if( formDebug.treeLang.Nodes.Count == 1 ) { formDebug.treeLang.Nodes[0].Expand(); } }
private bool CheckFormInputEmpty(Form form) { //检查窗体文本为空情况 bool hasEmtpy = false; var controls = form.GetAllControls().OfType<IControlEmptable>(); foreach (var control in controls) { if (!control.CanbeEmpty && string.IsNullOrEmpty(control.Text)) { dynamic c = control as Control; try { c.PromptText = control.EmptyWarning; } catch { } control.UseWarnStyle = true; hasEmtpy = true; } } return hasEmtpy; }