當前位置: 首頁>>代碼示例>>C#>>正文


C# Documents.Span類代碼示例

本文整理匯總了C#中System.Windows.Documents.Span的典型用法代碼示例。如果您正苦於以下問題:C# Span類的具體用法?C# Span怎麽用?C# Span使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Span類屬於System.Windows.Documents命名空間,在下文中一共展示了Span類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MakeFlowDocument

 public static FlowDocument MakeFlowDocument(string eugenstr, System.Windows.Media.Brush specialColor)
 {
     FlowDocument document = new FlowDocument();
     int i = 0;
     string[] parts = eugenstr.Split(GREEN_TAG, StringSplitOptions.None);
     if (parts.Length > 1)
     {
         Paragraph paragraph = new Paragraph();
         while (i < parts.Length)
         {
             if (i % 2 == 0)
             {
                 Span normalspan = new Span(new Run(parts[i].Replace("#styleGreen", string.Empty)));
                 paragraph.Inlines.Add(normalspan);
             }
             else
             {
                 Span coloredSpan = new Span(new Run(parts[i]));
                 coloredSpan.Foreground = specialColor;
                 paragraph.Inlines.Add(coloredSpan);
             }
             i++;
         }
         document.Blocks.Add(paragraph);
     }
     else { Paragraph paragraph = new Paragraph(new Run(eugenstr)); document.Blocks.Add(paragraph); }
     return document;
 }
開發者ID:KennyJLam,項目名稱:AoA,代碼行數:28,代碼來源:EugenStringConverter.cs

示例2: Convert

        public object Convert(object[] value, Type targetType, object parameter, CultureInfo cultureInfo)
        {
            var text = value[0] as string;
            var hdata = value[1] as List<int>;

            var textBlock = new Span();

            if (hdata == null || !hdata.Any())
            {
                // no highlight data, just return the text
                return new Run(text);
            }

            for (var i = 0; i < text.Length; i++)
            {
                var ch = text.Substring(i, 1);
                // should this character be highlighted?
                if (hdata.Contains(i))
                {
                    textBlock.Inlines.Add(new Bold(new Run(ch)));
                }
                else
                {
                    textBlock.Inlines.Add(new Run(ch));
                }
            }
            return textBlock;
        }
開發者ID:JohnTheGr8,項目名稱:Wox,代碼行數:28,代碼來源:HighlightTextConverter.cs

示例3: BuildFont

        private static Inline BuildFont(ElementToken token, Hint hint)
        {
            var span = new Span();

            string size;
            if (token.Attributes.TryGetValue("size", out size))
            {
                var fc = new FontSizeConverter();
                var sz = (double)fc.ConvertFromString(size);
                span.FontSize = sz;
            }

            string face;
            if (token.Attributes.TryGetValue("face", out face))
            {
                span.FontFamily = new FontFamily(face);
            }

            string color;
            if (token.Attributes.TryGetValue("color", out color))
            {
                var bc = new BrushConverter();
                var br = (Brush)bc.ConvertFromString(color);
                span.Foreground = br;
            }
            return span.Fill(token, hint);
        }
開發者ID:vestild,項目名稱:nemerle,代碼行數:27,代碼來源:HintBuilder.cs

示例4: GetTextSpan

        private static Span GetTextSpan(HelpOmniboxResult helpResult)
        {
            var span = new Span();

            for (int i = 0; i < helpResult.Text.Length; )
            {
                var start = helpResult.Text.IndexOf('(', i);
                if (start == -1)
                {
                    span.Inlines.Add(helpResult.Text.Substring(i));
                    break;
                }

                span.Inlines.Add(helpResult.Text.Substring(i, start - i));
                start++;

                var end = helpResult.Text.IndexOf(')', start);
                if (end == -1)
                {
                    span.Inlines.Add(helpResult.Text.Substring(start));
                    break;
                }

                span.Inlines.Add(new Bold(new Run(helpResult.Text.Substring(start, end - start ))));

                i = end + 1;
            }
            return span;
        }
開發者ID:mapacheL,項目名稱:extensions,代碼行數:29,代碼來源:OmniboxTemplate.xaml.cs

示例5: AddMsg

        public void AddMsg(string message, bool isRecieved)
        {
            if (currentSize >= logSize)
            {
                log.Inlines.Remove(log.Inlines.FirstInline); //удалили время
                log.Inlines.Remove(log.Inlines.FirstInline); //удалили текст
                currentSize--;
            }
            string time = "[" + System.DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss") + "] ";
            Span DateSpan = new Span();
            DateSpan.Inlines.Add(time);
            DateSpan.Foreground = Brushes.DarkGreen;
            DateSpan.FontWeight = FontWeights.Bold;
            log.Inlines.Add(DateSpan);

            Span Msg = new Span();
            Msg.Inlines.Add(message);
            if (isRecieved)
                Msg.Foreground = Brushes.OrangeRed;
            else
                Msg.Foreground = Brushes.DodgerBlue;

            log.Inlines.Add(Msg);
            scrollViewer.UpdateLayout();
            scrollViewer.ScrollToEnd();
            currentSize++;
        }
開發者ID:Retivykh-Serg,項目名稱:Dixit,代碼行數:27,代碼來源:messageViewer.xaml.cs

示例6: WarningView

        public WarningView()
        {
            this.InitializeComponent();

            // Init
            var warningService = Singleton<ServiceController>.Instance.Get<IWarningService>();
            var lightGrayBrush = new SolidColorBrush(Colors.DarkGray);

            foreach (var warning in warningService.GetWarnings().OrderByDescending(w => w.Issued))
            {
                var inline = new Span();
                inline.Inlines.Add(new Bold(new Run(warning.Title)));
                inline.Inlines.Add(new LineBreak());
                inline.Inlines.Add(new Run(warning.Message));
                inline.Inlines.Add(new LineBreak());
                inline.Inlines.Add(new Run(warning.Issued.ToShortDateString()) {Foreground = lightGrayBrush});
                if (warning.Read)
                {
                    foreach (var i in inline.Inlines)
                    {
                        i.Foreground = lightGrayBrush;
                    }
                }
                this.StackPanel.Children.Add(new TextBlock(inline) {Margin = new Thickness(5), LineHeight = 20});
            }

            warningService.SetAllWarningsRead();
        }
開發者ID:TheRealVira,項目名稱:Scrooge,代碼行數:28,代碼來源:WarningView.xaml.cs

示例7: DisplayFormula

 public Inline DisplayFormula()
 {
     string Pi = Char.ToString((char)0x03C0);
     Span form = new Span();
     form.Inlines.Add(Utilities.Num1(Parm[0], CParm[0])); //Coef
     form.Inlines.Add(new Italic(new Run("sin")));
     form.Inlines.Add("(2" + Pi + "(");
     form.Inlines.Add(Utilities.Num1(Parm[1], CParm[1])); //FreqC
     form.Inlines.Add(new Italic(new Run("t")));
     if (Parm[5] != 0D)
     {
         if (Parm[5] < 0D) form.Inlines.Add("(1 - ");
         else form.Inlines.Add("(1 + ");
         form.Inlines.Add(Utilities.Num1(Math.Abs(Parm[5] / 100D), CParm[5])); //Mod
         form.Inlines.Add(new Italic(new Run("sin")));
         form.Inlines.Add("(2" + Pi + "(");
         form.Inlines.Add(Utilities.Num1(Parm[3], CParm[3])); //FreqM
         form.Inlines.Add(new Italic(new Run("t")));
         form.Inlines.Add(Utilities.Num0(Parm[4] / 360D, CParm[4])); //PhaseM
         form.Inlines.Add(")))");
     }
     form.Inlines.Add(Utilities.Num0(Parm[2] / 360D, CParm[2])); //PhaseC
     form.Inlines.Add("))");
     return form;
 }
開發者ID:DOPS-CCI,項目名稱:CCI_project,代碼行數:25,代碼來源:FMTab.xaml.cs

示例8: CreateSubject

 private Inline CreateSubject(IMessage message)
 {
     var subj = message.XmppMessage.Subject;
     var span = new Span();
     span.Inlines.Add(subj);
     return new Italic(new Bold(span));
 }
開發者ID:Irdis,項目名稱:VSTalk,代碼行數:7,代碼來源:SubjectBlockBuilder.cs

示例9: AppendRange

        public static Inline AppendRange(this Inline inline, IEnumerable<Inline> inlines)
        {
            var span = new Span(inline);

            span.Inlines.AddRange(inlines);

            return span;
        }
開發者ID:WildGums,項目名稱:Orc.NuGetExplorer,代碼行數:8,代碼來源:InlineExtensions.cs

示例10: Append

        public static Inline Append(this Inline inline, Inline inlineToAdd)
        {
            var span = new Span(inline);

            span.Inlines.Add(inlineToAdd);

            return span;
        }
開發者ID:WildGums,項目名稱:Orc.NuGetExplorer,代碼行數:8,代碼來源:InlineExtensions.cs

示例11: DisplayFormula

 public Inline DisplayFormula()
 {
     Span form = new Span();
     form.Inlines.Add(Coef.ToString("G6"));
     Span sub = new Span(new Run(Utilities.ConvertFromVType(CCoef)));
     sub.Typography.Variants = System.Windows.FontVariants.Subscript;
     form.Inlines.Add(sub);
     return form;
 }
開發者ID:DOPS-CCI,項目名稱:CCI_project,代碼行數:9,代碼來源:NoiseTab.xaml.cs

示例12: CreateStatus

 private Inline CreateStatus(IMessage message)
 {
     var from = message.XmppMessage.From;
     var name = GetName(from);
     var chatstate = message.XmppMessage.Chatstate.ToString();
     var span = new Span();
     span.Inlines.Add(string.Format("{0} is {1}...", name, chatstate));
     return new Italic(span);
 }
開發者ID:Irdis,項目名稱:VSTalk,代碼行數:9,代碼來源:StatusBlockBuilder.cs

示例13: PasteContentData

 internal static bool PasteContentData(InputBox inputBox, IDataObject iDataObject)
 {
     TextData data = TryGetText(iDataObject);
     if (!data.ContainsData)
     {
         if (iDataObject.GetDataPresent(DataFormats.Bitmap, true))
         {
             inputBox.Paste(iDataObject);
             return true;
         }
         return false;
     }
     inputBox.TempFlowDocument.Blocks.Clear();
     TextRange range = null;
     if (data.Format == BamaDataFormat)
     {
         object obj2 = XamlReader.Parse(data.Data);
         if (obj2 is Block)
         {
             inputBox.TempFlowDocument.Blocks.Add(obj2 as Block);
         }
         else if (obj2 is Inline)
         {
             Span span = new Span(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd)
             {
                 Inlines = { obj2 as Span }
             };
         }
         range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
         range.ClearAllProperties();
         inputBox.Selection.Text = "";
         Span newspan = new Span(inputBox.Selection.Start, inputBox.Selection.End);
         ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, newspan);
         inputBox.CaretPosition = newspan.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
     }
     else
     {
         range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
         using (MemoryStream stream = new MemoryStream())
         {
             using (StreamWriter writer = new StreamWriter(stream))
             {
                 writer.Write(data.Data);
                 writer.Flush();
                 stream.Position = 0L;
                 range.Load(stream, data.Format);
             }
         }
         range.ClearAllProperties();
         inputBox.Selection.Text = "";
         Span span3 = new Span(inputBox.Selection.Start, inputBox.Selection.End);
         ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, span3);
         inputBox.CaretPosition = span3.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
     }
     inputBox.TempFlowDocument.Blocks.Clear();
     return true;
 }
開發者ID:QuocHuy7a10,項目名稱:Arianrhod,代碼行數:57,代碼來源:ClipboardMgr.cs

示例14: AppendText

 public void AppendText(Paragraph p, ScrollViewer scroll, ChatMessage message, string servername)
 {
     var text = string.Format("[{0}] [ {1:yyyy-MM-dd HH:mm:ss} ]  {2}\n", servername, message.Date, message.Message);
     var color = ServerMonitorModel.GetMessageColor(message);
     var brush = new SolidColorBrush(color);
     var span = new Span() { Foreground = brush };
     span.Inlines.Add(text);
     p.Inlines.Add(span);
 }
開發者ID:svargy,項目名稱:arma3beclient,代碼行數:9,代碼來源:ChatHistory.xaml.cs

示例15: DateSpan

 private Span DateSpan(DateTime date)
 {
     Span span = new Span();
     span.FontStyle = FontStyles.Normal;
     span.FontSize = 10;
     span.FontWeight = FontWeights.Bold;
     span.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
     span.Inlines.Add("[" + date + "] ");
     return span;
 }
開發者ID:iwikimon,項目名稱:diplom,代碼行數:10,代碼來源:ChatControl.xaml.cs


注:本文中的System.Windows.Documents.Span類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。