/// <summary>
        /// Obtiene el identicador,del campo del modelo
        /// El valor de este campo debe ser una Entity
        /// </summary>
        /// <param name="fieldForm">Campo a procesar</param>
        /// <param name="model">Modelo</param>
        /// <returns></returns>
        public static int?GetId(this FieldForm fieldForm, object model)
        {
            PropertyInfo property = model.GetType().GetProperty(fieldForm.Name);

            if (property == null)
            {
                var msg = string.Format("La propiedad [{0}] no existe en el modelo de tipo [{1}]",
                                        fieldForm.Name, model.GetType());
                throw new ArgumentException(msg);
            }

            var value = property.GetValue(model, null);

            if (value == null)
            {
                return(null);
            }

            if (!value.GetType().Implements(typeof(IEntity)))
            {
                var msg = string.Format("La propiedad [{0}] del tipo [{1}], no es IEntity",
                                        fieldForm.Name, model.GetType());

                throw new InvalidCastException(msg);
            }

            var entity = value as IEntity;


            return(entity.Id);
        }
Example #2
0
        private void InitializeFormularsTablePanel()
        {
            foreach (var formular in ezkoController.GetFormulars())
            {
                var checkBox = new CheckBox()
                {
                    Name      = "checkBox",
                    Text      = formular.Name,
                    TextAlign = ContentAlignment.MiddleLeft,
                    Tag       = formular,
                };

                var textBox = new TextBox()
                {
                    Name   = formular.ID.ToString(),
                    Dock   = DockStyle.Fill,
                    Height = 22,
                };

                if (field != null)
                {
                    FieldForm fieldForm = field.FieldForms.FirstOrDefault(x => x.FormID == formular.ID);
                    if (fieldForm != null)
                    {
                        checkBox.Checked = true;
                        textBox.Text     = fieldForm.Question.Value;
                    }
                }

                int lastRowIndex = formularsTablePanel.RowCount;
                formularsTablePanel.Controls.Add(checkBox, 0, lastRowIndex);
                formularsTablePanel.Controls.Add(textBox, 1, lastRowIndex);
                formularsTablePanel.RowCount++;
            }
        }
Example #3
0
        public void UpdateFieldForm(FieldForm fieldForm)
        {
            bool wasUpdated = false;

            foreach (var item in mainPanel.Controls)
            {
                if (item is FormFieldCard card)
                {
                    if (card.Field.ID == fieldForm.Field.ID)
                    {
                        card.SetField(fieldForm.Field);
                        //card.Question = fieldForm.Question.Value;
                        wasUpdated = true;
                        RedrawFormular();
                        card.Focus();
                        mainPanel.ScrollControlIntoView(card);
                        break;
                    }
                }
            }

            if (!wasUpdated)
            {
                AddField(fieldForm);
            }
        }
Example #4
0
        IControlAction IDataPanel.GetUIElement()
        {
            FieldForm f = new FieldForm();

            f.Items = this.Items;
            return(f);
        }
        public static FieldForm OpenFile(Form1 parent)
        {
            FieldForm fieldDraw = null;

            try
            {
                OpenFileDialog ofd = new OpenFileDialog
                {
                    Filter = "jpg|*.jpg| bmp|*.bmp"
                };

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }

                Bitmap load = new Bitmap(ofd.FileName);
                load      = GetResizedImage(load);
                fieldDraw = Field.GetField(parent, load);

                fieldDraw.Text      = System.IO.Path.GetFileName(ofd.FileName);
                fieldDraw.MdiParent = parent;

                fieldDraw.Show();
            }
            finally { }

            return(fieldDraw);
        }
Example #6
0
        private void AddField(FieldForm fieldForm)
        {
            FormFieldCard lastCard = FindLastCard();
            FormFieldCard card     = new FormFieldCard()
            {
                //Question = fieldForm.Question.Value,
                CardWidth       = mainPanel.Width - diffX,
                EditorMainPanel = mainPanel,
                MainControl     = this,
            };

            card.CardMouseMove     += card_MouseMove;
            card.CardMouseUp       += card_MouseUp;
            card.RemoveButtonClick += card_RemoveButtonClick;
            card.ChangeTopPanelVisibility(showTools);
            card.SetField(fieldForm.Field);

            if (lastCard != null)
            {
                lastCard.BelowCard = card;
            }

            mainPanel.Controls.Add(card);
            RedrawFormular();
            card.Focus();
            mainPanel.ScrollControlIntoView(card);
        }
Example #7
0
 public RendererForWinForm(World world, HiveForm hiveForm, FieldForm fieldForm) : base(world)
 {
     this.hiveForm      = hiveForm;
     this.fieldForm     = fieldForm;
     hiveForm.Renderer  = this;
     fieldForm.Renderer = this;
     InitializeImages();
 }
Example #8
0
 public LightSource(Point3 location, Vector3 direction, Color color, float brightness, FieldForm form)
 {
     this.location   = location;
     this.direction  = direction;
     this.color      = color;
     this.brightness = brightness;
     Form            = form;
     changed         = null;
 }
        public override bool CanHandle(FieldForm field)
        {
            Type fieldType = field.FieldType;

            if (fieldType.IsEnum)
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Obtener listado entidades del modelo, segun la definicion del campo
        /// El valor debe ser una collection de Entity
        /// </summary>
        /// <param name="fieldForm"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static IEnumerable <IEntity> GetValueListProperty(this FieldForm fieldForm, object model) // IEntity model)
        {
            PropertyInfo listProperty = model.GetType().GetProperty(fieldForm.Name);

            if (listProperty == null)
            {
                var msg = string.Format("La propiedad [{0}] no existe en el modelo de tipo [{1}]",
                                        fieldForm.Name, model.GetType());

                throw new ArgumentException(msg);
            }

            var value = listProperty.GetValue(model, null);

            if (value == null)
            {
                return(null);
            }

            if (value.GetType().IsPrimitive)
            {
                var msg = string.Format("La propiedad [{0}] del tipo [{1}], no es IEnumerable",
                                        fieldForm.Name, model.GetType());

                throw new InvalidCastException(msg);
            }


            //No es Generico
            if (!value.GetType().IsGenericType)
            {
                var msg = string.Format("La propiedad [{0}] del tipo [{1}], no es un tipo Generico",
                                        fieldForm.Name, model.GetType());

                throw new InvalidCastException(msg);
            }

            //Es Generico, y no es del  Tipo Enumarable o Collection
            if (value.GetType().IsGenericType &&
                !(value.GetType().GetGenericTypeDefinition() == typeof(IEnumerable <>) ||
                  value.GetType().GetGenericTypeDefinition() == typeof(ICollection <>) ||
                  value.GetType().GetGenericTypeDefinition().Implements(typeof(IEnumerable <>)) ||
                  value.GetType().GetGenericTypeDefinition().Implements(typeof(ICollection <>))))
            {
                var msg = string.Format("La propiedad [{0}] del tipo [{1}], no es IEnumerable",
                                        fieldForm.Name, model.GetType());

                throw new InvalidCastException(msg);
            }

            var enumerable = value as IEnumerable <IEntity>;

            return(enumerable);
        }
Example #11
0
        public virtual Form GeneratedFormView(Type type)
        {
            Form layout = new Form(generateWidget);

            //Reflection
            BindingFlags memberFlags = BindingFlags.Public | BindingFlags.Instance;

            PropertyInfo[] properties = type.GetProperties(memberFlags);

            foreach (var pro in properties)
            {
                if (ConsiderFieldView(pro.PropertyType))
                {
                    // Is Primitive, or Decimal, or String
                    FieldForm field = new FieldForm();
                    field.Name      = pro.Name;
                    field.Invisible = false;
                    field.FieldType = pro.PropertyType;

                    //TODO: LAS PROPIEDADES INVISIBLES NO DEBERIAN TENER WIDGET
                    //ANALIZAR LA MEJOR FORMA... DE NO COLOCAR..
                    //widget
                    field.Widget = generateWidget.AutoGenerate(pro);
                    layout.Fields.Add(field);
                }
            }


            //Filter properties invisible = true
            //IAuditableEntity, IEntity, IVersionable,IAssociatedEntitySystem
            layout = InvisiblePropertiesInterface(layout, type, typeof(IEntity));
            layout = InvisiblePropertiesInterface(layout, type, typeof(IEntityDto));
            layout = InvisiblePropertiesInterface(layout, type, typeof(IVersionable));

            //ICreationAudited, IHasCreationTime, IModificationAudited, IHasModificationTime
            layout = DeletePropertiesInterface(layout, type, typeof(ICreationAudited));
            layout = DeletePropertiesInterface(layout, type, typeof(IHasCreationTime));
            layout = DeletePropertiesInterface(layout, type, typeof(IModificationAudited));
            layout = DeletePropertiesInterface(layout, type, typeof(IHasModificationTime));

            layout = DeletePropertiesInterface(layout, type, typeof(IAudited));

            layout = DeletePropertiesInterface(layout, type, typeof(IDeletionAudited));
            layout = DeletePropertiesInterface(layout, type, typeof(IHasDeletionTime));
            layout = DeletePropertiesInterface(layout, type, typeof(ISoftDelete));

            layout = DeletePropertiesInterface(layout, type, typeof(IFullAudited));



            return(layout);
        }
        public override bool CanHandle(FieldForm field)
        {
            Type fieldType  = field.FieldType;
            Type entityType = null;

            //2. Entity
            if (fieldType.Implements <IEntity>())
            {
                return(true);
            }

            return(false);
        }
Example #13
0
        /// <summary>
        /// Top menu
        /// </summary>
        private void FileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!(sender is ToolStripMenuItem topMenuItem))
            {
                return;
            }

            switch (topMenuItem.Name)
            {
            case "newFile":
                if (fieldDraw != null)
                {
                    Field.Dispose();
                }

                FileOperations.NewFile(this, out fieldDraw);

                LockLeftMenu();
                fieldDraw.FormClosed += Ff_FormClosed;
                break;

            case "openFile":
                fieldDraw = FileOperations.OpenFile(this);
                if (fieldDraw == null)
                {
                    return;
                }

                LockLeftMenu();
                fieldDraw.FormClosed += Ff_FormClosed;
                break;

            case "saveFile":
                FileOperations.SaveFile(ref fieldDraw);
                break;

            case "clearField":
                ClearEvent?.Invoke();
                break;

            case "invertPic":
                InvertEvent?.Invoke();

                break;

            case "aboutAs":
                MessageBox.Show("The young programmer.\nWho wants to work for you.\nThank you for verified TZ.\n" +
                                "Aleksandr Hryhorenko 03.09.2018", "About Me )");
                break;
            }
        }
Example #14
0
 public static FieldForm GetField(Form1 parent, Bitmap bitmap = null)
 {
     lock (key)
         if (fieldDraw == null)
         {
             fieldDraw = new FieldForm(parent)
             {
                 Text        = "New Picture",
                 WindowState = System.Windows.Forms.FormWindowState.Maximized
             };
             fieldDraw.BitmapProp = bitmap;
         }
     return(fieldDraw);
 }
        /// <summary>
        /// Obtener el valor del campo, desde el modelo. (Segun la definicion del FieldForm)
        /// </summary>
        /// <param name="fieldForm"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static object GetValue(this FieldForm fieldForm, object model)
        {
            PropertyInfo property = model.GetType().GetProperty(fieldForm.Name);

            if (property == null)
            {
                var msg = string.Format("La propiedad [{0}] no existe en el modelo de tipo [{1}]",
                                        fieldForm.Name, model.GetType());
                throw new ArgumentException(msg);
            }

            var value = property.GetValue(model, null);

            return(value);
        }
        /// <summary>
        /// Obtener listado de identificadores, del campo del modelo.
        /// El valor de este campo debe ser una collection de objetos
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static int[] GetIds(this FieldForm fieldForm, object model)
        {
            var list = fieldForm.GetValueListProperty(model);

            if (list == null)
            {
                return new int[] { }
            }
            ;

            //Recuperar collection from Model. SelectedValue
            var selectedValue = list.Select(r => r.Id).ToArray();

            return(selectedValue);
        }
        public override object Generate(FieldForm field)
        {
            Type fieldType = field.FieldType;

            if (CanHandle(field))
            {
                var list = Enum.GetValues(fieldType);
                return(list);
            }
            else if (successor != null)
            {
                return(successor.Generate(field));
            }

            return(null);
        }
Example #18
0
 public IActionResult FieldEdit(FieldForm form)
 {
     try
     {
         campLogic.EditFieldState(form.FieldId, form.CampId, form.IsEnabled);
         return(Ok());
     }
     catch (ArgumentException ex)
     {
         return(NotFound(new { Message = ex.Message }));
     }
     catch (Exception ex)
     {
         Logger.LogError(ex, "FieldEdit method");
         return(NotFound(new { Message = "Ocurrió un error" }));
     }
 }
        public override bool CanHandle(FieldForm field)
        {
            Type fieldType  = field.FieldType;
            Type entityType = null;

            //1. List Entity.
            //Si es Lista de entidades, obtener lista de objetos, con IEntityService, y metodo GetList
            if (fieldType.IsGenericType &&
                (fieldType.GetGenericTypeDefinition() == typeof(IEnumerable <>) ||
                 fieldType.GetGenericTypeDefinition() == typeof(ICollection <>) ||
                 fieldType.GetGenericTypeDefinition().Implements(typeof(IEnumerable <>)) ||
                 fieldType.GetGenericTypeDefinition().Implements(typeof(ICollection <>))))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Generar metadatos, segun el tipo de campo. (Lista, Entidad, Enum).
        /// Lista de Entidades. (Obtener la lista de objetos)
        /// Entidad.
        /// Enum. (Pendiente)
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        private static object GenerateMetadataField(FieldForm field)
        {
            //TODO: Buscar una forma de mejorar, para agregar hander de una
            //forma mas flexible...
            //Option 1. Obtener un listado de hander... (inyectar en el constructor)
            //y agregar el succesor segun el orden en la lista...


            var enumerableEntityHandlerGenerateMetadata = new EnumerableEntiyHandlerGenerateMetadata();
            var entityHandlerGenerateMetadata           = new EntityHandlerGenerateMetadata();
            var enumEntiyHandlerGenerateMetadata        = new EnumEntiyHandlerGenerateMetadata();


            enumerableEntityHandlerGenerateMetadata.SetSuccessor(entityHandlerGenerateMetadata);
            entityHandlerGenerateMetadata.SetSuccessor(enumEntiyHandlerGenerateMetadata);

            return(enumerableEntityHandlerGenerateMetadata.Generate(field));
        }
        public static void SaveFile(ref FieldForm fieldDraw)
        {
            if (fieldDraw == null)
            {
                return;
            }

            SaveFileDialog sfd = new SaveFileDialog
            {
                FileName = $"{fieldDraw.Text}.png",
                Filter   = "Image*.png|Image*.jpg"
            };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            fieldDraw.BitmapProp.Save(sfd.FileName);
        }
 /// <summary>
 /// Si puede manejar el FieldForm
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 public abstract bool CanHandle(FieldForm field);
        public override object Generate(FieldForm field)
        {
            Type fieldType  = field.FieldType;
            Type entityType = null;

            if (CanHandle(field))
            {
                entityType = fieldType;

                //Primer recuperar alguna implementacion IEntityService<entityType>
                var    typeGeneric       = typeof(IEntityService <>);
                Type[] typeArgs          = { entityType };
                var    entityServiceType = typeGeneric.MakeGenericType(typeArgs);

                object instance = null;
                try
                {
                    instance = ServiceLocator.Current.GetInstance(entityServiceType);
                }
                catch (Exception)
                {
                    //var msg = string.Format("No se encuentra la implementacion de servicio: IEntityService<{0}>. Revisar las configuraciones del contenedor de Inyección de Dependencias ", entityType);
                    //throw new ArgumentException(msg);

                    //No existe, una implementacion IEntityService<entityType>
                    Log.WarnFormat("No existe una implementacion IEntityService<{0}> explicita.", typeArgs);
                }

                if (instance == null)
                {
                    //2) si existe algun error o es nulo, intenter recuperar clase generica de servicios
                    //GenericService<Entity> : IEntityService<Entity>
                    typeGeneric       = typeof(GenericService <>);
                    entityServiceType = typeGeneric.MakeGenericType(typeArgs);

                    instance = ServiceLocator.Current.GetInstance(entityServiceType);
                }


                //3)
                //TODO: Si no existe un servicio ?? que hacer??
                //Opcion 1. Retornar Null
                //Opcion 2. Lanzar excepcion
                if (instance == null)
                {
                    return(null);
                }

                //TODO: PENDIENTE APLICAR Domain, AL LISTADO.


                //TODO: Mejorar:
                MethodInfo method = entityServiceType.GetMethod("GetList", new Type[] { });
                var        result = method.Invoke(instance, null);

                var list = result as IEnumerable <IEntity>;

                return(list);
            }
            else if (successor != null)
            {
                return(successor.Generate(field));
            }

            return(null);
        }
Example #24
0
 IControlAction IDataPanel.GetUIElement()
 {
     FieldForm f = new FieldForm();
     f.Items = this.Items;
     return f;
 }
Example #25
0
        private void EditField_Click(object sender, System.EventArgs e)
        {
            TreeNode n = TypesView.SelectedNode;
            UPnPComplexType.ContentData cd = (UPnPComplexType.ContentData)n.Tag;

            FieldForm ff = new FieldForm(upnpService.GetComplexTypeList(),cd);
            if(ff.ShowDialog()==DialogResult.OK)
            {
                n.Text = ff.NewContentItem.ToString();
                n.Tag = ff.NewContentItem;
            }
        }
Example #26
0
 public static void Dispose()
 {
     fieldDraw = fieldDraw != null ? null : fieldDraw;
 }
 /// <summary>
 /// Generar del widget
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 public abstract object Generate(FieldForm field);
Example #28
0
 public DinamicLight(Point3 location, Vector3 direction, Color color, float brightness, FieldForm form) : base(location, direction, color, brightness, form)
 {
 }
 public static void NewFile(Form1 parent, out FieldForm fieldDraw)
 {
     fieldDraw           = Field.GetField(parent);
     fieldDraw.MdiParent = parent;
     fieldDraw.Show();
 }
Example #30
0
 public DinamicLight(Point3 location, Vector3 direction, Color color, float brightness, FieldForm form, Action behavior, int timeSleep) : this(location, direction, color, brightness, form)
 {
     AddBehavior(behavior, timeSleep);
 }
Example #31
0
        private void OnAdd_Field(object sender, System.EventArgs e)
        {
            TreeNode n = TypesView.SelectedNode;
            UPnPComplexType.ItemCollection ic = null;

            if(n.Tag.GetType()==typeof(UPnPComplexType))
            {
                if (((UPnPComplexType)n.Tag).Containers.Length == 0) return; // TODO: This sometimes happens and should not
                ic = ((UPnPComplexType)n.Tag).Containers[0].Collections[0];
            }
            else
            {
                ic = (UPnPComplexType.ItemCollection)n.Tag;
            }

            FieldForm ff = new FieldForm(upnpService.GetComplexTypeList(), null);
            if(ff.ShowDialog() == DialogResult.OK)
            {
                ic.AddContentItem(ff.NewContentItem);

                TreeNode nn = new TreeNode();
                nn.Text = ff.NewContentItem.ToString();
                nn.Tag = ff.NewContentItem;
                n.Nodes.Add(nn);
            }
        }