Ejemplo n.º 1
0
 void RecreateMarkers()
 {
     foreach (var tmo in textLineObjectManager.GetObjectsOfType <ITextMarkerObject>())
     {
         CreateMarker(tmo);
     }
 }
Ejemplo n.º 2
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            Size renderSize = this.RenderSize;
            var  theme      = themeManager.Theme;
            var  bgColor    = (theme.GetColor(ColorType.IconBar).Background as SolidColorBrush).Color;

            drawingContext.DrawRectangle(theme.GetColor(ColorType.IconBar).Background, null,
                                         new Rect(0, 0, renderSize.Width, renderSize.Height));
            drawingContext.DrawLine(new Pen(theme.GetColor(ColorType.IconBarBorder).Background, 1),
                                    new Point(renderSize.Width - 0.5, 0),
                                    new Point(renderSize.Width - 0.5, renderSize.Height));

            TextView textView = this.TextView;

            if (textView != null && textView.VisualLinesValid)
            {
                // create a dictionary line number => first bookmark
                Dictionary <int, List <IIconBarObject> > bookmarkDict = new Dictionary <int, List <IIconBarObject> >();
                foreach (var obj in textLineObjectManager.GetObjectsOfType <IIconBarObject>())
                {
                    if (!obj.IsVisible(uiContext))
                    {
                        continue;
                    }
                    int line = obj.GetLineNumber(uiContext);
                    List <IIconBarObject> list;
                    if (!bookmarkDict.TryGetValue(line, out list))
                    {
                        bookmarkDict[line] = list = new List <IIconBarObject>();
                    }
                    list.Add(obj);
                }

                const double imagePadding = 1.0;
                Size         pixelSize    = PixelSnapHelpers.GetPixelSize(this);
                foreach (VisualLine line in textView.VisualLines)
                {
                    int lineNumber = line.FirstDocumentLine.LineNumber;
                    List <IIconBarObject> list;
                    if (!bookmarkDict.TryGetValue(lineNumber, out list))
                    {
                        continue;
                    }
                    list.Sort((a, b) => a.ZOrder.CompareTo(b.ZOrder));
                    foreach (var bm in list)
                    {
                        Rect rect   = new Rect(imagePadding, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16);
                        var  imgRef = bm.ImageReference;
                        if (imgRef != null)
                        {
                            drawingContext.DrawImage(imageManager.GetImage(imgRef.Value.Assembly, imgRef.Value.Name, bgColor), rect);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
            public IEnumerable <GuidObject> GetGuidObjects(GuidObject creatorObject, bool openedFromKeyboard)
            {
                var iconBarMargin = (IIconBarMargin)creatorObject.Object;

                yield return(new GuidObject(MenuConstants.GUIDOBJ_TEXTEDITORUICONTEXT_GUID, iconBarMargin.UIContext));

                var line = iconBarMargin.GetLineFromMousePosition();

                if (line != null)
                {
                    var objects         = new List <IIconBarObject>(textLineObjectManager.GetObjectsOfType <IIconBarObject>());
                    var filteredObjects = GetIconBarObjects(objects, iconBarMargin.UIContext, line.Value);
                    foreach (var o in filteredObjects)
                    {
                        yield return(new GuidObject(MenuConstants.GUIDOBJ_IICONBAROBJECT_GUID, o));
                    }
                }
            }