示例#1
0
        /// <summary>
        /// 初始化数据库连接
        /// </summary>
        private void InitSqlConnection()
        {
            IniStructure m_inis;
            string       content;

            string   fileName = Path.Combine(Application.StartupPath, "GameDesingerTools_Public.ini");
            FileInfo fi       = new FileInfo(fileName);

            if (fi.Exists)
            {
                content = FileFolderHelper.FileToString(fileName);
                SymmetricCode sm = new SymmetricCode();
                content = sm.Decrypto(content);

                m_inis = IniStructure.ReadIniWithContent(content);
                string connectString = m_inis.GetValue("General", "ConnString");
                Conn = new SqlConnection(connectString);
            }
            else
            {
                MessageBox.Show("读取配置信息失败,请确认GameDesingerTools_Public.ini文件在程序目录中!", "初始化",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            fileName = Path.Combine(Application.StartupPath, "GameDesingerTools.ini");
            fi       = new FileInfo(fileName);
            if (fi.Exists)
            {
                content = FileFolderHelper.FileToString(fileName);
                m_inis  = IniStructure.ReadIniWithContent(content);
                rootDir = m_inis.GetValue("General", "RootDir");
            }
        }
示例#2
0
        /// <summary>
        /// 初始化npc阵营数据表
        /// </summary>
        private void InitNpcOrderTable()
        {
            string   filePath = string.Format("{0}\\settings\\NpcOrder\\OrderList.tab", Helper.RootDir);
            FileInfo fi       = new FileInfo(filePath);

            if (fi.Exists)
            {
                string   content   = FileFolderHelper.FileToString(filePath);
                string[] lines     = content.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                bool     firstLine = true;

                foreach (string s in lines)
                {
                    if (firstLine)
                    {
                        firstLine = false;
                    }
                    else
                    {
                        string   line          = s.TrimEnd(new char[] { '\r', ' ' });
                        string[] data          = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        string   orderID       = data[0];
                        string   orderName     = data[3];
                        string   orderFile     = data[1];
                        string   orderFilePath = string.Format("{0}\\settings\\NpcOrder\\{1}", Helper.RootDir, orderFile);

                        int      orderCount    = 0;
                        FileInfo orderFileInfo = new FileInfo(orderFilePath);

                        if (orderFileInfo.Exists)
                        {
                            content = FileFolderHelper.FileToString(orderFilePath);
                            string[] orderLines = content.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                            orderCount = orderLines.Length - 1;
                            if (orderCount < 0)
                            {
                                orderCount = 0;
                            }

                            DataRow dataRow = npcOrderTable.NewRow();
                            dataRow["ID"]    = orderID;
                            dataRow["Name"]  = orderName;
                            dataRow["Count"] = orderCount;
                            npcOrderTable.Rows.Add(dataRow);
                        }
                    }
                }
            }
        }
示例#3
0
        private void UpdateHistory(string filename)
        {
            string strfile    = Path.Combine(Application.StartupPath, "DesignerSceneEditor.history");
            string strHistory = FileFolderHelper.FileToString(strfile);

            string[] historys = strHistory.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            if (historys.Length < 4)
            {
                bool bHistoryContainsThisDoc = false;
                foreach (string history in historys)
                {
                    if (history == filename)
                    {
                        bHistoryContainsThisDoc = true;
                        break;
                    }
                }

                if (!bHistoryContainsThisDoc)
                {
                    string strContent = strHistory + (historys.Length == 0 ? string.Empty : "\r\n") + filename;
                    FileFolderHelper.StringToFile(strContent, strfile);
                }
            }
            else
            {
                bool bHistoryContainsThisDoc = false;
                foreach (string history in historys)
                {
                    if (history == filename)
                    {
                        bHistoryContainsThisDoc = true;
                        break;
                    }
                }

                if (!bHistoryContainsThisDoc)
                {
                    string[] newhistorys = new string[] { historys[1], historys[2], historys[3], filename };
                    string   content     = newhistorys[0] + "\r\n" + newhistorys[1] + "\r\n" + newhistorys[2] + "\r\n" + newhistorys[3];
                    FileFolderHelper.StringToFile(content, strfile);
                }
            }
        }
示例#4
0
        private void LoadHistory()
        {
            string strfile    = Path.Combine(Application.StartupPath, "DesignerSceneEditor.history");
            string strHistory = FileFolderHelper.FileToString(strfile);

            if (strHistory.Length == 0)
            {
                return;
            }

            string[] historys = strHistory.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string history in historys)
            {
                DevComponents.DotNetBar.ButtonItem newitem = new DevComponents.DotNetBar.ButtonItem();
                newitem.ImagePaddingHorizontal = 8;
                newitem.Name   = history;
                newitem.Text   = history;
                newitem.Click += new System.EventHandler(this.historyItem_Click);

                this.buttonOpen.SubItems.Add(newitem);
            }
        }