Example #1
0
        /// <summary>
        /// Tworzy fabrykę widoku edycji dla edycji na podstawie obiektu (tworzy widok na podstawie danych w moduelu typu T)
        /// Tworzy panel który może być łączony z innymi panelami
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="biznesObject"></param>
        /// <returns></returns>
        public UserData.UI.Html.Version1.Fluent.Views.DataFormFactory <T> CreateDataForm <T>(T biznesObject, string title = null, string description = null)
        {
            var view = new UserData.UI.Html.Version1.Fluent.Views.DataFormFactory <T>();

            view.DataContext(biznesObject);

            var visibleProperty = new List <VisibleProperty>();

            var type       = biznesObject.GetType();
            var properties = type.GetProperties();

            foreach (var propertyInfo in properties)
            {
                var displays = propertyInfo.GetCustomAttributes(typeof(DataFormViewAttribute));
                if (displays.Any())
                {
                    var display = displays.First() as DataFormViewAttribute;
                    visibleProperty.Add(new VisibleProperty()
                    {
                        DataFormView = display, PropertyInfo = propertyInfo
                    });
                }
            }

            var tabsName = visibleProperty.Where(w => w.DataFormView.TabName != null)
                           .Select(w => w.DataFormView.TabName).Distinct().ToList();

            if (tabsName.Count > 1)
            {
                var panel       = view.AddPanel();
                var tabsControl = panel.AddTabs();
                foreach (var tabName in tabsName)
                {
                    var tab = tabsControl.AddTab(tabName);

                    var tabWidgets = visibleProperty.Where(w => w.DataFormView.TabName == tabName);
                    generateGroups(tabWidgets, tab);
                }
            }
            else
            {
                //visibleProperty = visibleProperty.OrderBy(p => p.Order).ToList();
                var df = view.AddDataForm();
                if (title != null)
                {
                    df.AddLabel(title);
                }
                if (description != null)
                {
                    df.AddLabel(description);
                }

                view.ActiveDataForm = df;
                generateGroups(visibleProperty, df);
            }



            return(view);
        }
Example #2
0
        /// <summary>
        /// Tworzy widok dla trypu edycji na podstawie typu
        /// Tworzy panel który może być łączony z innymi panelami
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <returns></returns>
        public UserData.UI.Html.Version1.Fluent.Views.DataFormFactory <T> CreateDataForm <T>(string title = null, string description = null)
        {
            var view = new UserData.UI.Html.Version1.Fluent.Views.DataFormFactory <T>();
            var df   = view.AddDataForm();

            if (title != null)
            {
                df.AddLabel(title);
            }
            if (description != null)
            {
                df.AddLabel(description);
            }

            view.ActiveDataForm = df;
            return(view);
        }