Example #1
0
        public void TextViewCreated(IWpfTextView textView)
        {
            lock (sessions)
            {
                string filePath = textView.GetDocumentFullPath();
                if (filePath != null)
                {
                    ITextBuffer textBuffer = textView.TextBuffer;
                    if (!sessions.ContainsKey(filePath))
                    {
                        EditingSession editingSession = new EditingSession(filePath, textBuffer, textView);
                        sessions.Add(filePath, editingSession);

                        EventHandler textViewClosed = null;
                        textViewClosed = (o, e) =>
                        {
                            textView.Closed -= textViewClosed;
                            lock (sessions)
                            {
                                sessions.Remove(filePath);
                            }
                        };

                        textView.Closed += textViewClosed;
                    }
                }
            }
        }
Example #2
0
        public ConflictDataPoint(EditingSession editingSession, ICodeElementDescriptor methodIdentifier)
        {
            if (editingSession == null)
            {
                throw new ArgumentNullException("editingSession");
            }

            this.MethodIdentifier = methodIdentifier;
            this.EditingSession   = editingSession;

            EditingSession.ConflictDataChanged += this.OnConflictDataChanged;
        }
Example #3
0
        public ICodeLensDataPoint CreateDataPoint(ICodeLensDescriptor descriptor)
        {
            if (serviceProvider == null)
            {
                return(null);
            }

            ICodeElementDescriptor codeElement = descriptor as ICodeElementDescriptor;
            string         filePath            = codeElement.FilePath;
            EditingSession editingSession      = EditingSessionFactory.WaitForSession(filePath);

            return(new ConflictDataPoint(editingSession, codeElement));
        }
        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public ConflictPopupAdornment(IWpfTextView view)
        {
            _view           = view;
            _adornmentLayer = view.GetAdornmentLayer("ConflictPopupAdornment");

            string filePath = _view.GetDocumentFullPath();

            if (filePath != null)
            {
                this.editingSession = EditingSessionFactory.WaitForSession(_view.GetDocumentFullPath());
                editingSession.ConflictDataChanged += editingSession_ConflictDataChanged;
            }

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged  += delegate { this.onSizeChange(); };
        }
Example #5
0
        private static async void tfsQueryHistoryTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            IVsWindowFrame vsWindowFrame = ShellHelper.GetActiveWindowFrame(serviceProvider);

            if (vsWindowFrame != null)
            {
                object pvar = null;
                vsWindowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_pszMkDocument, out pvar);
                string fullPath = pvar as string;
                if (fullPath != null)
                {
                    EditingSession activeSession = EditingSessionFactory.WaitForSession(fullPath);
                    if (activeSession != null)
                    {
                        tfsQueryHistoryTimer.Enabled = false;
                        await activeSession.RecalculateConflicts(ForceCheckForNewVersion.LatestVersion);

                        tfsQueryHistoryTimer.Enabled = true;
                    }
                }
            }
        }
Example #6
0
        public ConflictTextAdornment(IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            _view  = view;
            _layer = view.GetAdornmentLayer("ConflictTextAdornment");

            //Listen to any event that changes the layout (text changes, scrolling, etc)
            _view.LayoutChanged += OnLayoutChanged;

            SolidColorBrush b = (SolidColorBrush)editorFormatMap.GetProperties(ConflictRegionFormatDefinition.Name)[EditorFormatDefinition.BackgroundBrushId];;

            _brush = new SolidColorBrush(Color.FromArgb((byte)(Opacity * 255), b.Color.R, b.Color.G, b.Color.B));
            Brush penBrush = (SolidColorBrush)editorFormatMap.GetProperties(ConflictRegionFormatDefinition.Name)[EditorFormatDefinition.ForegroundBrushId];;

            penBrush.Freeze();
            _pen = new Pen(penBrush, 1);

            string filePath = _view.GetDocumentFullPath();

            if (filePath != null)
            {
                this.editingSession = EditingSessionFactory.WaitForSession(_view.GetDocumentFullPath());
                editingSession.ConflictDataChanged += editingSession_ConflictDataChanged;
            }
        }