示例#1
0
        /// <summary>
        /// Save the current file under a different name.
        /// ! NOT really efficient, should only be used for small files !
        /// </summary>
        public void CommitChangesAs()
        {
            if (rpHexEditor.ByteDataSource.GetType() == typeof(RPHexEditor.MemoryByteData))
            {
                this.CommitChanges();
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter           = _fileFilter;

            if (saveFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            RPHexEditor.FileByteData fileByteData = rpHexEditor.ByteDataSource as RPHexEditor.FileByteData;
            FileStream _fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.ReadWrite);

            for (int i = 0; i < fileByteData.Length; i++)
            {
                _fileStream.WriteByte(fileByteData.ReadByte(i));
            }

            _fileStream.Dispose();

            RPHexEditorForm childForm = new RPHexEditorForm();

            childForm.MdiParent = this.MdiParent;
            childForm.Text      = saveFileDialog.FileName;
            childForm.LoadFile(saveFileDialog.FileName);
            childForm.Show();
        }
示例#2
0
        private void GoToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild;

            if (child != null)
            {
                child.GoTo();
            }
        }
示例#3
0
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild;

            if (child != null)
            {
                child.CommitChangesAs();
            }
        }
示例#4
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            RPHexEditorForm childForm = new RPHexEditorForm();

            childForm.MdiParent = this;
            childForm.NewFile();
            childForm.Text = childForm.GetFileName();
            childForm.Show();
        }
示例#5
0
        private void SaveFile(object sender, EventArgs e)
        {
            RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild;

            if (child != null)
            {
                if (child.IsChanged())
                {
                    child.CommitChanges();
                }
            }
        }
示例#6
0
        private void ToggleStatusBarControl_INS()
        {
            RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild;

            if (child != null)
            {
                InsertKeyMode ikm = child.GetInsertMode;

                if (ikm == InsertKeyMode.Insert)
                {
                    child.SetInsertMode(InsertKeyMode.Overwrite);
                }
                else
                {
                    child.SetInsertMode(InsertKeyMode.Insert);
                }
            }
        }
示例#7
0
        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.ShowReadOnly     = true;
            openFileDialog.Filter           = "All Files (*.*)|*.*|Bin Files (*.bin)|*.bin|Text Files (*.txt)|*.txt";

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                RPHexEditorForm childForm = new RPHexEditorForm();
                childForm.MdiParent = this;
                childForm.Text      = openFileDialog.FileName;
                // TODO: Check result
                childForm.LoadFile(openFileDialog.FileName, openFileDialog.ReadOnlyChecked);
                childForm.Show();
            }
        }
示例#8
0
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild;

            child.Paste();
        }