Beispiel #1
0
        /// <summary>
        /// Begins the process of renaming.
        /// </summary>
        private void StartRename(bool useInline, string oldName, string newName)
        {
            if (!string.IsNullOrEmpty(newName))
            {
                OnApply(null, oldName, newName);
                return;
            }

            if (useInline)
            {
                var sci = PluginBase.MainForm.CurrentDocument.SciControl;
                int position = sci.WordEndPosition(sci.CurrentPos, true);

                var inlineRename = new InlineRename(sci, oldName, position, null, null, isRenamePackage ? new bool?() : new bool?(true), Target);
                inlineRename.Apply += OnApply;
                inlineRename.Cancel += OnCancel;
            }
            else
            {
                string title = " " + string.Format(TextHelper.GetString("Title.RenameDialog"), oldName);
                string label = TextHelper.GetString("Label.NewName");
                var dialog = new LineEntryDialog(title, label, oldName);

                switch (dialog.ShowDialog())
                {
                    case DialogResult.OK:
                        OnApply(null, oldName, dialog.Line.Trim());
                        break;
                    case DialogResult.Cancel:
                        OnCancel(null);
                        break;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Add this <see cref="InlineRename"/> object as a message filter and handle internal
 /// messages and handle <see cref="ScintillaControl"/> events.
 /// </summary>
 private void AddMessageFilter()
 {
     Application.AddMessageFilter(this);
     sci.SelectionChanged += Sci_SelectionChanged;
     sci.TextInserted     += Sci_TextInserted;
     sci.TextDeleted      += Sci_TextDeleted;
     Current = this;
 }
Beispiel #3
0
 /// <summary>
 /// Update the default flags and clean up.
 /// </summary>
 private void UpdateDefaultFlags(InlineRename inlineRename)
 {
     if (inlineRename != null)
     {
         inlineRename.Apply -= OnApply;
         inlineRename.Cancel -= OnCancel;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Cancel renaming and clean up.
 /// </summary>
 private void OnCancel(InlineRename sender)
 {
     UpdateDefaultFlags(sender);
     if (findAllReferencesCommand != null)
     {
         findAllReferencesCommand.OnRefactorComplete -= OnFindAllReferencesCompleted;
     }
 }
Beispiel #5
0
        /// <summary>
        /// Apply the new name.
        /// </summary>
        private void OnApply(InlineRename sender, string oldName, string newName)
        {
            UpdateDefaultFlags(sender);
            if (newName.Length == 0 || oldName == newName) return;

            if (isRenamePackage)
            {
                renamePackage = new Move(new Dictionary<string, string> { { renamePackagePath, newName } }, true, true);
            }

            OldName = oldName;
            NewName = newName;
            RenamingHelper.AddToQueue(this);
        }
Beispiel #6
0
        /// <summary>
        /// Remove this <see cref="InlineRename"/> from the system message filters, dispose any
        /// resources used, and re-enable controls from <see cref="IMainForm"/>.
        /// </summary>
        void IDisposable.Dispose()
        {
            Application.RemoveMessageFilter(this);
            sci.SelectionChanged -= Sci_SelectionChanged;
            sci.TextInserted     -= Sci_TextInserted;
            sci.TextDeleted      -= Sci_TextDeleted;
            Current = null;

            currentDoc = null;
            currentRef = null;
            refs       = null;

            history.Clear();
            history = null;

            PluginBase.MainForm.MenuStrip.Enabled  = true;
            PluginBase.MainForm.ToolStrip.Enabled  = true;
            PluginBase.MainForm.EditorMenu.Enabled = true;
            UITools.Manager.DisableEvents          = false;
        }