Exemplo n.º 1
0
        public ListBoContractResolver(string mnemonic, IUiFasade uiFasade)
        {
            _uiFasade = uiFasade;

            if (!String.IsNullOrEmpty(mnemonic))
            {
                _config = uiFasade.GetViewModelConfig(mnemonic);
                _columns = uiFasade.GetColumns(mnemonic);
            }
        }
Exemplo n.º 2
0
        public override Preset Init(IUiFasade uiFasade)
        {
            base.Init(uiFasade);

            var columns = uiFasade.GetColumns(OwnerMnemonic)
                .Where(x => x.PropertyInfo.IsDefined(typeof(ListViewAttribute), false)).ToList();

            if (this.Columns == null)
            {
                this.PageSize = OwnerConfig.ListView.DataSource.PageSize;
                this.Groupable = OwnerConfig.ListView.DataSource.Groups.Groupable;

                this.Columns = new List<ColumnSetting>();

                columns.ForEach(col =>
                {
                    var columnSetting = this.Columns.FirstOrDefault(x => x.Name == col.PropertyName);

                    if (columnSetting == null)
                    {
                        columnSetting = new ColumnSetting(col)
                        {
                            Visible = col.Visible,
                            Width = col.Width,
                            SortOrder = col.Order,
                        };

                        columnSetting.ID = this.Columns.Count() + 1;

                        this.Columns.Add(columnSetting.Init(col));
                    }
                });
            }
            else
            {
                bool changeConfig = false;

                var properties = columns.Select(x => x.PropertyName).ToList();

                foreach (var col in this.Columns)
                {
                    var vm = columns.FirstOrDefault(x => x.PropertyName == col.Name);

                    if (vm == null)
                    {
                        changeConfig = true;
                        break;
                    }

                    properties.Remove(vm.PropertyName);

                    col.Init(vm);
                }

                if (changeConfig || properties.Count > 0)
                {
                    this.Columns = null;

                    return this.Init(uiFasade);
                }
            }


            return this;
        }