예제 #1
0
 /// <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.
 }
예제 #2
0
        /// <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.StartPosition = FormStartPosition.Manual;
                findForm.Location      = new System.Drawing.Point(0, 0);
                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;
            }
        }