/// <summary>
        /// Registered factory creation method
        /// </summary>
        /// <param name="aArgs">
        /// Arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IMappedColumnItem"/>
        /// </returns>
        public static IMappedColumnItem DefaultFactoryCreate(FactoryInvocationArgs aArgs)
        {
            MappedCellRendererText wdg = new MappedCellRendererText();

            if (aArgs.State == PropertyDefinition.ReadWrite)
            {
                wdg.Editable = true;
            }
            wdg.MappedTo = aArgs.PropertyName;
            return(wdg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates default widgets for properties which don't specify their property description
        /// </summary>
        /// <param name="aArgs">
        /// Widget creation arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IMappedColumnItem"/>
        /// </returns>
        private static IMappedColumnItem CreateDefaultGtkCellWidget(FactoryInvocationArgs aArgs)
        {
            foreach (CellFactoryInvokerClass invoker in AllCellWidgetsForType(aArgs.PropertyInfo.PropertyType))
            {
                return(invoker.Invoke(aArgs));
            }

            // Silly fallback if registration is not done
            IMappedColumnItem wdg = null;

            switch (aArgs.State)
            {
            case PropertyDefinition.ReadOnly:
                if (aArgs.PropertyInfo.PropertyType == typeof(string))
                {
                    wdg = new MappedCellRendererText();
                    break;
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(bool))
                {
                    wdg = new MappedCellRendererToggle();
//					(wdg as DataCheckButton).Editable = false;
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(Gdk.Pixbuf))
                {
                    wdg = new MappedCellRendererPixbuf();
                }
                else
                {
                    wdg = new MappedCellRendererText();
                }
                break;

            case PropertyDefinition.ReadWrite:
                if (aArgs.PropertyInfo.PropertyType == typeof(string))
                {
                    wdg = new MappedCellRendererText();
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(bool))
                {
                    wdg = new MappedCellRendererToggle();
                }
                else if ((aArgs.PropertyInfo.PropertyType == typeof(int)) || (aArgs.PropertyInfo.PropertyType == typeof(float)) || (aArgs.PropertyInfo.PropertyType == typeof(double)))
                {
                    wdg = new MappedCellRendererSpin();
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(DateTime))
                {
                    wdg = new MappedCellRendererText();
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(Gdk.Pixbuf))
                {
                    wdg = new MappedCellRendererPixbuf();
                }
                else
                {
                    wdg = new MappedCellRendererText();
                }
                break;
            }
            wdg.MappedTo = aArgs.PropertyName;

            return(wdg);
        }