private static RecordTable CreateDataSource(GridColumnInfo info, IDbAccess dataAccess)
        {
            SqlQuery query = new SqlQuery();
            StringBuilder text = query.Text;
            text.Append("SELECT ");
            text.Append(info.ParentValueField);
            text.Append(',');
            text.Append(info.ParentTextField);
            text.Append(" FROM ");
            text.Append(info.ParentTable);

            if (!String.IsNullOrEmpty(info.FilterExpression))
            {
                text.Append(" WHERE ");
                text.Append(info.FilterExpression);
            }
            if (!String.IsNullOrEmpty(info.SortExpression))
            {
                text.Append(" ORDER BY ");
                text.Append(info.SortExpression);
            }

            RecordTable table = new RecordTable(info.ParentTable);
            using(IDataReader dr = dataAccess.CreateDataReader(query, CommandBehavior.Default))
            {
                table.Load(dr, false, new UISchemaTableReader(info.ParentValueField));
            }
            return table;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <param name="asView"></param>
        /// <returns></returns>
        public static string GetNameValueMappingName(GridColumnInfo info, bool asView)
        {
            string initParam = asView ? info.CellViewerManagerParam : info.CellEditorManagerParam;
            if (string.IsNullOrEmpty(initParam))
                return null;

            //string filter = asView ? string.Empty : info.CellEditorManagerParamFilter;
            string nvName;
            if (initParam.StartsWith(GridColumnInfoHelper.StartWithBigEnum, StringComparison.Ordinal))
            {
                Type type = GridColumnInfoHelper.CreateTypeFromEnumInitParam(GridColumnInfoHelper.CreateType(info), initParam);
                System.Diagnostics.Debug.Assert(type != null, info.GridColumnName + "'s ControlInitParam should be valid");
                //ControlDataLoad.InitDataControl(control, type, false, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
                nvName = NameValueMappingCollection.Instance.Add(type, false);
            }
            else if (initParam.StartsWith(GridColumnInfoHelper.StartWithLittleEnum, StringComparison.Ordinal))
            {
                Type type = GridColumnInfoHelper.CreateTypeFromEnumInitParam(GridColumnInfoHelper.CreateType(info), initParam);
                System.Diagnostics.Debug.Assert(type != null, info.GridColumnName + "'s ControlInitParam should be valid");
                //ControlDataLoad.InitDataControl(control, type, true, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
                nvName = NameValueMappingCollection.Instance.Add(type, true);
            }
            else
            {
                nvName = initParam;
                //ControlDataLoad.InitDataControl(control, info.CellViewerManagerParam,
                //    info.CellEditorManagerParam, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
            }
            return nvName;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentColumn"></param>
        /// <returns></returns>
        protected override Cell CreateCell(Column parentColumn)
        {
            SearchCell cell = new SearchCell(parentColumn);

            cell.CellEditorManager = new SearchEditor();

            bool           enable = true;
            GridColumnInfo info   = parentColumn.Tag as GridColumnInfo;

            if (info != null)
            {
                enable = info.GridColumnType == GridColumnType.Normal;
                if (enable)
                {
                    string     searchPropertyName = SearchCell.GetSearchPropertyName(info);
                    IBoundGrid grid = this.GridControl as IBoundGrid;
                    if (grid != null && grid.DisplayManager != null)
                    {
                        var p = grid.DisplayManager.EntityInfo.GetPropertMetadata(searchPropertyName);
                        if (p == null)
                        {
                            enable = false;
                        }
                    }
                }
            }
            cell.ReadOnly = !enable;
            return(cell);
        }
        void ContextMenuStripForCell_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (m_grid.GridHelper.ContextCell != null ||
                m_grid.GridHelper.ContextSelector != null)
            {
                Xceed.Grid.CellRow rowCurrent;
                if (m_grid.GridHelper.ContextCell != null)
                {
                    rowCurrent = m_grid.GridHelper.ContextCell.ParentRow;
                }
                else
                {
                    rowCurrent = m_grid.GridHelper.ContextSelector.Row as Xceed.Grid.CellRow;
                }

                tsm默认本列.Visible        = true;
                tsmDeleteBatch.Visible = true;
                tsmDeleteBatch.Enabled = true;
                tsm默认本列.Enabled        = true;

                if ((rowCurrent != null && rowCurrent.IsBeingEdited))        // || m_grid.IsInDetailMode 不应该设置
                {
                    tsm默认本列.Visible        = false;
                    tsmDeleteBatch.Visible = false;
                }

                if (!m_grid.ControlManager.AllowDelete || !m_grid.AllowInnerDelete)
                {
                    tsmDeleteBatch.Visible = false;
                }

                if (m_grid.ReadOnly)
                {
                    tsmDeleteBatch.Enabled = false;
                    tsm默认本列.Enabled        = false;
                }
            }

            if (m_grid.GridHelper.ContextCell != null)
            {
                GridColumnInfo columnInfo = m_grid.GridHelper.ContextCell.ParentColumn.Tag as GridColumnInfo;
                if (columnInfo != null && columnInfo.AllowSetList.HasValue)
                {
                    tsm默认本列.Visible       = true;
                    m_allowSetListWarning = columnInfo.AllowSetList.Value;
                }
                else
                {
                    tsm默认本列.Visible = false;
                }
            }
            else if (m_grid.GridHelper.ContextSelector != null)
            {
                tsm默认本列.Visible = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
Example #5
0
        /// <summary>
        /// 创建Group
        /// </summary>
        internal static void CreateArchiveEvents(this IArchiveGrid grid)
        {
            foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(grid.GridName))
            {
                switch (info.GridColumnType)
                {
                case GridColumnType.NoColumn:
                    break;

                default:
                    if (info.DoubleClick != null)
                    {
                        GridColumnInfo          info2     = info;
                        Xceed.Grid.InsertionRow insertRow = grid.GetInsertionRow();
                        if (insertRow != null)
                        {
                            insertRow.Cells[info.GridColumnName].DoubleClick += new EventHandler(delegate(object sender, EventArgs e)
                            {
                                EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(info2.DoubleClick), sender, e);
                            });
                        }
                    }
                    break;
                    //default:
                    //    throw new InvalidOperationException("Invalide gridcolumnType of " + info.GridColumnType + " in " + info.Name);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <param name="asView"></param>
        /// <returns></returns>
        public static string GetNameValueMappingName(GridColumnInfo info, bool asView)
        {
            string initParam = asView ? info.CellViewerManagerParam : info.CellEditorManagerParam;

            if (string.IsNullOrEmpty(initParam))
            {
                return(null);
            }

            //string filter = asView ? string.Empty : info.CellEditorManagerParamFilter;
            string nvName;

            if (initParam.StartsWith(GridColumnInfoHelper.StartWithBigEnum, StringComparison.Ordinal))
            {
                Type type = GridColumnInfoHelper.CreateTypeFromEnumInitParam(GridColumnInfoHelper.CreateType(info), initParam);
                System.Diagnostics.Debug.Assert(type != null, info.GridColumnName + "'s ControlInitParam should be valid");
                //ControlDataLoad.InitDataControl(control, type, false, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
                nvName = NameValueMappingCollection.Instance.Add(type, false);
            }
            else if (initParam.StartsWith(GridColumnInfoHelper.StartWithLittleEnum, StringComparison.Ordinal))
            {
                Type type = GridColumnInfoHelper.CreateTypeFromEnumInitParam(GridColumnInfoHelper.CreateType(info), initParam);
                System.Diagnostics.Debug.Assert(type != null, info.GridColumnName + "'s ControlInitParam should be valid");
                //ControlDataLoad.InitDataControl(control, type, true, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
                nvName = NameValueMappingCollection.Instance.Add(type, true);
            }
            else
            {
                nvName = initParam;
                //ControlDataLoad.InitDataControl(control, info.CellViewerManagerParam,
                //    info.CellEditorManagerParam, (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter));
            }
            return(nvName);
        }
        internal static void ResetSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster)
        {
            if (dmMaster == null)
            {
                return;
            }

            if (dmMaster.SearchManager != null)
            {
                int n = 0;
                foreach (ISearchControl sc in dmMaster.SearchManager.SearchControls)
                {
                    GridColumnInfo info = sc.Tag as GridColumnInfo;

                    if (info == null || (!string.IsNullOrEmpty(info.SearchControlType) &&
                                         Authority.AuthorizeByRule(info.SearchControlVisible)))
                    {
                        sc.Available = true;
                    }
                    else
                    {
                        sc.Available = false;
                    }

                    sc.Index = n;
                    n++;
                }

                //LoadSearchControlInfos(grdSetup, dmMaster);
            }
        }
Example #8
0
        private ComponentArt.Web.UI.GridColumn GetColumn(GridColumnInfo info)
        {
            ComponentArt.Web.UI.GridColumn column = new ComponentArt.Web.UI.GridColumn {
                DataField   = info.GridColumnName,
                HeadingText = (string.IsNullOrEmpty(info.Caption) ? info.PropertyName : info.Caption)
            };

            Type type = info.CreateType();

            if (type.IsEnum ||
                (info.CellViewerManager == "Combo" || info.CellViewerManager == "MultiCombo"))
            {
                column.DataType = typeof(string);
            }
            else
            {
                column.DataType = type;
            }

            string fs = Feng.Utils.DataProcess.GetFormatString(info);

            if (!string.IsNullOrEmpty(fs))
            {
                column.FormatString = fs;
            }
            return(column);
        }
        internal static void LoadSearchControlInfos(MyGrid grdSetup, IDisplayManager dmMaster)
        {
            if (dmMaster == null)
            {
                return;
            }

            if (grdSetup.Columns.Count == 0)
            {
                grdSetup.Columns.Add(new Xceed.Grid.Column("名称", typeof(string)));
                grdSetup.Columns.Add(new Xceed.Grid.Column("是否显示", typeof(bool)));
                grdSetup.ReadOnly = false;
                grdSetup.Columns["是否显示"].ReadOnly = false;
                grdSetup.Columns["名称"].ReadOnly   = true;
            }

            grdSetup.DataRows.Clear();

            ISearchManager sm = dmMaster.SearchManager;

            if (sm != null)
            {
                SortedList <int, ISearchControl> scc1 = new SortedList <int, ISearchControl>();
                SortedList <int, ISearchControl> scc2 = new SortedList <int, ISearchControl>();

                foreach (ISearchControl sc in sm.SearchControls)
                {
                    GridColumnInfo info = sc.Tag as GridColumnInfo;
                    if (info == null || (!string.IsNullOrEmpty(info.SearchControlType) &&
                                         Authority.AuthorizeByRule(info.SearchControlVisible)))
                    {
                        if (sc.Available)
                        {
                            scc1.Add(sc.Index, sc);
                        }
                        else
                        {
                            scc2.Add(sc.Index, sc);
                        }
                    }
                }

                foreach (KeyValuePair <int, ISearchControl> kvp in scc1)
                {
                    Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew();
                    row.Cells["是否显示"].Value = kvp.Value.Available;
                    row.Cells["名称"].Value   = kvp.Value.Caption;
                    row.EndEdit();
                }
                foreach (KeyValuePair <int, ISearchControl> kvp in scc2)
                {
                    Xceed.Grid.DataRow row = grdSetup.DataRows.AddNew();
                    row.Cells["是否显示"].Value = kvp.Value.Available;
                    row.Cells["名称"].Value   = kvp.Value.Caption;
                    row.EndEdit();
                }
            }
        }
Example #10
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;
                }
            }
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="detailGrid"></param>
        protected void CreateDetailGridSumRow(MyDetailGrid detailGrid)
        {
            bool needSum = false;

            if (!needSum)
            {
                foreach (Column column in detailGrid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.StatFunction) || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    needSum = true;
                    break;
                }
            }

            if (needSum)
            {
                SummaryRow sumRow = detailGrid.AddSummaryRowToFixedFooter();
                sumRow.TextFormat = ADInfoBll.Instance.GetGridInfo(detailGrid.GridName).StatTitle;

                foreach (Column column in detailGrid.Columns)
                {
                    GridColumnInfo info = column.Tag as GridColumnInfo;
                    if (info == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(info.StatFunction) || !Authority.AuthorizeByRule(info.ColumnVisible))
                    {
                        continue;
                    }

                    MySummaryCell cell = ((MySummaryCell)sumRow.Cells[info.GridColumnName]);
                    cell.StatFunction          = BoundGridExtention.GetStatFunction(info.StatFunction);
                    cell.RunningStatGroupLevel = 0;
                    cell.ResultDataType        = typeof(string);

                    if (!string.IsNullOrEmpty(info.StatTitle))
                    {
                        cell.TitleFormat   = info.StatTitle;
                        cell.TitlePosition = TitlePosition.PreferablyRight;
                    }
                }
            }
        }
        void cell_EditLeft(object sender, EditLeftEventArgs e)
        {
            Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell;

            if (!Feng.Utils.ReflectionHelper.ObjectEquals(m_originalSelectedDataValue, cell.Value))
            {
                GridColumnInfo info = cell.ParentColumn.Tag as GridColumnInfo;
                string         s    = info != null ? info.GridColumnName : cell.ParentColumn.FieldName;
                m_cm.DisplayManager.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs(s, cell));
            }
        }
Example #13
0
        internal GridComboBoxColumn(GridColumnInfo info, IDbAccess dataAccess)
        {
            base.DataMemberBinding = new Binding(info.PropertyName);

            base.SelectedValueMemberPath = info.ParentValueField;
            base.DisplayMemberPath = info.ParentTextField;

            base.ItemsSource = CreateDataSource(info, dataAccess);

            base.IsComboBoxEditable = true;
        }
        // 表格配置用.xmlg,搜索窗口配置用.xmls
        void contextMenuStrip2_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Xceed.Grid.Cell cell = m_contextMenuManagerColumnCell;
            if (cell == null)
            {
                return;
            }
            GridColumnInfo columnInfo = cell.ParentColumn.Tag as GridColumnInfo;

            if (columnInfo.EnableCopy.HasValue)
            {
                tsmCopyColumn.Visible = columnInfo.EnableCopy.Value;
            }

            GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(m_grid.GridName);

            if (!Authority.AuthorizeByRule(gridInfo.AllowInnerFilter))
            {
                tsmFilter.Visible = false;
            }
            else
            {
                tsmFilter.Checked = m_grid.GetFilterRowVisible();
            }

            tsmGroup.Checked = (m_grid.GetGroupByRow() != null);

            if (m_masterGrid != null &&
                tsmPresetLayout.DropDownItems.Count == 0)
            {
                string[] folders = new string[] { m_masterGrid.GetGridDefaultDataDirectory(), m_masterGrid.GetGridGlobalDataDirectory() };

                foreach (string folder in folders)
                {
                    if (!System.IO.Directory.Exists(folder))
                    {
                        continue;
                    }
                    foreach (string fileName in System.IO.Directory.GetFiles(folder, "*.xmlg"))
                    {
                        ToolStripMenuItem item = new ToolStripMenuItem();
                        item.Text   = System.IO.Path.GetFileName(fileName).Replace(".xmlg", "");
                        item.Tag    = fileName;
                        item.Click += new EventHandler(tsmPresetSubitem_Click);
                        tsmPresetLayout.DropDownItems.Add(item);
                    }
                }

                if (tsmPresetLayout.DropDownItems.Count == 0)
                {
                    tsmPresetLayout.Visible = false;
                }
            }
        }
        /// <summary>
        /// Occured in ColumnManageRow's Cell MouseEnter
        /// Now is for Help Msg show
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void ColumnManageCell_MouseEnter(object sender, EventArgs e)
        {
            m_grid.GridHelper.GridToolTip.RemoveAll();

            Cell           cell = sender as Cell;
            GridColumnInfo info = cell.ParentColumn.Tag as GridColumnInfo;

            if (info != null && !string.IsNullOrEmpty(info.Help))
            {
                m_grid.GridHelper.GridToolTip.SetToolTip(cell.GridControl, info.Help);
            }
        }
Example #16
0
        private GridColumn <TResult> GetColumn(GridColumnInfo visibleColumn)
        {
            var column = _gridModel.Column.First(x =>
                                                 string.Equals(x.SystemName, visibleColumn.Name, StringComparison.OrdinalIgnoreCase));

            if (visibleColumn.Width > 0)
            {
                column.Width = visibleColumn.Width;
            }

            return(column);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetFormatString(GridColumnInfo info)
        {
            if (string.IsNullOrEmpty(info.CellViewerManager))
                return null;
            if (string.IsNullOrEmpty(info.CellViewerManagerParam))
                return null;

            if (info.CellViewerManager == "DateTime")
                return info.CellViewerManagerParam;
            if (info.CellViewerManager == "Numeric")
                return info.CellViewerManagerParam.Replace("+", "N");
            return null;
        }
Example #18
0
        private LabeledDataControl AddDataControl(IDesignerHost h, GridColumnInfo info)
        {
            //IDataControl dc = ControlFactory.GetDataControl(columnInfo);
            //Control control = dc as Control;
            //if (control == null)
            //{
            //    throw new ArgumentException("IDataControl should be System.Windows.Forms.Control!");
            //}
            //m_parentForm.Controls.Add(control);

            Control ic = null;

            foreach (string s in ControlsName.DataControlsTypeName)
            {
                if (s.LastIndexOf(info.DataControlType, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    ic = (Control)h.CreateComponent(Feng.Utils.ReflectionHelper.GetTypeFromName(s));
                    break;
                }
            }

            if (ic == null)
            {
                throw new InvalidOperationException("Invalid ControlType of " + info.DataControlType);
            }
            LabeledDataControl control = (LabeledDataControl)h.CreateComponent(typeof(LabeledDataControl));

            MyLabel lbl = (MyLabel)h.CreateComponent(typeof(MyLabel));

            lbl.Text = info.Caption;

            control.Controls.Add(lbl);
            control.Controls.Add(ic);
            control.Label   = lbl;
            control.Control = ic;

            IDataControl dc = control as IDataControl;

            dc.Caption      = info.Caption;
            dc.PropertyName = info.PropertyName;
            dc.Navigator    = info.Navigator;
            //dc.Index = info.SeqNo;
            dc.Name = info.GridColumnName;

            control.ResetLayout();

            m_parentForm.Controls.Add(control);

            return(control);
        }
Example #19
0
        private string GetViewerText(object value, GridColumnInfo info)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                return(null);
            }

            if (!m_viewers.ContainsKey(info))
            {
                string nvName = GridColumnInfoHelper.GetNameValueMappingName(info, true);
                m_viewers[info] = nvName;
            }

            return(Feng.Utils.NameValueControlHelper.GetMultiString(m_viewers[info], value));
        }
        private LabeledDataControl AddDataControl(IDesignerHost h, GridColumnInfo info)
        {
            //IDataControl dc = ControlFactory.GetDataControl(columnInfo);
            //Control control = dc as Control;
            //if (control == null)
            //{
            //    throw new ArgumentException("IDataControl should be System.Windows.Forms.Control!");
            //}
            //m_parentForm.Controls.Add(control);

            Control ic = null;
            foreach (string s in ControlsName.DataControlsTypeName)
            {
                if (s.LastIndexOf(info.DataControlType, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    ic = (Control)h.CreateComponent(Feng.Utils.ReflectionHelper.GetTypeFromName(s));
                    break;
                }
            }

            if (ic == null)
            {
                throw new InvalidOperationException("Invalid ControlType of " + info.DataControlType);
            }
            LabeledDataControl control = (LabeledDataControl)h.CreateComponent(typeof(LabeledDataControl));

            MyLabel lbl = (MyLabel)h.CreateComponent(typeof(MyLabel));
            lbl.Text = info.Caption;

            control.Controls.Add(lbl);
            control.Controls.Add(ic);
            control.Label = lbl;
            control.Control = ic;

            IDataControl dc = control as IDataControl;
            dc.Caption = info.Caption;
            dc.PropertyName = info.PropertyName;
            dc.Navigator = info.Navigator;
            //dc.Index = info.SeqNo;
            dc.Name = info.GridColumnName;

            control.ResetLayout();

            m_parentForm.Controls.Add(control);

            return control;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="column"></param>
 /// <param name="info"></param>
 public static void CreateCellEditorManager(Xceed.Grid.Column column, GridColumnInfo info, IDisplayManager dm)
 {
     try
     {
         Xceed.Grid.Editors.CellEditorManager editor = ControlFactory.CreateCellEditorManager(dm.Name,
             info.CellEditorManager, info.CellEditorManagerParam, GridColumnInfoHelper.CreateType(info), (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter),
             info.CellViewerManagerParam);
         if (editor != null)
         {
             column.CellEditorManager = editor;
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException("GridColumnInfo of " + info.Name + " is Invalid when CreateCellEditorManager!", ex);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ISearchExpression GetSearchExpression()
        {
            if (this.Value != null && this.Value != this.NullValue && this.Value.ToString() != this.NullText)
            {
                GridColumnInfo info = this.ParentColumn.Tag as GridColumnInfo;
                if (info != null)
                {
                    string searchPropertyName = GetSearchPropertyName(info);

                    ISearchExpression ret = SearchExpression.Like(searchPropertyName, this.Value);

                    object searchValue = this.Value;
                    if (searchValue != null && info.CellViewerManager == "Combo")
                    {
                        string nvName = Feng.Windows.Utils.GridColumnInfoHelper.GetNameValueMappingName(info, true);
                        searchValue = Feng.Utils.NameValueControlHelper.GetMultiValue(nvName, searchValue.ToString());

                        ret = SearchExpression.Or(ret, SearchExpression.Eq(searchPropertyName, searchValue));
                    }

                    return(ret);
                }
            }

            return(null);
            //object value;
            //if (this.IsBeingEdited)
            //{
            //    value = ((FilterEditor)this.CellEditorManager).TemplateControl.SelectedValue;
            //}
            //else
            //{
            //    value = this.Value;
            //}

            //if (m_filterItems.ContainsKey(value.ToString()))
            //{
            //    return m_filterItems[value.ToString()];
            //}
            //else
            //{
            //    // 因为Filter有保存,但是里面的内容有变化,所以可能产生无内容的情况
            //    // this.Value = s_anyText; // 但是还是保存Value
            //    return m_filterItems[s_anyText];
            //}
        }
Example #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="column"></param>
 /// <param name="info"></param>
 public static void CreateCellEditorManager(Xceed.Grid.Column column, GridColumnInfo info, IDisplayManager dm)
 {
     try
     {
         Xceed.Grid.Editors.CellEditorManager editor = ControlFactory.CreateCellEditorManager(dm.Name,
                                                                                              info.CellEditorManager, info.CellEditorManagerParam, GridColumnInfoHelper.CreateType(info), (string)ParamCreatorHelper.TryGetParam(info.CellEditorManagerParamFilter),
                                                                                              info.CellViewerManagerParam);
         if (editor != null)
         {
             column.CellEditorManager = editor;
         }
     }
     catch (Exception ex)
     {
         throw new ArgumentException("GridColumnInfo of " + info.Name + " is Invalid when CreateCellEditorManager!", ex);
     }
 }
        private static GridColumnInfo ReadColumnInfoAndSetWidth(XmlNode node, GridView gridView, float scaleCorrection)
        {
            if (!node.Name.Equals("Column"))
            {
                return(null);
            }
            var fieldName = node.Attributes["FieldName"].Value;
            var col       = gridView.Columns[fieldName];
            var ci        = new GridColumnInfo(fieldName);
            var conv      = new EnumConverter(typeof(ColumnSortOrder));

            for (XmlNode item = node.FirstChild; item != null; item = item.NextSibling)
            {
                if (item.Name.Equals("Width"))
                {
                    ci.Width = Convert.ToInt32(item.InnerText);
                    if (col != null)
                    {
                        col.Width = (int)Math.Round(ci.Width * scaleCorrection, 0);
                    }
                }
                else if (item.Name.Equals("VisibleIndex"))
                {
                    ci.VisibleIndex = Convert.ToInt32(item.InnerText);
                }
                else if (item.Name == "InvisibleIndex")
                {
                    ci.InvisibleIndex = Convert.ToInt32(item.InnerText);
                }
                else if (item.Name.Equals("SortIndex"))
                {
                    ci.SortIndex = Convert.ToInt32(item.InnerText);
                }
                else if (item.Name.Equals("SortOrder"))
                {
                    ci.SortOrder = (ColumnSortOrder)conv.ConvertFromString(item.InnerText);
                }
                else if (item.Name.Equals("GroupIndex"))
                {
                    ci.GroupIndex = int.Parse(item.InnerText);
                }
            }

            return(ci);
        }
Example #25
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);
             }
         }
     }
 }
Example #26
0
        /// <summary>
        /// 保存查找控件信息
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="profile"></param>
        /// <returns></returns>
        public bool LoadLayout(AMS.Profile.IProfile profile)
        {
            string sectionName = "SearchControlContainer." + "." + m_sm.Name + ".Layout";

            string s = profile.GetValue(sectionName, "SearchControls", "");

            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 != 3)
                {
                    continue;
                }

                ISearchControl sc = m_sm.SearchControls[ss[0]];
                if (sc == null)
                {
                    continue;
                }

                GridColumnInfo info = sc.Tag as GridColumnInfo;
                if (info == null || (!string.IsNullOrEmpty(info.SearchControlType) &&
                                     Authority.AuthorizeByRule(info.SearchControlVisible)))
                {
                    sc.Available = Convert.ToBoolean(ss[1]);
                }
                else
                {
                    m_sm.SearchControls[ss[0]].Available = false;
                }

                sc.Index = Convert.ToInt32(ss[2]);
            }
            return(true);
        }
        internal static ValidationCriterion GetValidationCriterion(GridColumnInfo columnInfo, IControlManager cm)
        {
            ValidationCriterion cri1 = null;

            if (!string.IsNullOrEmpty(columnInfo.ValidRegularExpression))
            {
                cri1 = new MyRegularExpressionCriterion(columnInfo.GridColumnName,
                                                        Xceed.Validation.ValidationLevel.Manual,
                                                        new System.Text.RegularExpressions.Regex(columnInfo.ValidRegularExpression, System.Text.RegularExpressions.RegexOptions.Singleline),
                                                        false, true, new Xceed.Validation.CustomValidationMessages());
                cri1.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }
            ValidationCriterion cri2 = null;

            if (!string.IsNullOrEmpty(columnInfo.ValidScript))
            {
                cri2 = new ScriptCriterion(columnInfo.GridColumnName,
                                           Xceed.Validation.ValidationLevel.Manual,
                                           columnInfo.ValidScript, new Dictionary <string, object> {
                    { "cm", cm }
                },
                                           false, true, new Xceed.Validation.CustomValidationMessages());
                cri2.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }

            ValidationCriterion cri3 = null;

            if (Authority.AuthorizeByRule(columnInfo.NotNull))
            {
                cri3 = new RequiredFieldCriterion(columnInfo.GridColumnName,
                                                  Xceed.Validation.ValidationLevel.Manual, GridColumnInfoHelper.CreateType(columnInfo),
                                                  false, true, new Xceed.Validation.CustomValidationMessages());
            }
            var ret = TryAndValidations(TryAndValidations(cri1, cri2), cri3);

            if (ret != null)
            {
                ret.Name = columnInfo.GridColumnName;
            }
            return(ret);
        }
Example #28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static string GetFormatString(GridColumnInfo info)
        {
            if (string.IsNullOrEmpty(info.CellViewerManager))
            {
                return(null);
            }
            if (string.IsNullOrEmpty(info.CellViewerManagerParam))
            {
                return(null);
            }

            if (info.CellViewerManager == "DateTime")
            {
                return(info.CellViewerManagerParam);
            }
            if (info.CellViewerManager == "Numeric")
            {
                return(info.CellViewerManagerParam.Replace("+", "N"));
            }
            return(null);
        }
Example #29
0
        public void ApplyFieldSettings(MyGridView gv, GridColumn grdCol, bool enableAutoFormat)
        {
            //Avoid access to null when field is complex name Like Name!Key or Name!
            var c = gv.Columns[ColumnName] ?? gv.Columns[$"{ColumnName}!Key"];

            if (c == null)
            {
                Debug.WriteLine($"{ColumnName} has been scapped from apply settings");
                return;
            }

            //Save Column information in grid column Tag
            GridColumnInfo info = new GridColumnInfo()
            {
                ColumnLablel = this
            };

            grdCol.Tag = info;
            // gv.Columns.Remove()

            c.Caption = ChooseValueForCurrentLang(MyEnums.UILabelType.FieldCaption);
            c.ToolTip = ChooseValueForCurrentLang(MyEnums.UILabelType.FieldHelp);

            if (!enableAutoFormat)
            {
                return;                   //Exit for non formated grid view
            }
            Size columnSize = TextRenderer.MeasureText("".PadLeft(Width, 'A'), grdCol.AppearanceCell.Font);

            c.Width = IsHidden ? 0: columnSize.Width;
            c.OptionsColumn.ReadOnly  = this.IsDisabled;
            c.OptionsColumn.AllowEdit = !IsDisabled;
            c.OptionsEditForm.Visible = IsDisabled ? DevExpress.Utils.DefaultBoolean.False : DevExpress.Utils.DefaultBoolean.Default;

            c.Visible      = !IsHidden;
            c.VisibleIndex = IsHidden ? -1 : VisibleOrder;
            c.OptionsEditForm.VisibleIndex = IsHidden ? -1 : VisibleOrder;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="column"></param>
        /// <param name="info"></param>
        public static void CreateCellViewerManager(Xceed.Grid.Column column, GridColumnInfo info, IDisplayManager dm)
        {
            try
            {
                Xceed.Grid.Viewers.CellViewerManager viewer = ControlFactory.CreateCellViewerManager(dm.Name,
                    info.CellViewerManager, info.CellViewerManagerParam, GridColumnInfoHelper.CreateType(info));
                if (viewer != null)
                {
                    column.CellViewerManager = viewer;

                    System.Collections.IComparer comp = ControlFactory.CreateColumnDataComparer(
                        info.CellViewerManager, info.CellViewerManagerParam, GridColumnInfoHelper.CreateType(info));
                    if (comp != null)
                    {
                        column.DataComparer = comp;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("GridColumnInfo of " + info.Name + " is Invalid when CreateCellViewerManager!", ex);
            }
        }
Example #31
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="column"></param>
        /// <param name="info"></param>
        public static void CreateCellViewerManager(Xceed.Grid.Column column, GridColumnInfo info, IDisplayManager dm)
        {
            try
            {
                Xceed.Grid.Viewers.CellViewerManager viewer = ControlFactory.CreateCellViewerManager(dm.Name,
                                                                                                     info.CellViewerManager, info.CellViewerManagerParam, GridColumnInfoHelper.CreateType(info));
                if (viewer != null)
                {
                    column.CellViewerManager = viewer;

                    System.Collections.IComparer comp = ControlFactory.CreateColumnDataComparer(
                        info.CellViewerManager, info.CellViewerManagerParam, GridColumnInfoHelper.CreateType(info));
                    if (comp != null)
                    {
                        column.DataComparer = comp;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("GridColumnInfo of " + info.Name + " is Invalid when CreateCellViewerManager!", ex);
            }
        }
        void ContextMenuStripForCell_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            GridInfo gridInfo = ADInfoBll.Instance.GetGridInfo(m_grid.GridName);

            if (!Authority.AuthorizeByRule(gridInfo.AllowInnerMenu) && !Authority.IsDeveloper())
            {
                e.Cancel = true;
                return;
            }
            if (m_grid.GridHelper.ContextCell != null)
            {
                GridColumnInfo columnInfo = m_grid.GridHelper.ContextCell.ParentColumn.Tag as GridColumnInfo;

                if (columnInfo.EnableSelectAll.HasValue)
                {
                    tsmSelectAll.Visible = columnInfo.EnableSelectAll.Value;
                }
                if (columnInfo.EnableCopy.HasValue)
                {
                    m_grid.GridHelper.ContextMenuStripForCell.Items["tsmCopy"].Visible = columnInfo.EnableCopy.Value;
                }
            }
        }
        /// <summary>
        /// 按照Property来默认设置Validation
        /// </summary>
        private void CreatePropertyValidations()
        {
            foreach (Xceed.Grid.Column column in m_grid.Columns)
            {
                if (!column.Visible)
                {
                    continue;
                }

                GridColumnInfo info = column.Tag as GridColumnInfo;
                if (info == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(info.Navigator) && !string.IsNullOrEmpty(info.PropertyName))
                {
                    var attribute = m_cm.DisplayManager.EntityInfo.GetPropertMetadata(info.PropertyName);
                    if (attribute != null)
                    {
                        ValidationCriterion cri1 = null;
                        if (attribute.NotNull)
                        {
                            cri1 = new RequiredFieldCriterion(info.GridColumnName, ValidationLevel.Manual, column.DataType, false, true, null);
                        }

                        ValidationCriterion cri2 = null;
                        if (attribute.Length > 0)
                        {
                            cri2 = new MaxLengthFieldCriterion(info.GridColumnName, ValidationLevel.Manual, attribute.Length, false, true, null);
                        }

                        SetGridValidation(column.FieldName, TryAndValidations(cri1, cri2));
                    }
                }
            }
        }
Example #34
0
        private string GetTitleFormat()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("%ColumnTitle% : %GroupTitle% - 共%DataRowCount%项. ");

            foreach (Xceed.Grid.Column col in this.ParentGrid.Columns)
            {
                GridColumnInfo info = col.Tag as GridColumnInfo;
                if (info != null)
                {
                    if (!string.IsNullOrEmpty(info.StatFunction))
                    {
                        sb.Append(info.Caption + ":");
                        sb.Append("%" + info.StatFunction + ":" + info.GridColumnName + "%");

                        sb.Append(",");
                    }
                    else if (!string.IsNullOrEmpty(info.StatTitle))
                    {
                        sb.Append(info.Caption + ":");
                        sb.Append(info.StatTitle);

                        sb.Append(",");
                    }
                }
            }

            string s = sb.ToString();

            if (sb[sb.Length - 2] == ',')
            {
                sb[sb.Length - 2] = '.';
            }
            return(sb.ToString());
        }
        //void FilterCell_DoubleClick(object sender, EventArgs e)
        //{
        //    TemplateControl_SelectedValueChanged(this.CellEditorManager.TemplateControl, System.EventArgs.Empty);
        //}

        #endregion CONSTRUCTORS


        internal static string GetSearchPropertyName(GridColumnInfo info)
        {
            string searchPropertyName = null;

            if (info != null)
            {
                if (string.IsNullOrEmpty(info.SearchControlFullPropertyName))
                {
                    if (string.IsNullOrEmpty(info.Navigator))
                    {
                        searchPropertyName = info.PropertyName;
                    }
                    else
                    {
                        searchPropertyName = info.Navigator.Replace('.', ':') + ":" + info.PropertyName;
                    }
                }
                else
                {
                    searchPropertyName = info.SearchControlFullPropertyName;
                }
            }
            return(searchPropertyName);
        }
 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);
             }
         }
     }
 }
Example #37
0
        private static void ReloadNvFromDataControl(EventProcessInfo eventProcessInfo, IDisplayManager dm, IDataControl dc, string changedDataControlName)
        {
            string[] columns = eventProcessInfo.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in columns)
            {
                IDataControl idc = dm.DataControls[s];
                if (idc == null)
                {
                    throw new ArgumentException("there is no IDataControl with name " + s + " in eventProcess's SelectedDataValueChanged!");
                }

                //object saveValue = idc.SelectedDataValue;
                GridColumnInfo iInfo = idc.Tag as GridColumnInfo;

                switch (iInfo.CellEditorManager)
                {
                case "Combo":
                case "MultiCombo":
                case "FreeCombo":
                {
                    // NameValueMapping
                    NameValueMapping nv = NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam];

                    // will throw 集合已改变Exception
                    List <string> ls = new List <string>();
                    foreach (KeyValuePair <string, object> kvp in nv.Params)
                    {
                        ls.Add(kvp.Key.Substring(1));
                    }
                    if (!ls.Contains(changedDataControlName))
                    {
                        continue;
                    }

                    object savedValue = idc.SelectedDataValue;
                    idc.SelectedDataValue = null;
                    foreach (string key in ls)
                    {
                        object o = GetDataControlValue(key, dm).Item2;

                        nv.Params["@" + key] = o == null ? System.DBNull.Value : o;
                    }
                    NameValueMappingCollection.Instance.Reload(dm.Name, iInfo.CellEditorManagerParam);
                    nv.ResetParams();

                    idc.SelectedDataValue = savedValue;
                }
                break;

                case "ObjectPicker":
                {
                    object savedValue = idc.SelectedDataValue;
                    idc.SelectedDataValue = null;

                    Feng.Windows.Forms.MyObjectPicker op = (idc as Feng.Windows.Forms.IWindowControl).Control as Feng.Windows.Forms.MyObjectPicker;
                    string exp = (string)ParamCreatorHelper.TryGetParam(iInfo.CellEditorManagerParamFilter);
                    exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                        {
                            return(GetDataControlValue(paramName, dm).Item2);
                        }));
                    op.DropDownControl.DisplayManager.SearchManager.LoadData(SearchExpression.Parse(exp), null);

                    idc.SelectedDataValue = savedValue;
                }
                break;

                default:
                    throw new ArgumentException("EventProcess's SelectedDataValueChanged CellEditorManagerType is not support!");
                }

                //idc.SelectedDataValue = saveValue;
            }
        }
        private string GetViewerText(object value, GridColumnInfo info)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
                return null;

            if (!m_viewers.ContainsKey(info))
            {
                string nvName = GridColumnInfoHelper.GetNameValueMappingName(info, true);
                m_viewers[info] = nvName;
            }

            return Feng.Utils.NameValueControlHelper.GetMultiString(m_viewers[info], value);
        }
Example #39
0
        private static void ReloadNvFromGridCell(EventProcessInfo eventProcessInfo, IDisplayManager dm, Xceed.Grid.Cell cell, string changedDataControlName)
        {
            string[] columns = eventProcessInfo.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in columns)
            {
                Xceed.Grid.Cell iCell = cell.ParentRow.Cells[s];
                if (iCell == null)
                {
                    continue;
                    //throw new ArgumentException("there is no column with name " + s + "!");
                }
                GridColumnInfo iInfo = iCell.ParentColumn.Tag as GridColumnInfo;

                switch (iInfo.CellEditorManager)
                {
                case "Combo":
                case "MultiCombo":
                case "FreeCombo":
                {
                    NameValueMapping nv = NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam];
                    List <string>    ls = new List <string>();
                    foreach (KeyValuePair <string, object> kvp in nv.Params)
                    {
                        ls.Add(kvp.Key.Substring(1));
                    }
                    if (!ls.Contains(changedDataControlName))
                    {
                        continue;
                    }

                    iCell.Value = null;
                    foreach (string key in ls)
                    {
                        object o = GetDataCellValue(key, iCell).Item2;
                        nv.Params["@" + key] = o == null ? System.DBNull.Value : o;
                    }
                    NameValueMappingCollection.Instance.Reload(dm.Name, iInfo.CellEditorManagerParam);

                    // when in grid, we can't use comboBox's DataTableChanged because combobox only created when in edit
                    System.Data.DataView dv = NameValueMappingCollection.Instance.GetDataSource(dm.Name, iInfo.CellEditorManagerParam, iInfo.CellEditorManagerParamFilter);
                    if (dv.Count == 1)
                    {
                        object toValue = dv[0][NameValueMappingCollection.Instance[iInfo.CellEditorManagerParam].ValueMember];
                        if (!Feng.Utils.ReflectionHelper.ObjectEquals(iCell.Value, toValue))
                        {
                            dm.OnSelectedDataValueChanged(new SelectedDataValueChangedEventArgs(s, iCell));
                        }
                        iCell.Value = toValue;
                    }

                    iCell.ReadOnly = (dv.Count == 0);

                    nv.ResetParams();
                }
                break;

                case "ObjectPicker":
                {
                    // Todo: if (!ls.Contains(changedDataControlName))

                    iCell.Value = null;
                    Feng.Windows.Forms.MyObjectPicker op = (iCell.CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl;
                    string exp = (string)ParamCreatorHelper.TryGetParam(iInfo.CellEditorManagerParamFilter);
                    exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                        {
                            return(GetDataCellValue(paramName, iCell).Item2);
                        }));
                    op.DropDownControl.DisplayManager.SearchManager.LoadData(SearchExpression.Parse(exp), null);
                }
                break;
                }
            }
        }
        internal static ValidationCriterion GetValidationCriterion(GridColumnInfo columnInfo, IControlManager cm)
        {
            ValidationCriterion cri1 = null;
            if (!string.IsNullOrEmpty(columnInfo.ValidRegularExpression))
            {
                cri1 = new MyRegularExpressionCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual,
                    new System.Text.RegularExpressions.Regex(columnInfo.ValidRegularExpression, System.Text.RegularExpressions.RegexOptions.Singleline),
                    false, true, new Xceed.Validation.CustomValidationMessages());
                cri1.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }
            ValidationCriterion cri2 = null;
            if (!string.IsNullOrEmpty(columnInfo.ValidScript))
            {
                cri2 = new ScriptCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual,
                    columnInfo.ValidScript, new Dictionary<string, object> { { "cm", cm } },
                    false, true, new Xceed.Validation.CustomValidationMessages());
                cri2.CustomValidationMessages.RegularExpression = columnInfo.ValidErrorMessage;
            }

            ValidationCriterion cri3 = null;
            if (Authority.AuthorizeByRule(columnInfo.NotNull))
            {
                cri3 = new RequiredFieldCriterion(columnInfo.GridColumnName,
                    Xceed.Validation.ValidationLevel.Manual, GridColumnInfoHelper.CreateType(columnInfo),
                    false, true, new Xceed.Validation.CustomValidationMessages());
            }
            var ret = TryAndValidations(TryAndValidations(cri1, cri2), cri3);
            if (ret != null)
            {
                ret.Name = columnInfo.GridColumnName;
            }
            return ret;
        }
 internal static string GetSearchPropertyName(GridColumnInfo info)
 {
     string searchPropertyName = null;
     if (info != null)
     {
         if (string.IsNullOrEmpty(info.SearchControlFullPropertyName))
         {
             if (string.IsNullOrEmpty(info.Navigator))
             {
                 searchPropertyName = info.PropertyName;
             }
             else
             {
                 searchPropertyName = info.Navigator.Replace('.', ':') + ":" + info.PropertyName;
             }
         }
         else
         {
             searchPropertyName = info.SearchControlFullPropertyName;
         }
     }
     return searchPropertyName;
 }
        public const string StartWithLittleEnum = "enum"; // 值用Int,string等序号

        #endregion Fields

        #region Methods

        public static Type CreateType(GridColumnInfo info)
        {
            return Feng.Utils.ReflectionHelper.GetTypeFromName(info.TypeName);
        }
        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;
                }
            }
        }