コード例 #1
0
ファイル: ViewBase.cs プロジェクト: maxpavlov/FlexNet
 public virtual void AddColumn(Column col)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
ファイル: ListView.cs プロジェクト: maxpavlov/FlexNet
 public override void AddColumn(Column col)
 {
     var cols = PrepareColumnList(Columns).ToList();
     cols.Add(col);
     Columns = SerializeColumnXml(cols);
 }
コード例 #3
0
ファイル: ListView.cs プロジェクト: maxpavlov/FlexNet
 private static int CompareColumnsByIndex(Column x, Column y)
 {
     return x.Index.CompareTo(y.Index);
 }
コード例 #4
0
ファイル: ColumnSelector.cs プロジェクト: maxpavlov/FlexNet
        private static int CompareColumns(Column x, Column y)
        {
            var xTitle = x.Title ?? string.Empty;
            var yTitle = y.Title ?? string.Empty;

            return xTitle.CompareTo(yTitle);
        }
コード例 #5
0
ファイル: ColumnSelector.cs プロジェクト: maxpavlov/FlexNet
        private IEnumerable<Column> GetSelectedColumns(WebControls.ListView listView)
        {
            var cols = new List<Column>();

            if (listView == null)
                return cols;

            foreach (var c in listView.Items)
            {
                var cb = c.FindControl("cbField") as CheckBox;
                var tb = c.FindControl("tbWidth") as TextBox;
                var ha = c.FindControl("ddHAlign") as DropDownList;
                var wm = c.FindControl("ddWrap") as DropDownList;
                var lblFullName = c.FindControl("lblColumnFullName") as Label;
                var ind = c.FindControl("ddIndex") as DropDownList;

                if ((cb == null) || !cb.Checked || lblFullName == null)
                    continue;

                var query = from FieldSetting f in AvailableFields
                            where f.FullName == lblFullName.Text
                            select f;

                if (query.Count() <= 0)
                    continue;

                var fs = query.First();
                var newcol = new Column
                {
                    Title = (string.IsNullOrEmpty(fs.DisplayName) ? fs.Name : fs.DisplayName),
                    FullName = fs.FullName,
                    BindingName = fs.BindingName,
                    Index = ind != null ? Convert.ToInt32(ind.SelectedValue) : 1
                };

                if (tb != null)
                {
                    var colWidth = 0;
                    if (int.TryParse(tb.Text, out colWidth))
                        newcol.Width = colWidth;
                }

                if (ha != null)
                {
                    newcol.HorizontalAlign = ha.SelectedValue;
                }

                if (wm != null)
                {
                    newcol.Wrap = wm.SelectedValue;
                }

                //TODO: refactor this
                if (fs.BindingName == "GenericContent_DisplayName" ||
                    fs.BindingName == "GenericContent_Title" ||
                    fs.BindingName == "GenericContent_Name" ||
                    fs.BindingName == "ContentType_DisplayName" ||
                    fs.BindingName == "ContentType_Title" ||
                    fs.BindingName == "ContentType_Name")
                {
                    newcol.IsLeadColumn = true;
                    newcol.Icon = fs.Icon;
                }

                cols.Add(newcol);
            }

            return cols;
        }
コード例 #6
0
ファイル: ColumnSelector.cs プロジェクト: maxpavlov/FlexNet
        public override void SetData(object data)
        {
            _columnIndexList = new List<int>();

            var index = 1;
            var unusedCols = new List<Column>();
            var advancedCols = new List<Column>();
            var colXml = data as string;
            var colEnum = Handler.PrepareColumnList(colXml);
            var fieldTitles = new List<string>();
            var duplicatedTitles = new List<string>();

            _columns = colEnum != null ? colEnum.ToList() : new List<Column>();
            _columnsAdvanced = new List<Column>();

            var ind = 1;

            foreach (var column in _columns)
            {
                column.Selected = true;

                //use the display name of the field instead of the value saved in the view
                var afs = AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                if (afs != null)
                    column.Title = afs.DisplayName;

                //default index for the selected columns)
                if (this.Field.Content.IsNew)
                    column.Index = ind++;

                //add index numbers for selected columns
                _columnIndexList.Add(index++);
            }

            foreach (var fs in AvailableFields)
            {
                if (fieldTitles.Contains(fs.DisplayName))
                    duplicatedTitles.Add(fs.DisplayName);
                else
                    fieldTitles.Add(fs.DisplayName);

                if (_columns.Any(c => c.BindingName == fs.BindingName)) 
                    continue;

                //add index numbers for remaining columns
                _columnIndexList.Add(index++);

                var col = new Column
                              {
                                  Title = (string.IsNullOrEmpty(fs.DisplayName) ? fs.Name : fs.DisplayName),
                                  FullName = fs.FullName,
                                  BindingName = fs.BindingName,
                                  Index = 1,
                                  Selected = false
                              };

                if (_advancedFieldNames.Contains(fs.BindingName))
                {
                    advancedCols.Add(col);
                }
                else
                {
                    unusedCols.Add(col);
                }
            }

            unusedCols.Sort(CompareColumns);
            advancedCols.Sort(CompareColumns);

            //default column indexes: 1,2,3,...
            ind = _columns.Count + 1;
            foreach (var col in unusedCols)
            {
                col.Index = ind++;
            }

            foreach (var col in advancedCols)
            {
                col.Index = ind++;
            }

            _columns.AddRange(unusedCols); 
            _columnsAdvanced.AddRange(advancedCols);

            foreach (var dupTitle in duplicatedTitles)
            {
                foreach (var column in _columns.Where(cc => cc.Title == dupTitle))
                {
                    var fs = this.AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                    if (fs == null)
                        continue;

                    column.Title = column.Title + string.Format(" ({0})", fs.Owner.DisplayName);
                }

                foreach (var column in _columnsAdvanced.Where(cc => cc.Title == dupTitle))
                {
                    var fs = this.AvailableFields.FirstOrDefault(af => af.FullName == column.FullName);
                    if (fs == null)
                        continue;

                    column.Title = column.Title + string.Format(" ({0})", fs.Owner.DisplayName);
                }
            }
        }