예제 #1
0
        public static HomePageNodeModel GetHomePageNodeModel(int nodeId)
        {
            HomePageNodeModel model = null;

            XMLDataManage.Manage().homePageNodeDict.TryGetValue(nodeId, out model);
            return(model);
        }
예제 #2
0
        public static GridControlModel GetGridControlModel(string type)
        {
            GridControlModel model = null;

            XMLDataManage.Manage().gridControlDict.TryGetValue(type, out model);
            return(model);
        }
예제 #3
0
 /// <summary>
 ///单例方法
 /// </summary>
 /// <returns></returns>
 private static XMLDataManage Manage()
 {
     if (manage == null)
     {
         manage = new XMLDataManage();
         manage.ReadGridControlXML();
         manage.ReadNodesXML();
     }
     return(manage);
 }
예제 #4
0
        private void ReadNodesXML()
        {
            string xmlFilePath = Application.StartupPath + "//ManageNodes.xml";

            homepageNodes = XMLDataManage.GetTreeNodes(xmlFilePath);
            foreach (HomePageNodeModel model in homepageNodes)
            {
                foreach (HomePageNodeModel child in model.childNodes)
                {
                    this.homePageNodeDict[child.nodeid] = child;
                }
                this.homePageNodeDict[model.nodeid] = model;
            }
        }
예제 #5
0
 /// <summary>
 /// 获取主页树节点的数据
 /// </summary>
 public static List <HomePageNodeModel> GetNodesXML()
 {
     return(XMLDataManage.Manage().homepageNodes);
 }
예제 #6
0
 public static void Init()
 {
     XMLDataManage.Manage();
 }
예제 #7
0
        /// <summary>
        ///  设置GridControl下的GridView
        /// </summary>
        /// <param name="gridView">被设置的GridView</param>
        /// <param name="type">GridControl 的类型</param>
        /// <param name="table">数据源DataTable</param>
        /// <param name="buttonclik">按钮列按钮点击事件</param>
        /// <param name="titleHandler">点击标题列点击事件</param>
        public static void SetGridView(GridView gridView,
                                       GridControlType type,
                                       out DataTable table
                                       , ButtonPressedEventHandler buttonclik,
                                       DevExpress.XtraGrid.Views.Base.CustomColumnSortEventHandler titleHandler)
        {
            GridControlModel model = XMLDataManage.GetGridControlModel(type.ToString());

            table = new DataTable();

            int i = 0;

            foreach (ColumnModel columnModel in model.columns)
            {
                string fieldname = "column_" + i;
                if (columnModel.field != "None")
                {
                    fieldname = columnModel.field;
                }

                GridColumn column = gridView.Columns.AddVisible(fieldname, columnModel.name);
                //表头文本水平位置
                column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                //表头文本自动换行
                column.AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                column.AppearanceHeader.Font = new Font("宋体", 12, GraphicsUnit.Pixel);


                column.OptionsColumn.AllowEdit = false;

                switch (columnModel.type)
                {
                    #region 添加链接
                case ColumnType.C_LineLink:
                {
                    RepositoryItemHyperLinkEdit link = new RepositoryItemHyperLinkEdit();
                    link.LinkColor = Color.Blue;

                    column.ColumnEdit = link;
                    column.OptionsColumn.AllowEdit = true;

                    DataColumn dataColumn = new DataColumn(fieldname);
                    table.Columns.Add(dataColumn);
                    // dataColumn.DataType = typeof(string);
                }


                break;

                    #endregion

                    #region 添加复选框
                case ColumnType.C_Check:            //添加复选框
                {
                    RepositoryItemCheckEdit check = new RepositoryItemCheckEdit();
                    check.NullStyle   = DevExpress.XtraEditors.Controls.StyleIndeterminate.Unchecked;
                    column.ColumnEdit = check;
                    column.OptionsColumn.AllowEdit = true;
                    column.Width = 40;

                    DataColumn dataColumn = new DataColumn(fieldname);
                    table.Columns.Add(dataColumn);
                    dataColumn.DataType = typeof(bool);
                }


                break;
                    #endregion

                    #region 添加按钮
                case ColumnType.C_Button:            //添加按钮
                {
                    //color = "131,157,199"
                    RepositoryItemButtonEdit buttonEdit = new RepositoryItemButtonEdit();
                    buttonEdit.Buttons.Clear();
                    buttonEdit.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
                    //buttonEdit.ButtonsStyle = BorderStyles.NoBorder;
                    //buttonEdit.BorderStyle = BorderStyles.NoBorder;
                    //buttonEdit.AutoHeight = false;
                    if (buttonclik != null)
                    {
                        buttonEdit.ButtonClick += buttonclik;
                    }

                    #region 添加按钮
                    int num   = 0;
                    int width = 8;
                    foreach (string name in columnModel.buttonNames)
                    {
                        char[]   splits = { '(', ')' };
                        string[] names  = name.Split(splits);

                        EditorButton button = new EditorButton();
                        button.Kind = ButtonPredefines.Glyph;

                        //按钮显示
                        button.Visible = true;
                        button.Tag     = fieldname + "_" + num;
                        //62,141,232
                        //if (names.Count() > 1)
                        //{
                        //    char[] color_sp = { ','};
                        //    string[] colors = names[1].Split(color_sp);
                        //    button.Appearance.ForeColor = Color.FromArgb(int.Parse(colors[0]), int.Parse(colors[1]), int.Parse(colors[2]));
                        //}
                        //else
                        //{
                        //    button.Appearance.ForeColor = Color.Blue;

                        //}

                        button.Appearance.ForeColor = Color.FromArgb(62, 141, 232);
                        button.Caption = names[0];
                        width         += 50;

                        //button.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
                        button.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                        buttonEdit.Buttons.Add(button);
                        num++;
                    }
                    #endregion
                    column.ColumnEdit = buttonEdit;
                    column.Width      = width;
                    //column.MinWidth = width;
                    column.OptionsColumn.AllowEdit = true;
                    column.UnboundType             = DevExpress.Data.UnboundColumnType.String;


                    DataColumn dataColumn = new DataColumn(fieldname);
                    table.Columns.Add(dataColumn);
                    //dataColumn.DataType = typeof(RepositoryItemButtonEdit);
                }
                break;

                    #endregion
                default:
                {
                    RepositoryItemMemoEdit edit = new RepositoryItemMemoEdit();
                    column.SortMode   = ColumnSortMode.Custom;
                    column.Width      = 100;   //columnModel.width;
                    column.ColumnEdit = edit;
                    //表头下文本自动换行
                    column.AppearanceCell.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                    //表头下文本书平内容
                    column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    column.AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;

                    DataColumn dataColumn = new DataColumn(fieldname);
                    table.Columns.Add(dataColumn);
                }

                break;
                }
                i++;
            }

            gridView.OptionsSelection.MultiSelect     = true;
            gridView.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect;
            gridView.RowHeight = 25;

            //表头高度
            gridView.ColumnPanelRowHeight = 30;

            //关闭最左侧
            gridView.OptionsView.ShowIndicator = false;
            //关闭表头右键快捷键
            gridView.OptionsMenu.EnableColumnMenu = false;
            if (titleHandler != null)
            {
                gridView.CustomColumnSort += titleHandler;
            }
        }