private void findForm_Closing(object sender, CancelEventArgs e) { this.formRestoreData = new MemoryStream(); this.findForm.GetRestoreData(this.formRestoreData, new BinaryFormatter()); this.findForm = null; this.ParentControl.Focus(); }
/// <summary> /// When the find form is being closed we record the user-changable settings for later restoration /// </summary> private void findForm_Closing(object sender, CancelEventArgs e) { formRestoreData = new MemoryStream(); findForm.GetRestoreData(formRestoreData, new BinaryFormatter()); findForm = null; ParentControl.Focus(); // This is required if an InforForm has been shown. // Otherwise, focus is orphaned. I am not sure why. }
public void Show(string defaultText, bool replaceMode) { if (this.findForm == null) { if (this.formRestoreData != null) { this.formRestoreData.Seek(0L, SeekOrigin.Begin); } this.findForm = new FindForm(this, this.formRestoreData, new BinaryFormatter(), defaultText, replaceMode, replaceMode || this.ReplaceAvailable); this.findForm.Deactivate += new EventHandler(this.findForm_Deactivate); this.findForm.Closing += new CancelEventHandler(this.findForm_Closing); } this.findForm.Reshow(); if (this.findForm.ReplaceMode != replaceMode) { this.findForm.ReplaceMode = replaceMode; } }
/// <summary> /// Present the form to the user with the given default text /// </summary> /// <param name="defaultText">The default text to set</param> /// <param name="replaceMode">Start in Replace mode?</param> public void Show(string defaultText, bool replaceMode) { if (findForm == null) // Create the form if it doesn't exist already { if (formRestoreData != null) { formRestoreData.Seek((long)0, SeekOrigin.Begin); } findForm = new FindForm(this, formRestoreData, new BinaryFormatter(), defaultText, replaceMode, replaceMode || ReplaceAvailable); findForm.Deactivate += new EventHandler(findForm_Deactivate); findForm.Closing += new CancelEventHandler(findForm_Closing); } findForm.Reshow(); // Re-show the form if (findForm.ReplaceMode != replaceMode) { findForm.ReplaceMode = replaceMode; } }