/// <summary> /// Affichage du filtre dans l'interface /// Remplissage de ListeComboBox /// </summary> private void InitInterface() { this.DisplayMember = ""; this.ValueMember = "Id"; Attribute selectionCriteriaAttribute = this.PropertyInfo.PropertyType.GetGenericArguments()[0] .GetCustomAttribute(typeof(SelectionCriteriaAttribute)); if (selectionCriteriaAttribute == null) { return; } SelectionCriteriaAttribute MetaSelectionCriteria = (SelectionCriteriaAttribute)selectionCriteriaAttribute; if (MetaSelectionCriteria == null) { this.isHasFilter = false; } else { this.isHasFilter = true; } int index = 10; // Si un objet du critère de selection exite dans la classe // Nous cherchons sa valeur pour l'utiliser foreach (Type item in MetaSelectionCriteria.Criteria) { // Meta information d'affichage du de Critère DisplayEntityAttribute DisplayEntityAttributeCritere = (DisplayEntityAttribute)item.GetCustomAttribute(typeof(DisplayEntityAttribute)); ManyToOneField manyToOneFilter = new ManyToOneField(this.Service, item, null, null, this.OrientationFiled, this.SizeLabel, this.SizeControl, 0, this.ConfigEntity ); manyToOneFilter.Name = item.Name; //manyToOneFilter.Size = new System.Drawing.Size(this.widthField, this.HeightField); manyToOneFilter.TabIndex = ++index; manyToOneFilter.Text_Label = item.Name; manyToOneFilter.ValueMember = "Id"; manyToOneFilter.DisplayMember = DisplayEntityAttributeCritere.DisplayMember; // pour le chargement de comboBox Suivant manyToOneFilter.FieldChanged += Value_SelectedIndexChanged; manyToOneFilter.Visible = true; // [bug] Le contôle ne s'affiche pas dans le formilaire ?? //Form f = new Form(); //f.Controls.Add(manyToOneFilter); //f.Show(); this.MainContainner.Controls.Add(manyToOneFilter); ListeComboBox.Add(item.Name, manyToOneFilter); LsiteTypeObjetCritere.Add(item.Name, item); } }
/// <summary> /// Affichage du filtre dans l'interface /// Remplissage de ListeComboBox /// </summary> private void InitAndLoadData() { this.DisplayMember = ""; this.ValueMember = "Id"; if (this.PropertyInfo != null) { // DisplayMember de combobox actuel // Annotation : Affichage de l'objet DisplayEntityAttribute MetaAffichageClasse = this.ConfigEntity.DisplayEntity; this.DisplayMember = MetaAffichageClasse.DisplayMember; this.Text_Label = MetaAffichageClasse.SingularName; Attribute getAffichagePropriete = PropertyInfo.GetCustomAttribute(typeof(DisplayPropertyAttribute)); DisplayPropertyAttribute AffichagePropriete = (DisplayPropertyAttribute)getAffichagePropriete; #region Annotatin // Annotation : Critère de filtre Attribute metaSelectionCriteriaAttribute = this.PropertyInfo.PropertyType .GetCustomAttribute(typeof(SelectionCriteriaAttribute)); if (metaSelectionCriteriaAttribute != null) { SelectionCriteriaAttribute MetaSelectionCriteria = (SelectionCriteriaAttribute)metaSelectionCriteriaAttribute; #endregion int index = 10; // Si un objet du critère de selection exite dans la classe // Nous cherchons sa valeur pour l'utiliser foreach (Type item in MetaSelectionCriteria.Criteria) { // Meta information d'affichage du de Critère DisplayEntityAttribute MetaAffichageClasseCritere = (DisplayEntityAttribute)item.GetCustomAttribute(typeof(DisplayEntityAttribute)); ManyToOneField manyToOneFilter = new ManyToOneField(this.Service, item, null, null, this.orientationFiled, this.SizeLabel, this.SizeControl, 0, ConfigEntity ); manyToOneFilter.Name = item.Name; //manyToOneFilter.Size = new System.Drawing.Size(this.widthField, this.HeightField); manyToOneFilter.TabIndex = ++index; manyToOneFilter.Text_Label = item.Name; manyToOneFilter.ValueMember = "Id"; manyToOneFilter.DisplayMember = MetaAffichageClasseCritere.DisplayMember; // pour le chargement de comboBox Suivant manyToOneFilter.FieldChanged += Value_SelectedIndexChanged; manyToOneFilter.Visible = true; // [bug] Le contôle ne s'affiche pas dans le formilaire ?? //Form f = new Form(); //f.Controls.Add(manyToOneFilter); //f.Show(); this.MainContainner.Controls.Add(manyToOneFilter); ListeComboBox.Add(item.Name, manyToOneFilter); LsiteTypeObjetCritere.Add(item.Name, item); } } // Insertion du ComBox Actuel pour qu'il sera remplit par les données ListeComboBox.Add(this.PropertyInfo.PropertyType.Name, this); LsiteTypeObjetCritere.Add(this.PropertyInfo.PropertyType.Name, this.PropertyInfo.PropertyType); } else { // Cas des sous ComBobox de filtre // Insertion du ComBox Actuel pour qu'il sera remplit par les données ListeComboBox.Add(this.TypeOfObject.Name, this); LsiteTypeObjetCritere.Add(this.TypeOfObject.Name, this.TypeOfObject); } this.FieldChanged += Value_SelectedIndexChanged; }
public ConfigProperty(PropertyInfo propertyInfo, ConfigEntity configEntity) { this.PropertyInfo = propertyInfo; this.ConfigEntity = configEntity; //Fill RessouceManager this.RessoucesManagers = this.ConfigEntity.RessourcesManagers; // Culture Info this.CultureInfo = GwinApp.Instance.CultureInfo; // Localizable this.TypeOfEntity = propertyInfo.ReflectedType; this.Localizable = this.ConfigEntity.GwinEntity.Localizable; // // Relationship // Attribute Relationship = propertyInfo.GetCustomAttribute(typeof(RelationshipAttribute)); this.Relationship = Relationship as RelationshipAttribute; if (this.Relationship != null) { // Check if Type of Memeber is valide Generic List if ( (this.Relationship.Relation == RelationshipAttribute.Relations.ManyToMany_Creation || this.Relationship.Relation == RelationshipAttribute.Relations.ManyToMany_Selection || this.Relationship.Relation == RelationshipAttribute.Relations.OneToMany) && this.PropertyInfo.PropertyType.GetGenericArguments().Count() == 0) { string msg_exception = "The Type :" + this.PropertyInfo.PropertyType.Name; msg_exception += " of member " + this.PropertyInfo.Name; msg_exception += " in Entity " + this.PropertyInfo.DeclaringType.Name; msg_exception += " is not a valid generic List"; throw new GwinException(msg_exception); } } // // DisplayProperty // #region DisplayProperty // Load DisplayProperty Attribute DisplayProperty = propertyInfo.GetCustomAttribute(typeof(DisplayPropertyAttribute)); this.DisplayProperty = DisplayProperty as DisplayPropertyAttribute; // If DisplayProperty not exist if (this.DisplayProperty == null) { if (this.Localizable == false) { string message = String.Format("The Attribute : {0} not exist", nameof(DisplayPropertyAttribute)); message += " with Property :" + propertyInfo.ToString(); message += " in Entity " + propertyInfo.ReflectedType.Name; message += " \n Bacause the Entity is not configured as Localazible"; throw new AnnotationNotExistException(message); } this.DisplayProperty = new DisplayPropertyAttribute(); } if (this.DisplayProperty.isInGlossary) { string GlossaryRessouceFullName = "App.Gwin.Entities.Resources.Glossary.Glossary"; ResourceManager GlossaryResourceManager = null; GlossaryResourceManager = new ResourceManager(GlossaryRessouceFullName, typeof(Glossary).Assembly); string title = GlossaryResourceManager.GetString(propertyInfo.Name, this.CultureInfo); if (title == null) { this.DisplayProperty.Title = this.CultureInfo.Name + "_Glossary_" + propertyInfo.Name; } else { this.DisplayProperty.Title = title; } } else { // // Title // if (this.DisplayProperty.Title == null) { if (this.PropertyInfo.PropertyType.IsSubclassOf(typeof(BaseEntity))) { this.DisplayProperty.Title = ConfigEntity.CreateConfigEntity(this.PropertyInfo.PropertyType).GwinEntity.SingularName; } else { this.DisplayProperty.Title = GetStringFromRessource(propertyInfo.Name); } } else { this.DisplayProperty.Title = GetStringFromRessource(propertyInfo.Name); } } #endregion // // EntryForm // Attribute EntryForm = propertyInfo.GetCustomAttribute(typeof(EntryFormAttribute)); this.EntryForm = EntryForm as EntryFormAttribute; // // DataGrid // Attribute DataGrid = propertyInfo.GetCustomAttribute(typeof(DataGridAttribute)); this.DataGrid = DataGrid as DataGridAttribute; // Order if (this.EntryForm != null && this.EntryForm.Ordre > 0 && this.DataGrid != null && this.DataGrid.Ordre == 0) { this.DataGrid.Ordre = this.EntryForm.Ordre; } // // Filter // Attribute Filter = propertyInfo.GetCustomAttribute(typeof(FilterAttribute)); this.Filter = Filter as FilterAttribute; // // DataSource // Attribute dataSource = propertyInfo.GetCustomAttribute(typeof(ReferencesDataSourceAttribute)); this.DataSource = dataSource as ReferencesDataSourceAttribute; // // Criteria // Attribute SelectionCriteria_Attribute = propertyInfo.GetCustomAttribute(typeof(SelectionCriteriaAttribute)); this.SelectionCriteria = SelectionCriteria_Attribute as SelectionCriteriaAttribute; // //BusinesRoleAttribute // Attribute aBusinesRole = propertyInfo.GetCustomAttribute(typeof(BusinesRoleAttribute)); this.BusinesRole = aBusinesRole as BusinesRoleAttribute; // Determine FieldNautre this.FieldNature = BaseFieldTraitement.DetermineFieldNature(this); }