public void UpdateOffsetOnNotes() { byte[] flag = NotesBrowser.getJPGFromImageControl(Properties.Resources.noteFlag); for (int i = ParentControl.NotesBrowser.Notes.Count - 1; i >= 0; i--) { var note = ParentControl.NotesBrowser.Notes.ElementAt(i); var a = SuperTextRedactor.TestRange(note.Value.Range); note.Value.Range.ApplyPropertyValue(TextElement.BackgroundProperty, null); for (TextPointer position = note.Value.Range.Start; position != null && position.CompareTo(note.Value.Range.End) != 1; position = position.GetNextContextPosition(LogicalDirection.Forward)) { InlineUIContainer element = position.Parent as InlineUIContainer; if (element != null && element.Child is System.Windows.Controls.Image) { var image = element.Child as System.Windows.Controls.Image; if (image == null) { continue; } var imageSourse = image.Source as System.Windows.Media.ImageSource; if (imageSourse == null) { continue; } byte[] byt = NotesBrowser.getJPGFromImageControl(imageSourse); //сравнивает картинки if (byt.Length == flag.Length) { bool isflag = true; for (int t = 0; t < byt.Length; t++) { if (byt[t] != flag[t]) { isflag = false; break; } } if (!isflag) { continue; } element.Unloaded -= Element_Unloaded; element.SiblingInlines.Remove(element); break; } } } note.Value.OffsetStart = ParentControl.TextBox.MainControl.Document.ContentStart.GetOffsetToPosition(note.Value.Range.Start); note.Value.OffsetEnd = ParentControl.TextBox.MainControl.Document.ContentStart.GetOffsetToPosition(note.Value.Range.End); } if (ParentControl.searchPanel != null) { ParentControl.searchPanel.ClearSearch(); } }
private void updageTagOnFlag(Note note) { byte[] flag = NotesBrowser.getJPGFromImageControl(Properties.Resources.noteFlag); for (TextPointer position = note.Range.Start; position != null && position.CompareTo(note.Range.End) != 1; position = position.GetNextContextPosition(LogicalDirection.Forward)) { InlineUIContainer element = position.Parent as InlineUIContainer; if (element != null && element.Child is System.Windows.Controls.Image) { var image = element.Child as System.Windows.Controls.Image; if (image == null) { continue; } var imageSourse = image.Source as System.Windows.Media.ImageSource; if (imageSourse == null) { continue; } byte[] byt = NotesBrowser.getJPGFromImageControl(imageSourse); //сравнивает картинки if (byt.Length == flag.Length) { bool isflag = true; for (int t = 0; t < byt.Length; t++) { if (byt[t] != flag[t]) { isflag = false; break; } } if (!isflag) { continue; } image.Tag = note.Name; } } } }