private void SaveAsChinaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.saveFileDialog.FileName = m_strFileName;
            if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

                STBData.SaveSTBDataChina(ref m_STBData, this.saveFileDialog.FileName);
            }
        }
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

            if (m_SaveLanguage == SaveLanguage.Korea)
            {
                STBData.SaveSTBDataKorea(ref m_STBData, m_STBData.FileName);
            }
            else if (m_SaveLanguage == SaveLanguage.China)
            {
                STBData.SaveSTBDataChina(ref m_STBData, m_STBData.FileName);
            }
        }
        private void LoadKoreaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.dataGridView.SuspendLayout();

                STBData.LoadSTBDataKorea(ref m_STBData, this.openFileDialog.FileName);
                m_strFileName = this.openFileDialog.FileName;

                this.dataGridView.DataSource = m_STBData.DataTable;

                for (int l_iIndex = 0; l_iIndex < m_STBData.ColumnsWidth.Length; l_iIndex++)
                {
                    this.dataGridView.Columns[l_iIndex].Width = m_STBData.ColumnsWidth[l_iIndex];
                }

                for (int l_iIndex = 0; l_iIndex < m_STBData.ColumnsHeaderText.Length; l_iIndex++)
                {
                    this.dataGridView.Columns[l_iIndex].HeaderText = m_STBData.ColumnsHeaderText[l_iIndex];
                }

                this.dataGridView.Columns[0].ReadOnly = true;

                string l_strStructName = m_STBData.StructName == string.Empty ? "NULL" : m_STBData.StructName;
                this.Text = "Demo R.O.S.E.STB.Editor.Form" + "( " + m_strFileName + " )" + " Name = " + l_strStructName + " ";

                this.dataGridView.AllowUserToAddRows    = false;
                this.dataGridView.AllowUserToDeleteRows = false;

                this.dataGridView.ResumeLayout();

                this.DelToolStripMenuItem.Enabled       = true;
                this.AddToolStripMenuItem.Enabled       = true;
                this.CloseToolStripMenuItem.Enabled     = true;
                this.SaveToolStripMenuItem.Enabled      = true;
                this.SaveAs949ToolStripMenuItem.Enabled = true;
                this.SaveAs936ToolStripMenuItem.Enabled = true;
                this.ColumnToolStripMenuItem.Enabled    = true;
                this.StructToolStripMenuItem.Enabled    = true;

                m_SaveLanguage = SaveLanguage.Korea;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 简体中文代码页(936)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool LoadSTBDataChina( ref STBData stbData, string strFileName )
        {
            try
            {
                FileStream l_FileStream = File.OpenRead( strFileName );
                BinaryReader l_FileReader = new BinaryReader( l_FileStream, Encoding.ASCII );

                string l_strFieldInfo;
                ushort l_iFieldLength;

                stbData.m_strFileName = strFileName;
                stbData.m_strFileType = new string( l_FileReader.ReadChars( 4 ) );
                stbData.m_iDataOffset = l_FileReader.ReadUInt32();
                stbData.m_iRowCount = l_FileReader.ReadUInt32();
                stbData.m_iFieldCount = l_FileReader.ReadUInt32();
                stbData.m_iUnknown = l_FileReader.ReadUInt32();

                stbData.m_ColumnsWidth = new ushort[stbData.m_iFieldCount + 1]; // 因为加了一个索引字段, 所以需要加一, 但它是不保存的
                for ( int iIndex = 0; iIndex < stbData.m_ColumnsWidth.Length; iIndex++ )
                    stbData.m_ColumnsWidth[iIndex] = l_FileReader.ReadUInt16();

                stbData.m_ColumnsHeaderText = new string[stbData.m_ColumnsWidth.Length];    // 因为加了一个索引字段, 所以需要加一, 但它是不保存的
                stbData.m_ColumnsHeaderText[0] = "#";   // 一个索引标题文字, 但它是不保存的
                for ( int iIndex = 1; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++ )
                {
                    l_iFieldLength = l_FileReader.ReadUInt16();
                    l_strFieldInfo = Encoding.GetEncoding( 936 ).GetString( l_FileReader.ReadBytes( l_iFieldLength ) );
                    stbData.m_ColumnsHeaderText[iIndex] = l_strFieldInfo;
                }

                stbData.m_iStructNameLength = l_FileReader.ReadUInt16();
                stbData.m_strStructName = Encoding.GetEncoding( 936 ).GetString( l_FileReader.ReadBytes( (int)stbData.m_iStructNameLength ) );

                stbData.m_DataTable = new DataTable();
                for ( int iIndex = 0; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++ )
                    stbData.m_DataTable.Columns.Add( string.Empty );

                stbData.m_STBFieldComment = new STBFieldComment[stbData.m_iRowCount - 1];
                for ( int iIndex = 0; iIndex < stbData.m_STBFieldComment.Length; iIndex++ )
                    stbData.m_DataTable.Rows.Add( stbData.m_DataTable.NewRow() );

                for ( int iIndex = 0; iIndex < stbData.m_STBFieldComment.Length; iIndex++ )
                {
                    stbData.m_STBFieldComment[iIndex].m_strFieldCommentLength = l_FileReader.ReadUInt16();
                    stbData.m_STBFieldComment[iIndex].FieldComment = Encoding.GetEncoding( 949 ).GetString( l_FileReader.ReadBytes( stbData.m_STBFieldComment[iIndex].m_strFieldCommentLength ) );
                    stbData.m_DataTable.Rows[iIndex][1] = stbData.m_STBFieldComment[iIndex].FieldComment;
                }

                stbData.m_STBFieldStringArray = new STBFieldStringArray[stbData.m_iRowCount - 1];
                for ( int iIndex = 0; iIndex < stbData.m_STBFieldStringArray.Length; iIndex++ )
                {
                    stbData.m_STBFieldStringArray[iIndex].FieldString = new STBFieldString[stbData.m_iFieldCount - 1];

                    stbData.m_DataTable.Rows[iIndex][0] = iIndex.ToString();
                    for ( int iIndex2 = 0; iIndex2 < stbData.m_STBFieldStringArray[iIndex].FieldString.Length; iIndex2++ )
                    {
                        stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].m_strFieldStringLength = l_FileReader.ReadUInt16();
                        stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].FieldString = Encoding.GetEncoding( 949 ).GetString( l_FileReader.ReadBytes( stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].m_strFieldStringLength ) );
                        stbData.m_DataTable.Rows[iIndex][iIndex2 + 2] = stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].FieldString;
                    }
                }

                l_FileReader.Close();
            }
            catch
            {
                stbData.Clear();
                return false;
            }

            return true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 简体中文代码页(936)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool SaveSTBDataChina( ref STBData stbData, string strFileName )
        {
            string l_strFieldInfo;
            byte[] l_byteArray;

            try
            {

                FileStream l_FileStream = File.Open( strFileName, FileMode.Create );
                BinaryWriter l_FileWriter = new BinaryWriter( l_FileStream, Encoding.ASCII );

                l_byteArray = Encoding.GetEncoding( 936 ).GetBytes( stbData.m_strFileType );
                l_FileWriter.Write( l_byteArray, 0, l_byteArray.Length );

                l_FileWriter.Seek( 4, SeekOrigin.Current );
                l_FileWriter.Write( stbData.m_DataTable.Rows.Count + 1 );
                l_FileWriter.Write( stbData.m_DataTable.Columns.Count - 1 );

                l_FileWriter.Write( stbData.m_iUnknown );

                for ( int iIndex = 0; iIndex < stbData.m_ColumnsWidth.Length; iIndex++ )
                    l_FileWriter.Write( stbData.m_ColumnsWidth[iIndex] );

                for ( int iIndex = 1; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++ )
                {
                    l_strFieldInfo = stbData.m_ColumnsHeaderText[iIndex];
                    l_byteArray = Encoding.GetEncoding( 936 ).GetBytes( l_strFieldInfo );
                    l_FileWriter.Write( (ushort)l_byteArray.Length );
                    l_FileWriter.Write( l_byteArray, 0, l_byteArray.Length );
                }

                l_byteArray = Encoding.GetEncoding( 936 ).GetBytes( stbData.m_strStructName );
                l_FileWriter.Write( (ushort)l_byteArray.Length );
                l_FileWriter.Write( l_byteArray, 0, l_byteArray.Length );

                for ( int iIndex = 0; iIndex < stbData.m_DataTable.Rows.Count; iIndex++ )
                {
                    l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][1].ToString();
                    l_byteArray = Encoding.GetEncoding( 949 ).GetBytes( l_strFieldInfo );

                    l_FileWriter.Write( (ushort)l_byteArray.Length );
                    l_FileWriter.Write( l_byteArray, 0, l_byteArray.Length );
                }

                uint l_iDataOffset = (uint)l_FileWriter.BaseStream.Position;
                l_FileWriter.Seek( 4, SeekOrigin.Begin );
                l_FileWriter.Write( l_iDataOffset );

                l_FileWriter.Seek( (int)l_iDataOffset, SeekOrigin.Begin );

                for ( int iIndex = 0; iIndex < stbData.m_DataTable.Rows.Count; iIndex++ )
                {
                    int iColumnsCount = stbData.m_DataTable.Columns.Count - 2;

                    for ( int iIndex2 = 0; iIndex2 < iColumnsCount; iIndex2++ )
                    {
                        l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][iIndex2 + 2].ToString();
                        l_byteArray = Encoding.GetEncoding( 949 ).GetBytes( l_strFieldInfo );

                        l_FileWriter.Write( (ushort)l_byteArray.Length );
                        l_FileWriter.Write( l_byteArray, 0, l_byteArray.Length );
                    }
                }

                l_FileWriter.Close();
            }
            catch
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 简体中文代码页(936)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool LoadSTBDataChina(ref STBData stbData, string strFileName)
        {
            try
            {
                FileStream   l_FileStream = File.OpenRead(strFileName);
                BinaryReader l_FileReader = new BinaryReader(l_FileStream, Encoding.ASCII);

                string l_strFieldInfo;
                ushort l_iFieldLength;

                stbData.m_strFileName = strFileName;
                stbData.m_strFileType = new string( l_FileReader.ReadChars(4));
                stbData.m_iDataOffset = l_FileReader.ReadUInt32();
                stbData.m_iRowCount   = l_FileReader.ReadUInt32();
                stbData.m_iFieldCount = l_FileReader.ReadUInt32();
                stbData.m_iUnknown    = l_FileReader.ReadUInt32();

                stbData.m_ColumnsWidth = new ushort[stbData.m_iFieldCount + 1]; // 因为加了一个索引字段, 所以需要加一, 但它是不保存的
                for (int iIndex = 0; iIndex < stbData.m_ColumnsWidth.Length; iIndex++)
                {
                    stbData.m_ColumnsWidth[iIndex] = l_FileReader.ReadUInt16();
                }

                stbData.m_ColumnsHeaderText    = new string[stbData.m_ColumnsWidth.Length]; // 因为加了一个索引字段, 所以需要加一, 但它是不保存的
                stbData.m_ColumnsHeaderText[0] = "#";                                       // 一个索引标题文字, 但它是不保存的
                for (int iIndex = 1; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++)
                {
                    l_iFieldLength = l_FileReader.ReadUInt16();
                    l_strFieldInfo = Encoding.GetEncoding(936).GetString(l_FileReader.ReadBytes(l_iFieldLength));
                    stbData.m_ColumnsHeaderText[iIndex] = l_strFieldInfo;
                }

                stbData.m_iStructNameLength = l_FileReader.ReadUInt16();
                stbData.m_strStructName     = Encoding.GetEncoding(936).GetString(l_FileReader.ReadBytes((int)stbData.m_iStructNameLength));

                stbData.m_DataTable = new DataTable();
                for (int iIndex = 0; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++)
                {
                    stbData.m_DataTable.Columns.Add(string.Empty);
                }

                stbData.m_STBFieldComment = new STBFieldComment[stbData.m_iRowCount - 1];
                for (int iIndex = 0; iIndex < stbData.m_STBFieldComment.Length; iIndex++)
                {
                    stbData.m_DataTable.Rows.Add(stbData.m_DataTable.NewRow());
                }

                for (int iIndex = 0; iIndex < stbData.m_STBFieldComment.Length; iIndex++)
                {
                    stbData.m_STBFieldComment[iIndex].m_strFieldCommentLength = l_FileReader.ReadUInt16();
                    stbData.m_STBFieldComment[iIndex].FieldComment            = Encoding.GetEncoding(949).GetString(l_FileReader.ReadBytes(stbData.m_STBFieldComment[iIndex].m_strFieldCommentLength));
                    stbData.m_DataTable.Rows[iIndex][1] = stbData.m_STBFieldComment[iIndex].FieldComment;
                }

                stbData.m_STBFieldStringArray = new STBFieldStringArray[stbData.m_iRowCount - 1];
                for (int iIndex = 0; iIndex < stbData.m_STBFieldStringArray.Length; iIndex++)
                {
                    stbData.m_STBFieldStringArray[iIndex].FieldString = new STBFieldString[stbData.m_iFieldCount - 1];

                    stbData.m_DataTable.Rows[iIndex][0] = iIndex.ToString();
                    for (int iIndex2 = 0; iIndex2 < stbData.m_STBFieldStringArray[iIndex].FieldString.Length; iIndex2++)
                    {
                        stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].m_strFieldStringLength = l_FileReader.ReadUInt16();
                        stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].FieldString            = Encoding.GetEncoding(949).GetString(l_FileReader.ReadBytes(stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].m_strFieldStringLength));
                        stbData.m_DataTable.Rows[iIndex][iIndex2 + 2] = stbData.m_STBFieldStringArray[iIndex].FieldString[iIndex2].FieldString;
                    }
                }

                l_FileReader.Close();
            }
            catch
            {
                stbData.Clear();
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 简体中文代码页(936)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool SaveSTBDataChina(ref STBData stbData, string strFileName)
        {
            string l_strFieldInfo;

            byte[] l_byteArray;

            try
            {
                FileStream   l_FileStream = File.Open(strFileName, FileMode.Create);
                BinaryWriter l_FileWriter = new BinaryWriter(l_FileStream, Encoding.ASCII);

                l_byteArray = Encoding.GetEncoding(936).GetBytes(stbData.m_strFileType);
                l_FileWriter.Write(l_byteArray, 0, l_byteArray.Length);

                l_FileWriter.Seek(4, SeekOrigin.Current);
                l_FileWriter.Write(stbData.m_DataTable.Rows.Count + 1);
                l_FileWriter.Write(stbData.m_DataTable.Columns.Count - 1);

                l_FileWriter.Write(stbData.m_iUnknown);

                for (int iIndex = 0; iIndex < stbData.m_ColumnsWidth.Length; iIndex++)
                {
                    l_FileWriter.Write(stbData.m_ColumnsWidth[iIndex]);
                }

                for (int iIndex = 1; iIndex < stbData.m_ColumnsHeaderText.Length; iIndex++)
                {
                    l_strFieldInfo = stbData.m_ColumnsHeaderText[iIndex];
                    l_byteArray    = Encoding.GetEncoding(936).GetBytes(l_strFieldInfo);
                    l_FileWriter.Write((ushort)l_byteArray.Length);
                    l_FileWriter.Write(l_byteArray, 0, l_byteArray.Length);
                }

                l_byteArray = Encoding.GetEncoding(936).GetBytes(stbData.m_strStructName);
                l_FileWriter.Write((ushort)l_byteArray.Length);
                l_FileWriter.Write(l_byteArray, 0, l_byteArray.Length);

                for (int iIndex = 0; iIndex < stbData.m_DataTable.Rows.Count; iIndex++)
                {
                    l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][1].ToString();
                    l_byteArray    = Encoding.GetEncoding(949).GetBytes(l_strFieldInfo);

                    l_FileWriter.Write((ushort)l_byteArray.Length);
                    l_FileWriter.Write(l_byteArray, 0, l_byteArray.Length);
                }

                uint l_iDataOffset = (uint)l_FileWriter.BaseStream.Position;
                l_FileWriter.Seek(4, SeekOrigin.Begin);
                l_FileWriter.Write(l_iDataOffset);

                l_FileWriter.Seek((int)l_iDataOffset, SeekOrigin.Begin);

                for (int iIndex = 0; iIndex < stbData.m_DataTable.Rows.Count; iIndex++)
                {
                    int iColumnsCount = stbData.m_DataTable.Columns.Count - 2;

                    for (int iIndex2 = 0; iIndex2 < iColumnsCount; iIndex2++)
                    {
                        l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][iIndex2 + 2].ToString();
                        l_byteArray    = Encoding.GetEncoding(949).GetBytes(l_strFieldInfo);

                        l_FileWriter.Write((ushort)l_byteArray.Length);
                        l_FileWriter.Write(l_byteArray, 0, l_byteArray.Length);
                    }
                }

                l_FileWriter.Close();
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        private static void LoadSTB()
        {
            for (int iIndex = 0; iIndex < STB_ITEM.Length; iIndex++)
            	STB_ITEM[iIndex] = new STBData();

            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=               |" );
            STBData.LoadSTBDataKorea( ref STB_SELL, "STB\\LIST_SELL.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |==              |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[0], "STB\\LIST_FACE.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |===             |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[1], "STB\\LIST_CAP.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |====            |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[2], "STB\\LIST_BODY.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=====           |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[3], "STB\\LIST_ARMS.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |======          |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[4], "STB\\LIST_FOOT.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=======         |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[5], "STB\\LIST_BACK.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |========        |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[6], "STB\\LIST_JEWEL.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=========       |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[7], "STB\\LIST_WEAPON.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=========       |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[8], "STB\\LIST_SUBWPN.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |==========      |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[9],"STB\\LIST_USEITEM.STB"  );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |===========     |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[10], "STB\\LIST_JEMITEM.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |============    |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[11], "STB\\LIST_NATURAL.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=============   |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[12], "STB\\LIST_QUESTITEM.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |==============  |" );
            STBData.LoadSTBDataKorea( ref STB_ITEM[13], "STB\\LIST_PAT.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |=============== |" );
            STBData.LoadSTBDataKorea( ref STB_PRODUCT, "STB\\LIST_PRODUCT.STB" );
            LOGs.WriteLine( LogMessageType.MSG_LOAD, "读取 STBs: |================|\n" );
        }