Exemple #1
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin containerMargin)
        {
            try {
                var containerMarginAsVerticalScrollBar = containerMargin as IVerticalScrollBar;
                if (containerMarginAsVerticalScrollBar == null)
                {
                    return(null);
                }

                if (!wpfTextViewHost.TextView.HasValidMarginRoles())
                {
                    return(null);
                }
                if (!TextDocumentExtensions.TryGetTextDocument(TextDocumentFactoryService,
                                                               wpfTextViewHost.TextView.TextBuffer, out var textDocument))
                {
                    return(null);
                }

                using (Log.CriticalOperation($"{nameof(DocumentMarkScrollbarProvider)} {nameof(CreateMargin)}", LogEventLevel.Debug)) {
                    TextViewMargin = new DocumentMarkScrollbar(
                        wpfTextViewHost,
                        containerMarginAsVerticalScrollBar, SessionService.Value
                        );

                    return(TextViewMargin);
                }
            }
            catch (Exception ex) {
                Log.Error(ex, nameof(CreateMargin));
                System.Diagnostics.Debug.WriteLine(ex);
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
            }

            return(null);
        }
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin containerMargin)
        {
            try {
                var containerMarginAsVerticalScrollBar = containerMargin as IVerticalScrollBar;
                if (containerMarginAsVerticalScrollBar == null)
                {
                    return(null);
                }

                if (!wpfTextViewHost.TextView.HasValidRoles())
                {
                    return(null);
                }
                if (!TextDocumentExtensions.TryGetTextDocument(TextDocumentFactoryService,
                                                               wpfTextViewHost.TextView.TextBuffer, out var textDocument))
                {
                    return(null);
                }

                var sessionService = (Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel)
                                     ?.GetService <ISessionService>();

                TextViewMargin = new DocumentMarkScrollbar(
                    wpfTextViewHost,
                    containerMarginAsVerticalScrollBar, sessionService
                    );

                return(TextViewMargin);
            }
            catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
#if DEBUG
                System.Diagnostics.Debugger.Break();
#endif
            }

            return(null);
        }