void RebuildMap() { _map.Clear(); var textBox = (TextBox)AdornedElement; IEnumerable notifications = Squiggle.GetNotifications(textBox); var page = Squiggle.GetPageFilter(textBox); if (notifications != null) { foreach (Notification notification in notifications) { if (notification.Page == page) { var fromIndex = GetIndex(textBox, notification.FromLineNo - 1, notification.FromCharNo - 1); var toIndex = GetIndex(textBox, notification.ToLineNo - 1, notification.ToCharNo - 1); _map.Set(fromIndex, toIndex - fromIndex + 1); } } } SignalInvalidate(); }
public SquiggleAdorner(TextBox textbox) : base(textbox) { _squigglePen = new Pen(new SolidColorBrush(Colors.Red) { Opacity = 0.5 }, 2.5); _squigglePen.Freeze(); _map = new RangeMap(); textbox.TextChanged += new TextChangedEventHandler(TextBox_TextChanged); var collection = Squiggle.GetNotifications(textbox); if (collection != null) { collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Notifications_CollectionChanged); Notifications_CollectionChanged(textbox, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } Squiggle.AddNotificationsChangedHandler(textbox, TextBox_NotificationsChanged); Squiggle.AddPageFilterChangedHandler(textbox, TextBox_PageFilterChanged); }