/// <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(); }
private void GoToToolStripMenuItem_Click(object sender, EventArgs e) { RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild; if (child != null) { child.GoTo(); } }
private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild; if (child != null) { child.CommitChangesAs(); } }
private void ShowNewForm(object sender, EventArgs e) { RPHexEditorForm childForm = new RPHexEditorForm(); childForm.MdiParent = this; childForm.NewFile(); childForm.Text = childForm.GetFileName(); childForm.Show(); }
private void SaveFile(object sender, EventArgs e) { RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild; if (child != null) { if (child.IsChanged()) { child.CommitChanges(); } } }
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); } } }
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(); } }
private void PasteToolStripMenuItem_Click(object sender, EventArgs e) { RPHexEditorForm child = (RPHexEditorForm)this.ActiveMdiChild; child.Paste(); }