Example #1
0
        /// <summary>
        /// 生成MOD文件
        /// </summary>
        /// <param name="tbName">窗口名字</param>
        private void BuildModsFiles(string tbName)
        {
            MyConfig item = DataHelper.FormConfig[tbName];

            string haveColumn = "YES";

            if (string.IsNullOrEmpty(item.HaveColumn) || item.HaveColumn.ToUpper() == "NO")
            {
                haveColumn = "NO";
            }
            switch (item.DtType)
            {
            case "1":
                StructureData1(item.MainDtName, item.DetailDtName, item.TxtName, haveColumn);
                if (item.IsCache == "1")
                {
                    _tl.BuildDataSetXml(item.MainDtName);
                    _tl.BuildDataSetXml(item.DetailDtName);
                }
                break;

            case "2":
                StructureData(item.MainDtName, item.TxtName, haveColumn);
                if (item.IsCache == "1")
                {
                    _tl.BuildDataSetXml(item.MainDtName);
                }
                break;

            case "3":
                StructureData3(item.MainDtName, item.TxtName, haveColumn);
                if (item.IsCache == "1")
                {
                    _tl.BuildDataSetXml(item.MainDtName);
                }
                break;
            }
        }
Example #2
0
        private void Almighty_Load(object sender, EventArgs e)
        {
            try
            {
                FileHelper.LoadTable("RewardData");

                BulidSn(DataHelper.XkfyData.Tables[_tbName]);
                dg1.DataSource = DataHelper.XkfyData.Tables[_tbName].DefaultView;

                for (int i = 0; i < dg1.Columns.Count; i++)
                {
                    dg1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                }
                //根据是否有定制窗体,显示复制新增
                if (DataHelper.FormConfig.ContainsKey(_configKey))
                {
                    MyConfig myConfig = DataHelper.FormConfig[_configKey];
                    _editForm = myConfig.EditFormName;
                    if (_configKey == Const.DevelopQuestData)
                    {
                        btnDebug.Visible = true;
                    }
                    else if (_configKey == Const.TalkManager || _configKey == Const.MapTalkManager)
                    {
                        btnEditTalkGroup.Visible = true;
                    }
                }

                //生成查询条件
                IList <TableExplain> list = DataHelper.ToolColumnConfig[_configKey];
                bool isSelColumn          = list.Where(s => s.IsSelColumn == 1).ToList().Count != 0;

                for (int i = 0; i < list.Count; i++)
                {
                    string columnName = StringUtils.FormatToolColumn(list[i].Column);
                    _dictTableExplain.Add(columnName, list[i]);
                    if (list[i].IsSelColumn == 1)
                    {
                        ControlHelper.BuidQueryControl(gbQueryCon, list[i], toolTip1);
                    }

                    //如果没设置查询列 默认前3行为查询列
                    if (!isSelColumn)
                    {
                        if (i < 4)
                        {
                            ControlHelper.BuidQueryControl(gbQueryCon, list[i], toolTip1);
                        }
                    }

                    if (string.IsNullOrEmpty(list[i].Text))
                    {
                        continue;
                    }

                    var dataGridViewColumn = dg1.Columns[columnName];
                    if (dataGridViewColumn != null)
                    {
                        dataGridViewColumn.HeaderText = list[i].Text;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void btnBuild_Click(object sender, EventArgs e)
        {
            string          path     = Application.StartupPath + "\\工具配置文件\\TableConfig.xml";
            List <MyConfig> menuList = XmlHelper.XmlDeserializeFromFile <List <MyConfig> >(path, Encoding.UTF8);

            int rowIndex = 1;

            foreach (DataGridViewRow row in dg1.Rows)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)row.Cells["chkSel"];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag)
                {
                    string dlcFileName = row.Cells["DlcFileName"].Value.ToString();
                    string dlcFilePath = row.Cells["DlcFilePath"].Value.ToString();
                    string tbName      = dlcFileName.Substring(0, dlcFileName.IndexOf("."));

                    string configFileName    = tbName + ".xml";
                    string configRawFileName = tbName.Substring(4, tbName.Length - 4) + ".xml";
                    string configFilepath    = Path.Combine(Application.StartupPath + "\\工具配置文件\\TableExplain", configFileName);
                    string configRawFilepath = Path.Combine(Application.StartupPath + "\\工具配置文件\\TableExplain", configRawFileName);

                    if (!File.Exists(configRawFilepath))
                    {
                        continue;
                    }


                    MyConfig mc = new MyConfig();
                    mc.TxtName          = dlcFileName;
                    mc.Classify         = "Dlc";
                    mc.Notes            = dlcFileName;
                    mc.HaveColumn       = "NO";
                    mc.IsCache          = "0";
                    mc.DtType           = "3";
                    mc.BasicCritical    = "";
                    mc.EffectCritical   = "";
                    mc.HaveHelperColumn = "";
                    mc.DetailDtName     = "";
                    mc.MainDtName       = tbName;
                    menuList.Add(mc);

                    List <TableExplain> configFileList = new List <TableExplain>();


                    int index = 0;
                    using (StreamReader sr = new StreamReader(dlcFilePath, Encoding.Default))
                    {
                        string names = string.Empty;
                        string ids   = string.Empty;
                        while (index < 2)
                        {
                            if (index == 0)
                            {
                                names = sr.ReadLine(); //读取一行数据
                            }
                            else
                            {
                                ids = sr.ReadLine();
                            }
                            index++;
                        }
                        string[] rowIds   = ids.Split('\t');
                        string[] rowNames = names.Split('\t');

                        List <TableExplain> teList = XmlHelper.XmlDeserializeFromFile <List <TableExplain> >(configRawFilepath, Encoding.UTF8);
                        for (int i = 0; i < rowIds.Length; i++)
                        {
                            TableExplain te = new TableExplain();
                            if (i < 3)
                            {
                                te.IsSelect = "1";
                            }
                            te.Column      = teList[i].Column;
                            te.Explain     = teList[i].Explain;
                            te.Text        = rowNames[i];
                            te.ToolsColumn = teList[i].ToolsColumn;
                            configFileList.Add(te);
                            rowIndex++;
                        }
                        rowIndex = rowIndex + 10;
                    }


                    XmlHelper.XmlSerializeToFile(configFileList, configFilepath, Encoding.UTF8);
                }
            }

            XmlHelper.XmlSerializeToFile(menuList, path, Encoding.UTF8);
            MessageBox.Show("修改成功!");
        }
Example #4
0
        private void Almighty_Load(object sender, EventArgs e)
        {
            if (DateTime.Now.Second % 2 == 0)
            {
                lblTag.Text = "点击序号,选中整行后,在不使用查询的情况下,可以使用方向键↑ ↓调整数据的顺序";
            }
            else
            {
                lblTag.Text = "如果当前表格不小心修改错了,可以通过点击顶部菜单【重新加载】按钮重新加载文件!";
            }

            if (DataHelper.ReadError.ToString() != "")
            {
                timer1.Start();
                gbError.Visible = true;
                txtError.Text   = DataHelper.ReadError.ToString();
            }

            dg1.AllowUserToAddRows = false;
            try
            {
                string    path = string.Empty;
                DataTable dt;

                string haveHelperColumn = string.Empty;
                if (DataHelper.FormConfig.ContainsKey(_tbName))
                {
                    _myConfig = DataHelper.FormConfig[_tbName];
                    _editForm = _myConfig.EditFormName;

                    if (_editForm != "" && _editForm != "0")
                    {
                        btnAdd.Visible     = true;
                        btnCopyAdd.Visible = true;
                    }
                }

                //绑定数据源
                if (_fileType == "other")
                {
                    BulidSn(DataHelper.XkfyData.Tables[_tbName]);
                    dt = DataHelper.XkfyData.Tables[_tbName];
                }
                else
                {
                    BulidSn(DataHelper.MapData.Tables[_tbName]);
                    dt = DataHelper.MapData.Tables[_tbName];
                }
                dg1.DataSource = dt.DefaultView;


                Dictionary <string, TableExplain> dlc = new Dictionary <string, TableExplain>();
                if (_fileType == "MapInfo")
                {
                    path = Path.Combine(ToolsHelper.ExplainPath, "MapInfo.xml");
                }
                else if (_fileType == "NpcProduct")
                {
                    path = Path.Combine(ToolsHelper.ExplainPath, "NpcProduct.xml");
                }
                else
                {
                    path = Path.Combine(ToolsHelper.ExplainPath, _tbName + ".xml");
                }

                if (File.Exists(path))
                {
                    int top         = 10;
                    int left        = 7;
                    int width       = 122;
                    int columnIndex = 0;

                    List <TableExplain> list = DataHelper.ReadXmlToList <TableExplain>(path);
                    foreach (TableExplain item in list)
                    {
                        if (!string.IsNullOrEmpty(item.Column))
                        {
                            dlc.Add(item.Column.Replace("#", "@"), item);
                        }
                        else
                        {
                            dlc.Add(item.ToolsColumn, item);
                        }
                        #region 生成查询控件
                        if (!string.IsNullOrEmpty(item.IsSelect) && item.IsSelect == "1")
                        {
                            if (columnIndex == 3)
                            {
                                top  = 40;
                                left = 7;
                            }
                            Label tips = new Label();
                            tips.Top   = top + 4;
                            tips.Left  = left;
                            tips.Width = width;
                            left      += tips.Width;

                            TextBox tb = new TextBox();
                            if (!string.IsNullOrEmpty(item.Column))
                            {
                                tb.Tag = item.Column;
                            }
                            else
                            {
                                tb.Tag = item.ToolsColumn;
                            }

                            tb.Top   = top;
                            tb.Left  = left;
                            tb.Width = width;

                            left += tb.Width + 15;
                            gbQueryCon.Controls.Add(tips);
                            gbQueryCon.Controls.Add(tb);


                            //把lable文字修改为中文显示
                            if (!string.IsNullOrEmpty(item.Text))
                            {
                                tips.Text = item.Text;
                            }
                            else if (!string.IsNullOrEmpty(item.Column))
                            {
                                tips.Text = item.Column;
                            }
                            else
                            {
                                tips.Text = item.ToolsColumn;
                            }
                            toolTip.SetToolTip(tips, item.Explain);
                            columnIndex++;
                        }
                        #endregion
                    }

                    CheckBox ck = new CheckBox();
                    ck.Tag   = "rowState";
                    ck.Top   = top;
                    ck.Left  = left;
                    ck.Width = width;
                    ck.Text  = "只显示我修改的";
                    gbQueryCon.Controls.Add(ck);
                }
                else
                {
                    MessageBox.Show("缺少列配置文件,文件路径" + path);
                }


                foreach (DataGridViewColumn dgvCol in dg1.Columns)
                {
                    if (dlc.ContainsKey(dgvCol.Name) && dlc[dgvCol.Name] != null)
                    {
                        TableExplain te = dlc[dgvCol.Name];
                        if (!string.IsNullOrEmpty(te.Text))
                        {
                            dgvCol.HeaderText = te.Text;
                        }
                        else if (!string.IsNullOrEmpty(te.Column))
                        {
                            dgvCol.HeaderText = te.Column;
                        }
                        else
                        {
                            dgvCol.HeaderText = te.ToolsColumn;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }