Beispiel #1
0
        /// <summary>
        /// 单击单个收件人,设置选中状态
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EmailReceiverButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (var block in this.Document.Blocks)
            {
                var paragraph = block as Paragraph;
                if (paragraph == null)
                {
                    continue;
                }

                foreach (var item in paragraph.Inlines)
                {
                    InlineUIContainer container = item as InlineUIContainer;
                    if (container == null)
                    {
                        continue;
                    }
                    EmailReceiverButton button = container.Child as EmailReceiverButton;
                    if (sender == button)
                    {
                        button.IsSelected = true;
                    }
                    else
                    {
                        button.IsSelected = false;
                    }
                }
            }
        }
Beispiel #2
0
        private void EmailBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Enter)
            {
                TextRange tr   = new TextRange(this.Document.ContentStart, this.Document.ContentEnd);
                string    text = tr.Text.Trim();

                //this.Document.Blocks.Clear();

                EmailReceiverButton btn = new EmailReceiverButton();
                btn.Content           = text;
                btn.VerticalAlignment = VerticalAlignment.Center;
                btn.Margin            = new Thickness(2);
                btn.Click            += EmailReceiverButton_Click;

                //TextPointer pointer = TextPointer.

                //Paragraph p = new Paragraph();
                InlineUIContainer container = new InlineUIContainer(btn, this.Selection.End);
                //p.Inlines.Add(container);
                container.SetValue(FocusManager.IsFocusScopeProperty, true);
            }
        }