예제 #1
0
        /// <summary>
        /// Sets the value ( as Guid )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            EntityPicker entityPicker = control as EntityPicker;

            if (entityPicker != null)
            {
                EntityTypeCache entityType = null;
                int?            entityId   = null;
                string[]        values     = (value ?? string.Empty).Split('|');
                if (values.Length == 2)
                {
                    Guid?entityTypeGuid = values[0].AsGuidOrNull();
                    entityId = values[1].AsIntegerOrNull();
                    if (entityTypeGuid.HasValue)
                    {
                        entityType = EntityTypeCache.Get(entityTypeGuid.Value);
                    }
                }

                if (entityType != null)
                {
                    entityPicker.EntityTypeId = entityType.Id;
                }
                else
                {
                    entityPicker.EntityTypeId = null;
                }

                entityPicker.EntityId = entityId;
            }
        }
예제 #2
0
        protected void LoadEntityPicker(EntityPicker picker, Enums.MealTypes mealType)
        {
            List <hccMenuItem> allItemsList      = hccMenuItem.GetBy(mealType);
            List <hccMenuItem> selectedItemsList = new List <hccMenuItem>();

            if (CurrentMenu != null)
            {
                selectedItemsList = CurrentMenu.GetMenuItems(false, mealType);
            }

            picker.Bind <hccMenuItem>(allItemsList, selectedItemsList);
        }
예제 #3
0
        /// <summary>
        /// Reads new values entered by the user for the field ( as Guid)
        /// </summary>
        /// <param name="control">Parent control that controls were added to in the CreateEditControl() method</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <returns></returns>
        public override string GetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues)
        {
            EntityPicker entityPicker = control as EntityPicker;

            if (entityPicker != null && entityPicker.EntityTypeId.HasValue)
            {
                var entityType = EntityTypeCache.Get(entityPicker.EntityTypeId.Value);
                if (entityType != null)
                {
                    return($"{entityType.Guid}|{entityPicker.EntityId}");
                }
            }

            return(null);
        }
예제 #4
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var entityPicker = new EntityPicker {
                ID = id
            };

            if (configurationValues != null)
            {
                if (configurationValues.ContainsKey(ENTITY_CONTROL_HELP_TEXT_FORMAT))
                {
                    entityPicker.EntityControlHelpTextFormat = configurationValues[ENTITY_CONTROL_HELP_TEXT_FORMAT].Value;
                }
            }

            return(entityPicker);
        }
예제 #5
0
 /// <summary>
 /// Sets the value ( as Guid )
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="value">The value.</param>
 public override void SetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
 {
     string[] values = (value ?? string.Empty).Split('|');
     if (values.Length == 2)
     {
         EntityPicker entityPicker = control as EntityPicker;
         if (entityPicker != null)
         {
             var entityType = EntityTypeCache.Read(values[0].AsGuid());
             if (entityType != null)
             {
                 entityPicker.EntityTypeId = entityType.Id;
                 entityPicker.EntityId     = values[1].AsIntegerOrNull();
             }
         }
     }
 }
        private void buttonSelectEntity_Click(object sender, EventArgs e)
        {
            if (service == null)
            {
                MessageBox.Show(ParentForm,
                                "You are not connected to an organization! Please connect to an organization and reopen this SubArea item",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            EntityPicker picker = new EntityPicker(emds);

            picker.StartPosition = FormStartPosition.CenterParent;

            if (picker.ShowDialog() == DialogResult.OK)
            {
                txtSubAreaEntity.Text = picker.SelectedEntity;
            }
        }
예제 #7
0
        /// <summary>
        /// Sets the value ( as Guid )
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="value">The value.</param>
        public override void SetEditValue(Control control, Dictionary <string, ConfigurationValue> configurationValues, string value)
        {
            EntityPicker entityPicker = control as EntityPicker;

            if (entityPicker != null)
            {
                int?entityId = GetEntityId(value, out EntityTypeCache entityType);

                if (entityType != null)
                {
                    entityPicker.EntityTypeId = entityType.Id;
                }
                else
                {
                    entityPicker.EntityTypeId = null;
                }

                entityPicker.EntityId = entityId;
            }
        }
예제 #8
0
        private void PbAddEntityClick(object sender, EventArgs e)
        {
            var epForm = new EntityPicker(emds);

            if (epForm.ShowDialog(this) == DialogResult.OK)
            {
                foreach (var emd in epForm.EntitiesToAdd)
                {
                    bool doContinue = true;
                    foreach (ListViewItem existingItem in lvEntities.Items)
                    {
                        if (((EntityMetadata)existingItem.Tag).LogicalName == emd.LogicalName)
                        {
                            doContinue = false;
                        }
                    }

                    if (!doContinue)
                    {
                        continue;
                    }

                    UpdateEntityDictionary(emd, ActionState.Added);

                    var item = new ListViewItem {
                        Text = emd.DisplayName.UserLocalizedLabel.Label, Tag = emd
                    };
                    item.SubItems.Add(emd.LogicalName);
                    item.Selected = true;
                    lvEntities.Items.Add(item);

                    // AddEntityAttributesToList(emd);

                    SortGroups(lvAttributes);
                }

                RefreshSorting(lvEntities);
            }
        }