Example #1
0
        public void UpdateRangeOnNotes()
        {
            foreach (var note in ParentControl.NotesBrowser.Notes)
            {
                var end =
                    ParentControl.TextBox.MainControl.Document.ContentStart.GetPositionAtOffset(note.Value.OffsetEnd);
                note.Value.Range = new TextRange(
                    ParentControl.TextBox.MainControl.Document.ContentStart.GetPositionAtOffset(note.Value.OffsetStart),
                    end != null ? end : ParentControl.TextBox.MainControl.Document.ContentEnd);
                var pointer = ParentControl.AddFlag(note.Value.Range, note.Value.Name);
                if (note.Value.Range.Start != pointer)
                {
                    note.Value.Range = new TextRange(pointer, note.Value.Range.End);
                }
            }

            //byte[] flag = NotesBrowser.getJPGFromImageControl(Properties.Resources.noteFlag);
            //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;
            //            image.Cursor = Cursors.Hand;
            //            image.Tag = note.Key;
            //            image.MouseUp += NoteFlag_MouseUp;
            //            element.Unloaded += Element_Unloaded;
            //            //new TextRange(element.ContentStart, element.ContentEnd).Text = string.Empty;
            //        }
            //    }
            //}
        }