Beispiel #1
0
 public virtual LineFormat Clone(IndentTheme theme)
 {
     return(new LineFormat(theme)
     {
         FormatIndex = FormatIndex,
         Visible = Visible,
         LineStyle = LineStyle,
         LineColor = LineColor,
         HighlightStyle = HighlightStyle,
         HighlightColor = HighlightColor
     });
 }
Beispiel #2
0
 public override LineFormat Clone(IndentTheme theme)
 {
     return(new PageWidthMarkerFormat(theme)
     {
         FormatIndex = FormatIndex,
         Visible = Visible,
         LineColor = LineColor,
         LineStyle = LineStyle,
         HighlightColor = HighlightColor,
         HighlightStyle = HighlightStyle,
         Position = Position
     });
 }
Beispiel #3
0
        public static LineFormat FromInvariantStrings(IndentTheme theme, Dictionary <string, string> values)
        {
            Type   subclass = typeof(LineFormat);
            string subclassName;

            if (values.TryGetValue("TypeName", out subclassName))
            {
                subclass = Type.GetType(subclassName, false) ?? typeof(LineFormat);
            }

            LineFormat inst = subclass.InvokeMember(null, BindingFlags.CreateInstance, null, null,
                                                    new[] { theme }) as LineFormat;

            if (inst == null)
            {
                throw new InvalidOperationException("Unable to create instance of " + subclass.FullName);
            }

            foreach (KeyValuePair <string, string> kv in values)
            {
                if (kv.Key == "TypeName")
                {
                    continue;
                }

                PropertyInfo prop = subclass.GetProperty(kv.Key);
                if (prop != null)
                {
                    try
                    {
                        prop.SetValue(inst,
                                      TypeDescriptor.GetConverter(prop.PropertyType).ConvertFromInvariantString(kv.Value));
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError("Error setting {0} to {1}:\n", kv.Key, kv.Value, ex);
                    }
                }
                else
                {
                    Trace.TraceWarning("Unable to find property {0} on type {1}", kv.Key, subclass.FullName);
                }
            }

            return(inst);
        }
Beispiel #4
0
        /// <summary>
        ///     Raised when the theme is updated.
        /// </summary>
        private async void Service_ThemesChanged(object sender, EventArgs e)
        {
            IIndentGuide 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();
        }
Beispiel #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)
        {
            GuideBrushCache = new Dictionary <Color, Brush>();
            GlowEffectCache = new Dictionary <Color, Effect>();

            View = view;
            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);

            if (!service.Themes.TryGetValue(View.TextDataModel.ContentType.DisplayName, out Theme))
            {
                Theme = service.DefaultTheme;
            }
            Debug.Assert(Theme != null, "No themes loaded");
            if (Theme == null)
            {
                Theme = new IndentTheme();
            }
            service.ThemesChanged += Service_ThemesChanged;

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

            GlobalVisible           = service.Visible;
            service.VisibleChanged += Service_VisibleChanged;

            Task t = AnalyzeAndUpdateAdornments();
        }
Beispiel #6
0
 public PageWidthMarkerFormat(IndentTheme theme)
     : this()
 {
     Theme = theme;
 }
Beispiel #7
0
 public LineFormat(IndentTheme theme)
     : this()
 {
     Theme = theme;
 }