Example #1
0
        /// <summary>
        /// Make a simple find dialog
        /// </summary>
        /// <param name="_findDialog">The FindDialog parent object</param>
        /// <param name="defaultText">Default text for the input box</param>
        /// <param name="restoreData">Restore data (if any) to restore the user-changeable form properties from</param>
        /// <param name="formatter">Formatter to read the above</param>
        /// <param name="replaceMode">Start in replace mode?</param>
        /// <param name="offerReplace">Offer the user the chance to switch to Replace mode?</param>
        public FindForm(FindDialog _findDialog, Stream restoreData, IFormatter formatter, string defaultText, bool replaceMode, bool offerReplace)
        {
            findDialog = _findDialog;

            Owner = findDialog.ParentControl.FindForm();
            InitializeComponent();

            findDialog.SearchMode = FindDialog.SearchModes.Ready;


            replaceModeCheckBox.Visible = offerReplace;

            // Populate searchTypeComboBox
            foreach (FindForm.SearchType searchType in Enum.GetValues(typeof(FindForm.SearchType)))
            {
                // convert StringsThatLookLikeThis to Strings that look like this
                searchTypeComboBox.Items.Add(searchType.ToString()[0] + Regex.Replace(searchType.ToString().Substring(1), @"(\B[A-Z])", " $1").ToLower());
            }

            searchTypeComboBox.SelectedIndex = 0;
            if (restoreData == null)
            {
                replaceModeCheckBox.Checked = replaceMode; // apply this attribute here because it can change the size of the form

                // Generate an appropriate position for the dialog - just off the parent control, but on the screen
                Control parentControl = findDialog.ParentControl;

                // Get the current bounds of the screen
                Rectangle screenBounds = Screen.GetWorkingArea(this);

                // Try a position top right of the parent
                Rectangle bounds = new Rectangle(parentControl.PointToScreen(new Point(parentControl.Width - Width, -Height)), Size);

                Rectangle intersection = Rectangle.Intersect(screenBounds, bounds);
                if (!intersection.Equals(bounds))
                {
                    // If intersection betwen screen bounds and dialog bounds is not exactly the same as the dialog bounds,
                    // some or all of the dialog is off screen.
                    // So, set the position to just below the bottom right of the parent control
                    bounds = new Rectangle(parentControl.PointToScreen(new Point(parentControl.Width - Width, parentControl.Height)), Size);
                }

                Bounds = bounds; // Appy the chosen bounds
            }
            else
            {
                // Restore the important settings from the previously recorded RestoreData
                ApplyRestoreData(restoreData, formatter);
                replaceModeCheckBox.Checked = replaceMode; // apply this attribute here because it can change the size of the form
            }

            ApplySearchMode(); // Set the initial visual setting

            if (defaultText != null)
            {
                searchHistoryComboBox.Text = defaultText;
            }

            Reshow();
        }
Example #2
0
 private void InitializeComponent()
 {
     this.components                 = new Container();
     this.contextMenuStrip           = new ContextMenuStrip(this.components);
     this.selectAllToolStripMenuItem = new ToolStripMenuItem();
     this.findToolStripMenuItem      = new ToolStripMenuItem();
     this.findDialog1                = new FindDialog();
     this.contextMenuStrip.SuspendLayout();
     base.SuspendLayout();
     this.contextMenuStrip.Items.AddRange(new ToolStripItem[]
     {
         this.selectAllToolStripMenuItem,
         this.findToolStripMenuItem
     });
     this.contextMenuStrip.Name               = "contextMenuStrip";
     this.contextMenuStrip.RenderMode         = ToolStripRenderMode.System;
     this.contextMenuStrip.ShowImageMargin    = false;
     this.contextMenuStrip.Size               = new Size(104, 48);
     this.contextMenuStrip.Opening           += new CancelEventHandler(this.contextMenuStrip_Opening);
     this.selectAllToolStripMenuItem.Name     = "selectAllToolStripMenuItem";
     this.selectAllToolStripMenuItem.Size     = new Size(103, 22);
     this.selectAllToolStripMenuItem.Text     = "Select &All";
     this.findToolStripMenuItem.Name          = "findToolStripMenuItem";
     this.findToolStripMenuItem.Size          = new Size(103, 22);
     this.findToolStripMenuItem.Text          = "&Find";
     this.findDialog1.ParentControl           = this;
     this.findDialog1.ReplaceAvailable        = false;
     this.findDialog1.SearchRegularExpression = null;
     this.findDialog1.SearchRequested        += new SearchEventHandler(this.findDialog1_SearchRequested);
     this.ContextMenuStrip = this.contextMenuStrip;
     base.KeyDown         += new KeyEventHandler(this.SearchableListView_KeyDown);
     this.contextMenuStrip.ResumeLayout(false);
     base.ResumeLayout(false);
 }
Example #3
0
 public FindForm(FindDialog _findDialog, Stream restoreData, IFormatter formatter, string defaultText, bool replaceMode, bool offerReplace)
 {
     this.findDialog = _findDialog;
     base.Owner      = this.findDialog.ParentControl.FindForm();
     this.InitializeComponent();
     this.findDialog.SearchMode       = FindDialog.SearchModes.Ready;
     this.replaceModeCheckBox.Visible = offerReplace;
     foreach (FindForm.SearchType searchType in Enum.GetValues(typeof(FindForm.SearchType)))
     {
         this.searchTypeComboBox.Items.Add(searchType.ToString()[0] + Regex.Replace(searchType.ToString().Substring(1), "(\\B[A-Z])", " $1").ToLower());
     }
     this.searchTypeComboBox.SelectedIndex = 0;
     if (restoreData == null)
     {
         this.replaceModeCheckBox.Checked = replaceMode;
         Control   parentControl = this.findDialog.ParentControl;
         Rectangle workingArea   = Screen.GetWorkingArea(this);
         Rectangle rectangle     = new Rectangle(parentControl.PointToScreen(new Point(parentControl.Width - base.Width, -base.Height)), base.Size);
         if (!Rectangle.Intersect(workingArea, rectangle).Equals(rectangle))
         {
             rectangle = new Rectangle(parentControl.PointToScreen(new Point(parentControl.Width - base.Width, parentControl.Height)), base.Size);
         }
         base.Bounds = rectangle;
     }
     else
     {
         this.ApplyRestoreData(restoreData, formatter);
         this.replaceModeCheckBox.Checked = replaceMode;
     }
     this.ApplySearchMode();
     if (defaultText != null)
     {
         this.searchHistoryComboBox.Text = defaultText;
     }
     this.Reshow();
 }
Example #4
0
 private void InitializeComponent()
 {
     this.components                 = new Container();
     this.contextMenuStrip           = new ContextMenuStrip(this.components);
     this.undoToolStripMenuItem      = new ToolStripMenuItem();
     this.toolStripSeparator1        = new ToolStripSeparator();
     this.cutToolStripMenuItem       = new ToolStripMenuItem();
     this.copyToolStripMenuItem      = new ToolStripMenuItem();
     this.pasteToolStripMenuItem     = new ToolStripMenuItem();
     this.deleteToolStripMenuItem    = new ToolStripMenuItem();
     this.toolStripSeparator2        = new ToolStripSeparator();
     this.findToolStripMenuItem      = new ToolStripMenuItem();
     this.replaceToolStripMenuItem   = new ToolStripMenuItem();
     this.toolStripSeparator3        = new ToolStripSeparator();
     this.selectAllToolStripMenuItem = new ToolStripMenuItem();
     this.findDialog1                = new FindDialog();
     this.contextMenuStrip.SuspendLayout();
     base.SuspendLayout();
     this.contextMenuStrip.Items.AddRange(new ToolStripItem[]
     {
         this.undoToolStripMenuItem,
         this.toolStripSeparator1,
         this.cutToolStripMenuItem,
         this.copyToolStripMenuItem,
         this.pasteToolStripMenuItem,
         this.deleteToolStripMenuItem,
         this.toolStripSeparator2,
         this.findToolStripMenuItem,
         this.replaceToolStripMenuItem,
         this.toolStripSeparator3,
         this.selectAllToolStripMenuItem
     });
     this.contextMenuStrip.Name               = "contextMenuStrip1";
     this.contextMenuStrip.RenderMode         = ToolStripRenderMode.System;
     this.contextMenuStrip.ShowImageMargin    = false;
     this.contextMenuStrip.Size               = new Size(104, 198);
     this.contextMenuStrip.Opening           += new CancelEventHandler(this.contextMenuStrip1_Opening);
     this.undoToolStripMenuItem.Name          = "undoToolStripMenuItem";
     this.undoToolStripMenuItem.Size          = new Size(103, 22);
     this.undoToolStripMenuItem.Text          = "&Undo";
     this.toolStripSeparator1.Name            = "toolStripSeparator1";
     this.toolStripSeparator1.Size            = new Size(100, 6);
     this.cutToolStripMenuItem.Name           = "cutToolStripMenuItem";
     this.cutToolStripMenuItem.Size           = new Size(103, 22);
     this.cutToolStripMenuItem.Text           = "C&ut";
     this.copyToolStripMenuItem.Name          = "copyToolStripMenuItem";
     this.copyToolStripMenuItem.Size          = new Size(103, 22);
     this.copyToolStripMenuItem.Text          = "&Copy";
     this.pasteToolStripMenuItem.Name         = "pasteToolStripMenuItem";
     this.pasteToolStripMenuItem.Size         = new Size(103, 22);
     this.pasteToolStripMenuItem.Text         = "&Paste";
     this.deleteToolStripMenuItem.Name        = "deleteToolStripMenuItem";
     this.deleteToolStripMenuItem.Size        = new Size(103, 22);
     this.deleteToolStripMenuItem.Text        = "&Delete";
     this.toolStripSeparator2.Name            = "toolStripSeparator2";
     this.toolStripSeparator2.Size            = new Size(100, 6);
     this.findToolStripMenuItem.Name          = "findToolStripMenuItem";
     this.findToolStripMenuItem.Size          = new Size(103, 22);
     this.findToolStripMenuItem.Text          = "&Find";
     this.replaceToolStripMenuItem.Name       = "replaceToolStripMenuItem";
     this.replaceToolStripMenuItem.Size       = new Size(103, 22);
     this.replaceToolStripMenuItem.Text       = "&Replace";
     this.toolStripSeparator3.Name            = "toolStripSeparator3";
     this.toolStripSeparator3.Size            = new Size(100, 6);
     this.selectAllToolStripMenuItem.Name     = "selectAllToolStripMenuItem";
     this.selectAllToolStripMenuItem.Size     = new Size(103, 22);
     this.selectAllToolStripMenuItem.Text     = "Select &All";
     this.findDialog1.ParentControl           = this;
     this.findDialog1.ReplaceAvailable        = false;
     this.findDialog1.SearchRegularExpression = null;
     this.findDialog1.ReplaceRequested       += new ReplaceEventHandler(this.findDialog1_ReplaceRequested);
     this.findDialog1.CancelReplaceRequested += new EventHandler(this.findDialog1_CancelReplaceRequested);
     this.findDialog1.SearchRequested        += new SearchEventHandler(this.findDialog1_SearchRequested);
     this.ContextMenuStrip = this.contextMenuStrip;
     base.ReadOnlyChanged += new EventHandler(this.SearchableTextBox_ReadOnlyChanged);
     base.KeyDown         += new KeyEventHandler(this.SearchableTextBox_KeyDown);
     this.contextMenuStrip.ResumeLayout(false);
     base.ResumeLayout(false);
 }