Пример #1
0
        private void MakeEditable(bool makeEditable)
        {
            Xceed.Grid.Column c = gridControl1.Columns["String_text"];
            if (c != null)
            {
                c.ReadOnly = !makeEditable;
            }

            c = gridControl1.Columns["category"];
            if (c != null)
            {
                c.ReadOnly = !makeEditable;
            }

            c = gridControl1.Columns["scenario"];
            if (c != null)
            {
                c.ReadOnly = !makeEditable;
            }

            c = gridControl1.Columns["subtitle"];
            if (c != null)
            {
                c.ReadOnly = !makeEditable;
            }
        }
Пример #2
0
        /// <summary>
        /// 读入保存的Column布局
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="sectionName"></param>
        /// <returns></returns>
        private static bool LoadLayout(this IGrid grid, string sectionName, AMS.Profile.IProfile profile)
        {
            string s = profile.GetValue(sectionName, "Column", "");

            if (string.IsNullOrEmpty(s))
            {
                return(false);
            }
            string[] columns = s.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string columnName in columns)
            {
                string[] ss = columnName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (ss.Length != 5)
                {
                    continue;
                }
                if (grid.Columns[ss[0]] == null)
                {
                    continue;
                }

                Xceed.Grid.Column column = grid.Columns[ss[0]];
                // 默认是-1,设置成0是gridcolumnInfo 设置成Invisible
                if (column != null && column.MaxWidth != 0)
                {
                    column.Visible      = Convert.ToBoolean(ss[1]);
                    column.VisibleIndex = Convert.ToInt32(ss[2]);
                    column.Width        = Convert.ToInt32(ss[3]);
                    column.Fixed        = Convert.ToBoolean(ss[4]);
                }
            }
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 重新读入绑定Grid默认Layout
        /// </summary>
        /// <param name="grid"></param>
        public static void LoadGridDefaultLayout(this IGrid grid)
        {
            if (ADInfoBll.Instance.GetGridColumnInfos(grid.GridName).Count > 0)
            {
                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                {
                    Xceed.Grid.Column column = grid.Columns[info.GridColumnName];
                    if (column != null)
                    {
                        column.Visible      = Authority.AuthorizeByRule(info.ColumnVisible);
                        column.VisibleIndex = info.SeqNo;

                        column.Fixed = info.ColumnFixed.HasValue ? info.ColumnFixed.Value : false;
                    }
                }
            }
            else
            {
                foreach (Xceed.Grid.Column column in grid.Columns)
                {
                    column.Visible = true;
                    column.Fixed   = false;
                }
            }
        }
Пример #4
0
        internal static void SetColumnProperties(Xceed.Grid.Column column, GridColumnInfo info, IGrid grid)
        {
            column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
            if (!column.Visible)
            {
                // only for column custom visible
                column.MaxWidth = 0;
            }

            column.VisibleIndex = info.SeqNo;
            column.Title        = (string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption);

            column.Tag = info;
            bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);

            if (readOnly)
            {
                column.ReadOnly = readOnly;
            }

            if (!string.IsNullOrEmpty(info.BackColor))
            {
                column.BackColor = System.Drawing.Color.FromName(info.BackColor);
            }
            if (!string.IsNullOrEmpty(info.ForeColor))
            {
                column.ForeColor = System.Drawing.Color.FromName(info.ForeColor);
            }
            if (!string.IsNullOrEmpty(info.FontName) && info.FontSize.HasValue)
            {
                column.Font = new System.Drawing.Font(info.FontName, info.FontSize.Value);
            }
            //if (info.ColumnWidth.HasValue)
            //{
            //    column.Width = info.ColumnWidth.Value * grid.Width / 1024;
            //}
            if (info.ColumnMaxWidth.HasValue)
            {
                column.MaxWidth = info.ColumnMaxWidth.Value;
            }
            if (info.ColumnFixed.HasValue)
            {
                column.Fixed = info.ColumnFixed.Value;
            }

            if (!string.IsNullOrEmpty(info.SortDirection))
            {
                if (info.SortDirection.ToUpper() == "ASC")
                {
                    column.SortDirection = SortDirection.Ascending;
                }
                else if (info.SortDirection.ToUpper() == "DESC")
                {
                    column.SortDirection = SortDirection.Descending;
                }
            }
        }
        internal CheckColumnHelper(Xceed.Grid.Column checkColumn, IGrid grid)
        {
            InitializeComponent();

            m_checkColumn = checkColumn;
            m_grid        = grid;
            if (m_grid.GridControl != null)
            {
                m_grid.GridControl.SelectionMode = SelectionMode.MultiExtended;
            }
            (checkColumn.CellEditorManager.TemplateControl as Xceed.Editors.WinCheckBox).ThreeState = false;

            this.m_selectColumnName = checkColumn.FieldName;
        }
        internal CheckColumnHelper(Xceed.Grid.Column checkColumn, IGrid grid)
        {
            InitializeComponent();

            m_checkColumn = checkColumn;
            m_grid = grid;
            if (m_grid.GridControl != null)
            {
                m_grid.GridControl.SelectionMode = SelectionMode.MultiExtended;
            }
            (checkColumn.CellEditorManager.TemplateControl as Xceed.Editors.WinCheckBox).ThreeState = false;

            this.m_selectColumnName = checkColumn.FieldName;
        }
Пример #7
0
        /// <summary>
        /// Resize the columns to better fit the grid control
        /// </summary>
        private void ResizeColumns()
        {
            Xceed.Grid.Column locColumn      = gridControl1.Columns["_locID"];
            Xceed.Grid.Column categoryColumn = gridControl1.Columns["category"];
            Xceed.Grid.Column scenarioColumn = gridControl1.Columns["scenario"];
            Xceed.Grid.Column subtitleColumn = gridControl1.Columns["subtitle"];

            Xceed.Grid.Column strColumn = gridControl1.Columns["String_text"];
            if ((locColumn != null) && (categoryColumn != null) && (scenarioColumn != null) && (subtitleColumn != null) && (strColumn != null))
            {
                int w = gridControl1.Width - locColumn.Width - categoryColumn.Width - scenarioColumn.Width - subtitleColumn.Width - 40;
                if (w > 0)
                {
                    strColumn.Width = w;
                }
            }
        }
Пример #8
0
 private void LoadDefaultLayout(DetailGrid detailGrid, GridColumnInfo info)
 {
     Xceed.Grid.Column column = detailGrid.Columns[info.GridColumnName];
     if (column != null)
     {
         column.Visible      = Authority.AuthorizeByRule(info.ColumnVisible);
         column.VisibleIndex = info.SeqNo;
     }
     else
     {
         foreach (Xceed.Grid.DataRow row in detailGrid.DataRows)
         {
             if (row.DetailGrids.Count > 0)
             {
                 LoadDefaultLayout(row.DetailGrids[0], info);
             }
         }
     }
 }
Пример #9
0
 /// <summary>
 /// 重新读入是否显示等属性
 /// </summary>
 public override void LoadDefaultLayout()
 {
     foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
     {
         Xceed.Grid.Column column = this.Columns[info.GridColumnName];
         if (column != null)
         {
             column.Visible      = Authority.AuthorizeByRule(info.ColumnVisible);
             column.VisibleIndex = info.SeqNo;
         }
         else
         {
             foreach (Xceed.Grid.DataRow row in this.DataRows)
             {
                 if (row.DetailGrids.Count > 0)
                 {
                     LoadDefaultLayout(row.DetailGrids[0], info);
                 }
             }
         }
     }
 }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        public override void CreateGrid()
        {
            this.BeginInit();

            m_infos = new Dictionary <string, GridColumnInfo>();
            Dictionary <string, int> levels = new Dictionary <string, int>();
            int cnt = 0;

            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
            {
                if (m_infos.ContainsKey(info.GridColumnName))
                {
                    throw new ArgumentException("there have already exist column " + info.GridColumnName);
                }
                m_infos[info.GridColumnName] = info;
                cnt++;
            }
            m_maxLevel = 0;
            int repeatTime = 0;

            while (levels.Count < cnt)
            {
                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
                {
                    if (levels.ContainsKey(info.GridColumnName))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.ParentPropertyName))
                    {
                        levels[info.GridColumnName] = 0;
                    }
                    else if (levels.ContainsKey(info.ParentPropertyName))
                    {
                        levels[info.GridColumnName] = levels[info.ParentPropertyName] + 1;
                        m_maxLevel = Math.Max(m_maxLevel, levels[info.GridColumnName]);
                    }
                }
                repeatTime++;
                if (repeatTime >= cnt)
                {
                    throw new ArgumentException("there must have some invalide ParentPropertyName!");
                }
            }
            Debug.Assert(m_maxLevel > 0);

            m_levelParents = new string[m_maxLevel];
            foreach (KeyValuePair <string, int> kvp in levels)
            {
                if (kvp.Value == 0)
                {
                    continue;
                }
                m_levelParents[kvp.Value - 1] = m_infos[kvp.Key].ParentPropertyName;
            }

            m_gridColumnNames = new List <string> [m_maxLevel + 1];
            for (int i = 0; i <= m_maxLevel; ++i)
            {
                m_gridColumnNames[i] = new List <string>();
            }
            foreach (KeyValuePair <string, int> kvp in levels)
            {
                if (Array.IndexOf <string>(m_levelParents, kvp.Key) != -1)
                {
                    m_gridColumnNames[kvp.Value].Insert(0, kvp.Key);
                }
                else
                {
                    m_gridColumnNames[kvp.Value].Add(kvp.Key);
                }
            }


            MyDetailGrid[] detailGrid = new MyDetailGrid[m_maxLevel];
            for (int i = 0; i < m_maxLevel; ++i)
            {
                MyDetailGrid detail = new MyDetailGrid();
                detail.Collapsed = true;

                if (i == 0)
                {
                    base.DetailGridTemplates.Add(detail);
                }
                else
                {
                    detailGrid[i - 1].DetailGridTemplates.Add(detail);
                }
                detailGrid[i] = detail;
            }
            this.UpdateDetailGrids();


            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
            {
                switch (info.GridColumnType)
                {
                case GridColumnType.NoColumn:
                    break;

                case GridColumnType.CheckColumn:
                    this.AddCheckColumn();
                    break;

                case GridColumnType.StatColumn:
                {
                    Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                    column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
                    if (!column.Visible)
                    {
                        // only for column custom visible
                        column.MaxWidth = 0;
                    }
                    column.Title    = string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption;
                    column.Tag      = info;
                    column.ReadOnly = true;
                    if (levels[info.GridColumnName] == 0)
                    {
                        this.Columns.Add(column);
                    }
                    else
                    {
                        detailGrid[levels[info.GridColumnName] - 1].Columns.Add(column);
                    }
                }
                break;

                case GridColumnType.ExpressionColumn:
                case GridColumnType.ImageColumn:
                case GridColumnType.SplitColumn:
                    break;

                case GridColumnType.Normal:
                {
                    Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                    column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
                    if (!column.Visible)
                    {
                        // only for column custom visible
                        column.MaxWidth = 0;
                    }
                    column.Title = string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption;
                    column.Tag   = info;

                    GridFactory.CreateCellViewerManager(column, info, this.DisplayManager);

                    bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                    if (readOnly)
                    {
                        column.ReadOnly = readOnly;
                    }
                    else
                    {
                        GridFactory.CreateCellEditorManager(column, info, this.DisplayManager);
                    }

                    if (levels[info.GridColumnName] == 0)
                    {
                        this.Columns.Add(column);
                    }
                    else
                    {
                        detailGrid[levels[info.GridColumnName] - 1].Columns.Add(column);
                    }
                }
                break;

                default:
                    throw new NotSupportedException("Invalid GridColumnType");
                }
            }
            this.UpdateDetailGrids();
            this.EndInit();

            this.CreateSumRow();
            this.CreateGroups();
            this.CreateEvents();

            for (int i = 0; i < m_maxLevel; ++i)
            {
                CreateDetailGridSumRow(detailGrid[i]);
            }

            this.BoundGridHelper.CreateColumnManageRowEvent();
            for (int i = 0; i < m_maxLevel; ++i)
            {
                CreateDetailGridColumnManageRowTips(detailGrid[i]);
            }
        }
        internal static void CreateUnBoundGrid(this IBoundGrid grid)
        {
            try
            {
                grid.BeginInit();

                grid.Columns.Clear();
                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                {
                    // 有些列是要设置值但不可见的,例如Id
                    //if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    //    continue;

                    switch (info.GridColumnType)
                    {
                        case GridColumnType.NoColumn:
                            break;
                        case GridColumnType.CheckColumn:
                            {
                                CheckColumn column = grid.AddCheckColumn(info.GridColumnName);
                                SetColumnProperties(column, info, grid);
                            }
                            break;
                        case GridColumnType.Normal:
                            {
                                Xceed.Grid.Column column;
                                if (grid.Columns[info.GridColumnName] != null)
                                {
                                    //throw new ArgumentException("there have already exist column " + info.GridColumnName);
                                    continue;
                                }
                                else
                                {
                                    column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                                }

                                SetColumnProperties(column, info, grid);

                                GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                                bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                                if (readOnly)
                                {
                                    column.ReadOnly = readOnly;
                                }
                                else
                                {
                                    GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                                }

                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.WarningColumn:
                            {
                                Columns.WarningColumn column = new Columns.WarningColumn(info.GridColumnName, info.PropertyName);
                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.StatColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                                SetColumnProperties(column, info, grid);
                                GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                                column.ReadOnly = true;
                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.ExpressionColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                                SetColumnProperties(column, info, grid);
                                GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                                bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                                if (readOnly)
                                {
                                    column.ReadOnly = readOnly;
                                }
                                else
                                {
                                    GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                                }
                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.ImageColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(System.Drawing.Image));
                                SetColumnProperties(column, info, grid);
                                column.ReadOnly = true;
                                column.MaxWidth = 72;
                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.SplitColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(string));
                                SetColumnProperties(column, info, grid);
                                column.ReadOnly = true;
                                column.BackColor = System.Drawing.Color.LightGray;
                                column.Title = " ";
                                column.MaxWidth = 5;
                                column.Width = 5;
                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.UnboundColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                                SetColumnProperties(column, info, grid);

                                GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                                bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                                if (readOnly)
                                {
                                    column.ReadOnly = readOnly;
                                }
                                else
                                {
                                    GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                                }

                                grid.Columns.Add(column);
                            }
                            break;
                        case GridColumnType.IndexColumn:
                            {
                                Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(int));
                                SetColumnProperties(column, info, grid);
                                column.ReadOnly = true;

                                grid.Columns.Add(column);
                            }
                            break;
                        default:
                            throw new NotSupportedException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
            finally
            {
                grid.EndInit();
            }

            grid.CreateSumRow();
            grid.CreateGroups();
            grid.CreateEvents();

            grid.BoundGridHelper.CreateColumnManageRowEvent();
            grid.SetColumnManagerRowHorizontalAlignment();
            grid.CreateMultiColumnHeaderColumnManagerRow();
        }
Пример #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="grid"></param>
 /// <param name="column"></param>
 public static void AddCheckColumn(this IGrid grid, Xceed.Grid.Column column)
 {
     Feng.Grid.Columns.CheckColumnHelper helper = new Columns.CheckColumnHelper(column);
     helper.Initialize();
 }
        /// <summary>
        /// 
        /// </summary>
        public override void CreateGrid()
        {
            this.BeginInit();

            m_infos = new Dictionary<string, GridColumnInfo>();
            Dictionary<string, int> levels = new Dictionary<string, int>();
            int cnt = 0;
            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
            {
                if (m_infos.ContainsKey(info.GridColumnName))
                {
                    throw new ArgumentException("there have already exist column " + info.GridColumnName);
                }
                m_infos[info.GridColumnName] = info;
                cnt++;
            }
            m_maxLevel = 0;
            int repeatTime = 0;
            while (levels.Count < cnt)
            {
                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
                {
                    if (levels.ContainsKey(info.GridColumnName))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.ParentPropertyName))
                    {
                        levels[info.GridColumnName] = 0;
                    }
                    else if (levels.ContainsKey(info.ParentPropertyName))
                    {
                        levels[info.GridColumnName] = levels[info.ParentPropertyName] + 1;
                        m_maxLevel = Math.Max(m_maxLevel, levels[info.GridColumnName]);
                    }
                }
                repeatTime++;
                if (repeatTime >= cnt)
                {
                    throw new ArgumentException("there must have some invalide ParentPropertyName!");
                }
            }
            Debug.Assert(m_maxLevel > 0);

            m_levelParents = new string[m_maxLevel];
            foreach (KeyValuePair<string, int> kvp in levels)
            {
                if (kvp.Value == 0)
                {
                    continue;
                }
                m_levelParents[kvp.Value - 1] = m_infos[kvp.Key].ParentPropertyName;
            }

            m_gridColumnNames = new List<string>[m_maxLevel + 1];
            for (int i = 0; i <= m_maxLevel; ++i)
            {
                m_gridColumnNames[i] = new List<string>();
            }
            foreach (KeyValuePair<string, int> kvp in levels)
            {
                if (Array.IndexOf<string>(m_levelParents, kvp.Key) != -1)
                {
                    m_gridColumnNames[kvp.Value].Insert(0, kvp.Key);
                }
                else
                {
                    m_gridColumnNames[kvp.Value].Add(kvp.Key);
                }
            }

            MyDetailGrid[] detailGrid = new MyDetailGrid[m_maxLevel];
            for (int i = 0; i < m_maxLevel; ++i)
            {
                MyDetailGrid detail = new MyDetailGrid();
                detail.Collapsed = true;

                if (i == 0)
                {
                    base.DetailGridTemplates.Add(detail);
                }
                else
                {
                    detailGrid[i - 1].DetailGridTemplates.Add(detail);
                }
                detailGrid[i] = detail;
            }
            this.UpdateDetailGrids();

            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(this.GridName))
            {
                switch (info.GridColumnType)
                {
                    case GridColumnType.NoColumn:
                        break;
                    case GridColumnType.CheckColumn:
                        this.AddCheckColumn();
                        break;
                    case GridColumnType.StatColumn:
                        {
                            Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                            column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
                            if (!column.Visible)
                            {
                                // only for column custom visible
                                column.MaxWidth = 0;
                            }
                            column.Title = string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption;
                            column.Tag = info;
                            column.ReadOnly = true;
                            if (levels[info.GridColumnName] == 0)
                            {
                                this.Columns.Add(column);
                            }
                            else
                            {
                                detailGrid[levels[info.GridColumnName] - 1].Columns.Add(column);
                            }
                        }
                        break;
                    case GridColumnType.ExpressionColumn:
                    case GridColumnType.ImageColumn:
                    case GridColumnType.SplitColumn:
                        break;
                    case GridColumnType.Normal:
                        {
                            Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                            column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
                            if (!column.Visible)
                            {
                                // only for column custom visible
                                column.MaxWidth = 0;
                            }
                            column.Title = string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption;
                            column.Tag = info;

                            GridFactory.CreateCellViewerManager(column, info, this.DisplayManager);

                            bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                            if (readOnly)
                            {
                                column.ReadOnly = readOnly;
                            }
                            else
                            {
                                GridFactory.CreateCellEditorManager(column, info, this.DisplayManager);
                            }

                            if (levels[info.GridColumnName] == 0)
                            {
                                this.Columns.Add(column);
                            }
                            else
                            {
                                detailGrid[levels[info.GridColumnName] - 1].Columns.Add(column);
                            }
                        }
                        break;
                    default:
                        throw new NotSupportedException("Invalid GridColumnType");
                }
            }
            this.UpdateDetailGrids();
            this.EndInit();

            this.CreateSumRow();
            this.CreateGroups();
            this.CreateEvents();

            for (int i = 0; i < m_maxLevel; ++i)
            {
                CreateDetailGridSumRow(detailGrid[i]);
            }

            this.BoundGridHelper.CreateColumnManageRowEvent();
            for (int i = 0; i < m_maxLevel; ++i)
            {
                CreateDetailGridColumnManageRowTips(detailGrid[i]);
            }
        }
Пример #14
0
        internal static void CreateUnBoundGrid(this IBoundGrid grid)
        {
            try
            {
                grid.BeginInit();

                grid.Columns.Clear();
                foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                {
                    // 有些列是要设置值但不可见的,例如Id
                    //if (!Authority.AuthorizeByRule(info.ColumnVisible))
                    //    continue;

                    switch (info.GridColumnType)
                    {
                    case GridColumnType.NoColumn:
                        break;

                    case GridColumnType.CheckColumn:
                    {
                        CheckColumn column = grid.AddCheckColumn(info.GridColumnName);
                        SetColumnProperties(column, info, grid);
                    }
                    break;

                    case GridColumnType.Normal:
                    {
                        Xceed.Grid.Column column;
                        if (grid.Columns[info.GridColumnName] != null)
                        {
                            //throw new ArgumentException("there have already exist column " + info.GridColumnName);
                            continue;
                        }
                        else
                        {
                            column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                        }

                        SetColumnProperties(column, info, grid);

                        GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                        bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                        if (readOnly)
                        {
                            column.ReadOnly = readOnly;
                        }
                        else
                        {
                            GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                        }

                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.WarningColumn:
                    {
                        Columns.WarningColumn column = new Columns.WarningColumn(info.GridColumnName, info.PropertyName);
                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.StatColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                        SetColumnProperties(column, info, grid);
                        GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                        column.ReadOnly = true;
                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.ExpressionColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                        SetColumnProperties(column, info, grid);
                        GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                        bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                        if (readOnly)
                        {
                            column.ReadOnly = readOnly;
                        }
                        else
                        {
                            GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                        }
                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.ImageColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(System.Drawing.Image));
                        SetColumnProperties(column, info, grid);
                        column.ReadOnly = true;
                        column.MaxWidth = 72;
                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.SplitColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(string));
                        SetColumnProperties(column, info, grid);
                        column.ReadOnly  = true;
                        column.BackColor = System.Drawing.Color.LightGray;
                        column.Title     = " ";
                        column.MaxWidth  = 5;
                        column.Width     = 5;
                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.UnboundColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, GridColumnInfoHelper.CreateType(info));
                        SetColumnProperties(column, info, grid);

                        GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);
                        bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                        if (readOnly)
                        {
                            column.ReadOnly = readOnly;
                        }
                        else
                        {
                            GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                        }

                        grid.Columns.Add(column);
                    }
                    break;

                    case GridColumnType.IndexColumn:
                    {
                        Xceed.Grid.Column column = new Xceed.Grid.Column(info.GridColumnName, typeof(int));
                        SetColumnProperties(column, info, grid);
                        column.ReadOnly = true;

                        grid.Columns.Add(column);
                    }
                    break;

                    default:
                        throw new NotSupportedException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionProcess.ProcessWithNotify(ex);
            }
            finally
            {
                grid.EndInit();
            }

            grid.CreateSumRow();
            grid.CreateGroups();
            grid.CreateEvents();

            grid.BoundGridHelper.CreateColumnManageRowEvent();
            grid.SetColumnManagerRowHorizontalAlignment();
            grid.CreateMultiColumnHeaderColumnManagerRow();
        }
Пример #15
0
        /// <summary>
        /// 创建绑定Grid
        /// </summary>
        /// <param name="grid"></param>
        internal static void CreateBoundGrid(this IBoundGrid grid)
        {
            grid.DisplayManager.SetDataBinding(grid.DisplayManager.SearchManager.GetSchema(), string.Empty);

            if (ADInfoBll.Instance.GetGridColumnInfos(grid.GridName).Count > 0)
            {
                try
                {
                    grid.BeginInit();

                    foreach (Xceed.Grid.Column column in grid.Columns)
                    {
                        column.Visible = false;
                    }

                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
                    {
                        switch (info.GridColumnType)
                        {
                        case GridColumnType.NoColumn:
                        case GridColumnType.StatColumn:
                        case GridColumnType.WarningColumn:
                        case GridColumnType.CheckColumn:
                            break;

                        case GridColumnType.Normal:
                            Xceed.Grid.Column column = grid.Columns[info.GridColumnName];
                            if (column == null)
                            {
                                throw new ArgumentException("Invalid GridColumnInfo of " + info.GridColumnName);
                            }

                            column.Visible = Authority.AuthorizeByRule(info.ColumnVisible);
                            if (!column.Visible)
                            {
                                // only for column custom visible.
                                // 当重置配置的时候,不会使他显示出来
                                column.MaxWidth = 0;
                            }

                            column.VisibleIndex = info.SeqNo;
                            column.Title        = (string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption);

                            if (!string.IsNullOrEmpty(info.BackColor))
                            {
                                column.BackColor = System.Drawing.Color.FromName(info.BackColor);
                            }
                            if (!string.IsNullOrEmpty(info.ForeColor))
                            {
                                column.ForeColor = System.Drawing.Color.FromName(info.ForeColor);
                            }
                            if (!string.IsNullOrEmpty(info.FontName) && info.FontSize.HasValue)
                            {
                                column.Font = new System.Drawing.Font(info.FontName, info.FontSize.Value);
                            }

                            column.Tag = info;

                            GridFactory.CreateCellViewerManager(column, info, grid.DisplayManager);

                            bool readOnly = Authority.AuthorizeByRule(info.ReadOnly);
                            if (readOnly)
                            {
                                column.ReadOnly = readOnly;
                            }
                            else
                            {
                                GridFactory.CreateCellEditorManager(column, info, grid.DisplayManager);
                            }
                            break;

                        default:
                            throw new NotSupportedException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                        }
                    }

                    grid.CreateSumRow();
                    grid.CreateGroups();
                    grid.CreateEvents();
                }
                catch (Exception ex)
                {
                    ExceptionProcess.ProcessWithNotify(ex);
                }
                finally
                {
                    grid.EndInit();
                }
            }

            grid.BoundGridHelper.CreateColumnManageRowEvent();
            grid.SetColumnManagerRowHorizontalAlignment();
        }
 /// <summary>
 ///
 /// </summary>
 internal CheckColumnHelper(Xceed.Grid.Column checkColumn)
     : this(checkColumn, checkColumn.GridControl as IGrid)
 {
 }
Пример #17
0
        /// <summary>
        /// Loads the stringtable into memory from the game work directory
        /// </summary>
        private void LoadStringtable()
        {
            gridControl1.DataRowTemplate.AutoHeightMode = AutoHeightMode.AllContent;
            gridControl1.WordWrap = true;

            mDoc = new XmlDataDocument();
            // mDoc.PreserveWhitespace = true;

            string strTablePath    = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, mStringTableFilename);
            string strTableXsdPath = Path.Combine(CoreGlobals.getWorkPaths().mGameDataDirectory, "stringtable.xsd");

            // these need to be pulled from the data directory
            mDoc.DataSet.ReadXmlSchema(strTableXsdPath);
            mDoc.Load(strTablePath);

            gridControl1.DataSource = mDoc.DataSet;
            gridControl1.DataMember = "String";

            System.Data.DataTable table = mDoc.DataSet.Tables[2];

            DataColumn[] PrimaryKeyColumns = new DataColumn[1];
            PrimaryKeyColumns[0] = table.Columns["_locID"];
            table.PrimaryKey     = PrimaryKeyColumns;

            Xceed.Grid.Column locColumn = gridControl1.Columns["_locID"];
            if (locColumn != null)
            {
                locColumn.ReadOnly = true;
            }

            Xceed.Grid.Column c = gridControl1.Columns["Language_Id"];
            if (c != null)
            {
                c.Visible = false;
            }

            c = gridControl1.Columns["category"];
            if (c != null)
            {
                // c.Visible = false;
                ComboBoxEditor combo = new ComboBoxEditor();

                combo.Items.Add(new ComboBoxItem(new object[1] {
                    ""
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Code"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Techs"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Squads"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Powers"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Abilities"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Leaders"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Objects"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "UI"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Campaign"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Cinematics"
                }));
                combo.Items.Add(new ComboBoxItem(new object[1] {
                    "Skirmish"
                }));

                c.CellEditorManager = combo;
            }
            mDoc.DataSet.AcceptChanges();

//         ResizeColumns();
        }