Esempio n. 1
0
        /// <summary>
        /// Reloads the field records
        /// </summary>
        private void ReloadFields()
        {
            /// pre-populate all the fields, along with any existing records
            FormfieldCollection allFields = new FormfieldCollection().Where(Formfield.Columns.Formid, this.Form.Id).Load();

            if (this.relatedFields == null)
                this.relatedFields = new List<DesignableField>();
            foreach (DesignableField field in this.relatedFields)
                field.FieldDeleted -= this.HandleFieldDeleted; //make sure it's unhooked if it's there
            this.relatedFields.Clear();
            for (int i = 0; i < allFields.Count; i++)
            {
                DesignableField field = new DesignableField(allFields[i], this);
                this.relatedFields.Add(field);
                field.FieldDeleted += new EventHandler(HandleFieldDeleted);
            }            

            /// First sort the fields based on the information we have
            this.SortFields();
            /// Now reset their FieldOrder ID if it's not right
            for (int i = 0; i < this.relatedFields.Count; i++)
            {
                if (this.relatedFields[i].Metadata.FieldOrder != i)
                {
                    this.relatedFields[i].Metadata.FieldOrder = i;
                    this.relatedFields[i].Store();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Unhooks and removes this field from the designer
        /// </summary>
        private void HandleFieldDeleted(object sender, EventArgs e)
        {
            DesignableField field = (DesignableField)sender;

            field.FieldDeleted -= this.HandleFieldDeleted;
            this.relatedFields.Remove(field);
        }
Esempio n. 3
0
        /// <summary>
        /// Attempts to swap the ordering of the selected field with one that is lower.
        /// </summary>
        internal void SwapOrderingDown(DesignableField higherField)
        {
            int             higherFieldOrder = higherField.Metadata.FieldOrder;
            DesignableField lowerField       = null;

            for (int i = 0; i < this.RelatedFields.Count; i++)
            {
                if (this.RelatedFields[i] == higherField)
                {
                    /// We have found our field. If we're not the last item in the list, then the proceeding one should be the "upper field"
                    if (i < this.RelatedFields.Count - 1)
                    {
                        lowerField = this.RelatedFields[i + 1];
                    }
                    break;
                }
            }
            if (lowerField != null)
            {
                int lowerFieldOrder = lowerField.Metadata.FieldOrder;
                ///Do the swap and save
                higherField.Metadata.FieldOrder = lowerFieldOrder;
                lowerField.Metadata.FieldOrder  = higherFieldOrder;
                higherField.Store();
                lowerField.Store();
                this.SortFields();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Reloads the field records
        /// </summary>
        private void ReloadFields()
        {
            /// pre-populate all the fields, along with any existing records
            FormfieldCollection allFields = new FormfieldCollection().Where(Formfield.Columns.Formid, this.Form.Id).Load();

            if (this.relatedFields == null)
            {
                this.relatedFields = new List <DesignableField>();
            }
            foreach (DesignableField field in this.relatedFields)
            {
                field.FieldDeleted -= this.HandleFieldDeleted; //make sure it's unhooked if it's there
            }
            this.relatedFields.Clear();
            for (int i = 0; i < allFields.Count; i++)
            {
                DesignableField field = new DesignableField(allFields[i], this);
                this.relatedFields.Add(field);
                field.FieldDeleted += new EventHandler(HandleFieldDeleted);
            }

            /// First sort the fields based on the information we have
            this.SortFields();
            /// Now reset their FieldOrder ID if it's not right
            for (int i = 0; i < this.relatedFields.Count; i++)
            {
                if (this.relatedFields[i].Metadata.FieldOrder != i)
                {
                    this.relatedFields[i].Metadata.FieldOrder = i;
                    this.relatedFields[i].Store();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Adds a new field to the form, and returns it's designer.
        /// </summary>
        public DesignableField AddField(string name)
        {
            Formfield field = new Formfield();

            field.Name = name;
            field.Form = this.Form;
            /// The field does not get saved until we store the form
            DesignableField designer = new DesignableField(field, this);

            designer.FieldDeleted += new EventHandler(HandleFieldDeleted);
            /// Set the default for the field ordering
            designer.Metadata.FieldOrder = this.relatedFields.Count;
            this.relatedFields.Add(designer);
            return(designer);
        }
Esempio n. 6
0
 /// <summary>
 /// Adds a new field to the form, and returns it's designer.
 /// </summary>
 public DesignableField AddField(string name)
 {
     Formfield field = new Formfield();
     field.Name = name;
     field.Form = this.Form;
     /// The field does not get saved until we store the form            
     DesignableField designer = new DesignableField(field, this);
     designer.FieldDeleted +=new EventHandler(HandleFieldDeleted);
     /// Set the default for the field ordering
     designer.Metadata.FieldOrder = this.relatedFields.Count;
     this.relatedFields.Add(designer);
     return designer;
 }
Esempio n. 7
0
 /// <summary>
 /// Sets a specific field as the keyfield
 /// </summary>
 internal void SetKeyField(DesignableField designableField)
 {
     this.Form.Keyfieldid = designableField.FormField.Id;            
 }
Esempio n. 8
0
 /// <summary>
 /// Attempts to swap the ordering of the selected field with one that is lower.
 /// </summary>
 internal void SwapOrderingDown(DesignableField higherField)
 {
     int higherFieldOrder = higherField.Metadata.FieldOrder;
     DesignableField lowerField = null;
     for (int i = 0; i < this.RelatedFields.Count; i++)
     {
         if (this.RelatedFields[i] == higherField)
         {
             /// We have found our field. If we're not the last item in the list, then the proceeding one should be the "upper field"
             if (i < this.RelatedFields.Count-1)
                 lowerField = this.RelatedFields[i + 1];
             break;
         }
     }
     if (lowerField != null)
     {
         int lowerFieldOrder = lowerField.Metadata.FieldOrder;
         ///Do the swap and save
         higherField.Metadata.FieldOrder = lowerFieldOrder;
         lowerField.Metadata.FieldOrder = higherFieldOrder;
         higherField.Store();
         lowerField.Store();
         this.SortFields();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Sets a specific field as the keyfield
 /// </summary>
 internal void SetKeyField(DesignableField designableField)
 {
     this.Form.Keyfieldid = designableField.FormField.Id;
 }