コード例 #1
0
        /// <summary>
        /// Adds the selection in the specified TextView to this view's MultiSelect list.
        /// </summary>
        /// <param name="textView">The TextView containing the MultiSelect list to add to.</param>
        public void Add(TextView textView)
        {
            if (textView == null)
                return;
            MultiSelect multiSelect = Get(textView);
            if (multiSelect == null)
            {
                multiSelect = new MultiSelect();
                multiSelect.FileName = textView.FileNode.Name;
                multiSelect.Language = textView.TextDocument.Language;
                multiSelect.TypeName = CodeRush.Source.ActiveTypeName;
                Set(textView, multiSelect);
            }
            else if (multiSelect.TypeName != CodeRush.Source.ActiveTypeName)		// Inconsistent class names, so let's clear it out.
                multiSelect.TypeName = String.Empty;

            MultiSelect redoMultiSelect = GetRedo(textView);
            if (redoMultiSelect != null)
                redoMultiSelect.Selections.Clear();

            multiSelect.AddSelection(textView);
        }
コード例 #2
0
 public MultiSelectEnumerator(MultiSelect multiSelect, LanguageElementType elementType)
 {
     _MultiSelect = multiSelect;
     _ElementType = elementType;
     Reset();
 }
コード例 #3
0
ファイル: PlugIn1.cs プロジェクト: modulexcite/CR_MultiSelect
        private void QueueAdd(TextDocument activeTextDocument, TypeDeclaration activeType, MultiSelect multiSelect, LanguageElementType elementType)
        {
            string codeToGenerate = GetCode(multiSelect, elementType);
            if (codeToGenerate == String.Empty)
                return;

            // TODO: Change RelativeLocation.After, DefaultLocation.Bottom parameters to instead reference fields populated from the MultiSelect options.
            SourcePoint insertionPoint = GetInsertionPoint(activeType, elementType, RelativeLocation.After, DefaultLocation.Bottom);
            activeTextDocument.QueueInsert(insertionPoint, codeToGenerate);
        }
コード例 #4
0
ファイル: PlugIn1.cs プロジェクト: modulexcite/CR_MultiSelect
        private string GetCode(MultiSelect multiSelect, LanguageElementType elementType)
        {
            string result = String.Empty;

            MultiSelectEnumerator allElements = new MultiSelectEnumerator(multiSelect, elementType);
            while (allElements.MoveNext())
            {
                PartialSelection partialSelection = allElements.Current as PartialSelection;
                if (partialSelection != null)
                {
                    result += partialSelection.Text;
                    partialSelection.Generated = true; // Prevents this from coming in later when LanguageElementType.Unknown is passed in.
                }
            }
            return result;
        }
コード例 #5
0
        public void Undo(TextView activeTextView)
        {
            MultiSelect multiSelect = Get(activeTextView);
            if (multiSelect == null || multiSelect.Selections.Count == 0)
                return;

            MultiSelect redoMultiSelect = GetRedo(activeTextView);
            if (redoMultiSelect == null)
            {
                redoMultiSelect = new MultiSelect();
                SetRedo(activeTextView, redoMultiSelect);
            }

            int lastIndex = multiSelect.Selections.Count - 1;
            PartialSelection selectionToRemove = multiSelect.GetSelectionAt(lastIndex);
            redoMultiSelect.Selections.Add(selectionToRemove);
            selectionToRemove.RemoveHighlighter();
            activeTextView.Caret.MoveTo(selectionToRemove.CaretPosition);
            multiSelect.RemoveSelectionAt(lastIndex);
        }
コード例 #6
0
 public void SetRedo(TextView textView, MultiSelect redoMultiSelect)
 {
     textView.Storage.AttachObject(STR_RedoMultiSelectList, redoMultiSelect);
 }
コード例 #7
0
 public void Set(TextView textView, MultiSelect multiSelect)
 {
     textView.Storage.AttachObject(STR_MultiSelectList, multiSelect);
 }
コード例 #8
0
        public void Delete(MultiSelect multiSelect, string operation)
        {
            TextDocument textDocument = CodeRush.Documents.Get(multiSelect.FileName) as TextDocument;
            if (textDocument == null)
                return;
            foreach (PartialSelection selection in multiSelect.Selections)
                textDocument.QueueDelete(selection.Range);

            textDocument.ApplyQueuedEdits(operation);
        }
コード例 #9
0
 /// <summary>
 /// Copies the specified MultiSelect object to the clipboard.
 /// </summary>
 /// <param name="multiSelect">The MultiSelect object to copy to the clipboard.</param>
 public void CopyToClipboard(MultiSelect multiSelect)
 {
     multiSelect.Sort();
     DataFormats.Format format = DataFormats.GetFormat(STR_ClipboardFormatName);
     IDataObject dataObject = new DataObject();
     dataObject.SetData(DataFormats.Text, multiSelect.ToText());
     dataObject.SetData(format.Name, multiSelect);
     Clipboard.SetDataObject(dataObject, true);
 }