Ejemplo n.º 1
0
        /// <summary>
        /// Called multiple times as subject buffers get connected and disconnected in the buffer graph
        /// </summary>
        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
        {
            EditorView.Create(textView);

            foreach (var textBuffer in subjectBuffers)
            {
                TextViewData viewData;
                var          newBuffer = !TextBufferToViewData.ContainsKey(textBuffer);
                if (newBuffer)
                {
                    viewData = new TextViewData();
                    TextBufferToViewData[textBuffer] = viewData;
                }
                else
                {
                    viewData = TextBufferToViewData[textBuffer];
                }

                viewData.AddView(textView);
                if (newBuffer)
                {
                    EditorBuffer.Create(textBuffer, _tdfs);
                    OnTextBufferCreated(textView, textBuffer);
                }

                OnTextViewConnected(textView, textBuffer);
            }
        }
Ejemplo n.º 2
0
        public virtual void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection <ITextBuffer> subjectBuffers)
        {
            if (TextBufferToViewData != null)
            {
                foreach (var textBuffer in subjectBuffers)
                {
                    OnTextViewDisconnected(textView, textBuffer);

                    if (TextBufferToViewData.ContainsKey(textBuffer))
                    {
                        TextViewData viewData = TextBufferToViewData[textBuffer];
                        viewData.RemoveView(textView);

                        if (viewData.AllViews.Count == 0 && _pendingCheckForViewlessTextBuffers == null)
                        {
                            if (reason == ConnectionReason.BufferGraphChange)
                            {
                                // The buffer could be temporarily removed from the view, so don't
                                // immediately check if it's unused - do that after posting a message.
                                _pendingCheckForViewlessTextBuffers = CheckForViewlessTextBuffers;
                                _idleTime.Idle += OnIdle;
                            }
                            else
                            {
                                CheckForViewlessTextBuffers();
                            }
                        }
                    }
                }
            }
        }