当前位置: 首页>>代码示例>>C#>>正文


C# Documents.Run类代码示例

本文整理汇总了C#中System.Windows.Documents.Run的典型用法代码示例。如果您正苦于以下问题:C# Run类的具体用法?C# Run怎么用?C# Run使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Run类属于System.Windows.Documents命名空间,在下文中一共展示了Run类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopulateDocument

 private void PopulateDocument()
 {
     // Add some data to the List item.
     this.listOfFunFacts.FontSize = 14;
     this.listOfFunFacts.MarkerStyle = TextMarkerStyle.Circle;
     this.listOfFunFacts.ListItems.Add(new ListItem(new
     Paragraph(new Run("Fixed documents are for WYSIWYG print ready docs!"))));
     this.listOfFunFacts.ListItems.Add(new ListItem(
     new Paragraph(new Run("The API supports tables and embedded figures!"))));
     this.listOfFunFacts.ListItems.Add(new ListItem(
     new Paragraph(new Run("Flow documents are read only!"))));
     this.listOfFunFacts.ListItems.Add(new ListItem(new Paragraph(new Run
     ("BlockUIContainer allows you to embed WPF controls in the document!")
     )));
     // Now add some data to the Paragraph.
     // First part of sentence.
     Run prefix = new Run("This paragraph was generated ");
     // Middle of paragraph.
     Bold b = new Bold();
     Run infix = new Run("dynamically");
     infix.Foreground = Brushes.Red;
     infix.FontSize = 30;
     b.Inlines.Add(infix);
     // Last part of paragraph.
     Run suffix = new Run(" at runtime!");
     // Now add each piece to the collection of inline elements
     // of the Paragraph.
     this.paraBodyText.Inlines.Add(prefix);
     this.paraBodyText.Inlines.Add(infix);
     this.paraBodyText.Inlines.Add(suffix);
 }
开发者ID:wordtinker,项目名称:c-sharp,代码行数:31,代码来源:MainWindow.xaml.cs

示例2: OnCommandChanged

        private static void OnCommandChanged(DependencyObject a_dependencyObject, DependencyPropertyChangedEventArgs a_e)
        {
            Hyperlink hyperlink = a_dependencyObject as Hyperlink;
            if (hyperlink == null)
                throw new InvalidOperationException(@"Hyperlink required");

            ICommand oldCommand = a_e.OldValue as ICommand;
            if (oldCommand != null)
            {
                hyperlink.Command = null;
            }

            ICommand newCommand = a_e.NewValue as ICommand;
            if (newCommand != null)
            {
                hyperlink.Command = newCommand;

                ICommandDescriptionProvider descProvider = newCommand as ICommandDescriptionProvider;
                if (GetSetText(hyperlink) && descProvider != null)
                {
                    var run = new Run();
                    BindingOperations.SetBinding(
                        run,
                        Run.TextProperty,
                        new Binding("Text") { Source = descProvider.Description });
                    hyperlink.Inlines.Clear();
                    hyperlink.Inlines.Add(run);
                }
            }
        }
开发者ID:liorm,项目名称:PowerTools,代码行数:30,代码来源:HyperlinkCommandBinder.cs

示例3: CompilePalLogger_OnError

        void CompilePalLogger_OnError(string errorText, Error e)
        {
            Dispatcher.Invoke(() =>
            {

                Hyperlink errorLink = new Hyperlink();

                Run text = new Run(errorText);

                text.Foreground = e.ErrorColor;

                errorLink.Inlines.Add(text);
                errorLink.TargetName = e.ID.ToString();
                errorLink.Click += errorLink_Click;

                if (CompileOutputTextbox.Document.Blocks.Any())
                {
                    var lastPara = (Paragraph)CompileOutputTextbox.Document.Blocks.LastBlock;
                    lastPara.Inlines.Add(errorLink);
                }
                else
                {
                    var newPara = new Paragraph(errorLink);
                    CompileOutputTextbox.Document.Blocks.Add(newPara);
                }

                CompileOutputTextbox.ScrollToEnd();

            });
        }
开发者ID:ruarai,项目名称:CompilePal,代码行数:30,代码来源:MainWindow.xaml.cs

示例4: cmdCreateDynamicDocument_Click

        private void cmdCreateDynamicDocument_Click(object sender, RoutedEventArgs e)
        {
            // Create first part of sentence.
            Run runFirst = new Run();
            runFirst.Text = "Hello world of ";

            // Create bolded text.
            Bold bold = new Bold();
            Run runBold = new Run();
            runBold.Text = "dynamically generated";
            bold.Inlines.Add(runBold);

            // Create last part of sentence.
            Run runLast = new Run();
            runLast.Text = " documents";

            // Add three parts of sentence to a paragraph, in order.
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(runFirst);
            paragraph.Inlines.Add(bold);
            paragraph.Inlines.Add(runLast);

            // Create a document and add this paragraph.
            FlowDocument document = new FlowDocument();
            document.Blocks.Add(paragraph);

            // Show the document.
            docViewer.Document = document;
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:29,代码来源:FlowContent.xaml.cs

示例5: AddInline

 private void AddInline(TextBlock txtBlock, string text, Color color)
 {
     Run run = new Run();
     run.Text = text;
     run.Foreground = new SolidColorBrush(color);
     txtBlock.Inlines.Add(run);
 }
开发者ID:asdanilenk,项目名称:Exp1,代码行数:7,代码来源:RulesManagementWindow.xaml.cs

示例6: ConvertToBlock

        /// <summary>
        /// Convert "data" to a flow document block object. If data is already a block, the return value is data recast.
        /// </summary>
        /// <param name="dataContext">only used when bindable content needs to be created</param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Block ConvertToBlock(object dataContext, object data)
        {
            if (data is Block)
                return (Block)data;
            else if (data is Inline)
                return new Paragraph((Inline)data);
            else if (data is BindingBase)
            {
                var run = new Run();

                if (dataContext is BindingBase)
                    run.SetBinding(Run.DataContextProperty, (BindingBase)dataContext);
                else
                    run.DataContext = dataContext;

                run.SetBinding(Run.TextProperty, (BindingBase)data);
                return new Paragraph(run);
            }
            else
            {
                var run = new Run();
                run.Text = (data == null) ? string.Empty : data.ToString();
                return new Paragraph(run);
            }
        }
开发者ID:Konctantin,项目名称:SpellWork,代码行数:31,代码来源:Helpers.cs

示例7: copyLink

 private void copyLink(object sender, RoutedEventArgs e)
 {
     Run testLink = new Run("Test Hyperlink");
     Hyperlink myLink = new Hyperlink(testLink);
     myLink.NavigateUri = new Uri("http://search.msn.com");
     Clipboard.SetDataObject(myLink);
 }
开发者ID:JamesPinkard,项目名称:SolutionsForWork,代码行数:7,代码来源:MainWindow.xaml.cs

示例8: ConvertToBlock

        internal static Block ConvertToBlock(object dataContext, object data)
        {
            if (data is Block)
            {
                return (Block)data;
            }
            else if (data is Inline)
            {
                return new Paragraph((Inline)data);
            }
            else if (data is BindingBase)
            {
                Run run = new Run();

                if (dataContext is BindingBase)
                {
                    run.SetBinding(Run.DataContextProperty, (BindingBase)dataContext);
                }
                else
                {
                    run.DataContext = dataContext;
                }

                run.SetBinding(Run.TextProperty, (BindingBase)data);

                return new Paragraph(run);
            }
            else
            {
                Run run = new Run();
                run.Text = (data == null) ? String.Empty : data.ToString();
                return new Paragraph(run);
            }
        }
开发者ID:rodrigovedovato,项目名称:FlowDocumentReporting,代码行数:34,代码来源:Helpers.cs

示例9: AddMessage

        /// <summary>
        /// Formats the ChatMessage and adds it as a new paragraph to the ChatTextBox.
        /// </summary>
        /// <param name="message"></param>
        public void AddMessage(ChatMessage message)
        {
            Paragraph p = new Paragraph();
            p.Margin = new Thickness (0, 0, 0, 3);

            var date = new Run (String.Format ("({0}) ", message.Timestamp.ToLongTimeString ()));
            date.FontSize = _fontsize - 2;
            date.FontWeight = FontWeights.Bold;
            date.Foreground = Brushes.DarkGray;

            var username = new Run (message.SenderNickname + ": ");
            username.FontSize = _fontsize;
            username.FontWeight = FontWeights.Bold;
            username.Foreground = Brushes.DarkOrchid;

            var text = new Run (message.Content);
            text.FontSize = _fontsize;

            p.Inlines.Add (date);
            p.Inlines.Add (username);
            p.Inlines.Add (text);

            this.Document.Blocks.Add (p);
            this.ScrollToEnd ();
        }
开发者ID:alexcepoi,项目名称:ShareTabWin,代码行数:29,代码来源:ChatTextBox.cs

示例10: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {

            if (FormattedText == null)
            {
                base.OnRender(drawingContext);
                return;
            }



            _textBlock.Inlines.Clear();
            _textBlock.Inlines.AddRange(FormattedText.Select(ft =>
            {
                var run = new Run(ft.Text);

                if (ft.Highlight && HighlightEnabled)
                {
                    if (HighlightBackground != null) run.Background = HighlightBackground;
                    if (HighlightForeground != null) run.Foreground = HighlightForeground;

                    run.FontWeight = FontWeights.Bold;
                }
                return run;
            }));

            base.OnRender(drawingContext);
        }
开发者ID:ItsJustSean,项目名称:TailBlazer,代码行数:28,代码来源:HighlightTextControl.cs

示例11: ColorizeXAML

    public static FlowDocument ColorizeXAML( string xamlText, FlowDocument targetDoc )
    {
      XmlTokenizer tokenizer = new XmlTokenizer();
      XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement;

      List<XmlToken> tokens = tokenizer.Tokenize( xamlText, ref mode );
      List<string> tokenTexts = new List<string>( tokens.Count );
      List<Color> colors = new List<Color>( tokens.Count );
      int position = 0;
      foreach( XmlToken token in tokens )
      {
        string tokenText = xamlText.Substring( position, token.Length );
        tokenTexts.Add( tokenText );
        Color color = ColorForToken( token, tokenText );
        colors.Add( color );
        position += token.Length;
      }

      Paragraph p = new Paragraph();

      // Loop through tokens
      for( int i = 0; i < tokenTexts.Count; i++ )
      {
        Run r = new Run( tokenTexts[ i ] );
        r.Foreground = new SolidColorBrush( colors[ i ] );
        p.Inlines.Add( r );
      }

      targetDoc.Blocks.Add( p );

      return targetDoc;
    }
开发者ID:Torion,项目名称:WpfExToolkit,代码行数:32,代码来源:XamlFormatter.cs

示例12: DoPrint

 public override void DoPrint(string[] lines)
 {
     var q = PrinterInfo.GetPrinter(Printer.ShareName);
     var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();
     var run = new Run(text) {Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255))};
     PrintFlowDocument(q, new FlowDocument(new Paragraph(run)));
 }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:7,代码来源:TextPrinterJob.cs

示例13: AddBlock

 private void AddBlock(Run run)
 {
     var p = new Paragraph();
     p.TextAlignment = TextAlignment.Left;
     p.Inlines.Add(run);
     _doc.Blocks.Add(p);
 }
开发者ID:peterson1,项目名称:ErrH,代码行数:7,代码来源:FlowDocLogFormatter.cs

示例14: AboutPage

 /// <summary>
 /// Constructor
 /// </summary>
 public AboutPage()
 {
     InitializeComponent();
     // Application version number
     var ver = Windows.ApplicationModel.Package.Current.Id.Version;
     var versionRun = string.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
     VersionParagraph.Inlines.Add(versionRun);
     // Application about text
     var aboutRun = new Run()
     {
         Text = AppResources.AboutPage_AboutRun + "\n"
     };
     AboutParagraph.Inlines.Add(aboutRun);
     // Link to project homepage
     var projectRunText = AppResources.AboutPage_ProjectRun;
     var projectRunTextSpans = projectRunText.Split(new string[] { "{0}" }, StringSplitOptions.None);
     var projectRunSpan1 = new Run { Text = projectRunTextSpans[0] };
     var projectsLink = new Hyperlink();
     projectsLink.Inlines.Add(AppResources.AboutPage_Hyperlink_Project);
     projectsLink.Click += ProjectsLink_Click;
     projectsLink.Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneForegroundColor"]);
     projectsLink.MouseOverForeground = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
     var projectRunSpan2 = new Run { Text = projectRunTextSpans[1] + "\n" };
     ProjectParagraph.Inlines.Add(projectRunSpan1);
     ProjectParagraph.Inlines.Add(projectsLink);
     ProjectParagraph.Inlines.Add(projectRunSpan2);
 }
开发者ID:sumitkm,项目名称:recorder,代码行数:30,代码来源:AboutPage.xaml.cs

示例15: AddTextToRTF

 private static void AddTextToRTF(FlowDocument myFlowDoc, string text)
 {
     var para = new Paragraph();
     var run = new Run(text);
     para.Inlines.Add(run);
     myFlowDoc.Blocks.Add(para);
 }
开发者ID:RobertHedgate,项目名称:TabInRichTextBox,代码行数:7,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Documents.Run类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。