Exemplo n.º 1
0
        private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.dataGridView.SuspendLayout();

                LTBData.LoadLTBData(ref m_LTBData, this.openFileDialog.FileName);
                m_strFileName = this.openFileDialog.FileName;

                this.dataGridView.DataSource = m_LTBData.DataTable;

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

                this.Text = "Demo R.O.S.E.STB.Editor.Form" + "( " + m_LTBData.RowCount.ToString() + " )";

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

                this.dataGridView.ResumeLayout();

                this.CloseToolStripMenuItem.Enabled     = true;
                this.SaveToolStripMenuItem.Enabled      = true;
                this.SaveAsToolStripMenuItem.Enabled    = true;
                this.LanguageToolStripMenuItem.Enabled  = true;
                this.自动填充空的字符串ToolStripMenuItem.Enabled = true;

                // 为了方便修改
                this.KoreanToolStripMenuItem.Checked   = false;
                this.JapaneseToolStripMenuItem.Checked = false;


                CheckedDataTable();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 韩国代码页(949)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool SaveLTBData(ref LTBData 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_FileWriter.Write(stbData.FieldCount);
                l_FileWriter.Write((uint)stbData.m_DataTable.Rows.Count);

                long l_iOffset     = (stbData.m_DataTable.Rows.Count * stbData.FieldCount * 6) + l_FileWriter.BaseStream.Position; // 前面的两个(行数和列数)的大小为8字节
                long l_iFileOffset = l_iOffset;

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

                    for (int iIndex2 = 0; iIndex2 < iColumnsCount; iIndex2++)
                    {
                        l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][iIndex2].ToString();

                        if (l_strFieldInfo == null || l_strFieldInfo == string.Empty)
                        {
                            l_FileWriter.Write((uint)0);
                            l_FileWriter.Write((ushort)0);
                        }
                        else
                        {
                            l_byteArray = Encoding.Unicode.GetBytes(l_strFieldInfo);

                            l_FileWriter.Write((uint)l_iFileOffset);
                            l_FileWriter.Write((ushort)l_strFieldInfo.Length);

                            long l_iOriginalOffset = l_FileWriter.BaseStream.Position;

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

                            l_FileWriter.Write(l_byteArray);
                            l_iFileOffset = l_FileWriter.BaseStream.Position;

                            l_FileWriter.Seek((int)l_iOriginalOffset, SeekOrigin.Begin);
                        }
                    }
                }

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

            return(true);
        }
Exemplo n.º 3
0
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.saveFileDialog.FileName = m_strFileName;
            if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

                LTBData.SaveLTBData(ref m_LTBData, this.saveFileDialog.FileName);
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (LTBData.LoadLTBData(ref m_LTBDataFile1, this.textBoxFile1.Text) == false)
            {
                MessageBox.Show(this.textBoxFile1.Text + "文件读取错误");
                return;
            }

            if (LTBData.LoadLTBData(ref m_LTBDataFile2, this.textBoxFile2.Text) == false)
            {
                MessageBox.Show(this.textBoxFile2.Text + "文件读取错误");
                return;
            }

            //LTBData.Language l_LanguageKeep1 = new LTBData.Language();
            //if ( this.checkBox1.Checked == true )
            //    l_LanguageKeep1 |=  LTBData.Language.Korean;

            //if ( this.checkBox2.Checked == true )
            //    l_LanguageKeep1 |= LTBData.Language.English;

            //if ( this.checkBox3.Checked == true )
            //    l_LanguageKeep1 |= LTBData.Language.Japanese;

            //if ( this.checkBox4.Checked == true )
            //    l_LanguageKeep1 |= LTBData.Language.ChinaTaiwan;

            //if ( this.checkBox5.Checked == true )
            //    l_LanguageKeep1 |= LTBData.Language.China;

            //if ( LTBData.CoalitionLTBData( ref m_LTBDataSave, m_LTBDataFile1, l_LanguageKeep1, m_LTBDataFile2 ) == false )
            //{
            //    MessageBox.Show( "文件合并检测时产生错误: 可能文件不匹配!" );
            //    return;
            //}

            //if ( LTBData.SaveLTBData( m_LTBDataSave, this.textBoxSaveFile.Text ) == false )
            //{
            //    MessageBox.Show(this.textBoxSaveFile.Text + "文件保存错误" );
            //    return;
            //}

            MessageBox.Show("文件合并成功");
        }
Exemplo n.º 5
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

            LTBData.SaveLTBData(ref m_LTBData, m_LTBData.FileName);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 韩国代码页(949)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool LoadLTBData(ref LTBData stbData, string strFileName)
        {
            try
            {
                FileStream   l_FileStream = File.OpenRead(strFileName);
                BinaryReader l_FileReader = new BinaryReader(l_FileStream, Encoding.ASCII);

                stbData.m_strFileName = strFileName;
                stbData.m_iFieldCount = l_FileReader.ReadUInt32();
                stbData.m_iRowCount   = l_FileReader.ReadUInt32();

                stbData.m_DataTable = new DataTable();
                stbData.m_DataTable.Columns.Add("ID");
                stbData.m_DataTable.Columns.Add("Korean");
                stbData.m_DataTable.Columns.Add("English");
                stbData.m_DataTable.Columns.Add("Japanese");
                stbData.m_DataTable.Columns.Add("China-Taiwan");
                stbData.m_DataTable.Columns.Add("China");
                stbData.m_DataTable.Columns.Add("Language1");
                stbData.m_DataTable.Columns.Add("Language2");

                for (int iIndex = 8; iIndex < stbData.m_iFieldCount; iIndex++)
                {
                    stbData.m_DataTable.Columns.Add("Language" + (iIndex - 5));
                }

                for (int iIndex = 0; iIndex < stbData.m_iRowCount; iIndex++)
                {
                    stbData.m_DataTable.Rows.Add(stbData.m_DataTable.NewRow());
                }

                stbData.m_STBFieldInfoArray = new STBFieldInfo[stbData.m_iFieldCount * stbData.m_iRowCount];
                for (int iIndex = 0; iIndex < stbData.m_STBFieldInfoArray.Length; iIndex++)
                {
                    stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset      = l_FileReader.ReadUInt32();
                    stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength = l_FileReader.ReadUInt16();

                    if (stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset != 0)
                    {
                        long l_iOffset = l_FileReader.BaseStream.Position;

                        l_FileReader.BaseStream.Seek(stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset, SeekOrigin.Begin);

                        stbData.m_STBFieldInfoArray[iIndex].FieldString = Encoding.Unicode.GetString(l_FileReader.ReadBytes(stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength * 2));
                        // 下面替换上面 用于不是UNICODE的文件
                        //stbData.m_STBFieldInfoArray[iIndex].FieldString = Encoding.GetEncoding( 949 ).GetString( l_FileReader.ReadBytes( stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength ) );

                        stbData.m_DataTable.Rows[(int)(iIndex / stbData.m_iFieldCount)][(int)(iIndex % stbData.m_iFieldCount)] = stbData.m_STBFieldInfoArray[iIndex].FieldString;

                        l_FileReader.BaseStream.Seek(l_iOffset, SeekOrigin.Begin);
                    }
                }

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

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 韩国代码页(949)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool LoadLTBData( ref LTBData stbData, string strFileName )
        {
            try
            {
                FileStream l_FileStream = File.OpenRead( strFileName );
                BinaryReader l_FileReader = new BinaryReader( l_FileStream, Encoding.ASCII );

                stbData.m_strFileName = strFileName;
                stbData.m_iFieldCount = l_FileReader.ReadUInt32();
                stbData.m_iRowCount = l_FileReader.ReadUInt32();

                stbData.m_DataTable = new DataTable();
                stbData.m_DataTable.Columns.Add( "ID" );
                stbData.m_DataTable.Columns.Add( "Korean" );
                stbData.m_DataTable.Columns.Add( "English" );
                stbData.m_DataTable.Columns.Add( "Japanese" );
                stbData.m_DataTable.Columns.Add( "China-Taiwan" );
                stbData.m_DataTable.Columns.Add( "China" );
                stbData.m_DataTable.Columns.Add( "Language1" );
                stbData.m_DataTable.Columns.Add( "Language2" );

                for ( int iIndex = 8; iIndex < stbData.m_iFieldCount; iIndex++ )
                    stbData.m_DataTable.Columns.Add( "Language" + (iIndex - 5) );

                for ( int iIndex = 0; iIndex < stbData.m_iRowCount; iIndex++ )
                    stbData.m_DataTable.Rows.Add( stbData.m_DataTable.NewRow() );

                stbData.m_STBFieldInfoArray = new STBFieldInfo[stbData.m_iFieldCount * stbData.m_iRowCount];
                for ( int iIndex = 0; iIndex < stbData.m_STBFieldInfoArray.Length; iIndex++ )
                {
                    stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset = l_FileReader.ReadUInt32();
                    stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength = l_FileReader.ReadUInt16();

                    if ( stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset != 0 )
                    {
                        long l_iOffset = l_FileReader.BaseStream.Position;

                        l_FileReader.BaseStream.Seek( stbData.m_STBFieldInfoArray[iIndex].m_strFieldoOffset, SeekOrigin.Begin );

                        stbData.m_STBFieldInfoArray[iIndex].FieldString = Encoding.Unicode.GetString( l_FileReader.ReadBytes( stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength * 2 ) );
                        // 下面替换上面 用于不是UNICODE的文件
                        //stbData.m_STBFieldInfoArray[iIndex].FieldString = Encoding.GetEncoding( 949 ).GetString( l_FileReader.ReadBytes( stbData.m_STBFieldInfoArray[iIndex].m_strFieldStringLength ) );

                        stbData.m_DataTable.Rows[(int)( iIndex / stbData.m_iFieldCount )][(int)( iIndex % stbData.m_iFieldCount )] = stbData.m_STBFieldInfoArray[iIndex].FieldString;

                        l_FileReader.BaseStream.Seek( l_iOffset, SeekOrigin.Begin );
                    }
                }

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

            return true;
        }
Exemplo n.º 8
0
        /// <summary>
        /// 韩国代码页(949)
        /// </summary>
        /// <param name="stbData"></param>
        /// <param name="strFileName"></param>
        public static bool SaveLTBData( ref LTBData 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_FileWriter.Write( stbData.FieldCount );
                l_FileWriter.Write( (uint)stbData.m_DataTable.Rows.Count );

                long l_iOffset = ( stbData.m_DataTable.Rows.Count * stbData.FieldCount * 6 ) + l_FileWriter.BaseStream.Position; // 前面的两个(行数和列数)的大小为8字节
                long l_iFileOffset = l_iOffset;

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

                    for ( int iIndex2 = 0; iIndex2 < iColumnsCount; iIndex2++ )
                    {
                        l_strFieldInfo = stbData.m_DataTable.Rows[iIndex][iIndex2].ToString();

                        if ( l_strFieldInfo == null || l_strFieldInfo == string.Empty )
                        {
                            l_FileWriter.Write( (uint)0 );
                            l_FileWriter.Write( (ushort)0 );
                        }
                        else
                        {
                            l_byteArray = Encoding.Unicode.GetBytes( l_strFieldInfo );

                            l_FileWriter.Write( (uint)l_iFileOffset );
                            l_FileWriter.Write( (ushort)l_strFieldInfo.Length );

                            long l_iOriginalOffset = l_FileWriter.BaseStream.Position;

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

                            l_FileWriter.Write( l_byteArray );
                            l_iFileOffset = l_FileWriter.BaseStream.Position;

                            l_FileWriter.Seek( (int)l_iOriginalOffset, SeekOrigin.Begin );
                        }
                    }
                }

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

            return true;
        }