Ejemplo n.º 1
0
        /// <summary>
        /// Registered factory creation method
        /// </summary>
        /// <param name="aArgs">
        /// Arguments <see cref="FactoryInvocationArgs"/>
        /// </param>
        /// <returns>
        /// Result widget <see cref="IAdaptableControl"/>
        /// </returns>
        public static IAdaptableControl DefaultFactoryCreate(FactoryInvocationArgs aArgs)
        {
            IAdaptableControl wdg = new DataCheckButton();

            wdg.Mappings = aArgs.PropertyName;
            if (aArgs.State == PropertyDefinition.ReadOnly)
            {
                (wdg as DataCheckButton).Editable = false;
            }
            (wdg as DataCheckButton).AutomaticTitle = aArgs.ResolveTitle;
            if ((wdg as DataCheckButton).AutomaticTitle == false)
            {
                (wdg as DataCheckButton).Label = aArgs.Title;
            }
            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="IAdaptableControl"/>
        /// </returns>
        private static IAdaptableControl CreateDefaultGtkWidget(FactoryInvocationArgs aArgs)
        {
            foreach (FactoryInvokerClass invoker in AllWidgetsForType(aArgs.PropertyInfo.PropertyType))
            {
                return(invoker.Invoke(aArgs));
            }

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

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

            case PropertyDefinition.ReadWrite:
                if (aArgs.PropertyInfo.PropertyType == typeof(string))
                {
                    wdg = new DataEntry(aArgs.PropertyName);
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(bool))
                {
                    wdg = new DataCheckButton(aArgs.PropertyName);
                }
                else if ((aArgs.PropertyInfo.PropertyType == typeof(int)) || (aArgs.PropertyInfo.PropertyType == typeof(float)) || (aArgs.PropertyInfo.PropertyType == typeof(double)))
                {
                    wdg = new DataSpinButton(-100000000, 100000000, 1, aArgs.PropertyName);
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(DateTime))
                {
                    wdg = new DataCalendar(aArgs.PropertyName);
                }
                else if (aArgs.PropertyInfo.PropertyType == typeof(Gdk.Pixbuf))
                {
                    wdg = new DataImage(aArgs.PropertyName);
                }
                else
                {
                    wdg = new DataLabel(aArgs.PropertyName);
                }
                break;
            }
            return(wdg);
        }