Beispiel #1
0
        /// <summary>
        /// Généric ToString
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            DisplayEntityAttribute AffichageClasse = (DisplayEntityAttribute)this.GetType().GetCustomAttributes(typeof(DisplayEntityAttribute), true)[0];
            string Titre = this.GetType().GetProperty(AffichageClasse.DisplayMember).GetValue(this).ToString();

            if (Titre == string.Empty)
            {
                return(AffichageClasse.SingularName);
            }
            else
            {
                return(Titre);
            }
        }
        /// <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;
        }
        /// <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 CreateInterface()
        {
            //
            // Suppresion de la zone de filtre si les critères de filtrage n'existe pas
            //
            if (this.MetaSelectionCriteria == null)
            {
                groupBoxFilter.Visible           = false;
                groupBoxListChoices.Location     = new Point(12, 0);
                groupBoxDisplaySelected.Location = new Point(12, groupBoxListChoices.Location.Y + groupBoxListChoices.Size.Height + 10);
                return;
            }

            //
            // Création de l'interface
            //
            // Positions
            int index = 0;
            int y     = 20;

            // 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));

                //
                // label1
                //
                Label label_comboBox = new Label();
                label_comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                               | System.Windows.Forms.AnchorStyles.Left)
                                                                              | System.Windows.Forms.AnchorStyles.Right)));
                label_comboBox.AutoSize = true;
                label_comboBox.Location = new System.Drawing.Point(6, y);
                label_comboBox.Name     = "label_" + item.Name;
                label_comboBox.Size     = new System.Drawing.Size(35, 13);
                label_comboBox.TabIndex = ++index;
                label_comboBox.Text     = item.Name;

                //
                // ComBobox
                //
                ComboBox comboBox = new ComboBox();
                comboBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                         | System.Windows.Forms.AnchorStyles.Left)
                                                                        | System.Windows.Forms.AnchorStyles.Right)));
                comboBox.FormattingEnabled = true;
                comboBox.Location          = new System.Drawing.Point(6, y + 20);
                comboBox.Name                  = "comboBoxFilter_" + item.Name;;
                comboBox.Size                  = new System.Drawing.Size(250, 21);
                comboBox.ValueMember           = "Id";
                comboBox.DisplayMember         = MetaAffichageClasseCritere.DisplayMember;
                comboBox.TabIndex              = ++index;;
                comboBox.SelectedIndexChanged += Value_SelectedIndexChanged;


                this.groupBoxFilter.Controls.Add(label_comboBox);
                this.groupBoxFilter.Controls.Add(comboBox);

                ListeComboBox.Add(item.Name, comboBox);
                LsiteTypeObjetCritere.Add(item.Name, item);
                y += 40;
            }

            //
            // Redimention de l'interface
            //
            groupBoxFilter.Location          = new Point(12, 5);
            groupBoxFilter.Size              = new System.Drawing.Size(188, y);
            groupBoxListChoices.Location     = new Point(12, groupBoxFilter.Location.Y + groupBoxFilter.Size.Height + 10);
            groupBoxDisplaySelected.Location = new Point(12, groupBoxListChoices.Location.Y + groupBoxListChoices.Size.Height + 10);
        }