示例#1
0
        private static string CreateData(IniStructure IniData, string comment)
        {               //Iterates through all categories and keys and appends all data to Data
            int CategoryCount = IniData.GetCategories().Length;

            int[]  KeyCountPerCategory = new int[CategoryCount];
            string Data = comment;

            string[] temp = new string[2];             // will contain key-value pair

            for (int i = 0; i < CategoryCount; i++)    // Gets keycount per category
            {
                string CategoryName = IniData.GetCategories()[i];
                KeyCountPerCategory[i] = IniData.GetKeys(CategoryName).Length;
            }

            for (int catcounter = 0; catcounter < CategoryCount; catcounter++)
            {
                Data += "\r\n[" + IniData.GetCategoryName(catcounter) + "]\r\n";
                // writes [Category] to Data
                for (int keycounter = 0; keycounter < KeyCountPerCategory[catcounter]; keycounter++)
                {
                    temp[0] = IniData.GetKeyName(catcounter, keycounter);
                    temp[1] = IniData.GetValue(catcounter, keycounter);
                    Data   += temp[0] + "=" + temp[1] + "\r\n";
                    // writes the key-value pair to Data
                }
            }
            return(Data);
        }
示例#2
0
文件: IniHandler.cs 项目: viticm/pap2
		private static string CreateData(IniStructure IniData, string comment)
		{	//Iterates through all categories and keys and appends all data to Data
			int CategoryCount = IniData.GetCategories().Length;
			int[] KeyCountPerCategory = new int[CategoryCount];
			string Data = comment;
			string[] temp = new string[2]; // will contain key-value pair
			
			for (int i = 0; i < CategoryCount; i++) // Gets keycount per category
			{
				string CategoryName = IniData.GetCategories()[i];
				KeyCountPerCategory[i] = IniData.GetKeys(CategoryName).Length;
			}

			for (int catcounter = 0; catcounter < CategoryCount; catcounter++)
			{
				Data += "\r\n[" + IniData.GetCategoryName(catcounter) + "]\r\n"; 
				// writes [Category] to Data
				for (int keycounter = 0; keycounter < KeyCountPerCategory[catcounter]; keycounter++)
				{
					temp[0] = IniData.GetKeyName(catcounter, keycounter);
					temp[1] = IniData.GetValue(catcounter, keycounter);
					Data += temp[0] + "=" + temp[1] + "\r\n";
					// writes the key-value pair to Data
				}
			}
			return Data;
		}
示例#3
0
        private static bool InitSettings()
        {
            m_strrootdir   = string.Empty;
            m_strconnstr   = string.Empty;
            m_strEngineDir = string.Empty;

            StringBuilder sb   = new StringBuilder(255);
            bool          bRet = false;

            while (m_strrootdir.Length <= 0)
            {
                FileFolderHelper.ReadIniFile("General", "RootDir", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strrootdir = sb.ToString();
                m_strrootdir = m_strrootdir.Trim();
                if (m_strrootdir.Length <= 0)
                {
                    MessageBox.Show("设置文件根目录不能为空,请设置您的本地设置文件存在的根目录。如:E:\\work\\Sword3\\sword3DesignBase\\commit_swap)", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            if (EnableRemoting)
            {
                while (Database == string.Empty)
                {
                    FileFolderHelper.ReadIniFile("Remote", "DataBase", "", sb, 255, Application.StartupPath + "/GameDesingerTools_remote.ini");
                    Database = sb.ToString().Trim();
                    if (Database == string.Empty && Database.Length == 0)
                    {
                        AppOptionsForm frm = new AppOptionsForm();
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            Database = frm.DataBase;
                            frm.Update();
                            break;
                        }
                        else
                        {
                            bRet = false;
                            MessageBox.Show("连接数据库名不能为空,请设置数据库。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }

                bRet = true;
            }


            m_strconnstr = Database;

            while (m_strconnstr.Length <= 0 && bRet)
            {
//                 // crypt
//                 string myString = @"[General]
// ConnString=Server = jx3web; DataBase = s3design_debug; Uid = s3design; Password = davidbowie;
// ";
//
//                 Misc.SymmetricMethod _sm = new Misc.SymmetricMethod();
//                 string c = _sm.Encrypto(myString);
//                 c = _sm.Decrypto(c);

                bRet = false;



                if (!System.IO.File.Exists(Application.StartupPath + "\\GameDesingerTools_Public.ini"))
                {
                    MessageBox.Show("GameDesingerTools_Public.ini 不存在,程序不能启动!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }


                string filename         = Application.StartupPath + "/GameDesingerTools_Public.ini";
                string content          = FileFolderHelper.FileToString(filename);
                Misc.SymmetricMethod sm = new Misc.SymmetricMethod();
                content = sm.Decrypto(content);
                Misc.IniStructure m_inis = new Misc.IniStructure();
                m_inis       = Misc.IniStructure.ReadIniWithContent(content);
                m_strconnstr = m_inis.GetValue("General", "ConnString");



                if (m_bLoadBackupDB) // 强制读取策划备份库的信息
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design-1-0-8-1380-new; Uid = s3design; Password = davidbowie;";
                }
                if (m_bSkillBranch) // 技能系统组分支2009-5-11
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design_skill_branch; Uid = s3design; Password = davidbowie;";
                }

                if (m_strconnstr.Length <= 0)
                {
                    MessageBox.Show("连接字符串不能为空,请设置数据库连接。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            while (m_strEngineDir.Length <= 0 && bRet)
            {
                bRet = false;
                FileFolderHelper.ReadIniFile("General", "3DEnginePath", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strEngineDir = sb.ToString();
                m_strEngineDir = m_strEngineDir.Trim();
                if (m_strEngineDir.Length <= 0)
                {
                    MessageBox.Show("3DEngine 路径设置不能为空,请设置 KG3DEngine.DLL 所在的路径", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            if (bRet)
            {
                MainForm.InitConn();
                m_rightmgr.Init();
            }

            // 读3d时钟参数
            FileFolderHelper.ReadIniFile("Advance", "tmrRenderInterval", "50", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
            int iInterval = 50;

            if (int.TryParse(sb.ToString(), out iInterval))
            {
                Program.m_3d_tmrRender = iInterval;
            }

            return(bRet);
        }
示例#4
0
文件: Program.cs 项目: viticm/pap2
        private static bool InitSettings()
        {
            m_strrootdir = string.Empty;
            m_strconnstr = string.Empty;
            m_strEngineDir = string.Empty;
            
            StringBuilder sb = new StringBuilder(255);
            bool bRet = false;
            while (m_strrootdir.Length <= 0)
            {
                FileFolderHelper.ReadIniFile("General", "RootDir", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strrootdir = sb.ToString();
                m_strrootdir = m_strrootdir.Trim();
                if (m_strrootdir.Length <= 0)
                {
                    MessageBox.Show("设置文件根目录不能为空,请设置您的本地设置文件存在的根目录。如:E:\\work\\Sword3\\sword3DesignBase\\commit_swap)", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                        fm.Update();
                    else
                        break;
                }
                bRet = true;
            }

            if (EnableRemoting)
            {
                while (Database == string.Empty)
                {
                    FileFolderHelper.ReadIniFile("Remote", "DataBase", "", sb, 255, Application.StartupPath + "/GameDesingerTools_remote.ini");
                    Database = sb.ToString().Trim();
                    if (Database == string.Empty && Database.Length == 0)
                    {
                        AppOptionsForm frm = new AppOptionsForm();
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            Database = frm.DataBase;
                            frm.Update();
                            break;
                        }
                        else
                        {
                            bRet = false;
                            MessageBox.Show("连接数据库名不能为空,请设置数据库。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }

                bRet = true;
            }


            m_strconnstr = Database;

            while (m_strconnstr.Length <= 0 && bRet)
            {
//                 // crypt 
//                 string myString = @"[General]
// ConnString=Server = jx3web; DataBase = s3design_debug; Uid = s3design; Password = davidbowie;
// ";
// 
//                 Misc.SymmetricMethod _sm = new Misc.SymmetricMethod();
//                 string c = _sm.Encrypto(myString);
//                 c = _sm.Decrypto(c);

                bRet = false;

               

                if (!System.IO.File.Exists(Application.StartupPath + "\\GameDesingerTools_Public.ini"))
                {
                    MessageBox.Show("GameDesingerTools_Public.ini 不存在,程序不能启动!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }

                
                string filename = Application.StartupPath + "/GameDesingerTools_Public.ini";
                string content = FileFolderHelper.FileToString(filename);
                Misc.SymmetricMethod sm = new Misc.SymmetricMethod();
                content = sm.Decrypto(content);
                Misc.IniStructure m_inis = new Misc.IniStructure();
                m_inis = Misc.IniStructure.ReadIniWithContent(content);
                m_strconnstr = m_inis.GetValue("General", "ConnString");
                


               



                if (m_bLoadBackupDB) // 强制读取策划备份库的信息
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design-1-0-8-1380-new; Uid = s3design; Password = davidbowie;";
                }
                if (m_bSkillBranch) // 技能系统组分支2009-5-11
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design_skill_branch; Uid = s3design; Password = davidbowie;";
                }
                
                if (m_strconnstr.Length <= 0)
                {
                    MessageBox.Show("连接字符串不能为空,请设置数据库连接。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                        fm.Update();
                    else
                        break;
                }
                bRet = true;
            }

            while (m_strEngineDir.Length <= 0 && bRet)
            {
                bRet = false;
                FileFolderHelper.ReadIniFile("General", "3DEnginePath", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strEngineDir = sb.ToString();
                m_strEngineDir = m_strEngineDir.Trim();
                if (m_strEngineDir.Length <= 0)
                {
                    MessageBox.Show("3DEngine 路径设置不能为空,请设置 KG3DEngine.DLL 所在的路径", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                        fm.Update();
                    else
                        break;
                }
                bRet = true;
            }

            if (bRet)
            {
                MainForm.InitConn();
                m_rightmgr.Init();
            }

            // 读3d时钟参数
            FileFolderHelper.ReadIniFile("Advance", "tmrRenderInterval", "50", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
            int iInterval = 50;
            if (int.TryParse(sb.ToString(), out iInterval))
                Program.m_3d_tmrRender = iInterval;

            return bRet;
        }