Exemplo n.º 1
0
 /// <summary>
 /// Removes the <see cref="Inline"/> that hosts the given <see cref="TokenButton"/>.
 /// </summary>
 /// <param name="Button"></param>
 public void RemoveToken(TokenButton Button)
 {
     Enumerate <Paragraph, InlineUIContainer, TokenButton>((p, i, b) =>
     {
         if (b == Button)
         {
             p.Inlines.Remove(i);
             return(false);
         }
         return(true);
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Generates an <see cref="Inline"/> element to host the given token.
        /// </summary>
        /// <param name="Token"></param>
        /// <returns></returns>
        InlineUIContainer GenerateInline(object Token)
        {
            OnTokenLoaded(Token);

            var Button = new TokenButton(Token);

            //BaselineAlignment is needed to align with run
            var Result = new InlineUIContainer(Button)
            {
                BaselineAlignment = BaselineAlignment.Center
            };

            return(Result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts the given token element to a <see cref="Run"/>.
        /// </summary>
        /// <param name="Button"></param>
        public void EditToken(TokenButton Button)
        {
            var Inline = default(Inline);

            Enumerate <Paragraph, InlineUIContainer, TokenButton>((p, i, b) =>
            {
                if (b == Button)
                {
                    Inline = GenerateRun(b.Content);

                    p.Inlines.InsertBefore(i, Inline);
                    p.Inlines.Remove(i);

                    return(false);
                }
                return(true);
            });
            Focus();

            if (Inline != null)
            {
                Selection.Select(Inline.ContentStart, Inline.ContentEnd);
            }
        }