Пример #1
0
        // Search type selected
        private void searchtypes_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Create instance of the selected type
            newfinder = (FindReplaceType)searchtypes.SelectedItem;

            // Now setup the interface
            browsefind.Enabled    = newfinder.Attributes.BrowseButton;
            browsefind.Image      = newfinder.BrowseImage;
            browsereplace.Enabled = newfinder.Attributes.BrowseButton;
            browsereplace.Image   = newfinder.BrowseImage;
            if (!newfinder.Attributes.Replacable)
            {
                doreplace.Checked = false;
            }
            doreplace.Enabled = newfinder.Attributes.Replacable;
        }
Пример #2
0
        // Find / Replace clicked
        private void findbutton_Click(object sender, EventArgs e)
        {
            // Reset results
            suppressevents = true;
            resultslist.Items.Clear();

            // Hide object information
            General.Interface.HideInfo();

            // Keep the finder we used for the search
            finder = newfinder;

            // Enable/disable buttons
            editbutton.Enabled   = false;
            deletebutton.Visible = finder.AllowDelete;
            deletebutton.Enabled = false;
            resultslist.BeginUpdate();

            // Perform the search / replace and show the results
            if (doreplace.Checked)
            {
                General.Map.UndoRedo.CreateUndo("Replace " + searchtypes.SelectedItem);

                resultslist.Items.AddRange(finder.Find(findinput.Text, withinselection.Checked, replaceinput.Text, false));
                resultscount.Text = resultslist.Items.Count + " items found and replaced.";

                // Withdraw the undo step if nothing was replaced
                if (resultslist.Items.Count <= 0)
                {
                    General.Map.UndoRedo.WithdrawUndo();
                }
            }
            else
            {
                resultslist.Items.AddRange(finder.Find(findinput.Text, withinselection.Checked, null, false));
                resultscount.Text = resultslist.Items.Count + " items found.";
            }

            // Select all results
            General.Map.Map.ClearAllSelected();
            for (int i = 0; i < resultslist.Items.Count; i++)
            {
                resultslist.SelectedIndices.Add(i);
            }

            // Let the finder know about the selection
            FindReplaceObject[] selection = GetSelection();
            finder.ObjectSelected(selection);

            // Open results part of window
            this.Size            = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top + resultspanel.Height);
            resultspanel.Visible = true;
            resultslist.EndUpdate();
            suppressevents = false;

            // Enable/disable buttons
            editbutton.Enabled   = (resultslist.SelectedIndex > -1);
            deletebutton.Enabled = (resultslist.SelectedIndex > -1);

            // Set correct presentation mode
            General.Map.Renderer2D.SetPresentation(finder.RenderPresentation);

            // Redraw the screen, this will show the selection
            General.Interface.RedrawDisplay();
        }