コード例 #1
0
        public LineTextPreview()
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.ResizeRedraw | ControlStyles.Opaque, true);

            InitializeComponent();

            _IndentSize = 4;
            _Theme      = null;
            Analysis    = null;
        }
コード例 #2
0
        public override void Refresh()
        {
            base.Refresh();

            if (Theme != null && Theme.Behavior != null && IsHandleCreated)
            {
                var snapshot = new FakeSnapshot(Text);
                Analysis = new DocumentAnalyzer(snapshot, Theme.Behavior, IndentSize, IndentSize);
                Analysis.Reset().ContinueWith(t => { BeginInvoke((Action)Invalidate); });
            }
        }
コード例 #3
0
        public override void Refresh()
        {
            base.Refresh();

            if (Theme != null && Theme.Behavior != null && IsHandleCreated)
            {
                var snapshot = new FakeSnapshot(Text);
                Analysis = new DocumentAnalyzer(snapshot, Theme.Behavior, IndentSize, IndentSize);
                IndentGuidePackage.JoinableTaskFactory.Run(async delegate {
                    await Analysis.ResetAsync().ContinueWith(_ => BeginInvoke((Action)Invalidate), TaskScheduler.Default).ConfigureAwait(true);
                });
            }
        }
コード例 #4
0
        /// <summary>
        /// Raised when a view option changes.
        /// </summary>
        async void View_OptionChanged(object sender, EditorOptionChangedEventArgs e)
        {
            if (e.OptionId == DefaultOptions.IndentSizeOptionId.Name)
            {
                Analysis = new DocumentAnalyzer(
                    View.TextSnapshot,
                    Theme.Behavior,
                    View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId),
                    View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId)
                    );
                GuideBrushCache.Clear();
                GlowEffectCache.Clear();

                await AnalyzeAndUpdateAdornments();
            }
        }
コード例 #5
0
        /// <summary>
        /// Instantiates a new indent guide manager for a view.
        /// </summary>
        /// <param name="view">The text view to provide guides for.</param>
        /// <param name="service">The Indent Guide service.</param>
        public IndentGuideView(IWpfTextView view, IIndentGuide service)
        {
            View = view;

            if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme))
            {
                Theme = service.DefaultTheme;
            }
            if (Theme != null && Theme.Behavior != null && Theme.Behavior.Disabled)
            {
                return;
            }

            GuideBrushCache = new Dictionary <System.Drawing.Color, Brush>();
            GlowEffectCache = new Dictionary <System.Drawing.Color, Effect>();

            View.Caret.PositionChanged += Caret_PositionChanged;
            View.LayoutChanged         += View_LayoutChanged;
            View.Options.OptionChanged += View_OptionChanged;

            Layer  = view.GetAdornmentLayer("IndentGuide");
            Canvas = new Canvas();
            Canvas.HorizontalAlignment = HorizontalAlignment.Stretch;
            Canvas.VerticalAlignment   = VerticalAlignment.Stretch;
            Layer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, null, Canvas, CanvasRemoved);

            Debug.Assert(Theme != null, "No themes loaded");
            if (Theme == null)
            {
                Theme = new IndentTheme();
            }
            service.ThemesChanged += new EventHandler(Service_ThemesChanged);

            Analysis = new DocumentAnalyzer(
                View.TextSnapshot,
                Theme.Behavior,
                View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId),
                View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId)
                );

            GlobalVisible           = service.Visible;
            service.VisibleChanged += new EventHandler(Service_VisibleChanged);

            var t = AnalyzeAndUpdateAdornments();
        }
コード例 #6
0
        /// <summary>
        /// Raised when the theme is updated.
        /// </summary>
        async void Service_ThemesChanged(object sender, EventArgs e)
        {
            var service = (IIndentGuide)sender;

            if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme))
            {
                Theme = service.DefaultTheme;
            }

            Analysis = new DocumentAnalyzer(
                View.TextSnapshot,
                Theme.Behavior,
                View.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId),
                View.Options.GetOptionValue(DefaultOptions.TabSizeOptionId)
                );
            GuideBrushCache.Clear();
            GlowEffectCache.Clear();

            await AnalyzeAndUpdateAdornments();
        }