public AdornmentLayer(IWpfTextView textView, LayerKind layerKind, MetadataAndOrder <IAdornmentLayersMetadata> info) { TextView = textView ?? throw new ArgumentNullException(nameof(textView)); this.layerKind = layerKind; Info = info; adornmentLayerElements = new List <AdornmentLayerElement>(); }
int GetInsertIndex(MetadataAndOrder<IAdornmentLayersMetadata> info) { for (int i = 0; i < adornmentLayers.Count; i++) { if (info.Order < adornmentLayers[i].Info.Order) return i; } return adornmentLayers.Count; }
AdornmentLayer Create(MetadataAndOrder<IAdornmentLayersMetadata> info) { var layer = new AdornmentLayer(wpfTextView, layerKind, info); int index = GetInsertIndex(info); adornmentLayers.Insert(index, layer); Children.Insert(index, layer); return layer; }
public IAdornmentLayer GetAdornmentLayer(MetadataAndOrder <IAdornmentLayersMetadata> info) { var layer = adornmentLayers.FirstOrDefault(a => a.Info.Metadata == info.Metadata); if (layer is null) { layer = Create(info); } return(layer); }