當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。