Example #1
0
        public bool IsInputable(int position)
        {
            if (position == 0 || position == ProfileText.Length)
            {
                return(true);
            }
            var pos = ProfileTextPostionList.FindAtPosition(position);

            if (pos.Position.Offset == position)
            {
                return(true);
            }
            if (pos.Position.Offset + pos.Position.Length == position)
            {
                return(true);
            }
            if (pos.Fragment.FragmentType == FragmentType.Text)
            {
                return(true);
            }
            return(false);
        }
Example #2
0
        public void GetFragmentsAt(out Fragment before, out Fragment after, int position)
        {
            var pos = ProfileTextPostionList.FindAtPosition(position);

            if (pos == null)
            {
                before = Profile;
                after  = null;
                return;
            }

            if (pos.Position.Offset + pos.Position.Length == position)
            {
                before = pos.Fragment;
                after  = null;
                return;
            }

            if (pos.Position.Offset != position && pos.Position.Offset + pos.Position.Length != position)
            {
                before = pos.Fragment;
                after  = pos.Fragment;
                return;
            }

            after = pos.Fragment;
            var fragments = ((FragmentBody)after.Parent).FragmentList;
            var i         = fragments.IndexOf(after);

            if (i == 0 && after.ParentFragment.FragmentType == FragmentType.TextBlock)
            {
                fragments = ((FragmentBody)after.ParentFragment.Parent).FragmentList;
                i         = fragments.IndexOf(after.ParentFragment);
            }
            before = i == 0 ? null : fragments[i - 1];
        }